babylon.module.d.ts 6.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251
  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>;
  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/Maths/math.vector" {
  2072. import { Viewport } from "babylonjs/Maths/math.viewport";
  2073. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2074. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2075. import { Plane } from "babylonjs/Maths/math.plane";
  2076. /**
  2077. * Class representing a vector containing 2 coordinates
  2078. */
  2079. export class Vector2 {
  2080. /** defines the first coordinate */
  2081. x: number;
  2082. /** defines the second coordinate */
  2083. y: number;
  2084. /**
  2085. * Creates a new Vector2 from the given x and y coordinates
  2086. * @param x defines the first coordinate
  2087. * @param y defines the second coordinate
  2088. */
  2089. constructor(
  2090. /** defines the first coordinate */
  2091. x?: number,
  2092. /** defines the second coordinate */
  2093. y?: number);
  2094. /**
  2095. * Gets a string with the Vector2 coordinates
  2096. * @returns a string with the Vector2 coordinates
  2097. */
  2098. toString(): string;
  2099. /**
  2100. * Gets class name
  2101. * @returns the string "Vector2"
  2102. */
  2103. getClassName(): string;
  2104. /**
  2105. * Gets current vector hash code
  2106. * @returns the Vector2 hash code as a number
  2107. */
  2108. getHashCode(): number;
  2109. /**
  2110. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2111. * @param array defines the source array
  2112. * @param index defines the offset in source array
  2113. * @returns the current Vector2
  2114. */
  2115. toArray(array: FloatArray, index?: number): Vector2;
  2116. /**
  2117. * Copy the current vector to an array
  2118. * @returns a new array with 2 elements: the Vector2 coordinates.
  2119. */
  2120. asArray(): number[];
  2121. /**
  2122. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2123. * @param source defines the source Vector2
  2124. * @returns the current updated Vector2
  2125. */
  2126. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2127. /**
  2128. * Sets the Vector2 coordinates with the given floats
  2129. * @param x defines the first coordinate
  2130. * @param y defines the second coordinate
  2131. * @returns the current updated Vector2
  2132. */
  2133. copyFromFloats(x: number, y: number): Vector2;
  2134. /**
  2135. * Sets the Vector2 coordinates with the given floats
  2136. * @param x defines the first coordinate
  2137. * @param y defines the second coordinate
  2138. * @returns the current updated Vector2
  2139. */
  2140. set(x: number, y: number): Vector2;
  2141. /**
  2142. * Add another vector with the current one
  2143. * @param otherVector defines the other vector
  2144. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2145. */
  2146. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2147. /**
  2148. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2149. * @param otherVector defines the other vector
  2150. * @param result defines the target vector
  2151. * @returns the unmodified current Vector2
  2152. */
  2153. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2154. /**
  2155. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2156. * @param otherVector defines the other vector
  2157. * @returns the current updated Vector2
  2158. */
  2159. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2160. /**
  2161. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2162. * @param otherVector defines the other vector
  2163. * @returns a new Vector2
  2164. */
  2165. addVector3(otherVector: Vector3): Vector2;
  2166. /**
  2167. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2168. * @param otherVector defines the other vector
  2169. * @returns a new Vector2
  2170. */
  2171. subtract(otherVector: Vector2): Vector2;
  2172. /**
  2173. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2174. * @param otherVector defines the other vector
  2175. * @param result defines the target vector
  2176. * @returns the unmodified current Vector2
  2177. */
  2178. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2179. /**
  2180. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2181. * @param otherVector defines the other vector
  2182. * @returns the current updated Vector2
  2183. */
  2184. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2185. /**
  2186. * Multiplies in place the current Vector2 coordinates by the given ones
  2187. * @param otherVector defines the other vector
  2188. * @returns the current updated Vector2
  2189. */
  2190. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2191. /**
  2192. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2193. * @param otherVector defines the other vector
  2194. * @returns a new Vector2
  2195. */
  2196. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2197. /**
  2198. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2199. * @param otherVector defines the other vector
  2200. * @param result defines the target vector
  2201. * @returns the unmodified current Vector2
  2202. */
  2203. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2204. /**
  2205. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2206. * @param x defines the first coordinate
  2207. * @param y defines the second coordinate
  2208. * @returns a new Vector2
  2209. */
  2210. multiplyByFloats(x: number, y: number): Vector2;
  2211. /**
  2212. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. divide(otherVector: Vector2): Vector2;
  2217. /**
  2218. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2219. * @param otherVector defines the other vector
  2220. * @param result defines the target vector
  2221. * @returns the unmodified current Vector2
  2222. */
  2223. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2224. /**
  2225. * Divides the current Vector2 coordinates by the given ones
  2226. * @param otherVector defines the other vector
  2227. * @returns the current updated Vector2
  2228. */
  2229. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Gets a new Vector2 with current Vector2 negated coordinates
  2232. * @returns a new Vector2
  2233. */
  2234. negate(): Vector2;
  2235. /**
  2236. * Negate this vector in place
  2237. * @returns this
  2238. */
  2239. negateInPlace(): Vector2;
  2240. /**
  2241. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2242. * @param result defines the Vector3 object where to store the result
  2243. * @returns the current Vector2
  2244. */
  2245. negateToRef(result: Vector2): Vector2;
  2246. /**
  2247. * Multiply the Vector2 coordinates by scale
  2248. * @param scale defines the scaling factor
  2249. * @returns the current updated Vector2
  2250. */
  2251. scaleInPlace(scale: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2254. * @param scale defines the scaling factor
  2255. * @returns a new Vector2
  2256. */
  2257. scale(scale: number): Vector2;
  2258. /**
  2259. * Scale the current Vector2 values by a factor to a given Vector2
  2260. * @param scale defines the scale factor
  2261. * @param result defines the Vector2 object where to store the result
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. scaleToRef(scale: number, result: Vector2): Vector2;
  2265. /**
  2266. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2267. * @param scale defines the scale factor
  2268. * @param result defines the Vector2 object where to store the result
  2269. * @returns the unmodified current Vector2
  2270. */
  2271. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2272. /**
  2273. * Gets a boolean if two vectors are equals
  2274. * @param otherVector defines the other vector
  2275. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2276. */
  2277. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2278. /**
  2279. * Gets a boolean if two vectors are equals (using an epsilon value)
  2280. * @param otherVector defines the other vector
  2281. * @param epsilon defines the minimal distance to consider equality
  2282. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2283. */
  2284. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2285. /**
  2286. * Gets a new Vector2 from current Vector2 floored values
  2287. * @returns a new Vector2
  2288. */
  2289. floor(): Vector2;
  2290. /**
  2291. * Gets a new Vector2 from current Vector2 floored values
  2292. * @returns a new Vector2
  2293. */
  2294. fract(): Vector2;
  2295. /**
  2296. * Gets the length of the vector
  2297. * @returns the vector length (float)
  2298. */
  2299. length(): number;
  2300. /**
  2301. * Gets the vector squared length
  2302. * @returns the vector squared length (float)
  2303. */
  2304. lengthSquared(): number;
  2305. /**
  2306. * Normalize the vector
  2307. * @returns the current updated Vector2
  2308. */
  2309. normalize(): Vector2;
  2310. /**
  2311. * Gets a new Vector2 copied from the Vector2
  2312. * @returns a new Vector2
  2313. */
  2314. clone(): Vector2;
  2315. /**
  2316. * Gets a new Vector2(0, 0)
  2317. * @returns a new Vector2
  2318. */
  2319. static Zero(): Vector2;
  2320. /**
  2321. * Gets a new Vector2(1, 1)
  2322. * @returns a new Vector2
  2323. */
  2324. static One(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 set from the given index element of the given array
  2327. * @param array defines the data source
  2328. * @param offset defines the offset in the data source
  2329. * @returns a new Vector2
  2330. */
  2331. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2332. /**
  2333. * Sets "result" from the given index element of the given array
  2334. * @param array defines the data source
  2335. * @param offset defines the offset in the data source
  2336. * @param result defines the target vector
  2337. */
  2338. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2339. /**
  2340. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2341. * @param value1 defines 1st point of control
  2342. * @param value2 defines 2nd point of control
  2343. * @param value3 defines 3rd point of control
  2344. * @param value4 defines 4th point of control
  2345. * @param amount defines the interpolation factor
  2346. * @returns a new Vector2
  2347. */
  2348. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2349. /**
  2350. * 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".
  2351. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2352. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2353. * @param value defines the value to clamp
  2354. * @param min defines the lower limit
  2355. * @param max defines the upper limit
  2356. * @returns a new Vector2
  2357. */
  2358. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2359. /**
  2360. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2361. * @param value1 defines the 1st control point
  2362. * @param tangent1 defines the outgoing tangent
  2363. * @param value2 defines the 2nd control point
  2364. * @param tangent2 defines the incoming tangent
  2365. * @param amount defines the interpolation factor
  2366. * @returns a new Vector2
  2367. */
  2368. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2369. /**
  2370. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2371. * @param start defines the start vector
  2372. * @param end defines the end vector
  2373. * @param amount defines the interpolation factor
  2374. * @returns a new Vector2
  2375. */
  2376. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2377. /**
  2378. * Gets the dot product of the vector "left" and the vector "right"
  2379. * @param left defines first vector
  2380. * @param right defines second vector
  2381. * @returns the dot product (float)
  2382. */
  2383. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2384. /**
  2385. * Returns a new Vector2 equal to the normalized given vector
  2386. * @param vector defines the vector to normalize
  2387. * @returns a new Vector2
  2388. */
  2389. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2390. /**
  2391. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2392. * @param left defines 1st vector
  2393. * @param right defines 2nd vector
  2394. * @returns a new Vector2
  2395. */
  2396. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2397. /**
  2398. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2399. * @param left defines 1st vector
  2400. * @param right defines 2nd vector
  2401. * @returns a new Vector2
  2402. */
  2403. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2404. /**
  2405. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2406. * @param vector defines the vector to transform
  2407. * @param transformation defines the matrix to apply
  2408. * @returns a new Vector2
  2409. */
  2410. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2411. /**
  2412. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2413. * @param vector defines the vector to transform
  2414. * @param transformation defines the matrix to apply
  2415. * @param result defines the target vector
  2416. */
  2417. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2418. /**
  2419. * Determines if a given vector is included in a triangle
  2420. * @param p defines the vector to test
  2421. * @param p0 defines 1st triangle point
  2422. * @param p1 defines 2nd triangle point
  2423. * @param p2 defines 3rd triangle point
  2424. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2425. */
  2426. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2427. /**
  2428. * Gets the distance between the vectors "value1" and "value2"
  2429. * @param value1 defines first vector
  2430. * @param value2 defines second vector
  2431. * @returns the distance between vectors
  2432. */
  2433. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2434. /**
  2435. * Returns the squared distance between the vectors "value1" and "value2"
  2436. * @param value1 defines first vector
  2437. * @param value2 defines second vector
  2438. * @returns the squared distance between vectors
  2439. */
  2440. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2441. /**
  2442. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2443. * @param value1 defines first vector
  2444. * @param value2 defines second vector
  2445. * @returns a new Vector2
  2446. */
  2447. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2448. /**
  2449. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2450. * @param p defines the middle point
  2451. * @param segA defines one point of the segment
  2452. * @param segB defines the other point of the segment
  2453. * @returns the shortest distance
  2454. */
  2455. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2456. }
  2457. /**
  2458. * Class used to store (x,y,z) vector representation
  2459. * A Vector3 is the main object used in 3D geometry
  2460. * It can represent etiher the coordinates of a point the space, either a direction
  2461. * Reminder: js uses a left handed forward facing system
  2462. */
  2463. export class Vector3 {
  2464. private static _UpReadOnly;
  2465. private static _ZeroReadOnly;
  2466. /** @hidden */
  2467. _x: number;
  2468. /** @hidden */
  2469. _y: number;
  2470. /** @hidden */
  2471. _z: number;
  2472. /** @hidden */
  2473. _isDirty: boolean;
  2474. /** Gets or sets the x coordinate */
  2475. get x(): number;
  2476. set x(value: number);
  2477. /** Gets or sets the y coordinate */
  2478. get y(): number;
  2479. set y(value: number);
  2480. /** Gets or sets the z coordinate */
  2481. get z(): number;
  2482. set z(value: number);
  2483. /**
  2484. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2485. * @param x defines the first coordinates (on X axis)
  2486. * @param y defines the second coordinates (on Y axis)
  2487. * @param z defines the third coordinates (on Z axis)
  2488. */
  2489. constructor(x?: number, y?: number, z?: number);
  2490. /**
  2491. * Creates a string representation of the Vector3
  2492. * @returns a string with the Vector3 coordinates.
  2493. */
  2494. toString(): string;
  2495. /**
  2496. * Gets the class name
  2497. * @returns the string "Vector3"
  2498. */
  2499. getClassName(): string;
  2500. /**
  2501. * Creates the Vector3 hash code
  2502. * @returns a number which tends to be unique between Vector3 instances
  2503. */
  2504. getHashCode(): number;
  2505. /**
  2506. * Creates an array containing three elements : the coordinates of the Vector3
  2507. * @returns a new array of numbers
  2508. */
  2509. asArray(): number[];
  2510. /**
  2511. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2512. * @param array defines the destination array
  2513. * @param index defines the offset in the destination array
  2514. * @returns the current Vector3
  2515. */
  2516. toArray(array: FloatArray, index?: number): Vector3;
  2517. /**
  2518. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2519. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2520. */
  2521. toQuaternion(): Quaternion;
  2522. /**
  2523. * Adds the given vector to the current Vector3
  2524. * @param otherVector defines the second operand
  2525. * @returns the current updated Vector3
  2526. */
  2527. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2528. /**
  2529. * Adds the given coordinates to the current Vector3
  2530. * @param x defines the x coordinate of the operand
  2531. * @param y defines the y coordinate of the operand
  2532. * @param z defines the z coordinate of the operand
  2533. * @returns the current updated Vector3
  2534. */
  2535. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2536. /**
  2537. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2538. * @param otherVector defines the second operand
  2539. * @returns the resulting Vector3
  2540. */
  2541. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2542. /**
  2543. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2544. * @param otherVector defines the second operand
  2545. * @param result defines the Vector3 object where to store the result
  2546. * @returns the current Vector3
  2547. */
  2548. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2549. /**
  2550. * Subtract the given vector from the current Vector3
  2551. * @param otherVector defines the second operand
  2552. * @returns the current updated Vector3
  2553. */
  2554. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2555. /**
  2556. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2557. * @param otherVector defines the second operand
  2558. * @returns the resulting Vector3
  2559. */
  2560. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2561. /**
  2562. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2563. * @param otherVector defines the second operand
  2564. * @param result defines the Vector3 object where to store the result
  2565. * @returns the current Vector3
  2566. */
  2567. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2568. /**
  2569. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2570. * @param x defines the x coordinate of the operand
  2571. * @param y defines the y coordinate of the operand
  2572. * @param z defines the z coordinate of the operand
  2573. * @returns the resulting Vector3
  2574. */
  2575. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2576. /**
  2577. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @param result defines the Vector3 object where to store the result
  2582. * @returns the current Vector3
  2583. */
  2584. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2585. /**
  2586. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2587. * @returns a new Vector3
  2588. */
  2589. negate(): Vector3;
  2590. /**
  2591. * Negate this vector in place
  2592. * @returns this
  2593. */
  2594. negateInPlace(): Vector3;
  2595. /**
  2596. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. negateToRef(result: Vector3): Vector3;
  2601. /**
  2602. * Multiplies the Vector3 coordinates by the float "scale"
  2603. * @param scale defines the multiplier factor
  2604. * @returns the current updated Vector3
  2605. */
  2606. scaleInPlace(scale: number): Vector3;
  2607. /**
  2608. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2609. * @param scale defines the multiplier factor
  2610. * @returns a new Vector3
  2611. */
  2612. scale(scale: number): Vector3;
  2613. /**
  2614. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2615. * @param scale defines the multiplier factor
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the current Vector3
  2618. */
  2619. scaleToRef(scale: number, result: Vector3): Vector3;
  2620. /**
  2621. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2622. * @param scale defines the scale factor
  2623. * @param result defines the Vector3 object where to store the result
  2624. * @returns the unmodified current Vector3
  2625. */
  2626. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2627. /**
  2628. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2629. * @param origin defines the origin of the projection ray
  2630. * @param plane defines the plane to project to
  2631. * @returns the projected vector3
  2632. */
  2633. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2634. /**
  2635. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2636. * @param origin defines the origin of the projection ray
  2637. * @param plane defines the plane to project to
  2638. * @param result defines the Vector3 where to store the result
  2639. */
  2640. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2641. /**
  2642. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2643. * @param otherVector defines the second operand
  2644. * @returns true if both vectors are equals
  2645. */
  2646. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2647. /**
  2648. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2649. * @param otherVector defines the second operand
  2650. * @param epsilon defines the minimal distance to define values as equals
  2651. * @returns true if both vectors are distant less than epsilon
  2652. */
  2653. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2654. /**
  2655. * Returns true if the current Vector3 coordinates equals the given floats
  2656. * @param x defines the x coordinate of the operand
  2657. * @param y defines the y coordinate of the operand
  2658. * @param z defines the z coordinate of the operand
  2659. * @returns true if both vectors are equals
  2660. */
  2661. equalsToFloats(x: number, y: number, z: number): boolean;
  2662. /**
  2663. * Multiplies the current Vector3 coordinates by the given ones
  2664. * @param otherVector defines the second operand
  2665. * @returns the current updated Vector3
  2666. */
  2667. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2668. /**
  2669. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2670. * @param otherVector defines the second operand
  2671. * @returns the new Vector3
  2672. */
  2673. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2676. * @param otherVector defines the second operand
  2677. * @param result defines the Vector3 object where to store the result
  2678. * @returns the current Vector3
  2679. */
  2680. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2681. /**
  2682. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2683. * @param x defines the x coordinate of the operand
  2684. * @param y defines the y coordinate of the operand
  2685. * @param z defines the z coordinate of the operand
  2686. * @returns the new Vector3
  2687. */
  2688. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2689. /**
  2690. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2691. * @param otherVector defines the second operand
  2692. * @returns the new Vector3
  2693. */
  2694. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2695. /**
  2696. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2697. * @param otherVector defines the second operand
  2698. * @param result defines the Vector3 object where to store the result
  2699. * @returns the current Vector3
  2700. */
  2701. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2702. /**
  2703. * Divides the current Vector3 coordinates by the given ones.
  2704. * @param otherVector defines the second operand
  2705. * @returns the current updated Vector3
  2706. */
  2707. divideInPlace(otherVector: Vector3): Vector3;
  2708. /**
  2709. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2710. * @param other defines the second operand
  2711. * @returns the current updated Vector3
  2712. */
  2713. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2714. /**
  2715. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2716. * @param other defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2720. /**
  2721. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2722. * @param x defines the x coordinate of the operand
  2723. * @param y defines the y coordinate of the operand
  2724. * @param z defines the z coordinate of the operand
  2725. * @returns the current updated Vector3
  2726. */
  2727. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2728. /**
  2729. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2730. * @param x defines the x coordinate of the operand
  2731. * @param y defines the y coordinate of the operand
  2732. * @param z defines the z coordinate of the operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2736. /**
  2737. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2738. * Check if is non uniform within a certain amount of decimal places to account for this
  2739. * @param epsilon the amount the values can differ
  2740. * @returns if the the vector is non uniform to a certain number of decimal places
  2741. */
  2742. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2743. /**
  2744. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2745. */
  2746. get isNonUniform(): boolean;
  2747. /**
  2748. * Gets a new Vector3 from current Vector3 floored values
  2749. * @returns a new Vector3
  2750. */
  2751. floor(): Vector3;
  2752. /**
  2753. * Gets a new Vector3 from current Vector3 floored values
  2754. * @returns a new Vector3
  2755. */
  2756. fract(): Vector3;
  2757. /**
  2758. * Gets the length of the Vector3
  2759. * @returns the length of the Vector3
  2760. */
  2761. length(): number;
  2762. /**
  2763. * Gets the squared length of the Vector3
  2764. * @returns squared length of the Vector3
  2765. */
  2766. lengthSquared(): number;
  2767. /**
  2768. * Normalize the current Vector3.
  2769. * Please note that this is an in place operation.
  2770. * @returns the current updated Vector3
  2771. */
  2772. normalize(): Vector3;
  2773. /**
  2774. * Reorders the x y z properties of the vector in place
  2775. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2776. * @returns the current updated vector
  2777. */
  2778. reorderInPlace(order: string): this;
  2779. /**
  2780. * Rotates the vector around 0,0,0 by a quaternion
  2781. * @param quaternion the rotation quaternion
  2782. * @param result vector to store the result
  2783. * @returns the resulting vector
  2784. */
  2785. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2786. /**
  2787. * Rotates a vector around a given point
  2788. * @param quaternion the rotation quaternion
  2789. * @param point the point to rotate around
  2790. * @param result vector to store the result
  2791. * @returns the resulting vector
  2792. */
  2793. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2794. /**
  2795. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2796. * The cross product is then orthogonal to both current and "other"
  2797. * @param other defines the right operand
  2798. * @returns the cross product
  2799. */
  2800. cross(other: Vector3): Vector3;
  2801. /**
  2802. * Normalize the current Vector3 with the given input length.
  2803. * Please note that this is an in place operation.
  2804. * @param len the length of the vector
  2805. * @returns the current updated Vector3
  2806. */
  2807. normalizeFromLength(len: number): Vector3;
  2808. /**
  2809. * Normalize the current Vector3 to a new vector
  2810. * @returns the new Vector3
  2811. */
  2812. normalizeToNew(): Vector3;
  2813. /**
  2814. * Normalize the current Vector3 to the reference
  2815. * @param reference define the Vector3 to update
  2816. * @returns the updated Vector3
  2817. */
  2818. normalizeToRef(reference: Vector3): Vector3;
  2819. /**
  2820. * Creates a new Vector3 copied from the current Vector3
  2821. * @returns the new Vector3
  2822. */
  2823. clone(): Vector3;
  2824. /**
  2825. * Copies the given vector coordinates to the current Vector3 ones
  2826. * @param source defines the source Vector3
  2827. * @returns the current updated Vector3
  2828. */
  2829. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2830. /**
  2831. * Copies the given floats to the current Vector3 coordinates
  2832. * @param x defines the x coordinate of the operand
  2833. * @param y defines the y coordinate of the operand
  2834. * @param z defines the z coordinate of the operand
  2835. * @returns the current updated Vector3
  2836. */
  2837. copyFromFloats(x: number, y: number, z: number): Vector3;
  2838. /**
  2839. * Copies the given floats to the current Vector3 coordinates
  2840. * @param x defines the x coordinate of the operand
  2841. * @param y defines the y coordinate of the operand
  2842. * @param z defines the z coordinate of the operand
  2843. * @returns the current updated Vector3
  2844. */
  2845. set(x: number, y: number, z: number): Vector3;
  2846. /**
  2847. * Copies the given float to the current Vector3 coordinates
  2848. * @param v defines the x, y and z coordinates of the operand
  2849. * @returns the current updated Vector3
  2850. */
  2851. setAll(v: number): Vector3;
  2852. /**
  2853. * Get the clip factor between two vectors
  2854. * @param vector0 defines the first operand
  2855. * @param vector1 defines the second operand
  2856. * @param axis defines the axis to use
  2857. * @param size defines the size along the axis
  2858. * @returns the clip factor
  2859. */
  2860. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2861. /**
  2862. * Get angle between two vectors
  2863. * @param vector0 angle between vector0 and vector1
  2864. * @param vector1 angle between vector0 and vector1
  2865. * @param normal direction of the normal
  2866. * @return the angle between vector0 and vector1
  2867. */
  2868. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2869. /**
  2870. * Returns a new Vector3 set from the index "offset" of the given array
  2871. * @param array defines the source array
  2872. * @param offset defines the offset in the source array
  2873. * @returns the new Vector3
  2874. */
  2875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2876. /**
  2877. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2878. * @param array defines the source array
  2879. * @param offset defines the offset in the source array
  2880. * @returns the new Vector3
  2881. * @deprecated Please use FromArray instead.
  2882. */
  2883. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2884. /**
  2885. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2886. * @param array defines the source array
  2887. * @param offset defines the offset in the source array
  2888. * @param result defines the Vector3 where to store the result
  2889. */
  2890. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2891. /**
  2892. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @param result defines the Vector3 where to store the result
  2896. * @deprecated Please use FromArrayToRef instead.
  2897. */
  2898. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2899. /**
  2900. * Sets the given vector "result" with the given floats.
  2901. * @param x defines the x coordinate of the source
  2902. * @param y defines the y coordinate of the source
  2903. * @param z defines the z coordinate of the source
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2907. /**
  2908. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2909. * @returns a new empty Vector3
  2910. */
  2911. static Zero(): Vector3;
  2912. /**
  2913. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2914. * @returns a new unit Vector3
  2915. */
  2916. static One(): Vector3;
  2917. /**
  2918. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2919. * @returns a new up Vector3
  2920. */
  2921. static Up(): Vector3;
  2922. /**
  2923. * Gets a up Vector3 that must not be updated
  2924. */
  2925. static get UpReadOnly(): DeepImmutable<Vector3>;
  2926. /**
  2927. * Gets a zero Vector3 that must not be updated
  2928. */
  2929. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2930. /**
  2931. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2932. * @returns a new down Vector3
  2933. */
  2934. static Down(): Vector3;
  2935. /**
  2936. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2937. * @param rightHandedSystem is the scene right-handed (negative z)
  2938. * @returns a new forward Vector3
  2939. */
  2940. static Forward(rightHandedSystem?: boolean): Vector3;
  2941. /**
  2942. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2943. * @param rightHandedSystem is the scene right-handed (negative-z)
  2944. * @returns a new forward Vector3
  2945. */
  2946. static Backward(rightHandedSystem?: boolean): Vector3;
  2947. /**
  2948. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2949. * @returns a new right Vector3
  2950. */
  2951. static Right(): Vector3;
  2952. /**
  2953. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2954. * @returns a new left Vector3
  2955. */
  2956. static Left(): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2959. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2960. * @param vector defines the Vector3 to transform
  2961. * @param transformation defines the transformation matrix
  2962. * @returns the transformed Vector3
  2963. */
  2964. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2965. /**
  2966. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2967. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2968. * @param vector defines the Vector3 to transform
  2969. * @param transformation defines the transformation matrix
  2970. * @param result defines the Vector3 where to store the result
  2971. */
  2972. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2973. /**
  2974. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2975. * This method computes tranformed coordinates only, not transformed direction vectors
  2976. * @param x define the x coordinate of the source vector
  2977. * @param y define the y coordinate of the source vector
  2978. * @param z define the z coordinate of the source vector
  2979. * @param transformation defines the transformation matrix
  2980. * @param result defines the Vector3 where to store the result
  2981. */
  2982. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2983. /**
  2984. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2985. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2986. * @param vector defines the Vector3 to transform
  2987. * @param transformation defines the transformation matrix
  2988. * @returns the new Vector3
  2989. */
  2990. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2991. /**
  2992. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2993. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2994. * @param vector defines the Vector3 to transform
  2995. * @param transformation defines the transformation matrix
  2996. * @param result defines the Vector3 where to store the result
  2997. */
  2998. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2999. /**
  3000. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3001. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3002. * @param x define the x coordinate of the source vector
  3003. * @param y define the y coordinate of the source vector
  3004. * @param z define the z coordinate of the source vector
  3005. * @param transformation defines the transformation matrix
  3006. * @param result defines the Vector3 where to store the result
  3007. */
  3008. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3009. /**
  3010. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3011. * @param value1 defines the first control point
  3012. * @param value2 defines the second control point
  3013. * @param value3 defines the third control point
  3014. * @param value4 defines the fourth control point
  3015. * @param amount defines the amount on the spline to use
  3016. * @returns the new Vector3
  3017. */
  3018. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3019. /**
  3020. * 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"
  3021. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3022. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3023. * @param value defines the current value
  3024. * @param min defines the lower range value
  3025. * @param max defines the upper range value
  3026. * @returns the new Vector3
  3027. */
  3028. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3029. /**
  3030. * 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"
  3031. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3032. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3033. * @param value defines the current value
  3034. * @param min defines the lower range value
  3035. * @param max defines the upper range value
  3036. * @param result defines the Vector3 where to store the result
  3037. */
  3038. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3039. /**
  3040. * Checks if a given vector is inside a specific range
  3041. * @param v defines the vector to test
  3042. * @param min defines the minimum range
  3043. * @param max defines the maximum range
  3044. */
  3045. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3046. /**
  3047. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3048. * @param value1 defines the first control point
  3049. * @param tangent1 defines the first tangent vector
  3050. * @param value2 defines the second control point
  3051. * @param tangent2 defines the second tangent vector
  3052. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3053. * @returns the new Vector3
  3054. */
  3055. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3056. /**
  3057. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3058. * @param start defines the start value
  3059. * @param end defines the end value
  3060. * @param amount max defines amount between both (between 0 and 1)
  3061. * @returns the new Vector3
  3062. */
  3063. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3064. /**
  3065. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3066. * @param start defines the start value
  3067. * @param end defines the end value
  3068. * @param amount max defines amount between both (between 0 and 1)
  3069. * @param result defines the Vector3 where to store the result
  3070. */
  3071. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3072. /**
  3073. * Returns the dot product (float) between the vectors "left" and "right"
  3074. * @param left defines the left operand
  3075. * @param right defines the right operand
  3076. * @returns the dot product
  3077. */
  3078. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3079. /**
  3080. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3081. * The cross product is then orthogonal to both "left" and "right"
  3082. * @param left defines the left operand
  3083. * @param right defines the right operand
  3084. * @returns the cross product
  3085. */
  3086. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3087. /**
  3088. * Sets the given vector "result" with the cross product of "left" and "right"
  3089. * The cross product is then orthogonal to both "left" and "right"
  3090. * @param left defines the left operand
  3091. * @param right defines the right operand
  3092. * @param result defines the Vector3 where to store the result
  3093. */
  3094. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3095. /**
  3096. * Returns a new Vector3 as the normalization of the given vector
  3097. * @param vector defines the Vector3 to normalize
  3098. * @returns the new Vector3
  3099. */
  3100. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3101. /**
  3102. * Sets the given vector "result" with the normalization of the given first vector
  3103. * @param vector defines the Vector3 to normalize
  3104. * @param result defines the Vector3 where to store the result
  3105. */
  3106. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3107. /**
  3108. * Project a Vector3 onto screen space
  3109. * @param vector defines the Vector3 to project
  3110. * @param world defines the world matrix to use
  3111. * @param transform defines the transform (view x projection) matrix to use
  3112. * @param viewport defines the screen viewport to use
  3113. * @returns the new Vector3
  3114. */
  3115. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3116. /** @hidden */
  3117. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3118. /**
  3119. * Unproject from screen space to object space
  3120. * @param source defines the screen space Vector3 to use
  3121. * @param viewportWidth defines the current width of the viewport
  3122. * @param viewportHeight defines the current height of the viewport
  3123. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3124. * @param transform defines the transform (view x projection) matrix to use
  3125. * @returns the new Vector3
  3126. */
  3127. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3128. /**
  3129. * Unproject from screen space to object space
  3130. * @param source defines the screen space Vector3 to use
  3131. * @param viewportWidth defines the current width of the viewport
  3132. * @param viewportHeight defines the current height of the viewport
  3133. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3134. * @param view defines the view matrix to use
  3135. * @param projection defines the projection matrix to use
  3136. * @returns the new Vector3
  3137. */
  3138. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3139. /**
  3140. * Unproject from screen space to object space
  3141. * @param source defines the screen space Vector3 to use
  3142. * @param viewportWidth defines the current width of the viewport
  3143. * @param viewportHeight defines the current height of the viewport
  3144. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3145. * @param view defines the view matrix to use
  3146. * @param projection defines the projection matrix to use
  3147. * @param result defines the Vector3 where to store the result
  3148. */
  3149. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3150. /**
  3151. * Unproject from screen space to object space
  3152. * @param sourceX defines the screen space x coordinate to use
  3153. * @param sourceY defines the screen space y coordinate to use
  3154. * @param sourceZ defines the screen space z coordinate to use
  3155. * @param viewportWidth defines the current width of the viewport
  3156. * @param viewportHeight defines the current height of the viewport
  3157. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3158. * @param view defines the view matrix to use
  3159. * @param projection defines the projection matrix to use
  3160. * @param result defines the Vector3 where to store the result
  3161. */
  3162. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3163. /**
  3164. * Gets the minimal coordinate values between two Vector3
  3165. * @param left defines the first operand
  3166. * @param right defines the second operand
  3167. * @returns the new Vector3
  3168. */
  3169. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3170. /**
  3171. * Gets the maximal coordinate values between two Vector3
  3172. * @param left defines the first operand
  3173. * @param right defines the second operand
  3174. * @returns the new Vector3
  3175. */
  3176. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3177. /**
  3178. * Returns the distance between the vectors "value1" and "value2"
  3179. * @param value1 defines the first operand
  3180. * @param value2 defines the second operand
  3181. * @returns the distance
  3182. */
  3183. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3184. /**
  3185. * Returns the squared distance between the vectors "value1" and "value2"
  3186. * @param value1 defines the first operand
  3187. * @param value2 defines the second operand
  3188. * @returns the squared distance
  3189. */
  3190. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3191. /**
  3192. * Returns a new Vector3 located at the center between "value1" and "value2"
  3193. * @param value1 defines the first operand
  3194. * @param value2 defines the second operand
  3195. * @returns the new Vector3
  3196. */
  3197. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3198. /**
  3199. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3200. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3201. * to something in order to rotate it from its local system to the given target system
  3202. * Note: axis1, axis2 and axis3 are normalized during this operation
  3203. * @param axis1 defines the first axis
  3204. * @param axis2 defines the second axis
  3205. * @param axis3 defines the third axis
  3206. * @returns a new Vector3
  3207. */
  3208. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3209. /**
  3210. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3211. * @param axis1 defines the first axis
  3212. * @param axis2 defines the second axis
  3213. * @param axis3 defines the third axis
  3214. * @param ref defines the Vector3 where to store the result
  3215. */
  3216. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3217. }
  3218. /**
  3219. * Vector4 class created for EulerAngle class conversion to Quaternion
  3220. */
  3221. export class Vector4 {
  3222. /** x value of the vector */
  3223. x: number;
  3224. /** y value of the vector */
  3225. y: number;
  3226. /** z value of the vector */
  3227. z: number;
  3228. /** w value of the vector */
  3229. w: number;
  3230. /**
  3231. * Creates a Vector4 object from the given floats.
  3232. * @param x x value of the vector
  3233. * @param y y value of the vector
  3234. * @param z z value of the vector
  3235. * @param w w value of the vector
  3236. */
  3237. constructor(
  3238. /** x value of the vector */
  3239. x: number,
  3240. /** y value of the vector */
  3241. y: number,
  3242. /** z value of the vector */
  3243. z: number,
  3244. /** w value of the vector */
  3245. w: number);
  3246. /**
  3247. * Returns the string with the Vector4 coordinates.
  3248. * @returns a string containing all the vector values
  3249. */
  3250. toString(): string;
  3251. /**
  3252. * Returns the string "Vector4".
  3253. * @returns "Vector4"
  3254. */
  3255. getClassName(): string;
  3256. /**
  3257. * Returns the Vector4 hash code.
  3258. * @returns a unique hash code
  3259. */
  3260. getHashCode(): number;
  3261. /**
  3262. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3263. * @returns the resulting array
  3264. */
  3265. asArray(): number[];
  3266. /**
  3267. * Populates the given array from the given index with the Vector4 coordinates.
  3268. * @param array array to populate
  3269. * @param index index of the array to start at (default: 0)
  3270. * @returns the Vector4.
  3271. */
  3272. toArray(array: FloatArray, index?: number): Vector4;
  3273. /**
  3274. * Adds the given vector to the current Vector4.
  3275. * @param otherVector the vector to add
  3276. * @returns the updated Vector4.
  3277. */
  3278. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3281. * @param otherVector the vector to add
  3282. * @returns the resulting vector
  3283. */
  3284. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3287. * @param otherVector the vector to add
  3288. * @param result the vector to store the result
  3289. * @returns the current Vector4.
  3290. */
  3291. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3292. /**
  3293. * Subtract in place the given vector from the current Vector4.
  3294. * @param otherVector the vector to subtract
  3295. * @returns the updated Vector4.
  3296. */
  3297. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3298. /**
  3299. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3300. * @param otherVector the vector to add
  3301. * @returns the new vector with the result
  3302. */
  3303. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3304. /**
  3305. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3306. * @param otherVector the vector to subtract
  3307. * @param result the vector to store the result
  3308. * @returns the current Vector4.
  3309. */
  3310. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3313. */
  3314. /**
  3315. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3316. * @param x value to subtract
  3317. * @param y value to subtract
  3318. * @param z value to subtract
  3319. * @param w value to subtract
  3320. * @returns new vector containing the result
  3321. */
  3322. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3323. /**
  3324. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3325. * @param x value to subtract
  3326. * @param y value to subtract
  3327. * @param z value to subtract
  3328. * @param w value to subtract
  3329. * @param result the vector to store the result in
  3330. * @returns the current Vector4.
  3331. */
  3332. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3333. /**
  3334. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3335. * @returns a new vector with the negated values
  3336. */
  3337. negate(): Vector4;
  3338. /**
  3339. * Negate this vector in place
  3340. * @returns this
  3341. */
  3342. negateInPlace(): Vector4;
  3343. /**
  3344. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3345. * @param result defines the Vector3 object where to store the result
  3346. * @returns the current Vector4
  3347. */
  3348. negateToRef(result: Vector4): Vector4;
  3349. /**
  3350. * Multiplies the current Vector4 coordinates by scale (float).
  3351. * @param scale the number to scale with
  3352. * @returns the updated Vector4.
  3353. */
  3354. scaleInPlace(scale: number): Vector4;
  3355. /**
  3356. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3357. * @param scale the number to scale with
  3358. * @returns a new vector with the result
  3359. */
  3360. scale(scale: number): Vector4;
  3361. /**
  3362. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3363. * @param scale the number to scale with
  3364. * @param result a vector to store the result in
  3365. * @returns the current Vector4.
  3366. */
  3367. scaleToRef(scale: number, result: Vector4): Vector4;
  3368. /**
  3369. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3370. * @param scale defines the scale factor
  3371. * @param result defines the Vector4 object where to store the result
  3372. * @returns the unmodified current Vector4
  3373. */
  3374. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3375. /**
  3376. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3377. * @param otherVector the vector to compare against
  3378. * @returns true if they are equal
  3379. */
  3380. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3381. /**
  3382. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3383. * @param otherVector vector to compare against
  3384. * @param epsilon (Default: very small number)
  3385. * @returns true if they are equal
  3386. */
  3387. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3388. /**
  3389. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3390. * @param x x value to compare against
  3391. * @param y y value to compare against
  3392. * @param z z value to compare against
  3393. * @param w w value to compare against
  3394. * @returns true if equal
  3395. */
  3396. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3397. /**
  3398. * Multiplies in place the current Vector4 by the given one.
  3399. * @param otherVector vector to multiple with
  3400. * @returns the updated Vector4.
  3401. */
  3402. multiplyInPlace(otherVector: Vector4): Vector4;
  3403. /**
  3404. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3405. * @param otherVector vector to multiple with
  3406. * @returns resulting new vector
  3407. */
  3408. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3409. /**
  3410. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3411. * @param otherVector vector to multiple with
  3412. * @param result vector to store the result
  3413. * @returns the current Vector4.
  3414. */
  3415. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3416. /**
  3417. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3418. * @param x x value multiply with
  3419. * @param y y value multiply with
  3420. * @param z z value multiply with
  3421. * @param w w value multiply with
  3422. * @returns resulting new vector
  3423. */
  3424. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3425. /**
  3426. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3427. * @param otherVector vector to devide with
  3428. * @returns resulting new vector
  3429. */
  3430. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3431. /**
  3432. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3433. * @param otherVector vector to devide with
  3434. * @param result vector to store the result
  3435. * @returns the current Vector4.
  3436. */
  3437. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3438. /**
  3439. * Divides the current Vector3 coordinates by the given ones.
  3440. * @param otherVector vector to devide with
  3441. * @returns the updated Vector3.
  3442. */
  3443. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3444. /**
  3445. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3446. * @param other defines the second operand
  3447. * @returns the current updated Vector4
  3448. */
  3449. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3450. /**
  3451. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3452. * @param other defines the second operand
  3453. * @returns the current updated Vector4
  3454. */
  3455. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3456. /**
  3457. * Gets a new Vector4 from current Vector4 floored values
  3458. * @returns a new Vector4
  3459. */
  3460. floor(): Vector4;
  3461. /**
  3462. * Gets a new Vector4 from current Vector3 floored values
  3463. * @returns a new Vector4
  3464. */
  3465. fract(): Vector4;
  3466. /**
  3467. * Returns the Vector4 length (float).
  3468. * @returns the length
  3469. */
  3470. length(): number;
  3471. /**
  3472. * Returns the Vector4 squared length (float).
  3473. * @returns the length squared
  3474. */
  3475. lengthSquared(): number;
  3476. /**
  3477. * Normalizes in place the Vector4.
  3478. * @returns the updated Vector4.
  3479. */
  3480. normalize(): Vector4;
  3481. /**
  3482. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3483. * @returns this converted to a new vector3
  3484. */
  3485. toVector3(): Vector3;
  3486. /**
  3487. * Returns a new Vector4 copied from the current one.
  3488. * @returns the new cloned vector
  3489. */
  3490. clone(): Vector4;
  3491. /**
  3492. * Updates the current Vector4 with the given one coordinates.
  3493. * @param source the source vector to copy from
  3494. * @returns the updated Vector4.
  3495. */
  3496. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3497. /**
  3498. * Updates the current Vector4 coordinates with the given floats.
  3499. * @param x float to copy from
  3500. * @param y float to copy from
  3501. * @param z float to copy from
  3502. * @param w float to copy from
  3503. * @returns the updated Vector4.
  3504. */
  3505. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3506. /**
  3507. * Updates the current Vector4 coordinates with the given floats.
  3508. * @param x float to set from
  3509. * @param y float to set from
  3510. * @param z float to set from
  3511. * @param w float to set from
  3512. * @returns the updated Vector4.
  3513. */
  3514. set(x: number, y: number, z: number, w: number): Vector4;
  3515. /**
  3516. * Copies the given float to the current Vector3 coordinates
  3517. * @param v defines the x, y, z and w coordinates of the operand
  3518. * @returns the current updated Vector3
  3519. */
  3520. setAll(v: number): Vector4;
  3521. /**
  3522. * Returns a new Vector4 set from the starting index of the given array.
  3523. * @param array the array to pull values from
  3524. * @param offset the offset into the array to start at
  3525. * @returns the new vector
  3526. */
  3527. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3528. /**
  3529. * Updates the given vector "result" from the starting index of the given array.
  3530. * @param array the array to pull values from
  3531. * @param offset the offset into the array to start at
  3532. * @param result the vector to store the result in
  3533. */
  3534. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3535. /**
  3536. * Updates the given vector "result" from the starting index of the given Float32Array.
  3537. * @param array the array to pull values from
  3538. * @param offset the offset into the array to start at
  3539. * @param result the vector to store the result in
  3540. */
  3541. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3542. /**
  3543. * Updates the given vector "result" coordinates from 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. * @param result the vector to the floats in
  3549. */
  3550. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3551. /**
  3552. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3553. * @returns the new vector
  3554. */
  3555. static Zero(): Vector4;
  3556. /**
  3557. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3558. * @returns the new vector
  3559. */
  3560. static One(): Vector4;
  3561. /**
  3562. * Returns a new normalized Vector4 from the given one.
  3563. * @param vector the vector to normalize
  3564. * @returns the vector
  3565. */
  3566. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3567. /**
  3568. * Updates the given vector "result" from the normalization of the given one.
  3569. * @param vector the vector to normalize
  3570. * @param result the vector to store the result in
  3571. */
  3572. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3573. /**
  3574. * Returns a vector with the minimum values from the left and right vectors
  3575. * @param left left vector to minimize
  3576. * @param right right vector to minimize
  3577. * @returns a new vector with the minimum of the left and right vector values
  3578. */
  3579. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3580. /**
  3581. * Returns a vector with the maximum values from the left and right vectors
  3582. * @param left left vector to maximize
  3583. * @param right right vector to maximize
  3584. * @returns a new vector with the maximum of the left and right vector values
  3585. */
  3586. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3587. /**
  3588. * Returns the distance (float) between the vectors "value1" and "value2".
  3589. * @param value1 value to calulate the distance between
  3590. * @param value2 value to calulate the distance between
  3591. * @return the distance between the two vectors
  3592. */
  3593. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3594. /**
  3595. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3596. * @param value1 value to calulate the distance between
  3597. * @param value2 value to calulate the distance between
  3598. * @return the distance between the two vectors squared
  3599. */
  3600. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3601. /**
  3602. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3603. * @param value1 value to calulate the center between
  3604. * @param value2 value to calulate the center between
  3605. * @return the center between the two vectors
  3606. */
  3607. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3608. /**
  3609. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3610. * This methods computes transformed normalized direction vectors only.
  3611. * @param vector the vector to transform
  3612. * @param transformation the transformation matrix to apply
  3613. * @returns the new vector
  3614. */
  3615. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3616. /**
  3617. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3618. * This methods computes transformed normalized direction vectors only.
  3619. * @param vector the vector to transform
  3620. * @param transformation the transformation matrix to apply
  3621. * @param result the vector to store the result in
  3622. */
  3623. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3624. /**
  3625. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3626. * This methods computes transformed normalized direction vectors only.
  3627. * @param x value to transform
  3628. * @param y value to transform
  3629. * @param z value to transform
  3630. * @param w value to transform
  3631. * @param transformation the transformation matrix to apply
  3632. * @param result the vector to store the results in
  3633. */
  3634. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3635. /**
  3636. * Creates a new Vector4 from a Vector3
  3637. * @param source defines the source data
  3638. * @param w defines the 4th component (default is 0)
  3639. * @returns a new Vector4
  3640. */
  3641. static FromVector3(source: Vector3, w?: number): Vector4;
  3642. }
  3643. /**
  3644. * Class used to store quaternion data
  3645. * @see https://en.wikipedia.org/wiki/Quaternion
  3646. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3647. */
  3648. export class Quaternion {
  3649. /** @hidden */
  3650. _x: number;
  3651. /** @hidden */
  3652. _y: number;
  3653. /** @hidden */
  3654. _z: number;
  3655. /** @hidden */
  3656. _w: number;
  3657. /** @hidden */
  3658. _isDirty: boolean;
  3659. /** Gets or sets the x coordinate */
  3660. get x(): number;
  3661. set x(value: number);
  3662. /** Gets or sets the y coordinate */
  3663. get y(): number;
  3664. set y(value: number);
  3665. /** Gets or sets the z coordinate */
  3666. get z(): number;
  3667. set z(value: number);
  3668. /** Gets or sets the w coordinate */
  3669. get w(): number;
  3670. set w(value: number);
  3671. /**
  3672. * Creates a new Quaternion from the given floats
  3673. * @param x defines the first component (0 by default)
  3674. * @param y defines the second component (0 by default)
  3675. * @param z defines the third component (0 by default)
  3676. * @param w defines the fourth component (1.0 by default)
  3677. */
  3678. constructor(x?: number, y?: number, z?: number, w?: number);
  3679. /**
  3680. * Gets a string representation for the current quaternion
  3681. * @returns a string with the Quaternion coordinates
  3682. */
  3683. toString(): string;
  3684. /**
  3685. * Gets the class name of the quaternion
  3686. * @returns the string "Quaternion"
  3687. */
  3688. getClassName(): string;
  3689. /**
  3690. * Gets a hash code for this quaternion
  3691. * @returns the quaternion hash code
  3692. */
  3693. getHashCode(): number;
  3694. /**
  3695. * Copy the quaternion to an array
  3696. * @returns a new array populated with 4 elements from the quaternion coordinates
  3697. */
  3698. asArray(): number[];
  3699. /**
  3700. * Check if two quaternions are equals
  3701. * @param otherQuaternion defines the second operand
  3702. * @return true if the current quaternion and the given one coordinates are strictly equals
  3703. */
  3704. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3705. /**
  3706. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3707. * @param otherQuaternion defines the other quaternion
  3708. * @param epsilon defines the minimal distance to consider equality
  3709. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3710. */
  3711. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3712. /**
  3713. * Clone the current quaternion
  3714. * @returns a new quaternion copied from the current one
  3715. */
  3716. clone(): Quaternion;
  3717. /**
  3718. * Copy a quaternion to the current one
  3719. * @param other defines the other quaternion
  3720. * @returns the updated current quaternion
  3721. */
  3722. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3723. /**
  3724. * Updates the current quaternion with the given float coordinates
  3725. * @param x defines the x coordinate
  3726. * @param y defines the y coordinate
  3727. * @param z defines the z coordinate
  3728. * @param w defines the w coordinate
  3729. * @returns the updated current quaternion
  3730. */
  3731. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3732. /**
  3733. * Updates the current quaternion from the given float coordinates
  3734. * @param x defines the x coordinate
  3735. * @param y defines the y coordinate
  3736. * @param z defines the z coordinate
  3737. * @param w defines the w coordinate
  3738. * @returns the updated current quaternion
  3739. */
  3740. set(x: number, y: number, z: number, w: number): Quaternion;
  3741. /**
  3742. * Adds two quaternions
  3743. * @param other defines the second operand
  3744. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3745. */
  3746. add(other: DeepImmutable<Quaternion>): Quaternion;
  3747. /**
  3748. * Add a quaternion to the current one
  3749. * @param other defines the quaternion to add
  3750. * @returns the current quaternion
  3751. */
  3752. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3753. /**
  3754. * Subtract two quaternions
  3755. * @param other defines the second operand
  3756. * @returns a new quaternion as the subtraction result of the given one from the current one
  3757. */
  3758. subtract(other: Quaternion): Quaternion;
  3759. /**
  3760. * Multiplies the current quaternion by a scale factor
  3761. * @param value defines the scale factor
  3762. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3763. */
  3764. scale(value: number): Quaternion;
  3765. /**
  3766. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3767. * @param scale defines the scale factor
  3768. * @param result defines the Quaternion object where to store the result
  3769. * @returns the unmodified current quaternion
  3770. */
  3771. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Multiplies in place the current quaternion by a scale factor
  3774. * @param value defines the scale factor
  3775. * @returns the current modified quaternion
  3776. */
  3777. scaleInPlace(value: number): Quaternion;
  3778. /**
  3779. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3780. * @param scale defines the scale factor
  3781. * @param result defines the Quaternion object where to store the result
  3782. * @returns the unmodified current quaternion
  3783. */
  3784. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3785. /**
  3786. * Multiplies two quaternions
  3787. * @param q1 defines the second operand
  3788. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3789. */
  3790. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3791. /**
  3792. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3793. * @param q1 defines the second operand
  3794. * @param result defines the target quaternion
  3795. * @returns the current quaternion
  3796. */
  3797. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3798. /**
  3799. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3800. * @param q1 defines the second operand
  3801. * @returns the currentupdated quaternion
  3802. */
  3803. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3804. /**
  3805. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3806. * @param ref defines the target quaternion
  3807. * @returns the current quaternion
  3808. */
  3809. conjugateToRef(ref: Quaternion): Quaternion;
  3810. /**
  3811. * Conjugates in place (1-q) the current quaternion
  3812. * @returns the current updated quaternion
  3813. */
  3814. conjugateInPlace(): Quaternion;
  3815. /**
  3816. * Conjugates in place (1-q) the current quaternion
  3817. * @returns a new quaternion
  3818. */
  3819. conjugate(): Quaternion;
  3820. /**
  3821. * Gets length of current quaternion
  3822. * @returns the quaternion length (float)
  3823. */
  3824. length(): number;
  3825. /**
  3826. * Normalize in place the current quaternion
  3827. * @returns the current updated quaternion
  3828. */
  3829. normalize(): Quaternion;
  3830. /**
  3831. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3832. * @param order is a reserved parameter and is ignore for now
  3833. * @returns a new Vector3 containing the Euler angles
  3834. */
  3835. toEulerAngles(order?: string): Vector3;
  3836. /**
  3837. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3838. * @param result defines the vector which will be filled with the Euler angles
  3839. * @param order is a reserved parameter and is ignore for now
  3840. * @returns the current unchanged quaternion
  3841. */
  3842. toEulerAnglesToRef(result: Vector3): Quaternion;
  3843. /**
  3844. * Updates the given rotation matrix with the current quaternion values
  3845. * @param result defines the target matrix
  3846. * @returns the current unchanged quaternion
  3847. */
  3848. toRotationMatrix(result: Matrix): Quaternion;
  3849. /**
  3850. * Updates the current quaternion from the given rotation matrix values
  3851. * @param matrix defines the source matrix
  3852. * @returns the current updated quaternion
  3853. */
  3854. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3855. /**
  3856. * Creates a new quaternion from a rotation matrix
  3857. * @param matrix defines the source matrix
  3858. * @returns a new quaternion created from the given rotation matrix values
  3859. */
  3860. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3861. /**
  3862. * Updates the given quaternion with the given rotation matrix values
  3863. * @param matrix defines the source matrix
  3864. * @param result defines the target quaternion
  3865. */
  3866. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3867. /**
  3868. * Returns the dot product (float) between the quaternions "left" and "right"
  3869. * @param left defines the left operand
  3870. * @param right defines the right operand
  3871. * @returns the dot product
  3872. */
  3873. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3874. /**
  3875. * Checks if the two quaternions are close to each other
  3876. * @param quat0 defines the first quaternion to check
  3877. * @param quat1 defines the second quaternion to check
  3878. * @returns true if the two quaternions are close to each other
  3879. */
  3880. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3881. /**
  3882. * Creates an empty quaternion
  3883. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3884. */
  3885. static Zero(): Quaternion;
  3886. /**
  3887. * Inverse a given quaternion
  3888. * @param q defines the source quaternion
  3889. * @returns a new quaternion as the inverted current quaternion
  3890. */
  3891. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3892. /**
  3893. * Inverse a given quaternion
  3894. * @param q defines the source quaternion
  3895. * @param result the quaternion the result will be stored in
  3896. * @returns the result quaternion
  3897. */
  3898. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3899. /**
  3900. * Creates an identity quaternion
  3901. * @returns the identity quaternion
  3902. */
  3903. static Identity(): Quaternion;
  3904. /**
  3905. * Gets a boolean indicating if the given quaternion is identity
  3906. * @param quaternion defines the quaternion to check
  3907. * @returns true if the quaternion is identity
  3908. */
  3909. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3910. /**
  3911. * Creates a quaternion from a rotation around an axis
  3912. * @param axis defines the axis to use
  3913. * @param angle defines the angle to use
  3914. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3915. */
  3916. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3917. /**
  3918. * Creates a rotation around an axis and stores it into the given quaternion
  3919. * @param axis defines the axis to use
  3920. * @param angle defines the angle to use
  3921. * @param result defines the target quaternion
  3922. * @returns the target quaternion
  3923. */
  3924. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3925. /**
  3926. * Creates a new quaternion from data stored into an array
  3927. * @param array defines the data source
  3928. * @param offset defines the offset in the source array where the data starts
  3929. * @returns a new quaternion
  3930. */
  3931. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3932. /**
  3933. * Updates the given quaternion "result" from the starting index of the given array.
  3934. * @param array the array to pull values from
  3935. * @param offset the offset into the array to start at
  3936. * @param result the quaternion to store the result in
  3937. */
  3938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3939. /**
  3940. * Create a quaternion from Euler rotation angles
  3941. * @param x Pitch
  3942. * @param y Yaw
  3943. * @param z Roll
  3944. * @returns the new Quaternion
  3945. */
  3946. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3947. /**
  3948. * Updates a quaternion from Euler rotation angles
  3949. * @param x Pitch
  3950. * @param y Yaw
  3951. * @param z Roll
  3952. * @param result the quaternion to store the result
  3953. * @returns the updated quaternion
  3954. */
  3955. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3956. /**
  3957. * Create a quaternion from Euler rotation vector
  3958. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3959. * @returns the new Quaternion
  3960. */
  3961. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3962. /**
  3963. * Updates a quaternion from Euler rotation vector
  3964. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3965. * @param result the quaternion to store the result
  3966. * @returns the updated quaternion
  3967. */
  3968. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3969. /**
  3970. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3971. * @param yaw defines the rotation around Y axis
  3972. * @param pitch defines the rotation around X axis
  3973. * @param roll defines the rotation around Z axis
  3974. * @returns the new quaternion
  3975. */
  3976. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3977. /**
  3978. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3979. * @param yaw defines the rotation around Y axis
  3980. * @param pitch defines the rotation around X axis
  3981. * @param roll defines the rotation around Z axis
  3982. * @param result defines the target quaternion
  3983. */
  3984. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3985. /**
  3986. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3987. * @param alpha defines the rotation around first axis
  3988. * @param beta defines the rotation around second axis
  3989. * @param gamma defines the rotation around third axis
  3990. * @returns the new quaternion
  3991. */
  3992. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3993. /**
  3994. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3995. * @param alpha defines the rotation around first axis
  3996. * @param beta defines the rotation around second axis
  3997. * @param gamma defines the rotation around third axis
  3998. * @param result defines the target quaternion
  3999. */
  4000. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4001. /**
  4002. * 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)
  4003. * @param axis1 defines the first axis
  4004. * @param axis2 defines the second axis
  4005. * @param axis3 defines the third axis
  4006. * @returns the new quaternion
  4007. */
  4008. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4009. /**
  4010. * 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
  4011. * @param axis1 defines the first axis
  4012. * @param axis2 defines the second axis
  4013. * @param axis3 defines the third axis
  4014. * @param ref defines the target quaternion
  4015. */
  4016. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4017. /**
  4018. * Interpolates between two quaternions
  4019. * @param left defines first quaternion
  4020. * @param right defines second quaternion
  4021. * @param amount defines the gradient to use
  4022. * @returns the new interpolated quaternion
  4023. */
  4024. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4025. /**
  4026. * Interpolates between two quaternions and stores it into a target quaternion
  4027. * @param left defines first quaternion
  4028. * @param right defines second quaternion
  4029. * @param amount defines the gradient to use
  4030. * @param result defines the target quaternion
  4031. */
  4032. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4033. /**
  4034. * Interpolate between two quaternions using Hermite interpolation
  4035. * @param value1 defines first quaternion
  4036. * @param tangent1 defines the incoming tangent
  4037. * @param value2 defines second quaternion
  4038. * @param tangent2 defines the outgoing tangent
  4039. * @param amount defines the target quaternion
  4040. * @returns the new interpolated quaternion
  4041. */
  4042. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4043. }
  4044. /**
  4045. * Class used to store matrix data (4x4)
  4046. */
  4047. export class Matrix {
  4048. private static _updateFlagSeed;
  4049. private static _identityReadOnly;
  4050. private _isIdentity;
  4051. private _isIdentityDirty;
  4052. private _isIdentity3x2;
  4053. private _isIdentity3x2Dirty;
  4054. /**
  4055. * Gets the update flag of the matrix which is an unique number for the matrix.
  4056. * It will be incremented every time the matrix data change.
  4057. * You can use it to speed the comparison between two versions of the same matrix.
  4058. */
  4059. updateFlag: number;
  4060. private readonly _m;
  4061. /**
  4062. * Gets the internal data of the matrix
  4063. */
  4064. get m(): DeepImmutable<Float32Array>;
  4065. /** @hidden */
  4066. _markAsUpdated(): void;
  4067. /** @hidden */
  4068. private _updateIdentityStatus;
  4069. /**
  4070. * Creates an empty matrix (filled with zeros)
  4071. */
  4072. constructor();
  4073. /**
  4074. * Check if the current matrix is identity
  4075. * @returns true is the matrix is the identity matrix
  4076. */
  4077. isIdentity(): boolean;
  4078. /**
  4079. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4080. * @returns true is the matrix is the identity matrix
  4081. */
  4082. isIdentityAs3x2(): boolean;
  4083. /**
  4084. * Gets the determinant of the matrix
  4085. * @returns the matrix determinant
  4086. */
  4087. determinant(): number;
  4088. /**
  4089. * Returns the matrix as a Float32Array
  4090. * @returns the matrix underlying array
  4091. */
  4092. toArray(): DeepImmutable<Float32Array>;
  4093. /**
  4094. * Returns the matrix as a Float32Array
  4095. * @returns the matrix underlying array.
  4096. */
  4097. asArray(): DeepImmutable<Float32Array>;
  4098. /**
  4099. * Inverts the current matrix in place
  4100. * @returns the current inverted matrix
  4101. */
  4102. invert(): Matrix;
  4103. /**
  4104. * Sets all the matrix elements to zero
  4105. * @returns the current matrix
  4106. */
  4107. reset(): Matrix;
  4108. /**
  4109. * Adds the current matrix with a second one
  4110. * @param other defines the matrix to add
  4111. * @returns a new matrix as the addition of the current matrix and the given one
  4112. */
  4113. add(other: DeepImmutable<Matrix>): Matrix;
  4114. /**
  4115. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4116. * @param other defines the matrix to add
  4117. * @param result defines the target matrix
  4118. * @returns the current matrix
  4119. */
  4120. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4121. /**
  4122. * Adds in place the given matrix to the current matrix
  4123. * @param other defines the second operand
  4124. * @returns the current updated matrix
  4125. */
  4126. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4127. /**
  4128. * Sets the given matrix to the current inverted Matrix
  4129. * @param other defines the target matrix
  4130. * @returns the unmodified current matrix
  4131. */
  4132. invertToRef(other: Matrix): Matrix;
  4133. /**
  4134. * add a value at the specified position in the current Matrix
  4135. * @param index the index of the value within the matrix. between 0 and 15.
  4136. * @param value the value to be added
  4137. * @returns the current updated matrix
  4138. */
  4139. addAtIndex(index: number, value: number): Matrix;
  4140. /**
  4141. * mutiply the specified position in the current Matrix by a value
  4142. * @param index the index of the value within the matrix. between 0 and 15.
  4143. * @param value the value to be added
  4144. * @returns the current updated matrix
  4145. */
  4146. multiplyAtIndex(index: number, value: number): Matrix;
  4147. /**
  4148. * Inserts the translation vector (using 3 floats) in the current matrix
  4149. * @param x defines the 1st component of the translation
  4150. * @param y defines the 2nd component of the translation
  4151. * @param z defines the 3rd component of the translation
  4152. * @returns the current updated matrix
  4153. */
  4154. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4155. /**
  4156. * Adds the translation vector (using 3 floats) in the current matrix
  4157. * @param x defines the 1st component of the translation
  4158. * @param y defines the 2nd component of the translation
  4159. * @param z defines the 3rd component of the translation
  4160. * @returns the current updated matrix
  4161. */
  4162. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4163. /**
  4164. * Inserts the translation vector in the current matrix
  4165. * @param vector3 defines the translation to insert
  4166. * @returns the current updated matrix
  4167. */
  4168. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4169. /**
  4170. * Gets the translation value of the current matrix
  4171. * @returns a new Vector3 as the extracted translation from the matrix
  4172. */
  4173. getTranslation(): Vector3;
  4174. /**
  4175. * Fill a Vector3 with the extracted translation from the matrix
  4176. * @param result defines the Vector3 where to store the translation
  4177. * @returns the current matrix
  4178. */
  4179. getTranslationToRef(result: Vector3): Matrix;
  4180. /**
  4181. * Remove rotation and scaling part from the matrix
  4182. * @returns the updated matrix
  4183. */
  4184. removeRotationAndScaling(): Matrix;
  4185. /**
  4186. * Multiply two matrices
  4187. * @param other defines the second operand
  4188. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4189. */
  4190. multiply(other: DeepImmutable<Matrix>): Matrix;
  4191. /**
  4192. * Copy the current matrix from the given one
  4193. * @param other defines the source matrix
  4194. * @returns the current updated matrix
  4195. */
  4196. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4197. /**
  4198. * Populates the given array from the starting index with the current matrix values
  4199. * @param array defines the target array
  4200. * @param offset defines the offset in the target array where to start storing values
  4201. * @returns the current matrix
  4202. */
  4203. copyToArray(array: Float32Array, offset?: number): Matrix;
  4204. /**
  4205. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4206. * @param other defines the second operand
  4207. * @param result defines the matrix where to store the multiplication
  4208. * @returns the current matrix
  4209. */
  4210. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4211. /**
  4212. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4213. * @param other defines the second operand
  4214. * @param result defines the array where to store the multiplication
  4215. * @param offset defines the offset in the target array where to start storing values
  4216. * @returns the current matrix
  4217. */
  4218. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4219. /**
  4220. * Check equality between this matrix and a second one
  4221. * @param value defines the second matrix to compare
  4222. * @returns true is the current matrix and the given one values are strictly equal
  4223. */
  4224. equals(value: DeepImmutable<Matrix>): boolean;
  4225. /**
  4226. * Clone the current matrix
  4227. * @returns a new matrix from the current matrix
  4228. */
  4229. clone(): Matrix;
  4230. /**
  4231. * Returns the name of the current matrix class
  4232. * @returns the string "Matrix"
  4233. */
  4234. getClassName(): string;
  4235. /**
  4236. * Gets the hash code of the current matrix
  4237. * @returns the hash code
  4238. */
  4239. getHashCode(): number;
  4240. /**
  4241. * Decomposes the current Matrix into a translation, rotation and scaling components
  4242. * @param scale defines the scale vector3 given as a reference to update
  4243. * @param rotation defines the rotation quaternion given as a reference to update
  4244. * @param translation defines the translation vector3 given as a reference to update
  4245. * @returns true if operation was successful
  4246. */
  4247. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4248. /**
  4249. * Gets specific row of the matrix
  4250. * @param index defines the number of the row to get
  4251. * @returns the index-th row of the current matrix as a new Vector4
  4252. */
  4253. getRow(index: number): Nullable<Vector4>;
  4254. /**
  4255. * Sets the index-th row of the current matrix to the vector4 values
  4256. * @param index defines the number of the row to set
  4257. * @param row defines the target vector4
  4258. * @returns the updated current matrix
  4259. */
  4260. setRow(index: number, row: Vector4): Matrix;
  4261. /**
  4262. * Compute the transpose of the matrix
  4263. * @returns the new transposed matrix
  4264. */
  4265. transpose(): Matrix;
  4266. /**
  4267. * Compute the transpose of the matrix and store it in a given matrix
  4268. * @param result defines the target matrix
  4269. * @returns the current matrix
  4270. */
  4271. transposeToRef(result: Matrix): Matrix;
  4272. /**
  4273. * Sets the index-th row of the current matrix with the given 4 x float values
  4274. * @param index defines the row index
  4275. * @param x defines the x component to set
  4276. * @param y defines the y component to set
  4277. * @param z defines the z component to set
  4278. * @param w defines the w component to set
  4279. * @returns the updated current matrix
  4280. */
  4281. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4282. /**
  4283. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4284. * @param scale defines the scale factor
  4285. * @returns a new matrix
  4286. */
  4287. scale(scale: number): Matrix;
  4288. /**
  4289. * Scale the current matrix values by a factor to a given result matrix
  4290. * @param scale defines the scale factor
  4291. * @param result defines the matrix to store the result
  4292. * @returns the current matrix
  4293. */
  4294. scaleToRef(scale: number, result: Matrix): Matrix;
  4295. /**
  4296. * Scale the current matrix values by a factor and add the result to a given matrix
  4297. * @param scale defines the scale factor
  4298. * @param result defines the Matrix to store the result
  4299. * @returns the current matrix
  4300. */
  4301. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4302. /**
  4303. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4304. * @param ref matrix to store the result
  4305. */
  4306. toNormalMatrix(ref: Matrix): void;
  4307. /**
  4308. * Gets only rotation part of the current matrix
  4309. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4310. */
  4311. getRotationMatrix(): Matrix;
  4312. /**
  4313. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4314. * @param result defines the target matrix to store data to
  4315. * @returns the current matrix
  4316. */
  4317. getRotationMatrixToRef(result: Matrix): Matrix;
  4318. /**
  4319. * Toggles model matrix from being right handed to left handed in place and vice versa
  4320. */
  4321. toggleModelMatrixHandInPlace(): void;
  4322. /**
  4323. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4324. */
  4325. toggleProjectionMatrixHandInPlace(): void;
  4326. /**
  4327. * Creates a matrix from an array
  4328. * @param array defines the source array
  4329. * @param offset defines an offset in the source array
  4330. * @returns a new Matrix set from the starting index of the given array
  4331. */
  4332. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4333. /**
  4334. * Copy the content of an array into a given matrix
  4335. * @param array defines the source array
  4336. * @param offset defines an offset in the source array
  4337. * @param result defines the target matrix
  4338. */
  4339. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4340. /**
  4341. * Stores an array into a matrix after having multiplied each component by a given factor
  4342. * @param array defines the source array
  4343. * @param offset defines the offset in the source array
  4344. * @param scale defines the scaling factor
  4345. * @param result defines the target matrix
  4346. */
  4347. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4348. /**
  4349. * Gets an identity matrix that must not be updated
  4350. */
  4351. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4352. /**
  4353. * Stores a list of values (16) inside a given matrix
  4354. * @param initialM11 defines 1st value of 1st row
  4355. * @param initialM12 defines 2nd value of 1st row
  4356. * @param initialM13 defines 3rd value of 1st row
  4357. * @param initialM14 defines 4th value of 1st row
  4358. * @param initialM21 defines 1st value of 2nd row
  4359. * @param initialM22 defines 2nd value of 2nd row
  4360. * @param initialM23 defines 3rd value of 2nd row
  4361. * @param initialM24 defines 4th value of 2nd row
  4362. * @param initialM31 defines 1st value of 3rd row
  4363. * @param initialM32 defines 2nd value of 3rd row
  4364. * @param initialM33 defines 3rd value of 3rd row
  4365. * @param initialM34 defines 4th value of 3rd row
  4366. * @param initialM41 defines 1st value of 4th row
  4367. * @param initialM42 defines 2nd value of 4th row
  4368. * @param initialM43 defines 3rd value of 4th row
  4369. * @param initialM44 defines 4th value of 4th row
  4370. * @param result defines the target matrix
  4371. */
  4372. 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;
  4373. /**
  4374. * Creates new matrix from a list of values (16)
  4375. * @param initialM11 defines 1st value of 1st row
  4376. * @param initialM12 defines 2nd value of 1st row
  4377. * @param initialM13 defines 3rd value of 1st row
  4378. * @param initialM14 defines 4th value of 1st row
  4379. * @param initialM21 defines 1st value of 2nd row
  4380. * @param initialM22 defines 2nd value of 2nd row
  4381. * @param initialM23 defines 3rd value of 2nd row
  4382. * @param initialM24 defines 4th value of 2nd row
  4383. * @param initialM31 defines 1st value of 3rd row
  4384. * @param initialM32 defines 2nd value of 3rd row
  4385. * @param initialM33 defines 3rd value of 3rd row
  4386. * @param initialM34 defines 4th value of 3rd row
  4387. * @param initialM41 defines 1st value of 4th row
  4388. * @param initialM42 defines 2nd value of 4th row
  4389. * @param initialM43 defines 3rd value of 4th row
  4390. * @param initialM44 defines 4th value of 4th row
  4391. * @returns the new matrix
  4392. */
  4393. 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;
  4394. /**
  4395. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4396. * @param scale defines the scale vector3
  4397. * @param rotation defines the rotation quaternion
  4398. * @param translation defines the translation vector3
  4399. * @returns a new matrix
  4400. */
  4401. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4402. /**
  4403. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4404. * @param scale defines the scale vector3
  4405. * @param rotation defines the rotation quaternion
  4406. * @param translation defines the translation vector3
  4407. * @param result defines the target matrix
  4408. */
  4409. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4410. /**
  4411. * Creates a new identity matrix
  4412. * @returns a new identity matrix
  4413. */
  4414. static Identity(): Matrix;
  4415. /**
  4416. * Creates a new identity matrix and stores the result in a given matrix
  4417. * @param result defines the target matrix
  4418. */
  4419. static IdentityToRef(result: Matrix): void;
  4420. /**
  4421. * Creates a new zero matrix
  4422. * @returns a new zero matrix
  4423. */
  4424. static Zero(): Matrix;
  4425. /**
  4426. * Creates a new rotation matrix for "angle" radians around the X axis
  4427. * @param angle defines the angle (in radians) to use
  4428. * @return the new matrix
  4429. */
  4430. static RotationX(angle: number): Matrix;
  4431. /**
  4432. * Creates a new matrix as the invert of a given matrix
  4433. * @param source defines the source matrix
  4434. * @returns the new matrix
  4435. */
  4436. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4437. /**
  4438. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4439. * @param angle defines the angle (in radians) to use
  4440. * @param result defines the target matrix
  4441. */
  4442. static RotationXToRef(angle: number, result: Matrix): void;
  4443. /**
  4444. * Creates a new rotation matrix for "angle" radians around the Y axis
  4445. * @param angle defines the angle (in radians) to use
  4446. * @return the new matrix
  4447. */
  4448. static RotationY(angle: number): Matrix;
  4449. /**
  4450. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4451. * @param angle defines the angle (in radians) to use
  4452. * @param result defines the target matrix
  4453. */
  4454. static RotationYToRef(angle: number, result: Matrix): void;
  4455. /**
  4456. * Creates a new rotation matrix for "angle" radians around the Z axis
  4457. * @param angle defines the angle (in radians) to use
  4458. * @return the new matrix
  4459. */
  4460. static RotationZ(angle: number): Matrix;
  4461. /**
  4462. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4463. * @param angle defines the angle (in radians) to use
  4464. * @param result defines the target matrix
  4465. */
  4466. static RotationZToRef(angle: number, result: Matrix): void;
  4467. /**
  4468. * Creates a new rotation matrix for "angle" radians around the given axis
  4469. * @param axis defines the axis to use
  4470. * @param angle defines the angle (in radians) to use
  4471. * @return the new matrix
  4472. */
  4473. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4474. /**
  4475. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4476. * @param axis defines the axis to use
  4477. * @param angle defines the angle (in radians) to use
  4478. * @param result defines the target matrix
  4479. */
  4480. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4481. /**
  4482. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4483. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4484. * @param from defines the vector to align
  4485. * @param to defines the vector to align to
  4486. * @param result defines the target matrix
  4487. */
  4488. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4489. /**
  4490. * Creates a rotation matrix
  4491. * @param yaw defines the yaw angle in radians (Y axis)
  4492. * @param pitch defines the pitch angle in radians (X axis)
  4493. * @param roll defines the roll angle in radians (X axis)
  4494. * @returns the new rotation matrix
  4495. */
  4496. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4497. /**
  4498. * Creates a rotation matrix and stores it in a given matrix
  4499. * @param yaw defines the yaw angle in radians (Y axis)
  4500. * @param pitch defines the pitch angle in radians (X axis)
  4501. * @param roll defines the roll angle in radians (X axis)
  4502. * @param result defines the target matrix
  4503. */
  4504. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4505. /**
  4506. * Creates a scaling matrix
  4507. * @param x defines the scale factor on X axis
  4508. * @param y defines the scale factor on Y axis
  4509. * @param z defines the scale factor on Z axis
  4510. * @returns the new matrix
  4511. */
  4512. static Scaling(x: number, y: number, z: number): Matrix;
  4513. /**
  4514. * Creates a scaling matrix and stores it in a given matrix
  4515. * @param x defines the scale factor on X axis
  4516. * @param y defines the scale factor on Y axis
  4517. * @param z defines the scale factor on Z axis
  4518. * @param result defines the target matrix
  4519. */
  4520. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4521. /**
  4522. * Creates a translation matrix
  4523. * @param x defines the translation on X axis
  4524. * @param y defines the translation on Y axis
  4525. * @param z defines the translationon Z axis
  4526. * @returns the new matrix
  4527. */
  4528. static Translation(x: number, y: number, z: number): Matrix;
  4529. /**
  4530. * Creates a translation matrix and stores it in a given matrix
  4531. * @param x defines the translation on X axis
  4532. * @param y defines the translation on Y axis
  4533. * @param z defines the translationon Z axis
  4534. * @param result defines the target matrix
  4535. */
  4536. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4537. /**
  4538. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4539. * @param startValue defines the start value
  4540. * @param endValue defines the end value
  4541. * @param gradient defines the gradient factor
  4542. * @returns the new matrix
  4543. */
  4544. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4545. /**
  4546. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4547. * @param startValue defines the start value
  4548. * @param endValue defines the end value
  4549. * @param gradient defines the gradient factor
  4550. * @param result defines the Matrix object where to store data
  4551. */
  4552. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4553. /**
  4554. * Builds a new matrix whose values are computed by:
  4555. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4556. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4557. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4558. * @param startValue defines the first matrix
  4559. * @param endValue defines the second matrix
  4560. * @param gradient defines the gradient between the two matrices
  4561. * @returns the new matrix
  4562. */
  4563. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4564. /**
  4565. * Update a matrix to values which are computed by:
  4566. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4567. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4568. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4569. * @param startValue defines the first matrix
  4570. * @param endValue defines the second matrix
  4571. * @param gradient defines the gradient between the two matrices
  4572. * @param result defines the target matrix
  4573. */
  4574. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4575. /**
  4576. * 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"
  4577. * This function works in left handed mode
  4578. * @param eye defines the final position of the entity
  4579. * @param target defines where the entity should look at
  4580. * @param up defines the up vector for the entity
  4581. * @returns the new matrix
  4582. */
  4583. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4584. /**
  4585. * 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".
  4586. * This function works in left handed mode
  4587. * @param eye defines the final position of the entity
  4588. * @param target defines where the entity should look at
  4589. * @param up defines the up vector for the entity
  4590. * @param result defines the target matrix
  4591. */
  4592. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4593. /**
  4594. * 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"
  4595. * This function works in right handed mode
  4596. * @param eye defines the final position of the entity
  4597. * @param target defines where the entity should look at
  4598. * @param up defines the up vector for the entity
  4599. * @returns the new matrix
  4600. */
  4601. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4602. /**
  4603. * 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".
  4604. * This function works in right handed mode
  4605. * @param eye defines the final position of the entity
  4606. * @param target defines where the entity should look at
  4607. * @param up defines the up vector for the entity
  4608. * @param result defines the target matrix
  4609. */
  4610. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4611. /**
  4612. * Create a left-handed orthographic projection matrix
  4613. * @param width defines the viewport width
  4614. * @param height defines the viewport height
  4615. * @param znear defines the near clip plane
  4616. * @param zfar defines the far clip plane
  4617. * @returns a new matrix as a left-handed orthographic projection matrix
  4618. */
  4619. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4620. /**
  4621. * Store a left-handed orthographic projection to a given matrix
  4622. * @param width defines the viewport width
  4623. * @param height defines the viewport height
  4624. * @param znear defines the near clip plane
  4625. * @param zfar defines the far clip plane
  4626. * @param result defines the target matrix
  4627. */
  4628. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4629. /**
  4630. * Create a left-handed orthographic projection matrix
  4631. * @param left defines the viewport left coordinate
  4632. * @param right defines the viewport right coordinate
  4633. * @param bottom defines the viewport bottom coordinate
  4634. * @param top defines the viewport top coordinate
  4635. * @param znear defines the near clip plane
  4636. * @param zfar defines the far clip plane
  4637. * @returns a new matrix as a left-handed orthographic projection matrix
  4638. */
  4639. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4640. /**
  4641. * Stores a left-handed orthographic projection into a given matrix
  4642. * @param left defines the viewport left coordinate
  4643. * @param right defines the viewport right coordinate
  4644. * @param bottom defines the viewport bottom coordinate
  4645. * @param top defines the viewport top coordinate
  4646. * @param znear defines the near clip plane
  4647. * @param zfar defines the far clip plane
  4648. * @param result defines the target matrix
  4649. */
  4650. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4651. /**
  4652. * Creates a right-handed orthographic projection matrix
  4653. * @param left defines the viewport left coordinate
  4654. * @param right defines the viewport right coordinate
  4655. * @param bottom defines the viewport bottom coordinate
  4656. * @param top defines the viewport top coordinate
  4657. * @param znear defines the near clip plane
  4658. * @param zfar defines the far clip plane
  4659. * @returns a new matrix as a right-handed orthographic projection matrix
  4660. */
  4661. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4662. /**
  4663. * Stores a right-handed orthographic projection into a given matrix
  4664. * @param left defines the viewport left coordinate
  4665. * @param right defines the viewport right coordinate
  4666. * @param bottom defines the viewport bottom coordinate
  4667. * @param top defines the viewport top coordinate
  4668. * @param znear defines the near clip plane
  4669. * @param zfar defines the far clip plane
  4670. * @param result defines the target matrix
  4671. */
  4672. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4673. /**
  4674. * Creates a left-handed perspective projection matrix
  4675. * @param width defines the viewport width
  4676. * @param height defines the viewport height
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed perspective projection matrix
  4680. */
  4681. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Creates a left-handed perspective projection matrix
  4684. * @param fov defines the horizontal field of view
  4685. * @param aspect defines the aspect ratio
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @returns a new matrix as a left-handed perspective projection matrix
  4689. */
  4690. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4691. /**
  4692. * Stores a left-handed perspective projection into a given matrix
  4693. * @param fov defines the horizontal field of view
  4694. * @param aspect defines the aspect ratio
  4695. * @param znear defines the near clip plane
  4696. * @param zfar defines the far clip plane
  4697. * @param result defines the target matrix
  4698. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4699. */
  4700. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4701. /**
  4702. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4703. * @param fov defines the horizontal field of view
  4704. * @param aspect defines the aspect ratio
  4705. * @param znear defines the near clip plane
  4706. * @param zfar not used as infinity is used as far clip
  4707. * @param result defines the target matrix
  4708. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4709. */
  4710. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4711. /**
  4712. * Creates a right-handed perspective projection matrix
  4713. * @param fov defines the horizontal field of view
  4714. * @param aspect defines the aspect ratio
  4715. * @param znear defines the near clip plane
  4716. * @param zfar defines the far clip plane
  4717. * @returns a new matrix as a right-handed perspective projection matrix
  4718. */
  4719. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4720. /**
  4721. * Stores a right-handed perspective projection into a given matrix
  4722. * @param fov defines the horizontal field of view
  4723. * @param aspect defines the aspect ratio
  4724. * @param znear defines the near clip plane
  4725. * @param zfar defines the far clip plane
  4726. * @param result defines the target matrix
  4727. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4728. */
  4729. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4730. /**
  4731. * Stores a right-handed perspective projection into a given matrix
  4732. * @param fov defines the horizontal field of view
  4733. * @param aspect defines the aspect ratio
  4734. * @param znear defines the near clip plane
  4735. * @param zfar not used as infinity is used as far clip
  4736. * @param result defines the target matrix
  4737. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4738. */
  4739. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4740. /**
  4741. * Stores a perspective projection for WebVR info a given matrix
  4742. * @param fov defines the field of view
  4743. * @param znear defines the near clip plane
  4744. * @param zfar defines the far clip plane
  4745. * @param result defines the target matrix
  4746. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4747. */
  4748. static PerspectiveFovWebVRToRef(fov: {
  4749. upDegrees: number;
  4750. downDegrees: number;
  4751. leftDegrees: number;
  4752. rightDegrees: number;
  4753. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4754. /**
  4755. * Computes a complete transformation matrix
  4756. * @param viewport defines the viewport to use
  4757. * @param world defines the world matrix
  4758. * @param view defines the view matrix
  4759. * @param projection defines the projection matrix
  4760. * @param zmin defines the near clip plane
  4761. * @param zmax defines the far clip plane
  4762. * @returns the transformation matrix
  4763. */
  4764. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4765. /**
  4766. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4767. * @param matrix defines the matrix to use
  4768. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4769. */
  4770. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4771. /**
  4772. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4773. * @param matrix defines the matrix to use
  4774. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4775. */
  4776. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4777. /**
  4778. * Compute the transpose of a given matrix
  4779. * @param matrix defines the matrix to transpose
  4780. * @returns the new matrix
  4781. */
  4782. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4783. /**
  4784. * Compute the transpose of a matrix and store it in a target matrix
  4785. * @param matrix defines the matrix to transpose
  4786. * @param result defines the target matrix
  4787. */
  4788. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4789. /**
  4790. * Computes a reflection matrix from a plane
  4791. * @param plane defines the reflection plane
  4792. * @returns a new matrix
  4793. */
  4794. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4795. /**
  4796. * Computes a reflection matrix from a plane
  4797. * @param plane defines the reflection plane
  4798. * @param result defines the target matrix
  4799. */
  4800. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4801. /**
  4802. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4803. * @param xaxis defines the value of the 1st axis
  4804. * @param yaxis defines the value of the 2nd axis
  4805. * @param zaxis defines the value of the 3rd axis
  4806. * @param result defines the target matrix
  4807. */
  4808. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4809. /**
  4810. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4811. * @param quat defines the quaternion to use
  4812. * @param result defines the target matrix
  4813. */
  4814. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4815. }
  4816. /**
  4817. * @hidden
  4818. */
  4819. export class TmpVectors {
  4820. static Vector2: Vector2[];
  4821. static Vector3: Vector3[];
  4822. static Vector4: Vector4[];
  4823. static Quaternion: Quaternion[];
  4824. static Matrix: Matrix[];
  4825. }
  4826. }
  4827. declare module "babylonjs/Maths/math.path" {
  4828. import { DeepImmutable, Nullable } from "babylonjs/types";
  4829. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4830. /**
  4831. * Defines potential orientation for back face culling
  4832. */
  4833. export enum Orientation {
  4834. /**
  4835. * Clockwise
  4836. */
  4837. CW = 0,
  4838. /** Counter clockwise */
  4839. CCW = 1
  4840. }
  4841. /** Class used to represent a Bezier curve */
  4842. export class BezierCurve {
  4843. /**
  4844. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4845. * @param t defines the time
  4846. * @param x1 defines the left coordinate on X axis
  4847. * @param y1 defines the left coordinate on Y axis
  4848. * @param x2 defines the right coordinate on X axis
  4849. * @param y2 defines the right coordinate on Y axis
  4850. * @returns the interpolated value
  4851. */
  4852. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4853. }
  4854. /**
  4855. * Defines angle representation
  4856. */
  4857. export class Angle {
  4858. private _radians;
  4859. /**
  4860. * Creates an Angle object of "radians" radians (float).
  4861. * @param radians the angle in radians
  4862. */
  4863. constructor(radians: number);
  4864. /**
  4865. * Get value in degrees
  4866. * @returns the Angle value in degrees (float)
  4867. */
  4868. degrees(): number;
  4869. /**
  4870. * Get value in radians
  4871. * @returns the Angle value in radians (float)
  4872. */
  4873. radians(): number;
  4874. /**
  4875. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4876. * @param a defines first point as the origin
  4877. * @param b defines point
  4878. * @returns a new Angle
  4879. */
  4880. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4881. /**
  4882. * Gets a new Angle object from the given float in radians
  4883. * @param radians defines the angle value in radians
  4884. * @returns a new Angle
  4885. */
  4886. static FromRadians(radians: number): Angle;
  4887. /**
  4888. * Gets a new Angle object from the given float in degrees
  4889. * @param degrees defines the angle value in degrees
  4890. * @returns a new Angle
  4891. */
  4892. static FromDegrees(degrees: number): Angle;
  4893. }
  4894. /**
  4895. * This represents an arc in a 2d space.
  4896. */
  4897. export class Arc2 {
  4898. /** Defines the start point of the arc */
  4899. startPoint: Vector2;
  4900. /** Defines the mid point of the arc */
  4901. midPoint: Vector2;
  4902. /** Defines the end point of the arc */
  4903. endPoint: Vector2;
  4904. /**
  4905. * Defines the center point of the arc.
  4906. */
  4907. centerPoint: Vector2;
  4908. /**
  4909. * Defines the radius of the arc.
  4910. */
  4911. radius: number;
  4912. /**
  4913. * Defines the angle of the arc (from mid point to end point).
  4914. */
  4915. angle: Angle;
  4916. /**
  4917. * Defines the start angle of the arc (from start point to middle point).
  4918. */
  4919. startAngle: Angle;
  4920. /**
  4921. * Defines the orientation of the arc (clock wise/counter clock wise).
  4922. */
  4923. orientation: Orientation;
  4924. /**
  4925. * Creates an Arc object from the three given points : start, middle and end.
  4926. * @param startPoint Defines the start point of the arc
  4927. * @param midPoint Defines the midlle point of the arc
  4928. * @param endPoint Defines the end point of the arc
  4929. */
  4930. constructor(
  4931. /** Defines the start point of the arc */
  4932. startPoint: Vector2,
  4933. /** Defines the mid point of the arc */
  4934. midPoint: Vector2,
  4935. /** Defines the end point of the arc */
  4936. endPoint: Vector2);
  4937. }
  4938. /**
  4939. * Represents a 2D path made up of multiple 2D points
  4940. */
  4941. export class Path2 {
  4942. private _points;
  4943. private _length;
  4944. /**
  4945. * If the path start and end point are the same
  4946. */
  4947. closed: boolean;
  4948. /**
  4949. * Creates a Path2 object from the starting 2D coordinates x and y.
  4950. * @param x the starting points x value
  4951. * @param y the starting points y value
  4952. */
  4953. constructor(x: number, y: number);
  4954. /**
  4955. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4956. * @param x the added points x value
  4957. * @param y the added points y value
  4958. * @returns the updated Path2.
  4959. */
  4960. addLineTo(x: number, y: number): Path2;
  4961. /**
  4962. * 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.
  4963. * @param midX middle point x value
  4964. * @param midY middle point y value
  4965. * @param endX end point x value
  4966. * @param endY end point y value
  4967. * @param numberOfSegments (default: 36)
  4968. * @returns the updated Path2.
  4969. */
  4970. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4971. /**
  4972. * Closes the Path2.
  4973. * @returns the Path2.
  4974. */
  4975. close(): Path2;
  4976. /**
  4977. * Gets the sum of the distance between each sequential point in the path
  4978. * @returns the Path2 total length (float).
  4979. */
  4980. length(): number;
  4981. /**
  4982. * Gets the points which construct the path
  4983. * @returns the Path2 internal array of points.
  4984. */
  4985. getPoints(): Vector2[];
  4986. /**
  4987. * Retreives the point at the distance aways from the starting point
  4988. * @param normalizedLengthPosition the length along the path to retreive the point from
  4989. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4990. */
  4991. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4992. /**
  4993. * Creates a new path starting from an x and y position
  4994. * @param x starting x value
  4995. * @param y starting y value
  4996. * @returns a new Path2 starting at the coordinates (x, y).
  4997. */
  4998. static StartingAt(x: number, y: number): Path2;
  4999. }
  5000. /**
  5001. * Represents a 3D path made up of multiple 3D points
  5002. */
  5003. export class Path3D {
  5004. /**
  5005. * an array of Vector3, the curve axis of the Path3D
  5006. */
  5007. path: Vector3[];
  5008. private _curve;
  5009. private _distances;
  5010. private _tangents;
  5011. private _normals;
  5012. private _binormals;
  5013. private _raw;
  5014. private _alignTangentsWithPath;
  5015. private readonly _pointAtData;
  5016. /**
  5017. * new Path3D(path, normal, raw)
  5018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5020. * @param path an array of Vector3, the curve axis of the Path3D
  5021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5023. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5024. */
  5025. constructor(
  5026. /**
  5027. * an array of Vector3, the curve axis of the Path3D
  5028. */
  5029. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5030. /**
  5031. * Returns the Path3D array of successive Vector3 designing its curve.
  5032. * @returns the Path3D array of successive Vector3 designing its curve.
  5033. */
  5034. getCurve(): Vector3[];
  5035. /**
  5036. * Returns the Path3D array of successive Vector3 designing its curve.
  5037. * @returns the Path3D array of successive Vector3 designing its curve.
  5038. */
  5039. getPoints(): Vector3[];
  5040. /**
  5041. * @returns the computed length (float) of the path.
  5042. */
  5043. length(): number;
  5044. /**
  5045. * Returns an array populated with tangent vectors on each Path3D curve point.
  5046. * @returns an array populated with tangent vectors on each Path3D curve point.
  5047. */
  5048. getTangents(): Vector3[];
  5049. /**
  5050. * Returns an array populated with normal vectors on each Path3D curve point.
  5051. * @returns an array populated with normal vectors on each Path3D curve point.
  5052. */
  5053. getNormals(): Vector3[];
  5054. /**
  5055. * Returns an array populated with binormal vectors on each Path3D curve point.
  5056. * @returns an array populated with binormal vectors on each Path3D curve point.
  5057. */
  5058. getBinormals(): Vector3[];
  5059. /**
  5060. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5061. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5062. */
  5063. getDistances(): number[];
  5064. /**
  5065. * Returns an interpolated point along this path
  5066. * @param position the position of the point along this path, from 0.0 to 1.0
  5067. * @returns a new Vector3 as the point
  5068. */
  5069. getPointAt(position: number): Vector3;
  5070. /**
  5071. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5072. * @param position the position of the point along this path, from 0.0 to 1.0
  5073. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5074. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5075. */
  5076. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5077. /**
  5078. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5079. * @param position the position of the point along this path, from 0.0 to 1.0
  5080. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5081. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5082. */
  5083. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5084. /**
  5085. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5086. * @param position the position of the point along this path, from 0.0 to 1.0
  5087. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5088. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5089. */
  5090. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5091. /**
  5092. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5093. * @param position the position of the point along this path, from 0.0 to 1.0
  5094. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5095. */
  5096. getDistanceAt(position: number): number;
  5097. /**
  5098. * Returns the array index of the previous point of an interpolated point along this path
  5099. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5100. * @returns the array index
  5101. */
  5102. getPreviousPointIndexAt(position: number): number;
  5103. /**
  5104. * 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)
  5105. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5106. * @returns the sub position
  5107. */
  5108. getSubPositionAt(position: number): number;
  5109. /**
  5110. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5111. * @param target the vector of which to get the closest position to
  5112. * @returns the position of the closest virtual point on this path to the target vector
  5113. */
  5114. getClosestPositionTo(target: Vector3): number;
  5115. /**
  5116. * Returns a sub path (slice) of this path
  5117. * @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
  5118. * @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
  5119. * @returns a sub path (slice) of this path
  5120. */
  5121. slice(start?: number, end?: number): Path3D;
  5122. /**
  5123. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5124. * @param path path which all values are copied into the curves points
  5125. * @param firstNormal which should be projected onto the curve
  5126. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5127. * @returns the same object updated.
  5128. */
  5129. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5130. private _compute;
  5131. private _getFirstNonNullVector;
  5132. private _getLastNonNullVector;
  5133. private _normalVector;
  5134. /**
  5135. * Updates the point at data for an interpolated point along this curve
  5136. * @param position the position of the point along this curve, from 0.0 to 1.0
  5137. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5138. * @returns the (updated) point at data
  5139. */
  5140. private _updatePointAtData;
  5141. /**
  5142. * Updates the point at data from the specified parameters
  5143. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5144. * @param point the interpolated point
  5145. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5146. */
  5147. private _setPointAtData;
  5148. /**
  5149. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5150. */
  5151. private _updateInterpolationMatrix;
  5152. }
  5153. /**
  5154. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5155. * A Curve3 is designed from a series of successive Vector3.
  5156. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5157. */
  5158. export class Curve3 {
  5159. private _points;
  5160. private _length;
  5161. /**
  5162. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5163. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5164. * @param v1 (Vector3) the control point
  5165. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5166. * @param nbPoints (integer) the wanted number of points in the curve
  5167. * @returns the created Curve3
  5168. */
  5169. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5170. /**
  5171. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5172. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5173. * @param v1 (Vector3) the first control point
  5174. * @param v2 (Vector3) the second control point
  5175. * @param v3 (Vector3) the end point of the Cubic Bezier
  5176. * @param nbPoints (integer) the wanted number of points in the curve
  5177. * @returns the created Curve3
  5178. */
  5179. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5180. /**
  5181. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5182. * @param p1 (Vector3) the origin point of the Hermite Spline
  5183. * @param t1 (Vector3) the tangent vector at the origin point
  5184. * @param p2 (Vector3) the end point of the Hermite Spline
  5185. * @param t2 (Vector3) the tangent vector at the end point
  5186. * @param nbPoints (integer) the wanted number of points in the curve
  5187. * @returns the created Curve3
  5188. */
  5189. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5190. /**
  5191. * Returns a Curve3 object along a CatmullRom Spline curve :
  5192. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5193. * @param nbPoints (integer) the wanted number of points between each curve control points
  5194. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5195. * @returns the created Curve3
  5196. */
  5197. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5198. /**
  5199. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5200. * A Curve3 is designed from a series of successive Vector3.
  5201. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5202. * @param points points which make up the curve
  5203. */
  5204. constructor(points: Vector3[]);
  5205. /**
  5206. * @returns the Curve3 stored array of successive Vector3
  5207. */
  5208. getPoints(): Vector3[];
  5209. /**
  5210. * @returns the computed length (float) of the curve.
  5211. */
  5212. length(): number;
  5213. /**
  5214. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5215. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5216. * curveA and curveB keep unchanged.
  5217. * @param curve the curve to continue from this curve
  5218. * @returns the newly constructed curve
  5219. */
  5220. continue(curve: DeepImmutable<Curve3>): Curve3;
  5221. private _computeLength;
  5222. }
  5223. }
  5224. declare module "babylonjs/Animations/easing" {
  5225. /**
  5226. * This represents the main contract an easing function should follow.
  5227. * Easing functions are used throughout the animation system.
  5228. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export interface IEasingFunction {
  5231. /**
  5232. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5233. * of the easing function.
  5234. * The link below provides some of the most common examples of easing functions.
  5235. * @see https://easings.net/
  5236. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5237. * @returns the corresponding value on the curve defined by the easing function
  5238. */
  5239. ease(gradient: number): number;
  5240. }
  5241. /**
  5242. * Base class used for every default easing function.
  5243. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5244. */
  5245. export class EasingFunction implements IEasingFunction {
  5246. /**
  5247. * Interpolation follows the mathematical formula associated with the easing function.
  5248. */
  5249. static readonly EASINGMODE_EASEIN: number;
  5250. /**
  5251. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5252. */
  5253. static readonly EASINGMODE_EASEOUT: number;
  5254. /**
  5255. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5256. */
  5257. static readonly EASINGMODE_EASEINOUT: number;
  5258. private _easingMode;
  5259. /**
  5260. * Sets the easing mode of the current function.
  5261. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5262. */
  5263. setEasingMode(easingMode: number): void;
  5264. /**
  5265. * Gets the current easing mode.
  5266. * @returns the easing mode
  5267. */
  5268. getEasingMode(): number;
  5269. /**
  5270. * @hidden
  5271. */
  5272. easeInCore(gradient: number): number;
  5273. /**
  5274. * Given an input gradient between 0 and 1, this returns the corresponding value
  5275. * of the easing function.
  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. * Easing function with a circle shape (see link below).
  5283. * @see https://easings.net/#easeInCirc
  5284. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5285. */
  5286. export class CircleEase extends EasingFunction implements IEasingFunction {
  5287. /** @hidden */
  5288. easeInCore(gradient: number): number;
  5289. }
  5290. /**
  5291. * Easing function with a ease back shape (see link below).
  5292. * @see https://easings.net/#easeInBack
  5293. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5294. */
  5295. export class BackEase extends EasingFunction implements IEasingFunction {
  5296. /** Defines the amplitude of the function */
  5297. amplitude: number;
  5298. /**
  5299. * Instantiates a back ease easing
  5300. * @see https://easings.net/#easeInBack
  5301. * @param amplitude Defines the amplitude of the function
  5302. */
  5303. constructor(
  5304. /** Defines the amplitude of the function */
  5305. amplitude?: number);
  5306. /** @hidden */
  5307. easeInCore(gradient: number): number;
  5308. }
  5309. /**
  5310. * Easing function with a bouncing shape (see link below).
  5311. * @see https://easings.net/#easeInBounce
  5312. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5313. */
  5314. export class BounceEase extends EasingFunction implements IEasingFunction {
  5315. /** Defines the number of bounces */
  5316. bounces: number;
  5317. /** Defines the amplitude of the bounce */
  5318. bounciness: number;
  5319. /**
  5320. * Instantiates a bounce easing
  5321. * @see https://easings.net/#easeInBounce
  5322. * @param bounces Defines the number of bounces
  5323. * @param bounciness Defines the amplitude of the bounce
  5324. */
  5325. constructor(
  5326. /** Defines the number of bounces */
  5327. bounces?: number,
  5328. /** Defines the amplitude of the bounce */
  5329. bounciness?: number);
  5330. /** @hidden */
  5331. easeInCore(gradient: number): number;
  5332. }
  5333. /**
  5334. * Easing function with a power of 3 shape (see link below).
  5335. * @see https://easings.net/#easeInCubic
  5336. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5337. */
  5338. export class CubicEase extends EasingFunction implements IEasingFunction {
  5339. /** @hidden */
  5340. easeInCore(gradient: number): number;
  5341. }
  5342. /**
  5343. * Easing function with an elastic shape (see link below).
  5344. * @see https://easings.net/#easeInElastic
  5345. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5346. */
  5347. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5348. /** Defines the number of oscillations*/
  5349. oscillations: number;
  5350. /** Defines the amplitude of the oscillations*/
  5351. springiness: number;
  5352. /**
  5353. * Instantiates an elastic easing function
  5354. * @see https://easings.net/#easeInElastic
  5355. * @param oscillations Defines the number of oscillations
  5356. * @param springiness Defines the amplitude of the oscillations
  5357. */
  5358. constructor(
  5359. /** Defines the number of oscillations*/
  5360. oscillations?: number,
  5361. /** Defines the amplitude of the oscillations*/
  5362. springiness?: number);
  5363. /** @hidden */
  5364. easeInCore(gradient: number): number;
  5365. }
  5366. /**
  5367. * Easing function with an exponential shape (see link below).
  5368. * @see https://easings.net/#easeInExpo
  5369. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5370. */
  5371. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5372. /** Defines the exponent of the function */
  5373. exponent: number;
  5374. /**
  5375. * Instantiates an exponential easing function
  5376. * @see https://easings.net/#easeInExpo
  5377. * @param exponent Defines the exponent of the function
  5378. */
  5379. constructor(
  5380. /** Defines the exponent of the function */
  5381. exponent?: number);
  5382. /** @hidden */
  5383. easeInCore(gradient: number): number;
  5384. }
  5385. /**
  5386. * Easing function with a power shape (see link below).
  5387. * @see https://easings.net/#easeInQuad
  5388. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5389. */
  5390. export class PowerEase extends EasingFunction implements IEasingFunction {
  5391. /** Defines the power of the function */
  5392. power: number;
  5393. /**
  5394. * Instantiates an power base easing function
  5395. * @see https://easings.net/#easeInQuad
  5396. * @param power Defines the power of the function
  5397. */
  5398. constructor(
  5399. /** Defines the power of the function */
  5400. power?: number);
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with a power of 2 shape (see link below).
  5406. * @see https://easings.net/#easeInQuad
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5410. /** @hidden */
  5411. easeInCore(gradient: number): number;
  5412. }
  5413. /**
  5414. * Easing function with a power of 4 shape (see link below).
  5415. * @see https://easings.net/#easeInQuart
  5416. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5417. */
  5418. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5419. /** @hidden */
  5420. easeInCore(gradient: number): number;
  5421. }
  5422. /**
  5423. * Easing function with a power of 5 shape (see link below).
  5424. * @see https://easings.net/#easeInQuint
  5425. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5426. */
  5427. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5428. /** @hidden */
  5429. easeInCore(gradient: number): number;
  5430. }
  5431. /**
  5432. * Easing function with a sin shape (see link below).
  5433. * @see https://easings.net/#easeInSine
  5434. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5435. */
  5436. export class SineEase extends EasingFunction implements IEasingFunction {
  5437. /** @hidden */
  5438. easeInCore(gradient: number): number;
  5439. }
  5440. /**
  5441. * Easing function with a bezier shape (see link below).
  5442. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5443. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5444. */
  5445. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5446. /** Defines the x component of the start tangent in the bezier curve */
  5447. x1: number;
  5448. /** Defines the y component of the start tangent in the bezier curve */
  5449. y1: number;
  5450. /** Defines the x component of the end tangent in the bezier curve */
  5451. x2: number;
  5452. /** Defines the y component of the end tangent in the bezier curve */
  5453. y2: number;
  5454. /**
  5455. * Instantiates a bezier function
  5456. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5457. * @param x1 Defines the x component of the start tangent in the bezier curve
  5458. * @param y1 Defines the y component of the start tangent in the bezier curve
  5459. * @param x2 Defines the x component of the end tangent in the bezier curve
  5460. * @param y2 Defines the y component of the end tangent in the bezier curve
  5461. */
  5462. constructor(
  5463. /** Defines the x component of the start tangent in the bezier curve */
  5464. x1?: number,
  5465. /** Defines the y component of the start tangent in the bezier curve */
  5466. y1?: number,
  5467. /** Defines the x component of the end tangent in the bezier curve */
  5468. x2?: number,
  5469. /** Defines the y component of the end tangent in the bezier curve */
  5470. y2?: number);
  5471. /** @hidden */
  5472. easeInCore(gradient: number): number;
  5473. }
  5474. }
  5475. declare module "babylonjs/Maths/math.color" {
  5476. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5477. /**
  5478. * Class used to hold a RBG color
  5479. */
  5480. export class Color3 {
  5481. /**
  5482. * Defines the red component (between 0 and 1, default is 0)
  5483. */
  5484. r: number;
  5485. /**
  5486. * Defines the green component (between 0 and 1, default is 0)
  5487. */
  5488. g: number;
  5489. /**
  5490. * Defines the blue component (between 0 and 1, default is 0)
  5491. */
  5492. b: number;
  5493. /**
  5494. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5495. * @param r defines the red component (between 0 and 1, default is 0)
  5496. * @param g defines the green component (between 0 and 1, default is 0)
  5497. * @param b defines the blue component (between 0 and 1, default is 0)
  5498. */
  5499. constructor(
  5500. /**
  5501. * Defines the red component (between 0 and 1, default is 0)
  5502. */
  5503. r?: number,
  5504. /**
  5505. * Defines the green component (between 0 and 1, default is 0)
  5506. */
  5507. g?: number,
  5508. /**
  5509. * Defines the blue component (between 0 and 1, default is 0)
  5510. */
  5511. b?: number);
  5512. /**
  5513. * Creates a string with the Color3 current values
  5514. * @returns the string representation of the Color3 object
  5515. */
  5516. toString(): string;
  5517. /**
  5518. * Returns the string "Color3"
  5519. * @returns "Color3"
  5520. */
  5521. getClassName(): string;
  5522. /**
  5523. * Compute the Color3 hash code
  5524. * @returns an unique number that can be used to hash Color3 objects
  5525. */
  5526. getHashCode(): number;
  5527. /**
  5528. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5529. * @param array defines the array where to store the r,g,b components
  5530. * @param index defines an optional index in the target array to define where to start storing values
  5531. * @returns the current Color3 object
  5532. */
  5533. toArray(array: FloatArray, index?: number): Color3;
  5534. /**
  5535. * Returns a new Color4 object from the current Color3 and the given alpha
  5536. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5537. * @returns a new Color4 object
  5538. */
  5539. toColor4(alpha?: number): Color4;
  5540. /**
  5541. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5542. * @returns the new array
  5543. */
  5544. asArray(): number[];
  5545. /**
  5546. * Returns the luminance value
  5547. * @returns a float value
  5548. */
  5549. toLuminance(): number;
  5550. /**
  5551. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5552. * @param otherColor defines the second operand
  5553. * @returns the new Color3 object
  5554. */
  5555. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5556. /**
  5557. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5558. * @param otherColor defines the second operand
  5559. * @param result defines the Color3 object where to store the result
  5560. * @returns the current Color3
  5561. */
  5562. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5563. /**
  5564. * Determines equality between Color3 objects
  5565. * @param otherColor defines the second operand
  5566. * @returns true if the rgb values are equal to the given ones
  5567. */
  5568. equals(otherColor: DeepImmutable<Color3>): boolean;
  5569. /**
  5570. * Determines equality between the current Color3 object and a set of r,b,g values
  5571. * @param r defines the red component to check
  5572. * @param g defines the green component to check
  5573. * @param b defines the blue component to check
  5574. * @returns true if the rgb values are equal to the given ones
  5575. */
  5576. equalsFloats(r: number, g: number, b: number): boolean;
  5577. /**
  5578. * Multiplies in place each rgb value by scale
  5579. * @param scale defines the scaling factor
  5580. * @returns the updated Color3
  5581. */
  5582. scale(scale: number): Color3;
  5583. /**
  5584. * Multiplies the rgb values by scale and stores the result into "result"
  5585. * @param scale defines the scaling factor
  5586. * @param result defines the Color3 object where to store the result
  5587. * @returns the unmodified current Color3
  5588. */
  5589. scaleToRef(scale: number, result: Color3): Color3;
  5590. /**
  5591. * Scale the current Color3 values by a factor and add the result to a given Color3
  5592. * @param scale defines the scale factor
  5593. * @param result defines color to store the result into
  5594. * @returns the unmodified current Color3
  5595. */
  5596. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5597. /**
  5598. * Clamps the rgb values by the min and max values and stores the result into "result"
  5599. * @param min defines minimum clamping value (default is 0)
  5600. * @param max defines maximum clamping value (default is 1)
  5601. * @param result defines color to store the result into
  5602. * @returns the original Color3
  5603. */
  5604. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5605. /**
  5606. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5607. * @param otherColor defines the second operand
  5608. * @returns the new Color3
  5609. */
  5610. add(otherColor: DeepImmutable<Color3>): Color3;
  5611. /**
  5612. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5613. * @param otherColor defines the second operand
  5614. * @param result defines Color3 object to store the result into
  5615. * @returns the unmodified current Color3
  5616. */
  5617. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5618. /**
  5619. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5620. * @param otherColor defines the second operand
  5621. * @returns the new Color3
  5622. */
  5623. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5624. /**
  5625. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5626. * @param otherColor defines the second operand
  5627. * @param result defines Color3 object to store the result into
  5628. * @returns the unmodified current Color3
  5629. */
  5630. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5631. /**
  5632. * Copy the current object
  5633. * @returns a new Color3 copied the current one
  5634. */
  5635. clone(): Color3;
  5636. /**
  5637. * Copies the rgb values from the source in the current Color3
  5638. * @param source defines the source Color3 object
  5639. * @returns the updated Color3 object
  5640. */
  5641. copyFrom(source: DeepImmutable<Color3>): Color3;
  5642. /**
  5643. * Updates the Color3 rgb values from the given floats
  5644. * @param r defines the red component to read from
  5645. * @param g defines the green component to read from
  5646. * @param b defines the blue component to read from
  5647. * @returns the current Color3 object
  5648. */
  5649. copyFromFloats(r: number, g: number, b: number): Color3;
  5650. /**
  5651. * Updates the Color3 rgb values from the given floats
  5652. * @param r defines the red component to read from
  5653. * @param g defines the green component to read from
  5654. * @param b defines the blue component to read from
  5655. * @returns the current Color3 object
  5656. */
  5657. set(r: number, g: number, b: number): Color3;
  5658. /**
  5659. * Compute the Color3 hexadecimal code as a string
  5660. * @returns a string containing the hexadecimal representation of the Color3 object
  5661. */
  5662. toHexString(): string;
  5663. /**
  5664. * Computes a new Color3 converted from the current one to linear space
  5665. * @returns a new Color3 object
  5666. */
  5667. toLinearSpace(): Color3;
  5668. /**
  5669. * Converts current color in rgb space to HSV values
  5670. * @returns a new color3 representing the HSV values
  5671. */
  5672. toHSV(): Color3;
  5673. /**
  5674. * Converts current color in rgb space to HSV values
  5675. * @param result defines the Color3 where to store the HSV values
  5676. */
  5677. toHSVToRef(result: Color3): void;
  5678. /**
  5679. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5680. * @param convertedColor defines the Color3 object where to store the linear space version
  5681. * @returns the unmodified Color3
  5682. */
  5683. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5684. /**
  5685. * Computes a new Color3 converted from the current one to gamma space
  5686. * @returns a new Color3 object
  5687. */
  5688. toGammaSpace(): Color3;
  5689. /**
  5690. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5691. * @param convertedColor defines the Color3 object where to store the gamma space version
  5692. * @returns the unmodified Color3
  5693. */
  5694. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5695. private static _BlackReadOnly;
  5696. /**
  5697. * Convert Hue, saturation and value to a Color3 (RGB)
  5698. * @param hue defines the hue
  5699. * @param saturation defines the saturation
  5700. * @param value defines the value
  5701. * @param result defines the Color3 where to store the RGB values
  5702. */
  5703. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5704. /**
  5705. * Creates a new Color3 from the string containing valid hexadecimal values
  5706. * @param hex defines a string containing valid hexadecimal values
  5707. * @returns a new Color3 object
  5708. */
  5709. static FromHexString(hex: string): Color3;
  5710. /**
  5711. * Creates a new Color3 from the starting index of the given array
  5712. * @param array defines the source array
  5713. * @param offset defines an offset in the source array
  5714. * @returns a new Color3 object
  5715. */
  5716. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5717. /**
  5718. * Creates a new Color3 from integer values (< 256)
  5719. * @param r defines the red component to read from (value between 0 and 255)
  5720. * @param g defines the green component to read from (value between 0 and 255)
  5721. * @param b defines the blue component to read from (value between 0 and 255)
  5722. * @returns a new Color3 object
  5723. */
  5724. static FromInts(r: number, g: number, b: number): Color3;
  5725. /**
  5726. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5727. * @param start defines the start Color3 value
  5728. * @param end defines the end Color3 value
  5729. * @param amount defines the gradient value between start and end
  5730. * @returns a new Color3 object
  5731. */
  5732. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5733. /**
  5734. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5735. * @param left defines the start value
  5736. * @param right defines the end value
  5737. * @param amount defines the gradient factor
  5738. * @param result defines the Color3 object where to store the result
  5739. */
  5740. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5741. /**
  5742. * Returns a Color3 value containing a red color
  5743. * @returns a new Color3 object
  5744. */
  5745. static Red(): Color3;
  5746. /**
  5747. * Returns a Color3 value containing a green color
  5748. * @returns a new Color3 object
  5749. */
  5750. static Green(): Color3;
  5751. /**
  5752. * Returns a Color3 value containing a blue color
  5753. * @returns a new Color3 object
  5754. */
  5755. static Blue(): Color3;
  5756. /**
  5757. * Returns a Color3 value containing a black color
  5758. * @returns a new Color3 object
  5759. */
  5760. static Black(): Color3;
  5761. /**
  5762. * Gets a Color3 value containing a black color that must not be updated
  5763. */
  5764. static get BlackReadOnly(): DeepImmutable<Color3>;
  5765. /**
  5766. * Returns a Color3 value containing a white color
  5767. * @returns a new Color3 object
  5768. */
  5769. static White(): Color3;
  5770. /**
  5771. * Returns a Color3 value containing a purple color
  5772. * @returns a new Color3 object
  5773. */
  5774. static Purple(): Color3;
  5775. /**
  5776. * Returns a Color3 value containing a magenta color
  5777. * @returns a new Color3 object
  5778. */
  5779. static Magenta(): Color3;
  5780. /**
  5781. * Returns a Color3 value containing a yellow color
  5782. * @returns a new Color3 object
  5783. */
  5784. static Yellow(): Color3;
  5785. /**
  5786. * Returns a Color3 value containing a gray color
  5787. * @returns a new Color3 object
  5788. */
  5789. static Gray(): Color3;
  5790. /**
  5791. * Returns a Color3 value containing a teal color
  5792. * @returns a new Color3 object
  5793. */
  5794. static Teal(): Color3;
  5795. /**
  5796. * Returns a Color3 value containing a random color
  5797. * @returns a new Color3 object
  5798. */
  5799. static Random(): Color3;
  5800. }
  5801. /**
  5802. * Class used to hold a RBGA color
  5803. */
  5804. export class Color4 {
  5805. /**
  5806. * Defines the red component (between 0 and 1, default is 0)
  5807. */
  5808. r: number;
  5809. /**
  5810. * Defines the green component (between 0 and 1, default is 0)
  5811. */
  5812. g: number;
  5813. /**
  5814. * Defines the blue component (between 0 and 1, default is 0)
  5815. */
  5816. b: number;
  5817. /**
  5818. * Defines the alpha component (between 0 and 1, default is 1)
  5819. */
  5820. a: number;
  5821. /**
  5822. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5823. * @param r defines the red component (between 0 and 1, default is 0)
  5824. * @param g defines the green component (between 0 and 1, default is 0)
  5825. * @param b defines the blue component (between 0 and 1, default is 0)
  5826. * @param a defines the alpha component (between 0 and 1, default is 1)
  5827. */
  5828. constructor(
  5829. /**
  5830. * Defines the red component (between 0 and 1, default is 0)
  5831. */
  5832. r?: number,
  5833. /**
  5834. * Defines the green component (between 0 and 1, default is 0)
  5835. */
  5836. g?: number,
  5837. /**
  5838. * Defines the blue component (between 0 and 1, default is 0)
  5839. */
  5840. b?: number,
  5841. /**
  5842. * Defines the alpha component (between 0 and 1, default is 1)
  5843. */
  5844. a?: number);
  5845. /**
  5846. * Adds in place the given Color4 values to the current Color4 object
  5847. * @param right defines the second operand
  5848. * @returns the current updated Color4 object
  5849. */
  5850. addInPlace(right: DeepImmutable<Color4>): Color4;
  5851. /**
  5852. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5853. * @returns the new array
  5854. */
  5855. asArray(): number[];
  5856. /**
  5857. * Stores from the starting index in the given array the Color4 successive values
  5858. * @param array defines the array where to store the r,g,b components
  5859. * @param index defines an optional index in the target array to define where to start storing values
  5860. * @returns the current Color4 object
  5861. */
  5862. toArray(array: number[], index?: number): Color4;
  5863. /**
  5864. * Determines equality between Color4 objects
  5865. * @param otherColor defines the second operand
  5866. * @returns true if the rgba values are equal to the given ones
  5867. */
  5868. equals(otherColor: DeepImmutable<Color4>): boolean;
  5869. /**
  5870. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5871. * @param right defines the second operand
  5872. * @returns a new Color4 object
  5873. */
  5874. add(right: DeepImmutable<Color4>): Color4;
  5875. /**
  5876. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5877. * @param right defines the second operand
  5878. * @returns a new Color4 object
  5879. */
  5880. subtract(right: DeepImmutable<Color4>): Color4;
  5881. /**
  5882. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5883. * @param right defines the second operand
  5884. * @param result defines the Color4 object where to store the result
  5885. * @returns the current Color4 object
  5886. */
  5887. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5888. /**
  5889. * Creates a new Color4 with the current Color4 values multiplied by scale
  5890. * @param scale defines the scaling factor to apply
  5891. * @returns a new Color4 object
  5892. */
  5893. scale(scale: number): Color4;
  5894. /**
  5895. * Multiplies the current Color4 values by scale and stores the result in "result"
  5896. * @param scale defines the scaling factor to apply
  5897. * @param result defines the Color4 object where to store the result
  5898. * @returns the current unmodified Color4
  5899. */
  5900. scaleToRef(scale: number, result: Color4): Color4;
  5901. /**
  5902. * Scale the current Color4 values by a factor and add the result to a given Color4
  5903. * @param scale defines the scale factor
  5904. * @param result defines the Color4 object where to store the result
  5905. * @returns the unmodified current Color4
  5906. */
  5907. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5908. /**
  5909. * Clamps the rgb values by the min and max values and stores the result into "result"
  5910. * @param min defines minimum clamping value (default is 0)
  5911. * @param max defines maximum clamping value (default is 1)
  5912. * @param result defines color to store the result into.
  5913. * @returns the cuurent Color4
  5914. */
  5915. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5916. /**
  5917. * Multipy an Color4 value by another and return a new Color4 object
  5918. * @param color defines the Color4 value to multiply by
  5919. * @returns a new Color4 object
  5920. */
  5921. multiply(color: Color4): Color4;
  5922. /**
  5923. * Multipy a Color4 value by another and push the result in a reference value
  5924. * @param color defines the Color4 value to multiply by
  5925. * @param result defines the Color4 to fill the result in
  5926. * @returns the result Color4
  5927. */
  5928. multiplyToRef(color: Color4, result: Color4): Color4;
  5929. /**
  5930. * Creates a string with the Color4 current values
  5931. * @returns the string representation of the Color4 object
  5932. */
  5933. toString(): string;
  5934. /**
  5935. * Returns the string "Color4"
  5936. * @returns "Color4"
  5937. */
  5938. getClassName(): string;
  5939. /**
  5940. * Compute the Color4 hash code
  5941. * @returns an unique number that can be used to hash Color4 objects
  5942. */
  5943. getHashCode(): number;
  5944. /**
  5945. * Creates a new Color4 copied from the current one
  5946. * @returns a new Color4 object
  5947. */
  5948. clone(): Color4;
  5949. /**
  5950. * Copies the given Color4 values into the current one
  5951. * @param source defines the source Color4 object
  5952. * @returns the current updated Color4 object
  5953. */
  5954. copyFrom(source: Color4): Color4;
  5955. /**
  5956. * Copies the given float values into the current one
  5957. * @param r defines the red component to read from
  5958. * @param g defines the green component to read from
  5959. * @param b defines the blue component to read from
  5960. * @param a defines the alpha component to read from
  5961. * @returns the current updated Color4 object
  5962. */
  5963. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5964. /**
  5965. * Copies the given float values into the current one
  5966. * @param r defines the red component to read from
  5967. * @param g defines the green component to read from
  5968. * @param b defines the blue component to read from
  5969. * @param a defines the alpha component to read from
  5970. * @returns the current updated Color4 object
  5971. */
  5972. set(r: number, g: number, b: number, a: number): Color4;
  5973. /**
  5974. * Compute the Color4 hexadecimal code as a string
  5975. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  5976. * @returns a string containing the hexadecimal representation of the Color4 object
  5977. */
  5978. toHexString(returnAsColor3?: boolean): string;
  5979. /**
  5980. * Computes a new Color4 converted from the current one to linear space
  5981. * @returns a new Color4 object
  5982. */
  5983. toLinearSpace(): Color4;
  5984. /**
  5985. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5986. * @param convertedColor defines the Color4 object where to store the linear space version
  5987. * @returns the unmodified Color4
  5988. */
  5989. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5990. /**
  5991. * Computes a new Color4 converted from the current one to gamma space
  5992. * @returns a new Color4 object
  5993. */
  5994. toGammaSpace(): Color4;
  5995. /**
  5996. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5997. * @param convertedColor defines the Color4 object where to store the gamma space version
  5998. * @returns the unmodified Color4
  5999. */
  6000. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6001. /**
  6002. * Creates a new Color4 from the string containing valid hexadecimal values
  6003. * @param hex defines a string containing valid hexadecimal values
  6004. * @returns a new Color4 object
  6005. */
  6006. static FromHexString(hex: string): Color4;
  6007. /**
  6008. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6009. * @param left defines the start value
  6010. * @param right defines the end value
  6011. * @param amount defines the gradient factor
  6012. * @returns a new Color4 object
  6013. */
  6014. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6015. /**
  6016. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6017. * @param left defines the start value
  6018. * @param right defines the end value
  6019. * @param amount defines the gradient factor
  6020. * @param result defines the Color4 object where to store data
  6021. */
  6022. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6023. /**
  6024. * Creates a new Color4 from a Color3 and an alpha value
  6025. * @param color3 defines the source Color3 to read from
  6026. * @param alpha defines the alpha component (1.0 by default)
  6027. * @returns a new Color4 object
  6028. */
  6029. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6030. /**
  6031. * Creates a new Color4 from the starting index element of the given array
  6032. * @param array defines the source array to read from
  6033. * @param offset defines the offset in the source array
  6034. * @returns a new Color4 object
  6035. */
  6036. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6037. /**
  6038. * Creates a new Color3 from integer values (< 256)
  6039. * @param r defines the red component to read from (value between 0 and 255)
  6040. * @param g defines the green component to read from (value between 0 and 255)
  6041. * @param b defines the blue component to read from (value between 0 and 255)
  6042. * @param a defines the alpha component to read from (value between 0 and 255)
  6043. * @returns a new Color3 object
  6044. */
  6045. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6046. /**
  6047. * Check the content of a given array and convert it to an array containing RGBA data
  6048. * If the original array was already containing count * 4 values then it is returned directly
  6049. * @param colors defines the array to check
  6050. * @param count defines the number of RGBA data to expect
  6051. * @returns an array containing count * 4 values (RGBA)
  6052. */
  6053. static CheckColors4(colors: number[], count: number): number[];
  6054. }
  6055. /**
  6056. * @hidden
  6057. */
  6058. export class TmpColors {
  6059. static Color3: Color3[];
  6060. static Color4: Color4[];
  6061. }
  6062. }
  6063. declare module "babylonjs/Animations/animationKey" {
  6064. /**
  6065. * Defines an interface which represents an animation key frame
  6066. */
  6067. export interface IAnimationKey {
  6068. /**
  6069. * Frame of the key frame
  6070. */
  6071. frame: number;
  6072. /**
  6073. * Value at the specifies key frame
  6074. */
  6075. value: any;
  6076. /**
  6077. * The input tangent for the cubic hermite spline
  6078. */
  6079. inTangent?: any;
  6080. /**
  6081. * The output tangent for the cubic hermite spline
  6082. */
  6083. outTangent?: any;
  6084. /**
  6085. * The animation interpolation type
  6086. */
  6087. interpolation?: AnimationKeyInterpolation;
  6088. }
  6089. /**
  6090. * Enum for the animation key frame interpolation type
  6091. */
  6092. export enum AnimationKeyInterpolation {
  6093. /**
  6094. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6095. */
  6096. STEP = 1
  6097. }
  6098. }
  6099. declare module "babylonjs/Animations/animationRange" {
  6100. /**
  6101. * Represents the range of an animation
  6102. */
  6103. export class AnimationRange {
  6104. /**The name of the animation range**/
  6105. name: string;
  6106. /**The starting frame of the animation */
  6107. from: number;
  6108. /**The ending frame of the animation*/
  6109. to: number;
  6110. /**
  6111. * Initializes the range of an animation
  6112. * @param name The name of the animation range
  6113. * @param from The starting frame of the animation
  6114. * @param to The ending frame of the animation
  6115. */
  6116. constructor(
  6117. /**The name of the animation range**/
  6118. name: string,
  6119. /**The starting frame of the animation */
  6120. from: number,
  6121. /**The ending frame of the animation*/
  6122. to: number);
  6123. /**
  6124. * Makes a copy of the animation range
  6125. * @returns A copy of the animation range
  6126. */
  6127. clone(): AnimationRange;
  6128. }
  6129. }
  6130. declare module "babylonjs/Animations/animationEvent" {
  6131. /**
  6132. * Composed of a frame, and an action function
  6133. */
  6134. export class AnimationEvent {
  6135. /** The frame for which the event is triggered **/
  6136. frame: number;
  6137. /** The event to perform when triggered **/
  6138. action: (currentFrame: number) => void;
  6139. /** Specifies if the event should be triggered only once**/
  6140. onlyOnce?: boolean | undefined;
  6141. /**
  6142. * Specifies if the animation event is done
  6143. */
  6144. isDone: boolean;
  6145. /**
  6146. * Initializes the animation event
  6147. * @param frame The frame for which the event is triggered
  6148. * @param action The event to perform when triggered
  6149. * @param onlyOnce Specifies if the event should be triggered only once
  6150. */
  6151. constructor(
  6152. /** The frame for which the event is triggered **/
  6153. frame: number,
  6154. /** The event to perform when triggered **/
  6155. action: (currentFrame: number) => void,
  6156. /** Specifies if the event should be triggered only once**/
  6157. onlyOnce?: boolean | undefined);
  6158. /** @hidden */
  6159. _clone(): AnimationEvent;
  6160. }
  6161. }
  6162. declare module "babylonjs/Behaviors/behavior" {
  6163. import { Nullable } from "babylonjs/types";
  6164. /**
  6165. * Interface used to define a behavior
  6166. */
  6167. export interface Behavior<T> {
  6168. /** gets or sets behavior's name */
  6169. name: string;
  6170. /**
  6171. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6172. */
  6173. init(): void;
  6174. /**
  6175. * Called when the behavior is attached to a target
  6176. * @param target defines the target where the behavior is attached to
  6177. */
  6178. attach(target: T): void;
  6179. /**
  6180. * Called when the behavior is detached from its target
  6181. */
  6182. detach(): void;
  6183. }
  6184. /**
  6185. * Interface implemented by classes supporting behaviors
  6186. */
  6187. export interface IBehaviorAware<T> {
  6188. /**
  6189. * Attach a behavior
  6190. * @param behavior defines the behavior to attach
  6191. * @returns the current host
  6192. */
  6193. addBehavior(behavior: Behavior<T>): T;
  6194. /**
  6195. * Remove a behavior from the current object
  6196. * @param behavior defines the behavior to detach
  6197. * @returns the current host
  6198. */
  6199. removeBehavior(behavior: Behavior<T>): T;
  6200. /**
  6201. * Gets a behavior using its name to search
  6202. * @param name defines the name to search
  6203. * @returns the behavior or null if not found
  6204. */
  6205. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6206. }
  6207. }
  6208. declare module "babylonjs/Misc/smartArray" {
  6209. /**
  6210. * Defines an array and its length.
  6211. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6212. */
  6213. export interface ISmartArrayLike<T> {
  6214. /**
  6215. * The data of the array.
  6216. */
  6217. data: Array<T>;
  6218. /**
  6219. * The active length of the array.
  6220. */
  6221. length: number;
  6222. }
  6223. /**
  6224. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6225. */
  6226. export class SmartArray<T> implements ISmartArrayLike<T> {
  6227. /**
  6228. * The full set of data from the array.
  6229. */
  6230. data: Array<T>;
  6231. /**
  6232. * The active length of the array.
  6233. */
  6234. length: number;
  6235. protected _id: number;
  6236. /**
  6237. * Instantiates a Smart Array.
  6238. * @param capacity defines the default capacity of the array.
  6239. */
  6240. constructor(capacity: number);
  6241. /**
  6242. * Pushes a value at the end of the active data.
  6243. * @param value defines the object to push in the array.
  6244. */
  6245. push(value: T): void;
  6246. /**
  6247. * Iterates over the active data and apply the lambda to them.
  6248. * @param func defines the action to apply on each value.
  6249. */
  6250. forEach(func: (content: T) => void): void;
  6251. /**
  6252. * Sorts the full sets of data.
  6253. * @param compareFn defines the comparison function to apply.
  6254. */
  6255. sort(compareFn: (a: T, b: T) => number): void;
  6256. /**
  6257. * Resets the active data to an empty array.
  6258. */
  6259. reset(): void;
  6260. /**
  6261. * Releases all the data from the array as well as the array.
  6262. */
  6263. dispose(): void;
  6264. /**
  6265. * Concats the active data with a given array.
  6266. * @param array defines the data to concatenate with.
  6267. */
  6268. concat(array: any): void;
  6269. /**
  6270. * Returns the position of a value in the active data.
  6271. * @param value defines the value to find the index for
  6272. * @returns the index if found in the active data otherwise -1
  6273. */
  6274. indexOf(value: T): number;
  6275. /**
  6276. * Returns whether an element is part of the active data.
  6277. * @param value defines the value to look for
  6278. * @returns true if found in the active data otherwise false
  6279. */
  6280. contains(value: T): boolean;
  6281. private static _GlobalId;
  6282. }
  6283. /**
  6284. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6285. * The data in this array can only be present once
  6286. */
  6287. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6288. private _duplicateId;
  6289. /**
  6290. * Pushes a value at the end of the active data.
  6291. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6292. * @param value defines the object to push in the array.
  6293. */
  6294. push(value: T): void;
  6295. /**
  6296. * Pushes a value at the end of the active data.
  6297. * If the data is already present, it won t be added again
  6298. * @param value defines the object to push in the array.
  6299. * @returns true if added false if it was already present
  6300. */
  6301. pushNoDuplicate(value: T): boolean;
  6302. /**
  6303. * Resets the active data to an empty array.
  6304. */
  6305. reset(): void;
  6306. /**
  6307. * Concats the active data with a given array.
  6308. * This ensures no dupplicate will be present in the result.
  6309. * @param array defines the data to concatenate with.
  6310. */
  6311. concatWithNoDuplicate(array: any): void;
  6312. }
  6313. }
  6314. declare module "babylonjs/Cameras/cameraInputsManager" {
  6315. import { Nullable } from "babylonjs/types";
  6316. import { Camera } from "babylonjs/Cameras/camera";
  6317. /**
  6318. * @ignore
  6319. * This is a list of all the different input types that are available in the application.
  6320. * Fo instance: ArcRotateCameraGamepadInput...
  6321. */
  6322. export var CameraInputTypes: {};
  6323. /**
  6324. * This is the contract to implement in order to create a new input class.
  6325. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6326. */
  6327. export interface ICameraInput<TCamera extends Camera> {
  6328. /**
  6329. * Defines the camera the input is attached to.
  6330. */
  6331. camera: Nullable<TCamera>;
  6332. /**
  6333. * Gets the class name of the current intput.
  6334. * @returns the class name
  6335. */
  6336. getClassName(): string;
  6337. /**
  6338. * Get the friendly name associated with the input class.
  6339. * @returns the input friendly name
  6340. */
  6341. getSimpleName(): string;
  6342. /**
  6343. * Attach the input controls to a specific dom element to get the input from.
  6344. * @param element Defines the element the controls should be listened from
  6345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6346. */
  6347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6348. /**
  6349. * Detach the current controls from the specified dom element.
  6350. * @param element Defines the element to stop listening the inputs from
  6351. */
  6352. detachControl(element: Nullable<HTMLElement>): void;
  6353. /**
  6354. * Update the current camera state depending on the inputs that have been used this frame.
  6355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6356. */
  6357. checkInputs?: () => void;
  6358. }
  6359. /**
  6360. * Represents a map of input types to input instance or input index to input instance.
  6361. */
  6362. export interface CameraInputsMap<TCamera extends Camera> {
  6363. /**
  6364. * Accessor to the input by input type.
  6365. */
  6366. [name: string]: ICameraInput<TCamera>;
  6367. /**
  6368. * Accessor to the input by input index.
  6369. */
  6370. [idx: number]: ICameraInput<TCamera>;
  6371. }
  6372. /**
  6373. * This represents the input manager used within a camera.
  6374. * It helps dealing with all the different kind of input attached to a camera.
  6375. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6376. */
  6377. export class CameraInputsManager<TCamera extends Camera> {
  6378. /**
  6379. * Defines the list of inputs attahed to the camera.
  6380. */
  6381. attached: CameraInputsMap<TCamera>;
  6382. /**
  6383. * Defines the dom element the camera is collecting inputs from.
  6384. * This is null if the controls have not been attached.
  6385. */
  6386. attachedElement: Nullable<HTMLElement>;
  6387. /**
  6388. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6389. */
  6390. noPreventDefault: boolean;
  6391. /**
  6392. * Defined the camera the input manager belongs to.
  6393. */
  6394. camera: TCamera;
  6395. /**
  6396. * Update the current camera state depending on the inputs that have been used this frame.
  6397. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6398. */
  6399. checkInputs: () => void;
  6400. /**
  6401. * Instantiate a new Camera Input Manager.
  6402. * @param camera Defines the camera the input manager blongs to
  6403. */
  6404. constructor(camera: TCamera);
  6405. /**
  6406. * Add an input method to a camera
  6407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6408. * @param input camera input method
  6409. */
  6410. add(input: ICameraInput<TCamera>): void;
  6411. /**
  6412. * Remove a specific input method from a camera
  6413. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6414. * @param inputToRemove camera input method
  6415. */
  6416. remove(inputToRemove: ICameraInput<TCamera>): void;
  6417. /**
  6418. * Remove a specific input type from a camera
  6419. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6420. * @param inputType the type of the input to remove
  6421. */
  6422. removeByType(inputType: string): void;
  6423. private _addCheckInputs;
  6424. /**
  6425. * Attach the input controls to the currently attached dom element to listen the events from.
  6426. * @param input Defines the input to attach
  6427. */
  6428. attachInput(input: ICameraInput<TCamera>): void;
  6429. /**
  6430. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6431. * @param element Defines the dom element to collect the events from
  6432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6433. */
  6434. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6435. /**
  6436. * Detach the current manager inputs controls from a specific dom element.
  6437. * @param element Defines the dom element to collect the events from
  6438. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6439. */
  6440. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6441. /**
  6442. * Rebuild the dynamic inputCheck function from the current list of
  6443. * defined inputs in the manager.
  6444. */
  6445. rebuildInputCheck(): void;
  6446. /**
  6447. * Remove all attached input methods from a camera
  6448. */
  6449. clear(): void;
  6450. /**
  6451. * Serialize the current input manager attached to a camera.
  6452. * This ensures than once parsed,
  6453. * the input associated to the camera will be identical to the current ones
  6454. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6455. */
  6456. serialize(serializedCamera: any): void;
  6457. /**
  6458. * Parses an input manager serialized JSON to restore the previous list of inputs
  6459. * and states associated to a camera.
  6460. * @param parsedCamera Defines the JSON to parse
  6461. */
  6462. parse(parsedCamera: any): void;
  6463. }
  6464. }
  6465. declare module "babylonjs/Meshes/buffer" {
  6466. import { Nullable, DataArray } from "babylonjs/types";
  6467. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6468. /**
  6469. * Class used to store data that will be store in GPU memory
  6470. */
  6471. export class Buffer {
  6472. private _engine;
  6473. private _buffer;
  6474. /** @hidden */
  6475. _data: Nullable<DataArray>;
  6476. private _updatable;
  6477. private _instanced;
  6478. private _divisor;
  6479. /**
  6480. * Gets the byte stride.
  6481. */
  6482. readonly byteStride: number;
  6483. /**
  6484. * Constructor
  6485. * @param engine the engine
  6486. * @param data the data to use for this buffer
  6487. * @param updatable whether the data is updatable
  6488. * @param stride the stride (optional)
  6489. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6490. * @param instanced whether the buffer is instanced (optional)
  6491. * @param useBytes set to true if the stride in in bytes (optional)
  6492. * @param divisor sets an optional divisor for instances (1 by default)
  6493. */
  6494. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6495. /**
  6496. * Create a new VertexBuffer based on the current buffer
  6497. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6498. * @param offset defines offset in the buffer (0 by default)
  6499. * @param size defines the size in floats of attributes (position is 3 for instance)
  6500. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6501. * @param instanced defines if the vertex buffer contains indexed data
  6502. * @param useBytes defines if the offset and stride are in bytes *
  6503. * @param divisor sets an optional divisor for instances (1 by default)
  6504. * @returns the new vertex buffer
  6505. */
  6506. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6507. /**
  6508. * Gets a boolean indicating if the Buffer is updatable?
  6509. * @returns true if the buffer is updatable
  6510. */
  6511. isUpdatable(): boolean;
  6512. /**
  6513. * Gets current buffer's data
  6514. * @returns a DataArray or null
  6515. */
  6516. getData(): Nullable<DataArray>;
  6517. /**
  6518. * Gets underlying native buffer
  6519. * @returns underlying native buffer
  6520. */
  6521. getBuffer(): Nullable<DataBuffer>;
  6522. /**
  6523. * Gets the stride in float32 units (i.e. byte stride / 4).
  6524. * May not be an integer if the byte stride is not divisible by 4.
  6525. * @returns the stride in float32 units
  6526. * @deprecated Please use byteStride instead.
  6527. */
  6528. getStrideSize(): number;
  6529. /**
  6530. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6531. * @param data defines the data to store
  6532. */
  6533. create(data?: Nullable<DataArray>): void;
  6534. /** @hidden */
  6535. _rebuild(): void;
  6536. /**
  6537. * Update current buffer data
  6538. * @param data defines the data to store
  6539. */
  6540. update(data: DataArray): void;
  6541. /**
  6542. * Updates the data directly.
  6543. * @param data the new data
  6544. * @param offset the new offset
  6545. * @param vertexCount the vertex count (optional)
  6546. * @param useBytes set to true if the offset is in bytes
  6547. */
  6548. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6549. /**
  6550. * Release all resources
  6551. */
  6552. dispose(): void;
  6553. }
  6554. /**
  6555. * Specialized buffer used to store vertex data
  6556. */
  6557. export class VertexBuffer {
  6558. /** @hidden */
  6559. _buffer: Buffer;
  6560. private _kind;
  6561. private _size;
  6562. private _ownsBuffer;
  6563. private _instanced;
  6564. private _instanceDivisor;
  6565. /**
  6566. * The byte type.
  6567. */
  6568. static readonly BYTE: number;
  6569. /**
  6570. * The unsigned byte type.
  6571. */
  6572. static readonly UNSIGNED_BYTE: number;
  6573. /**
  6574. * The short type.
  6575. */
  6576. static readonly SHORT: number;
  6577. /**
  6578. * The unsigned short type.
  6579. */
  6580. static readonly UNSIGNED_SHORT: number;
  6581. /**
  6582. * The integer type.
  6583. */
  6584. static readonly INT: number;
  6585. /**
  6586. * The unsigned integer type.
  6587. */
  6588. static readonly UNSIGNED_INT: number;
  6589. /**
  6590. * The float type.
  6591. */
  6592. static readonly FLOAT: number;
  6593. /**
  6594. * Gets or sets the instance divisor when in instanced mode
  6595. */
  6596. get instanceDivisor(): number;
  6597. set instanceDivisor(value: number);
  6598. /**
  6599. * Gets the byte stride.
  6600. */
  6601. readonly byteStride: number;
  6602. /**
  6603. * Gets the byte offset.
  6604. */
  6605. readonly byteOffset: number;
  6606. /**
  6607. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6608. */
  6609. readonly normalized: boolean;
  6610. /**
  6611. * Gets the data type of each component in the array.
  6612. */
  6613. readonly type: number;
  6614. /**
  6615. * Constructor
  6616. * @param engine the engine
  6617. * @param data the data to use for this vertex buffer
  6618. * @param kind the vertex buffer kind
  6619. * @param updatable whether the data is updatable
  6620. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6621. * @param stride the stride (optional)
  6622. * @param instanced whether the buffer is instanced (optional)
  6623. * @param offset the offset of the data (optional)
  6624. * @param size the number of components (optional)
  6625. * @param type the type of the component (optional)
  6626. * @param normalized whether the data contains normalized data (optional)
  6627. * @param useBytes set to true if stride and offset are in bytes (optional)
  6628. * @param divisor defines the instance divisor to use (1 by default)
  6629. */
  6630. 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);
  6631. /** @hidden */
  6632. _rebuild(): void;
  6633. /**
  6634. * Returns the kind of the VertexBuffer (string)
  6635. * @returns a string
  6636. */
  6637. getKind(): string;
  6638. /**
  6639. * Gets a boolean indicating if the VertexBuffer is updatable?
  6640. * @returns true if the buffer is updatable
  6641. */
  6642. isUpdatable(): boolean;
  6643. /**
  6644. * Gets current buffer's data
  6645. * @returns a DataArray or null
  6646. */
  6647. getData(): Nullable<DataArray>;
  6648. /**
  6649. * Gets underlying native buffer
  6650. * @returns underlying native buffer
  6651. */
  6652. getBuffer(): Nullable<DataBuffer>;
  6653. /**
  6654. * Gets the stride in float32 units (i.e. byte stride / 4).
  6655. * May not be an integer if the byte stride is not divisible by 4.
  6656. * @returns the stride in float32 units
  6657. * @deprecated Please use byteStride instead.
  6658. */
  6659. getStrideSize(): number;
  6660. /**
  6661. * Returns the offset as a multiple of the type byte length.
  6662. * @returns the offset in bytes
  6663. * @deprecated Please use byteOffset instead.
  6664. */
  6665. getOffset(): number;
  6666. /**
  6667. * Returns the number of components per vertex attribute (integer)
  6668. * @returns the size in float
  6669. */
  6670. getSize(): number;
  6671. /**
  6672. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6673. * @returns true if this buffer is instanced
  6674. */
  6675. getIsInstanced(): boolean;
  6676. /**
  6677. * Returns the instancing divisor, zero for non-instanced (integer).
  6678. * @returns a number
  6679. */
  6680. getInstanceDivisor(): number;
  6681. /**
  6682. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6683. * @param data defines the data to store
  6684. */
  6685. create(data?: DataArray): void;
  6686. /**
  6687. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6688. * This function will create a new buffer if the current one is not updatable
  6689. * @param data defines the data to store
  6690. */
  6691. update(data: DataArray): void;
  6692. /**
  6693. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6694. * Returns the directly updated WebGLBuffer.
  6695. * @param data the new data
  6696. * @param offset the new offset
  6697. * @param useBytes set to true if the offset is in bytes
  6698. */
  6699. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6700. /**
  6701. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6702. */
  6703. dispose(): void;
  6704. /**
  6705. * Enumerates each value of this vertex buffer as numbers.
  6706. * @param count the number of values to enumerate
  6707. * @param callback the callback function called for each value
  6708. */
  6709. forEach(count: number, callback: (value: number, index: number) => void): void;
  6710. /**
  6711. * Positions
  6712. */
  6713. static readonly PositionKind: string;
  6714. /**
  6715. * Normals
  6716. */
  6717. static readonly NormalKind: string;
  6718. /**
  6719. * Tangents
  6720. */
  6721. static readonly TangentKind: string;
  6722. /**
  6723. * Texture coordinates
  6724. */
  6725. static readonly UVKind: string;
  6726. /**
  6727. * Texture coordinates 2
  6728. */
  6729. static readonly UV2Kind: string;
  6730. /**
  6731. * Texture coordinates 3
  6732. */
  6733. static readonly UV3Kind: string;
  6734. /**
  6735. * Texture coordinates 4
  6736. */
  6737. static readonly UV4Kind: string;
  6738. /**
  6739. * Texture coordinates 5
  6740. */
  6741. static readonly UV5Kind: string;
  6742. /**
  6743. * Texture coordinates 6
  6744. */
  6745. static readonly UV6Kind: string;
  6746. /**
  6747. * Colors
  6748. */
  6749. static readonly ColorKind: string;
  6750. /**
  6751. * Matrix indices (for bones)
  6752. */
  6753. static readonly MatricesIndicesKind: string;
  6754. /**
  6755. * Matrix weights (for bones)
  6756. */
  6757. static readonly MatricesWeightsKind: string;
  6758. /**
  6759. * Additional matrix indices (for bones)
  6760. */
  6761. static readonly MatricesIndicesExtraKind: string;
  6762. /**
  6763. * Additional matrix weights (for bones)
  6764. */
  6765. static readonly MatricesWeightsExtraKind: string;
  6766. /**
  6767. * Deduces the stride given a kind.
  6768. * @param kind The kind string to deduce
  6769. * @returns The deduced stride
  6770. */
  6771. static DeduceStride(kind: string): number;
  6772. /**
  6773. * Gets the byte length of the given type.
  6774. * @param type the type
  6775. * @returns the number of bytes
  6776. */
  6777. static GetTypeByteLength(type: number): number;
  6778. /**
  6779. * Enumerates each value of the given parameters as numbers.
  6780. * @param data the data to enumerate
  6781. * @param byteOffset the byte offset of the data
  6782. * @param byteStride the byte stride of the data
  6783. * @param componentCount the number of components per element
  6784. * @param componentType the type of the component
  6785. * @param count the number of values to enumerate
  6786. * @param normalized whether the data is normalized
  6787. * @param callback the callback function called for each value
  6788. */
  6789. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6790. private static _GetFloatValue;
  6791. }
  6792. }
  6793. declare module "babylonjs/Collisions/intersectionInfo" {
  6794. import { Nullable } from "babylonjs/types";
  6795. /**
  6796. * @hidden
  6797. */
  6798. export class IntersectionInfo {
  6799. bu: Nullable<number>;
  6800. bv: Nullable<number>;
  6801. distance: number;
  6802. faceId: number;
  6803. subMeshId: number;
  6804. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6805. }
  6806. }
  6807. declare module "babylonjs/Culling/boundingSphere" {
  6808. import { DeepImmutable } from "babylonjs/types";
  6809. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6810. import { Plane } from "babylonjs/Maths/math.plane";
  6811. /**
  6812. * Class used to store bounding sphere information
  6813. */
  6814. export class BoundingSphere {
  6815. /**
  6816. * Gets the center of the bounding sphere in local space
  6817. */
  6818. readonly center: Vector3;
  6819. /**
  6820. * Radius of the bounding sphere in local space
  6821. */
  6822. radius: number;
  6823. /**
  6824. * Gets the center of the bounding sphere in world space
  6825. */
  6826. readonly centerWorld: Vector3;
  6827. /**
  6828. * Radius of the bounding sphere in world space
  6829. */
  6830. radiusWorld: number;
  6831. /**
  6832. * Gets the minimum vector in local space
  6833. */
  6834. readonly minimum: Vector3;
  6835. /**
  6836. * Gets the maximum vector in local space
  6837. */
  6838. readonly maximum: Vector3;
  6839. private _worldMatrix;
  6840. private static readonly TmpVector3;
  6841. /**
  6842. * Creates a new bounding sphere
  6843. * @param min defines the minimum vector (in local space)
  6844. * @param max defines the maximum vector (in local space)
  6845. * @param worldMatrix defines the new world matrix
  6846. */
  6847. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6848. /**
  6849. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6850. * @param min defines the new minimum vector (in local space)
  6851. * @param max defines the new maximum vector (in local space)
  6852. * @param worldMatrix defines the new world matrix
  6853. */
  6854. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6855. /**
  6856. * Scale the current bounding sphere by applying a scale factor
  6857. * @param factor defines the scale factor to apply
  6858. * @returns the current bounding box
  6859. */
  6860. scale(factor: number): BoundingSphere;
  6861. /**
  6862. * Gets the world matrix of the bounding box
  6863. * @returns a matrix
  6864. */
  6865. getWorldMatrix(): DeepImmutable<Matrix>;
  6866. /** @hidden */
  6867. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6868. /**
  6869. * Tests if the bounding sphere is intersecting the frustum planes
  6870. * @param frustumPlanes defines the frustum planes to test
  6871. * @returns true if there is an intersection
  6872. */
  6873. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6874. /**
  6875. * Tests if the bounding sphere center is in between the frustum planes.
  6876. * Used for optimistic fast inclusion.
  6877. * @param frustumPlanes defines the frustum planes to test
  6878. * @returns true if the sphere center is in between the frustum planes
  6879. */
  6880. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6881. /**
  6882. * Tests if a point is inside the bounding sphere
  6883. * @param point defines the point to test
  6884. * @returns true if the point is inside the bounding sphere
  6885. */
  6886. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6887. /**
  6888. * Checks if two sphere intersct
  6889. * @param sphere0 sphere 0
  6890. * @param sphere1 sphere 1
  6891. * @returns true if the speres intersect
  6892. */
  6893. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6894. }
  6895. }
  6896. declare module "babylonjs/Culling/boundingBox" {
  6897. import { DeepImmutable } from "babylonjs/types";
  6898. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6899. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6900. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6901. import { Plane } from "babylonjs/Maths/math.plane";
  6902. /**
  6903. * Class used to store bounding box information
  6904. */
  6905. export class BoundingBox implements ICullable {
  6906. /**
  6907. * Gets the 8 vectors representing the bounding box in local space
  6908. */
  6909. readonly vectors: Vector3[];
  6910. /**
  6911. * Gets the center of the bounding box in local space
  6912. */
  6913. readonly center: Vector3;
  6914. /**
  6915. * Gets the center of the bounding box in world space
  6916. */
  6917. readonly centerWorld: Vector3;
  6918. /**
  6919. * Gets the extend size in local space
  6920. */
  6921. readonly extendSize: Vector3;
  6922. /**
  6923. * Gets the extend size in world space
  6924. */
  6925. readonly extendSizeWorld: Vector3;
  6926. /**
  6927. * Gets the OBB (object bounding box) directions
  6928. */
  6929. readonly directions: Vector3[];
  6930. /**
  6931. * Gets the 8 vectors representing the bounding box in world space
  6932. */
  6933. readonly vectorsWorld: Vector3[];
  6934. /**
  6935. * Gets the minimum vector in world space
  6936. */
  6937. readonly minimumWorld: Vector3;
  6938. /**
  6939. * Gets the maximum vector in world space
  6940. */
  6941. readonly maximumWorld: Vector3;
  6942. /**
  6943. * Gets the minimum vector in local space
  6944. */
  6945. readonly minimum: Vector3;
  6946. /**
  6947. * Gets the maximum vector in local space
  6948. */
  6949. readonly maximum: Vector3;
  6950. private _worldMatrix;
  6951. private static readonly TmpVector3;
  6952. /**
  6953. * @hidden
  6954. */
  6955. _tag: number;
  6956. /**
  6957. * Creates a new bounding box
  6958. * @param min defines the minimum vector (in local space)
  6959. * @param max defines the maximum vector (in local space)
  6960. * @param worldMatrix defines the new world matrix
  6961. */
  6962. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6963. /**
  6964. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6965. * @param min defines the new minimum vector (in local space)
  6966. * @param max defines the new maximum vector (in local space)
  6967. * @param worldMatrix defines the new world matrix
  6968. */
  6969. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6970. /**
  6971. * Scale the current bounding box by applying a scale factor
  6972. * @param factor defines the scale factor to apply
  6973. * @returns the current bounding box
  6974. */
  6975. scale(factor: number): BoundingBox;
  6976. /**
  6977. * Gets the world matrix of the bounding box
  6978. * @returns a matrix
  6979. */
  6980. getWorldMatrix(): DeepImmutable<Matrix>;
  6981. /** @hidden */
  6982. _update(world: DeepImmutable<Matrix>): void;
  6983. /**
  6984. * Tests if the bounding box is intersecting the frustum planes
  6985. * @param frustumPlanes defines the frustum planes to test
  6986. * @returns true if there is an intersection
  6987. */
  6988. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6989. /**
  6990. * Tests if the bounding box is entirely inside the frustum planes
  6991. * @param frustumPlanes defines the frustum planes to test
  6992. * @returns true if there is an inclusion
  6993. */
  6994. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6995. /**
  6996. * Tests if a point is inside the bounding box
  6997. * @param point defines the point to test
  6998. * @returns true if the point is inside the bounding box
  6999. */
  7000. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7001. /**
  7002. * Tests if the bounding box intersects with a bounding sphere
  7003. * @param sphere defines the sphere to test
  7004. * @returns true if there is an intersection
  7005. */
  7006. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7007. /**
  7008. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7009. * @param min defines the min vector to use
  7010. * @param max defines the max vector to use
  7011. * @returns true if there is an intersection
  7012. */
  7013. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7014. /**
  7015. * Tests if two bounding boxes are intersections
  7016. * @param box0 defines the first box to test
  7017. * @param box1 defines the second box to test
  7018. * @returns true if there is an intersection
  7019. */
  7020. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7021. /**
  7022. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7023. * @param minPoint defines the minimum vector of the bounding box
  7024. * @param maxPoint defines the maximum vector of the bounding box
  7025. * @param sphereCenter defines the sphere center
  7026. * @param sphereRadius defines the sphere radius
  7027. * @returns true if there is an intersection
  7028. */
  7029. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7030. /**
  7031. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7032. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7033. * @param frustumPlanes defines the frustum planes to test
  7034. * @return true if there is an inclusion
  7035. */
  7036. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7037. /**
  7038. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7039. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7040. * @param frustumPlanes defines the frustum planes to test
  7041. * @return true if there is an intersection
  7042. */
  7043. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7044. }
  7045. }
  7046. declare module "babylonjs/Collisions/collider" {
  7047. import { Nullable, IndicesArray } from "babylonjs/types";
  7048. import { Vector3 } from "babylonjs/Maths/math.vector";
  7049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7050. import { Plane } from "babylonjs/Maths/math.plane";
  7051. /** @hidden */
  7052. export class Collider {
  7053. /** Define if a collision was found */
  7054. collisionFound: boolean;
  7055. /**
  7056. * Define last intersection point in local space
  7057. */
  7058. intersectionPoint: Vector3;
  7059. /**
  7060. * Define last collided mesh
  7061. */
  7062. collidedMesh: Nullable<AbstractMesh>;
  7063. private _collisionPoint;
  7064. private _planeIntersectionPoint;
  7065. private _tempVector;
  7066. private _tempVector2;
  7067. private _tempVector3;
  7068. private _tempVector4;
  7069. private _edge;
  7070. private _baseToVertex;
  7071. private _destinationPoint;
  7072. private _slidePlaneNormal;
  7073. private _displacementVector;
  7074. /** @hidden */
  7075. _radius: Vector3;
  7076. /** @hidden */
  7077. _retry: number;
  7078. private _velocity;
  7079. private _basePoint;
  7080. private _epsilon;
  7081. /** @hidden */
  7082. _velocityWorldLength: number;
  7083. /** @hidden */
  7084. _basePointWorld: Vector3;
  7085. private _velocityWorld;
  7086. private _normalizedVelocity;
  7087. /** @hidden */
  7088. _initialVelocity: Vector3;
  7089. /** @hidden */
  7090. _initialPosition: Vector3;
  7091. private _nearestDistance;
  7092. private _collisionMask;
  7093. get collisionMask(): number;
  7094. set collisionMask(mask: number);
  7095. /**
  7096. * Gets the plane normal used to compute the sliding response (in local space)
  7097. */
  7098. get slidePlaneNormal(): Vector3;
  7099. /** @hidden */
  7100. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7101. /** @hidden */
  7102. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7103. /** @hidden */
  7104. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7105. /** @hidden */
  7106. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7107. /** @hidden */
  7108. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7109. /** @hidden */
  7110. _getResponse(pos: Vector3, vel: Vector3): void;
  7111. }
  7112. }
  7113. declare module "babylonjs/Culling/boundingInfo" {
  7114. import { DeepImmutable } from "babylonjs/types";
  7115. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7116. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7117. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7118. import { Plane } from "babylonjs/Maths/math.plane";
  7119. import { Collider } from "babylonjs/Collisions/collider";
  7120. /**
  7121. * Interface for cullable objects
  7122. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7123. */
  7124. export interface ICullable {
  7125. /**
  7126. * Checks if the object or part of the object is in the frustum
  7127. * @param frustumPlanes Camera near/planes
  7128. * @returns true if the object is in frustum otherwise false
  7129. */
  7130. isInFrustum(frustumPlanes: Plane[]): boolean;
  7131. /**
  7132. * Checks if a cullable object (mesh...) is in the camera frustum
  7133. * Unlike isInFrustum this cheks the full bounding box
  7134. * @param frustumPlanes Camera near/planes
  7135. * @returns true if the object is in frustum otherwise false
  7136. */
  7137. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7138. }
  7139. /**
  7140. * Info for a bounding data of a mesh
  7141. */
  7142. export class BoundingInfo implements ICullable {
  7143. /**
  7144. * Bounding box for the mesh
  7145. */
  7146. readonly boundingBox: BoundingBox;
  7147. /**
  7148. * Bounding sphere for the mesh
  7149. */
  7150. readonly boundingSphere: BoundingSphere;
  7151. private _isLocked;
  7152. private static readonly TmpVector3;
  7153. /**
  7154. * Constructs bounding info
  7155. * @param minimum min vector of the bounding box/sphere
  7156. * @param maximum max vector of the bounding box/sphere
  7157. * @param worldMatrix defines the new world matrix
  7158. */
  7159. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7160. /**
  7161. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7162. * @param min defines the new minimum vector (in local space)
  7163. * @param max defines the new maximum vector (in local space)
  7164. * @param worldMatrix defines the new world matrix
  7165. */
  7166. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7167. /**
  7168. * min vector of the bounding box/sphere
  7169. */
  7170. get minimum(): Vector3;
  7171. /**
  7172. * max vector of the bounding box/sphere
  7173. */
  7174. get maximum(): Vector3;
  7175. /**
  7176. * If the info is locked and won't be updated to avoid perf overhead
  7177. */
  7178. get isLocked(): boolean;
  7179. set isLocked(value: boolean);
  7180. /**
  7181. * Updates the bounding sphere and box
  7182. * @param world world matrix to be used to update
  7183. */
  7184. update(world: DeepImmutable<Matrix>): void;
  7185. /**
  7186. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7187. * @param center New center of the bounding info
  7188. * @param extend New extend of the bounding info
  7189. * @returns the current bounding info
  7190. */
  7191. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7192. /**
  7193. * Scale the current bounding info by applying a scale factor
  7194. * @param factor defines the scale factor to apply
  7195. * @returns the current bounding info
  7196. */
  7197. scale(factor: number): BoundingInfo;
  7198. /**
  7199. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7200. * @param frustumPlanes defines the frustum to test
  7201. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7202. * @returns true if the bounding info is in the frustum planes
  7203. */
  7204. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7205. /**
  7206. * Gets the world distance between the min and max points of the bounding box
  7207. */
  7208. get diagonalLength(): number;
  7209. /**
  7210. * Checks if a cullable object (mesh...) is in the camera frustum
  7211. * Unlike isInFrustum this cheks the full bounding box
  7212. * @param frustumPlanes Camera near/planes
  7213. * @returns true if the object is in frustum otherwise false
  7214. */
  7215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7216. /** @hidden */
  7217. _checkCollision(collider: Collider): boolean;
  7218. /**
  7219. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7220. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7221. * @param point the point to check intersection with
  7222. * @returns if the point intersects
  7223. */
  7224. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7225. /**
  7226. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7227. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7228. * @param boundingInfo the bounding info to check intersection with
  7229. * @param precise if the intersection should be done using OBB
  7230. * @returns if the bounding info intersects
  7231. */
  7232. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7233. }
  7234. }
  7235. declare module "babylonjs/Maths/math.functions" {
  7236. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7237. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7238. /**
  7239. * Extracts minimum and maximum values from a list of indexed positions
  7240. * @param positions defines the positions to use
  7241. * @param indices defines the indices to the positions
  7242. * @param indexStart defines the start index
  7243. * @param indexCount defines the end index
  7244. * @param bias defines bias value to add to the result
  7245. * @return minimum and maximum values
  7246. */
  7247. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7248. minimum: Vector3;
  7249. maximum: Vector3;
  7250. };
  7251. /**
  7252. * Extracts minimum and maximum values from a list of positions
  7253. * @param positions defines the positions to use
  7254. * @param start defines the start index in the positions array
  7255. * @param count defines the number of positions to handle
  7256. * @param bias defines bias value to add to the result
  7257. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7258. * @return minimum and maximum values
  7259. */
  7260. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7261. minimum: Vector3;
  7262. maximum: Vector3;
  7263. };
  7264. }
  7265. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7266. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7267. /** @hidden */
  7268. export class WebGLDataBuffer extends DataBuffer {
  7269. private _buffer;
  7270. constructor(resource: WebGLBuffer);
  7271. get underlyingResource(): any;
  7272. }
  7273. }
  7274. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7275. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7276. import { Nullable } from "babylonjs/types";
  7277. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7278. /** @hidden */
  7279. export class WebGLPipelineContext implements IPipelineContext {
  7280. engine: ThinEngine;
  7281. program: Nullable<WebGLProgram>;
  7282. context?: WebGLRenderingContext;
  7283. vertexShader?: WebGLShader;
  7284. fragmentShader?: WebGLShader;
  7285. isParallelCompiled: boolean;
  7286. onCompiled?: () => void;
  7287. transformFeedback?: WebGLTransformFeedback | null;
  7288. vertexCompilationError: Nullable<string>;
  7289. fragmentCompilationError: Nullable<string>;
  7290. programLinkError: Nullable<string>;
  7291. programValidationError: Nullable<string>;
  7292. get isAsync(): boolean;
  7293. get isReady(): boolean;
  7294. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7295. _getVertexShaderCode(): string | null;
  7296. _getFragmentShaderCode(): string | null;
  7297. }
  7298. }
  7299. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7300. import { FloatArray, Nullable } from "babylonjs/types";
  7301. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7302. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7303. module "babylonjs/Engines/thinEngine" {
  7304. interface ThinEngine {
  7305. /**
  7306. * Create an uniform buffer
  7307. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7308. * @param elements defines the content of the uniform buffer
  7309. * @returns the webGL uniform buffer
  7310. */
  7311. createUniformBuffer(elements: FloatArray): DataBuffer;
  7312. /**
  7313. * Create a dynamic uniform buffer
  7314. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7315. * @param elements defines the content of the uniform buffer
  7316. * @returns the webGL uniform buffer
  7317. */
  7318. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7319. /**
  7320. * Update an existing uniform buffer
  7321. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7322. * @param uniformBuffer defines the target uniform buffer
  7323. * @param elements defines the content to update
  7324. * @param offset defines the offset in the uniform buffer where update should start
  7325. * @param count defines the size of the data to update
  7326. */
  7327. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7328. /**
  7329. * Bind an uniform buffer to the current webGL context
  7330. * @param buffer defines the buffer to bind
  7331. */
  7332. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7333. /**
  7334. * Bind a buffer to the current webGL context at a given location
  7335. * @param buffer defines the buffer to bind
  7336. * @param location defines the index where to bind the buffer
  7337. */
  7338. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7339. /**
  7340. * Bind a specific block at a given index in a specific shader program
  7341. * @param pipelineContext defines the pipeline context to use
  7342. * @param blockName defines the block name
  7343. * @param index defines the index where to bind the block
  7344. */
  7345. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7346. }
  7347. }
  7348. }
  7349. declare module "babylonjs/Materials/uniformBuffer" {
  7350. import { Nullable, FloatArray } from "babylonjs/types";
  7351. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7352. import { Engine } from "babylonjs/Engines/engine";
  7353. import { Effect } from "babylonjs/Materials/effect";
  7354. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7355. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7356. import { Color3 } from "babylonjs/Maths/math.color";
  7357. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7358. /**
  7359. * Uniform buffer objects.
  7360. *
  7361. * Handles blocks of uniform on the GPU.
  7362. *
  7363. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7364. *
  7365. * For more information, please refer to :
  7366. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7367. */
  7368. export class UniformBuffer {
  7369. private _engine;
  7370. private _buffer;
  7371. private _data;
  7372. private _bufferData;
  7373. private _dynamic?;
  7374. private _uniformLocations;
  7375. private _uniformSizes;
  7376. private _uniformLocationPointer;
  7377. private _needSync;
  7378. private _noUBO;
  7379. private _currentEffect;
  7380. /** @hidden */
  7381. _alreadyBound: boolean;
  7382. private static _MAX_UNIFORM_SIZE;
  7383. private static _tempBuffer;
  7384. /**
  7385. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7386. * This is dynamic to allow compat with webgl 1 and 2.
  7387. * You will need to pass the name of the uniform as well as the value.
  7388. */
  7389. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7390. /**
  7391. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7392. * This is dynamic to allow compat with webgl 1 and 2.
  7393. * You will need to pass the name of the uniform as well as the value.
  7394. */
  7395. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7396. /**
  7397. * Lambda to Update a single float in a uniform buffer.
  7398. * This is dynamic to allow compat with webgl 1 and 2.
  7399. * You will need to pass the name of the uniform as well as the value.
  7400. */
  7401. updateFloat: (name: string, x: number) => void;
  7402. /**
  7403. * Lambda to Update a vec2 of float in a uniform buffer.
  7404. * This is dynamic to allow compat with webgl 1 and 2.
  7405. * You will need to pass the name of the uniform as well as the value.
  7406. */
  7407. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7408. /**
  7409. * Lambda to Update a vec3 of float in a uniform buffer.
  7410. * This is dynamic to allow compat with webgl 1 and 2.
  7411. * You will need to pass the name of the uniform as well as the value.
  7412. */
  7413. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7414. /**
  7415. * Lambda to Update a vec4 of float in a uniform buffer.
  7416. * This is dynamic to allow compat with webgl 1 and 2.
  7417. * You will need to pass the name of the uniform as well as the value.
  7418. */
  7419. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7420. /**
  7421. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7422. * This is dynamic to allow compat with webgl 1 and 2.
  7423. * You will need to pass the name of the uniform as well as the value.
  7424. */
  7425. updateMatrix: (name: string, mat: Matrix) => void;
  7426. /**
  7427. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7428. * This is dynamic to allow compat with webgl 1 and 2.
  7429. * You will need to pass the name of the uniform as well as the value.
  7430. */
  7431. updateVector3: (name: string, vector: Vector3) => void;
  7432. /**
  7433. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7434. * This is dynamic to allow compat with webgl 1 and 2.
  7435. * You will need to pass the name of the uniform as well as the value.
  7436. */
  7437. updateVector4: (name: string, vector: Vector4) => void;
  7438. /**
  7439. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7440. * This is dynamic to allow compat with webgl 1 and 2.
  7441. * You will need to pass the name of the uniform as well as the value.
  7442. */
  7443. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7444. /**
  7445. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7446. * This is dynamic to allow compat with webgl 1 and 2.
  7447. * You will need to pass the name of the uniform as well as the value.
  7448. */
  7449. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7450. /**
  7451. * Instantiates a new Uniform buffer objects.
  7452. *
  7453. * Handles blocks of uniform on the GPU.
  7454. *
  7455. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7456. *
  7457. * For more information, please refer to :
  7458. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7459. * @param engine Define the engine the buffer is associated with
  7460. * @param data Define the data contained in the buffer
  7461. * @param dynamic Define if the buffer is updatable
  7462. */
  7463. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7464. /**
  7465. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7466. * or just falling back on setUniformXXX calls.
  7467. */
  7468. get useUbo(): boolean;
  7469. /**
  7470. * Indicates if the WebGL underlying uniform buffer is in sync
  7471. * with the javascript cache data.
  7472. */
  7473. get isSync(): boolean;
  7474. /**
  7475. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7476. * Also, a dynamic UniformBuffer will disable cache verification and always
  7477. * update the underlying WebGL uniform buffer to the GPU.
  7478. * @returns if Dynamic, otherwise false
  7479. */
  7480. isDynamic(): boolean;
  7481. /**
  7482. * The data cache on JS side.
  7483. * @returns the underlying data as a float array
  7484. */
  7485. getData(): Float32Array;
  7486. /**
  7487. * The underlying WebGL Uniform buffer.
  7488. * @returns the webgl buffer
  7489. */
  7490. getBuffer(): Nullable<DataBuffer>;
  7491. /**
  7492. * std140 layout specifies how to align data within an UBO structure.
  7493. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7494. * for specs.
  7495. */
  7496. private _fillAlignment;
  7497. /**
  7498. * Adds an uniform in the buffer.
  7499. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7500. * for the layout to be correct !
  7501. * @param name Name of the uniform, as used in the uniform block in the shader.
  7502. * @param size Data size, or data directly.
  7503. */
  7504. addUniform(name: string, size: number | number[]): void;
  7505. /**
  7506. * Adds a Matrix 4x4 to the uniform buffer.
  7507. * @param name Name of the uniform, as used in the uniform block in the shader.
  7508. * @param mat A 4x4 matrix.
  7509. */
  7510. addMatrix(name: string, mat: Matrix): void;
  7511. /**
  7512. * Adds a vec2 to the uniform buffer.
  7513. * @param name Name of the uniform, as used in the uniform block in the shader.
  7514. * @param x Define the x component value of the vec2
  7515. * @param y Define the y component value of the vec2
  7516. */
  7517. addFloat2(name: string, x: number, y: number): void;
  7518. /**
  7519. * Adds a vec3 to the uniform buffer.
  7520. * @param name Name of the uniform, as used in the uniform block in the shader.
  7521. * @param x Define the x component value of the vec3
  7522. * @param y Define the y component value of the vec3
  7523. * @param z Define the z component value of the vec3
  7524. */
  7525. addFloat3(name: string, x: number, y: number, z: number): void;
  7526. /**
  7527. * Adds a vec3 to the uniform buffer.
  7528. * @param name Name of the uniform, as used in the uniform block in the shader.
  7529. * @param color Define the vec3 from a Color
  7530. */
  7531. addColor3(name: string, color: Color3): void;
  7532. /**
  7533. * Adds a vec4 to the uniform buffer.
  7534. * @param name Name of the uniform, as used in the uniform block in the shader.
  7535. * @param color Define the rgb components from a Color
  7536. * @param alpha Define the a component of the vec4
  7537. */
  7538. addColor4(name: string, color: Color3, alpha: number): void;
  7539. /**
  7540. * Adds a vec3 to the uniform buffer.
  7541. * @param name Name of the uniform, as used in the uniform block in the shader.
  7542. * @param vector Define the vec3 components from a Vector
  7543. */
  7544. addVector3(name: string, vector: Vector3): void;
  7545. /**
  7546. * Adds a Matrix 3x3 to the uniform buffer.
  7547. * @param name Name of the uniform, as used in the uniform block in the shader.
  7548. */
  7549. addMatrix3x3(name: string): void;
  7550. /**
  7551. * Adds a Matrix 2x2 to the uniform buffer.
  7552. * @param name Name of the uniform, as used in the uniform block in the shader.
  7553. */
  7554. addMatrix2x2(name: string): void;
  7555. /**
  7556. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7557. */
  7558. create(): void;
  7559. /** @hidden */
  7560. _rebuild(): void;
  7561. /**
  7562. * Updates the WebGL Uniform Buffer on the GPU.
  7563. * If the `dynamic` flag is set to true, no cache comparison is done.
  7564. * Otherwise, the buffer will be updated only if the cache differs.
  7565. */
  7566. update(): void;
  7567. /**
  7568. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7569. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7570. * @param data Define the flattened data
  7571. * @param size Define the size of the data.
  7572. */
  7573. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7574. private _valueCache;
  7575. private _cacheMatrix;
  7576. private _updateMatrix3x3ForUniform;
  7577. private _updateMatrix3x3ForEffect;
  7578. private _updateMatrix2x2ForEffect;
  7579. private _updateMatrix2x2ForUniform;
  7580. private _updateFloatForEffect;
  7581. private _updateFloatForUniform;
  7582. private _updateFloat2ForEffect;
  7583. private _updateFloat2ForUniform;
  7584. private _updateFloat3ForEffect;
  7585. private _updateFloat3ForUniform;
  7586. private _updateFloat4ForEffect;
  7587. private _updateFloat4ForUniform;
  7588. private _updateMatrixForEffect;
  7589. private _updateMatrixForUniform;
  7590. private _updateVector3ForEffect;
  7591. private _updateVector3ForUniform;
  7592. private _updateVector4ForEffect;
  7593. private _updateVector4ForUniform;
  7594. private _updateColor3ForEffect;
  7595. private _updateColor3ForUniform;
  7596. private _updateColor4ForEffect;
  7597. private _updateColor4ForUniform;
  7598. /**
  7599. * Sets a sampler uniform on the effect.
  7600. * @param name Define the name of the sampler.
  7601. * @param texture Define the texture to set in the sampler
  7602. */
  7603. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7604. /**
  7605. * Directly updates the value of the uniform in the cache AND on the GPU.
  7606. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7607. * @param data Define the flattened data
  7608. */
  7609. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7610. /**
  7611. * Binds this uniform buffer to an effect.
  7612. * @param effect Define the effect to bind the buffer to
  7613. * @param name Name of the uniform block in the shader.
  7614. */
  7615. bindToEffect(effect: Effect, name: string): void;
  7616. /**
  7617. * Disposes the uniform buffer.
  7618. */
  7619. dispose(): void;
  7620. }
  7621. }
  7622. declare module "babylonjs/Misc/iInspectable" {
  7623. /**
  7624. * Enum that determines the text-wrapping mode to use.
  7625. */
  7626. export enum InspectableType {
  7627. /**
  7628. * Checkbox for booleans
  7629. */
  7630. Checkbox = 0,
  7631. /**
  7632. * Sliders for numbers
  7633. */
  7634. Slider = 1,
  7635. /**
  7636. * Vector3
  7637. */
  7638. Vector3 = 2,
  7639. /**
  7640. * Quaternions
  7641. */
  7642. Quaternion = 3,
  7643. /**
  7644. * Color3
  7645. */
  7646. Color3 = 4,
  7647. /**
  7648. * String
  7649. */
  7650. String = 5
  7651. }
  7652. /**
  7653. * Interface used to define custom inspectable properties.
  7654. * This interface is used by the inspector to display custom property grids
  7655. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7656. */
  7657. export interface IInspectable {
  7658. /**
  7659. * Gets the label to display
  7660. */
  7661. label: string;
  7662. /**
  7663. * Gets the name of the property to edit
  7664. */
  7665. propertyName: string;
  7666. /**
  7667. * Gets the type of the editor to use
  7668. */
  7669. type: InspectableType;
  7670. /**
  7671. * Gets the minimum value of the property when using in "slider" mode
  7672. */
  7673. min?: number;
  7674. /**
  7675. * Gets the maximum value of the property when using in "slider" mode
  7676. */
  7677. max?: number;
  7678. /**
  7679. * Gets the setp to use when using in "slider" mode
  7680. */
  7681. step?: number;
  7682. }
  7683. }
  7684. declare module "babylonjs/Misc/timingTools" {
  7685. /**
  7686. * Class used to provide helper for timing
  7687. */
  7688. export class TimingTools {
  7689. /**
  7690. * Polyfill for setImmediate
  7691. * @param action defines the action to execute after the current execution block
  7692. */
  7693. static SetImmediate(action: () => void): void;
  7694. }
  7695. }
  7696. declare module "babylonjs/Misc/instantiationTools" {
  7697. /**
  7698. * Class used to enable instatition of objects by class name
  7699. */
  7700. export class InstantiationTools {
  7701. /**
  7702. * Use this object to register external classes like custom textures or material
  7703. * to allow the laoders to instantiate them
  7704. */
  7705. static RegisteredExternalClasses: {
  7706. [key: string]: Object;
  7707. };
  7708. /**
  7709. * Tries to instantiate a new object from a given class name
  7710. * @param className defines the class name to instantiate
  7711. * @returns the new object or null if the system was not able to do the instantiation
  7712. */
  7713. static Instantiate(className: string): any;
  7714. }
  7715. }
  7716. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7717. /**
  7718. * Define options used to create a depth texture
  7719. */
  7720. export class DepthTextureCreationOptions {
  7721. /** Specifies whether or not a stencil should be allocated in the texture */
  7722. generateStencil?: boolean;
  7723. /** Specifies whether or not bilinear filtering is enable on the texture */
  7724. bilinearFiltering?: boolean;
  7725. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7726. comparisonFunction?: number;
  7727. /** Specifies if the created texture is a cube texture */
  7728. isCube?: boolean;
  7729. }
  7730. }
  7731. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7732. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7733. import { Nullable } from "babylonjs/types";
  7734. import { Scene } from "babylonjs/scene";
  7735. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7736. module "babylonjs/Engines/thinEngine" {
  7737. interface ThinEngine {
  7738. /**
  7739. * Creates a depth stencil cube texture.
  7740. * This is only available in WebGL 2.
  7741. * @param size The size of face edge in the cube texture.
  7742. * @param options The options defining the cube texture.
  7743. * @returns The cube texture
  7744. */
  7745. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7746. /**
  7747. * Creates a cube texture
  7748. * @param rootUrl defines the url where the files to load is located
  7749. * @param scene defines the current scene
  7750. * @param files defines the list of files to load (1 per face)
  7751. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7752. * @param onLoad defines an optional callback raised when the texture is loaded
  7753. * @param onError defines an optional callback raised if there is an issue to load the texture
  7754. * @param format defines the format of the data
  7755. * @param forcedExtension defines the extension to use to pick the right loader
  7756. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7757. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7758. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7759. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7760. * @returns the cube texture as an InternalTexture
  7761. */
  7762. 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;
  7763. /**
  7764. * Creates a cube texture
  7765. * @param rootUrl defines the url where the files to load is located
  7766. * @param scene defines the current scene
  7767. * @param files defines the list of files to load (1 per face)
  7768. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7769. * @param onLoad defines an optional callback raised when the texture is loaded
  7770. * @param onError defines an optional callback raised if there is an issue to load the texture
  7771. * @param format defines the format of the data
  7772. * @param forcedExtension defines the extension to use to pick the right loader
  7773. * @returns the cube texture as an InternalTexture
  7774. */
  7775. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7776. /**
  7777. * Creates a cube texture
  7778. * @param rootUrl defines the url where the files to load is located
  7779. * @param scene defines the current scene
  7780. * @param files defines the list of files to load (1 per face)
  7781. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7782. * @param onLoad defines an optional callback raised when the texture is loaded
  7783. * @param onError defines an optional callback raised if there is an issue to load the texture
  7784. * @param format defines the format of the data
  7785. * @param forcedExtension defines the extension to use to pick the right loader
  7786. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7787. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7788. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7789. * @returns the cube texture as an InternalTexture
  7790. */
  7791. 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;
  7792. /** @hidden */
  7793. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7794. /** @hidden */
  7795. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7796. /** @hidden */
  7797. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7798. /** @hidden */
  7799. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7800. /**
  7801. * @hidden
  7802. */
  7803. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7804. }
  7805. }
  7806. }
  7807. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7808. import { Nullable } from "babylonjs/types";
  7809. import { Scene } from "babylonjs/scene";
  7810. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7811. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7812. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7813. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7814. import { Observable } from "babylonjs/Misc/observable";
  7815. /**
  7816. * Class for creating a cube texture
  7817. */
  7818. export class CubeTexture extends BaseTexture {
  7819. private _delayedOnLoad;
  7820. /**
  7821. * Observable triggered once the texture has been loaded.
  7822. */
  7823. onLoadObservable: Observable<CubeTexture>;
  7824. /**
  7825. * The url of the texture
  7826. */
  7827. url: string;
  7828. /**
  7829. * Gets or sets the center of the bounding box associated with the cube texture.
  7830. * It must define where the camera used to render the texture was set
  7831. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7832. */
  7833. boundingBoxPosition: Vector3;
  7834. private _boundingBoxSize;
  7835. /**
  7836. * Gets or sets the size of the bounding box associated with the cube texture
  7837. * When defined, the cubemap will switch to local mode
  7838. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7839. * @example https://www.babylonjs-playground.com/#RNASML
  7840. */
  7841. set boundingBoxSize(value: Vector3);
  7842. /**
  7843. * Returns the bounding box size
  7844. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7845. */
  7846. get boundingBoxSize(): Vector3;
  7847. protected _rotationY: number;
  7848. /**
  7849. * Sets texture matrix rotation angle around Y axis in radians.
  7850. */
  7851. set rotationY(value: number);
  7852. /**
  7853. * Gets texture matrix rotation angle around Y axis radians.
  7854. */
  7855. get rotationY(): number;
  7856. /**
  7857. * Are mip maps generated for this texture or not.
  7858. */
  7859. get noMipmap(): boolean;
  7860. private _noMipmap;
  7861. private _files;
  7862. protected _forcedExtension: Nullable<string>;
  7863. private _extensions;
  7864. private _textureMatrix;
  7865. private _format;
  7866. private _createPolynomials;
  7867. /**
  7868. * Creates a cube texture from an array of image urls
  7869. * @param files defines an array of image urls
  7870. * @param scene defines the hosting scene
  7871. * @param noMipmap specifies if mip maps are not used
  7872. * @returns a cube texture
  7873. */
  7874. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7875. /**
  7876. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7877. * @param url defines the url of the prefiltered texture
  7878. * @param scene defines the scene the texture is attached to
  7879. * @param forcedExtension defines the extension of the file if different from the url
  7880. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7881. * @return the prefiltered texture
  7882. */
  7883. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7884. /**
  7885. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7886. * as prefiltered data.
  7887. * @param rootUrl defines the url of the texture or the root name of the six images
  7888. * @param null defines the scene or engine the texture is attached to
  7889. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7890. * @param noMipmap defines if mipmaps should be created or not
  7891. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7892. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7893. * @param onError defines a callback triggered in case of error during load
  7894. * @param format defines the internal format to use for the texture once loaded
  7895. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7896. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7897. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7898. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7899. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7900. * @return the cube texture
  7901. */
  7902. 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);
  7903. /**
  7904. * Get the current class name of the texture useful for serialization or dynamic coding.
  7905. * @returns "CubeTexture"
  7906. */
  7907. getClassName(): string;
  7908. /**
  7909. * Update the url (and optional buffer) of this texture if url was null during construction.
  7910. * @param url the url of the texture
  7911. * @param forcedExtension defines the extension to use
  7912. * @param onLoad callback called when the texture is loaded (defaults to null)
  7913. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7914. */
  7915. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7916. /**
  7917. * Delays loading of the cube texture
  7918. * @param forcedExtension defines the extension to use
  7919. */
  7920. delayLoad(forcedExtension?: string): void;
  7921. /**
  7922. * Returns the reflection texture matrix
  7923. * @returns the reflection texture matrix
  7924. */
  7925. getReflectionTextureMatrix(): Matrix;
  7926. /**
  7927. * Sets the reflection texture matrix
  7928. * @param value Reflection texture matrix
  7929. */
  7930. setReflectionTextureMatrix(value: Matrix): void;
  7931. /**
  7932. * Parses text to create a cube texture
  7933. * @param parsedTexture define the serialized text to read from
  7934. * @param scene defines the hosting scene
  7935. * @param rootUrl defines the root url of the cube texture
  7936. * @returns a cube texture
  7937. */
  7938. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7939. /**
  7940. * Makes a clone, or deep copy, of the cube texture
  7941. * @returns a new cube texture
  7942. */
  7943. clone(): CubeTexture;
  7944. }
  7945. }
  7946. declare module "babylonjs/Materials/materialDefines" {
  7947. /**
  7948. * Manages the defines for the Material
  7949. */
  7950. export class MaterialDefines {
  7951. /** @hidden */
  7952. protected _keys: string[];
  7953. private _isDirty;
  7954. /** @hidden */
  7955. _renderId: number;
  7956. /** @hidden */
  7957. _areLightsDirty: boolean;
  7958. /** @hidden */
  7959. _areLightsDisposed: boolean;
  7960. /** @hidden */
  7961. _areAttributesDirty: boolean;
  7962. /** @hidden */
  7963. _areTexturesDirty: boolean;
  7964. /** @hidden */
  7965. _areFresnelDirty: boolean;
  7966. /** @hidden */
  7967. _areMiscDirty: boolean;
  7968. /** @hidden */
  7969. _areImageProcessingDirty: boolean;
  7970. /** @hidden */
  7971. _normals: boolean;
  7972. /** @hidden */
  7973. _uvs: boolean;
  7974. /** @hidden */
  7975. _needNormals: boolean;
  7976. /** @hidden */
  7977. _needUVs: boolean;
  7978. [id: string]: any;
  7979. /**
  7980. * Specifies if the material needs to be re-calculated
  7981. */
  7982. get isDirty(): boolean;
  7983. /**
  7984. * Marks the material to indicate that it has been re-calculated
  7985. */
  7986. markAsProcessed(): void;
  7987. /**
  7988. * Marks the material to indicate that it needs to be re-calculated
  7989. */
  7990. markAsUnprocessed(): void;
  7991. /**
  7992. * Marks the material to indicate all of its defines need to be re-calculated
  7993. */
  7994. markAllAsDirty(): void;
  7995. /**
  7996. * Marks the material to indicate that image processing needs to be re-calculated
  7997. */
  7998. markAsImageProcessingDirty(): void;
  7999. /**
  8000. * Marks the material to indicate the lights need to be re-calculated
  8001. * @param disposed Defines whether the light is dirty due to dispose or not
  8002. */
  8003. markAsLightDirty(disposed?: boolean): void;
  8004. /**
  8005. * Marks the attribute state as changed
  8006. */
  8007. markAsAttributesDirty(): void;
  8008. /**
  8009. * Marks the texture state as changed
  8010. */
  8011. markAsTexturesDirty(): void;
  8012. /**
  8013. * Marks the fresnel state as changed
  8014. */
  8015. markAsFresnelDirty(): void;
  8016. /**
  8017. * Marks the misc state as changed
  8018. */
  8019. markAsMiscDirty(): void;
  8020. /**
  8021. * Rebuilds the material defines
  8022. */
  8023. rebuild(): void;
  8024. /**
  8025. * Specifies if two material defines are equal
  8026. * @param other - A material define instance to compare to
  8027. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8028. */
  8029. isEqual(other: MaterialDefines): boolean;
  8030. /**
  8031. * Clones this instance's defines to another instance
  8032. * @param other - material defines to clone values to
  8033. */
  8034. cloneTo(other: MaterialDefines): void;
  8035. /**
  8036. * Resets the material define values
  8037. */
  8038. reset(): void;
  8039. /**
  8040. * Converts the material define values to a string
  8041. * @returns - String of material define information
  8042. */
  8043. toString(): string;
  8044. }
  8045. }
  8046. declare module "babylonjs/Materials/colorCurves" {
  8047. import { Effect } from "babylonjs/Materials/effect";
  8048. /**
  8049. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8050. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8051. * 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;
  8052. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8053. */
  8054. export class ColorCurves {
  8055. private _dirty;
  8056. private _tempColor;
  8057. private _globalCurve;
  8058. private _highlightsCurve;
  8059. private _midtonesCurve;
  8060. private _shadowsCurve;
  8061. private _positiveCurve;
  8062. private _negativeCurve;
  8063. private _globalHue;
  8064. private _globalDensity;
  8065. private _globalSaturation;
  8066. private _globalExposure;
  8067. /**
  8068. * Gets the global Hue value.
  8069. * 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).
  8070. */
  8071. get globalHue(): number;
  8072. /**
  8073. * Sets the global Hue value.
  8074. * 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).
  8075. */
  8076. set globalHue(value: number);
  8077. /**
  8078. * Gets the global Density value.
  8079. * 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.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get globalDensity(): number;
  8083. /**
  8084. * Sets the global Density value.
  8085. * 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.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set globalDensity(value: number);
  8089. /**
  8090. * Gets the global Saturation value.
  8091. * 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.
  8092. */
  8093. get globalSaturation(): number;
  8094. /**
  8095. * Sets the global Saturation value.
  8096. * 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.
  8097. */
  8098. set globalSaturation(value: number);
  8099. /**
  8100. * Gets the global Exposure value.
  8101. * 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.
  8102. */
  8103. get globalExposure(): number;
  8104. /**
  8105. * Sets the global Exposure value.
  8106. * 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.
  8107. */
  8108. set globalExposure(value: number);
  8109. private _highlightsHue;
  8110. private _highlightsDensity;
  8111. private _highlightsSaturation;
  8112. private _highlightsExposure;
  8113. /**
  8114. * Gets the highlights Hue value.
  8115. * 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).
  8116. */
  8117. get highlightsHue(): number;
  8118. /**
  8119. * Sets the highlights Hue value.
  8120. * 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).
  8121. */
  8122. set highlightsHue(value: number);
  8123. /**
  8124. * Gets the highlights Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get highlightsDensity(): number;
  8129. /**
  8130. * Sets the highlights Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set highlightsDensity(value: number);
  8135. /**
  8136. * Gets the highlights Saturation value.
  8137. * 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.
  8138. */
  8139. get highlightsSaturation(): number;
  8140. /**
  8141. * Sets the highlights Saturation value.
  8142. * 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.
  8143. */
  8144. set highlightsSaturation(value: number);
  8145. /**
  8146. * Gets the highlights Exposure value.
  8147. * 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.
  8148. */
  8149. get highlightsExposure(): number;
  8150. /**
  8151. * Sets the highlights Exposure value.
  8152. * 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.
  8153. */
  8154. set highlightsExposure(value: number);
  8155. private _midtonesHue;
  8156. private _midtonesDensity;
  8157. private _midtonesSaturation;
  8158. private _midtonesExposure;
  8159. /**
  8160. * Gets the midtones Hue value.
  8161. * 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).
  8162. */
  8163. get midtonesHue(): number;
  8164. /**
  8165. * Sets the midtones Hue value.
  8166. * 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).
  8167. */
  8168. set midtonesHue(value: number);
  8169. /**
  8170. * Gets the midtones Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get midtonesDensity(): number;
  8175. /**
  8176. * Sets the midtones Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set midtonesDensity(value: number);
  8181. /**
  8182. * Gets the midtones Saturation value.
  8183. * 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.
  8184. */
  8185. get midtonesSaturation(): number;
  8186. /**
  8187. * Sets the midtones Saturation value.
  8188. * 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.
  8189. */
  8190. set midtonesSaturation(value: number);
  8191. /**
  8192. * Gets the midtones Exposure value.
  8193. * 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.
  8194. */
  8195. get midtonesExposure(): number;
  8196. /**
  8197. * Sets the midtones Exposure value.
  8198. * 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.
  8199. */
  8200. set midtonesExposure(value: number);
  8201. private _shadowsHue;
  8202. private _shadowsDensity;
  8203. private _shadowsSaturation;
  8204. private _shadowsExposure;
  8205. /**
  8206. * Gets the shadows Hue value.
  8207. * 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).
  8208. */
  8209. get shadowsHue(): number;
  8210. /**
  8211. * Sets the shadows Hue value.
  8212. * 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).
  8213. */
  8214. set shadowsHue(value: number);
  8215. /**
  8216. * Gets the shadows Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get shadowsDensity(): number;
  8221. /**
  8222. * Sets the shadows Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set shadowsDensity(value: number);
  8227. /**
  8228. * Gets the shadows Saturation value.
  8229. * 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.
  8230. */
  8231. get shadowsSaturation(): number;
  8232. /**
  8233. * Sets the shadows Saturation value.
  8234. * 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.
  8235. */
  8236. set shadowsSaturation(value: number);
  8237. /**
  8238. * Gets the shadows Exposure value.
  8239. * 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.
  8240. */
  8241. get shadowsExposure(): number;
  8242. /**
  8243. * Sets the shadows Exposure value.
  8244. * 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.
  8245. */
  8246. set shadowsExposure(value: number);
  8247. /**
  8248. * Returns the class name
  8249. * @returns The class name
  8250. */
  8251. getClassName(): string;
  8252. /**
  8253. * Binds the color curves to the shader.
  8254. * @param colorCurves The color curve to bind
  8255. * @param effect The effect to bind to
  8256. * @param positiveUniform The positive uniform shader parameter
  8257. * @param neutralUniform The neutral uniform shader parameter
  8258. * @param negativeUniform The negative uniform shader parameter
  8259. */
  8260. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8261. /**
  8262. * Prepare the list of uniforms associated with the ColorCurves effects.
  8263. * @param uniformsList The list of uniforms used in the effect
  8264. */
  8265. static PrepareUniforms(uniformsList: string[]): void;
  8266. /**
  8267. * Returns color grading data based on a hue, density, saturation and exposure value.
  8268. * @param filterHue The hue of the color filter.
  8269. * @param filterDensity The density of the color filter.
  8270. * @param saturation The saturation.
  8271. * @param exposure The exposure.
  8272. * @param result The result data container.
  8273. */
  8274. private getColorGradingDataToRef;
  8275. /**
  8276. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8277. * @param value The input slider value in range [-100,100].
  8278. * @returns Adjusted value.
  8279. */
  8280. private static applyColorGradingSliderNonlinear;
  8281. /**
  8282. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8283. * @param hue The hue (H) input.
  8284. * @param saturation The saturation (S) input.
  8285. * @param brightness The brightness (B) input.
  8286. * @result An RGBA color represented as Vector4.
  8287. */
  8288. private static fromHSBToRef;
  8289. /**
  8290. * Returns a value clamped between min and max
  8291. * @param value The value to clamp
  8292. * @param min The minimum of value
  8293. * @param max The maximum of value
  8294. * @returns The clamped value.
  8295. */
  8296. private static clamp;
  8297. /**
  8298. * Clones the current color curve instance.
  8299. * @return The cloned curves
  8300. */
  8301. clone(): ColorCurves;
  8302. /**
  8303. * Serializes the current color curve instance to a json representation.
  8304. * @return a JSON representation
  8305. */
  8306. serialize(): any;
  8307. /**
  8308. * Parses the color curve from a json representation.
  8309. * @param source the JSON source to parse
  8310. * @return The parsed curves
  8311. */
  8312. static Parse(source: any): ColorCurves;
  8313. }
  8314. }
  8315. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8316. import { Observable } from "babylonjs/Misc/observable";
  8317. import { Nullable } from "babylonjs/types";
  8318. import { Color4 } from "babylonjs/Maths/math.color";
  8319. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8320. import { Effect } from "babylonjs/Materials/effect";
  8321. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8322. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8323. /**
  8324. * Interface to follow in your material defines to integrate easily the
  8325. * Image proccessing functions.
  8326. * @hidden
  8327. */
  8328. export interface IImageProcessingConfigurationDefines {
  8329. IMAGEPROCESSING: boolean;
  8330. VIGNETTE: boolean;
  8331. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8332. VIGNETTEBLENDMODEOPAQUE: boolean;
  8333. TONEMAPPING: boolean;
  8334. TONEMAPPING_ACES: boolean;
  8335. CONTRAST: boolean;
  8336. EXPOSURE: boolean;
  8337. COLORCURVES: boolean;
  8338. COLORGRADING: boolean;
  8339. COLORGRADING3D: boolean;
  8340. SAMPLER3DGREENDEPTH: boolean;
  8341. SAMPLER3DBGRMAP: boolean;
  8342. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8343. }
  8344. /**
  8345. * @hidden
  8346. */
  8347. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8348. IMAGEPROCESSING: boolean;
  8349. VIGNETTE: boolean;
  8350. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8351. VIGNETTEBLENDMODEOPAQUE: boolean;
  8352. TONEMAPPING: boolean;
  8353. TONEMAPPING_ACES: boolean;
  8354. CONTRAST: boolean;
  8355. COLORCURVES: boolean;
  8356. COLORGRADING: boolean;
  8357. COLORGRADING3D: boolean;
  8358. SAMPLER3DGREENDEPTH: boolean;
  8359. SAMPLER3DBGRMAP: boolean;
  8360. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8361. EXPOSURE: boolean;
  8362. constructor();
  8363. }
  8364. /**
  8365. * This groups together the common properties used for image processing either in direct forward pass
  8366. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8367. * or not.
  8368. */
  8369. export class ImageProcessingConfiguration {
  8370. /**
  8371. * Default tone mapping applied in BabylonJS.
  8372. */
  8373. static readonly TONEMAPPING_STANDARD: number;
  8374. /**
  8375. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8376. * to other engines rendering to increase portability.
  8377. */
  8378. static readonly TONEMAPPING_ACES: number;
  8379. /**
  8380. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8381. */
  8382. colorCurves: Nullable<ColorCurves>;
  8383. private _colorCurvesEnabled;
  8384. /**
  8385. * Gets wether the color curves effect is enabled.
  8386. */
  8387. get colorCurvesEnabled(): boolean;
  8388. /**
  8389. * Sets wether the color curves effect is enabled.
  8390. */
  8391. set colorCurvesEnabled(value: boolean);
  8392. private _colorGradingTexture;
  8393. /**
  8394. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8395. */
  8396. get colorGradingTexture(): Nullable<BaseTexture>;
  8397. /**
  8398. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8399. */
  8400. set colorGradingTexture(value: Nullable<BaseTexture>);
  8401. private _colorGradingEnabled;
  8402. /**
  8403. * Gets wether the color grading effect is enabled.
  8404. */
  8405. get colorGradingEnabled(): boolean;
  8406. /**
  8407. * Sets wether the color grading effect is enabled.
  8408. */
  8409. set colorGradingEnabled(value: boolean);
  8410. private _colorGradingWithGreenDepth;
  8411. /**
  8412. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8413. */
  8414. get colorGradingWithGreenDepth(): boolean;
  8415. /**
  8416. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8417. */
  8418. set colorGradingWithGreenDepth(value: boolean);
  8419. private _colorGradingBGR;
  8420. /**
  8421. * Gets wether the color grading texture contains BGR values.
  8422. */
  8423. get colorGradingBGR(): boolean;
  8424. /**
  8425. * Sets wether the color grading texture contains BGR values.
  8426. */
  8427. set colorGradingBGR(value: boolean);
  8428. /** @hidden */
  8429. _exposure: number;
  8430. /**
  8431. * Gets the Exposure used in the effect.
  8432. */
  8433. get exposure(): number;
  8434. /**
  8435. * Sets the Exposure used in the effect.
  8436. */
  8437. set exposure(value: number);
  8438. private _toneMappingEnabled;
  8439. /**
  8440. * Gets wether the tone mapping effect is enabled.
  8441. */
  8442. get toneMappingEnabled(): boolean;
  8443. /**
  8444. * Sets wether the tone mapping effect is enabled.
  8445. */
  8446. set toneMappingEnabled(value: boolean);
  8447. private _toneMappingType;
  8448. /**
  8449. * Gets the type of tone mapping effect.
  8450. */
  8451. get toneMappingType(): number;
  8452. /**
  8453. * Sets the type of tone mapping effect used in BabylonJS.
  8454. */
  8455. set toneMappingType(value: number);
  8456. protected _contrast: number;
  8457. /**
  8458. * Gets the contrast used in the effect.
  8459. */
  8460. get contrast(): number;
  8461. /**
  8462. * Sets the contrast used in the effect.
  8463. */
  8464. set contrast(value: number);
  8465. /**
  8466. * Vignette stretch size.
  8467. */
  8468. vignetteStretch: number;
  8469. /**
  8470. * Vignette centre X Offset.
  8471. */
  8472. vignetteCentreX: number;
  8473. /**
  8474. * Vignette centre Y Offset.
  8475. */
  8476. vignetteCentreY: number;
  8477. /**
  8478. * Vignette weight or intensity of the vignette effect.
  8479. */
  8480. vignetteWeight: number;
  8481. /**
  8482. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8483. * if vignetteEnabled is set to true.
  8484. */
  8485. vignetteColor: Color4;
  8486. /**
  8487. * Camera field of view used by the Vignette effect.
  8488. */
  8489. vignetteCameraFov: number;
  8490. private _vignetteBlendMode;
  8491. /**
  8492. * Gets the vignette blend mode allowing different kind of effect.
  8493. */
  8494. get vignetteBlendMode(): number;
  8495. /**
  8496. * Sets the vignette blend mode allowing different kind of effect.
  8497. */
  8498. set vignetteBlendMode(value: number);
  8499. private _vignetteEnabled;
  8500. /**
  8501. * Gets wether the vignette effect is enabled.
  8502. */
  8503. get vignetteEnabled(): boolean;
  8504. /**
  8505. * Sets wether the vignette effect is enabled.
  8506. */
  8507. set vignetteEnabled(value: boolean);
  8508. private _applyByPostProcess;
  8509. /**
  8510. * Gets wether the image processing is applied through a post process or not.
  8511. */
  8512. get applyByPostProcess(): boolean;
  8513. /**
  8514. * Sets wether the image processing is applied through a post process or not.
  8515. */
  8516. set applyByPostProcess(value: boolean);
  8517. private _isEnabled;
  8518. /**
  8519. * Gets wether the image processing is enabled or not.
  8520. */
  8521. get isEnabled(): boolean;
  8522. /**
  8523. * Sets wether the image processing is enabled or not.
  8524. */
  8525. set isEnabled(value: boolean);
  8526. /**
  8527. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8528. */
  8529. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8530. /**
  8531. * Method called each time the image processing information changes requires to recompile the effect.
  8532. */
  8533. protected _updateParameters(): void;
  8534. /**
  8535. * Gets the current class name.
  8536. * @return "ImageProcessingConfiguration"
  8537. */
  8538. getClassName(): string;
  8539. /**
  8540. * Prepare the list of uniforms associated with the Image Processing effects.
  8541. * @param uniforms The list of uniforms used in the effect
  8542. * @param defines the list of defines currently in use
  8543. */
  8544. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8545. /**
  8546. * Prepare the list of samplers associated with the Image Processing effects.
  8547. * @param samplersList The list of uniforms used in the effect
  8548. * @param defines the list of defines currently in use
  8549. */
  8550. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8551. /**
  8552. * Prepare the list of defines associated to the shader.
  8553. * @param defines the list of defines to complete
  8554. * @param forPostProcess Define if we are currently in post process mode or not
  8555. */
  8556. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8557. /**
  8558. * Returns true if all the image processing information are ready.
  8559. * @returns True if ready, otherwise, false
  8560. */
  8561. isReady(): boolean;
  8562. /**
  8563. * Binds the image processing to the shader.
  8564. * @param effect The effect to bind to
  8565. * @param overrideAspectRatio Override the aspect ratio of the effect
  8566. */
  8567. bind(effect: Effect, overrideAspectRatio?: number): void;
  8568. /**
  8569. * Clones the current image processing instance.
  8570. * @return The cloned image processing
  8571. */
  8572. clone(): ImageProcessingConfiguration;
  8573. /**
  8574. * Serializes the current image processing instance to a json representation.
  8575. * @return a JSON representation
  8576. */
  8577. serialize(): any;
  8578. /**
  8579. * Parses the image processing from a json representation.
  8580. * @param source the JSON source to parse
  8581. * @return The parsed image processing
  8582. */
  8583. static Parse(source: any): ImageProcessingConfiguration;
  8584. private static _VIGNETTEMODE_MULTIPLY;
  8585. private static _VIGNETTEMODE_OPAQUE;
  8586. /**
  8587. * Used to apply the vignette as a mix with the pixel color.
  8588. */
  8589. static get VIGNETTEMODE_MULTIPLY(): number;
  8590. /**
  8591. * Used to apply the vignette as a replacement of the pixel color.
  8592. */
  8593. static get VIGNETTEMODE_OPAQUE(): number;
  8594. }
  8595. }
  8596. declare module "babylonjs/Shaders/postprocess.vertex" {
  8597. /** @hidden */
  8598. export var postprocessVertexShader: {
  8599. name: string;
  8600. shader: string;
  8601. };
  8602. }
  8603. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8604. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8605. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8606. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8607. module "babylonjs/Engines/thinEngine" {
  8608. interface ThinEngine {
  8609. /**
  8610. * Creates a new render target texture
  8611. * @param size defines the size of the texture
  8612. * @param options defines the options used to create the texture
  8613. * @returns a new render target texture stored in an InternalTexture
  8614. */
  8615. createRenderTargetTexture(size: number | {
  8616. width: number;
  8617. height: number;
  8618. layers?: number;
  8619. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8620. /**
  8621. * Creates a depth stencil texture.
  8622. * This is only available in WebGL 2 or with the depth texture extension available.
  8623. * @param size The size of face edge in the texture.
  8624. * @param options The options defining the texture.
  8625. * @returns The texture
  8626. */
  8627. createDepthStencilTexture(size: number | {
  8628. width: number;
  8629. height: number;
  8630. layers?: number;
  8631. }, options: DepthTextureCreationOptions): InternalTexture;
  8632. /** @hidden */
  8633. _createDepthStencilTexture(size: number | {
  8634. width: number;
  8635. height: number;
  8636. layers?: number;
  8637. }, options: DepthTextureCreationOptions): InternalTexture;
  8638. }
  8639. }
  8640. }
  8641. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8642. /**
  8643. * Defines the kind of connection point for node based material
  8644. */
  8645. export enum NodeMaterialBlockConnectionPointTypes {
  8646. /** Float */
  8647. Float = 1,
  8648. /** Int */
  8649. Int = 2,
  8650. /** Vector2 */
  8651. Vector2 = 4,
  8652. /** Vector3 */
  8653. Vector3 = 8,
  8654. /** Vector4 */
  8655. Vector4 = 16,
  8656. /** Color3 */
  8657. Color3 = 32,
  8658. /** Color4 */
  8659. Color4 = 64,
  8660. /** Matrix */
  8661. Matrix = 128,
  8662. /** Custom object */
  8663. Object = 256,
  8664. /** Detect type based on connection */
  8665. AutoDetect = 1024,
  8666. /** Output type that will be defined by input type */
  8667. BasedOnInput = 2048
  8668. }
  8669. }
  8670. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8671. /**
  8672. * Enum used to define the target of a block
  8673. */
  8674. export enum NodeMaterialBlockTargets {
  8675. /** Vertex shader */
  8676. Vertex = 1,
  8677. /** Fragment shader */
  8678. Fragment = 2,
  8679. /** Neutral */
  8680. Neutral = 4,
  8681. /** Vertex and Fragment */
  8682. VertexAndFragment = 3
  8683. }
  8684. }
  8685. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8686. /**
  8687. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8688. */
  8689. export enum NodeMaterialBlockConnectionPointMode {
  8690. /** Value is an uniform */
  8691. Uniform = 0,
  8692. /** Value is a mesh attribute */
  8693. Attribute = 1,
  8694. /** Value is a varying between vertex and fragment shaders */
  8695. Varying = 2,
  8696. /** Mode is undefined */
  8697. Undefined = 3
  8698. }
  8699. }
  8700. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8701. /**
  8702. * Enum used to define system values e.g. values automatically provided by the system
  8703. */
  8704. export enum NodeMaterialSystemValues {
  8705. /** World */
  8706. World = 1,
  8707. /** View */
  8708. View = 2,
  8709. /** Projection */
  8710. Projection = 3,
  8711. /** ViewProjection */
  8712. ViewProjection = 4,
  8713. /** WorldView */
  8714. WorldView = 5,
  8715. /** WorldViewProjection */
  8716. WorldViewProjection = 6,
  8717. /** CameraPosition */
  8718. CameraPosition = 7,
  8719. /** Fog Color */
  8720. FogColor = 8,
  8721. /** Delta time */
  8722. DeltaTime = 9
  8723. }
  8724. }
  8725. declare module "babylonjs/Maths/math.axis" {
  8726. import { Vector3 } from "babylonjs/Maths/math.vector";
  8727. /** Defines supported spaces */
  8728. export enum Space {
  8729. /** Local (object) space */
  8730. LOCAL = 0,
  8731. /** World space */
  8732. WORLD = 1,
  8733. /** Bone space */
  8734. BONE = 2
  8735. }
  8736. /** Defines the 3 main axes */
  8737. export class Axis {
  8738. /** X axis */
  8739. static X: Vector3;
  8740. /** Y axis */
  8741. static Y: Vector3;
  8742. /** Z axis */
  8743. static Z: Vector3;
  8744. }
  8745. }
  8746. declare module "babylonjs/Maths/math.frustum" {
  8747. import { Matrix } from "babylonjs/Maths/math.vector";
  8748. import { DeepImmutable } from "babylonjs/types";
  8749. import { Plane } from "babylonjs/Maths/math.plane";
  8750. /**
  8751. * Represents a camera frustum
  8752. */
  8753. export class Frustum {
  8754. /**
  8755. * Gets the planes representing the frustum
  8756. * @param transform matrix to be applied to the returned planes
  8757. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8758. */
  8759. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8760. /**
  8761. * Gets the near frustum plane transformed by the transform matrix
  8762. * @param transform transformation matrix to be applied to the resulting frustum plane
  8763. * @param frustumPlane the resuling frustum plane
  8764. */
  8765. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8766. /**
  8767. * Gets the far frustum plane transformed by the transform matrix
  8768. * @param transform transformation matrix to be applied to the resulting frustum plane
  8769. * @param frustumPlane the resuling frustum plane
  8770. */
  8771. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8772. /**
  8773. * Gets the left frustum plane transformed by the transform matrix
  8774. * @param transform transformation matrix to be applied to the resulting frustum plane
  8775. * @param frustumPlane the resuling frustum plane
  8776. */
  8777. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8778. /**
  8779. * Gets the right frustum plane transformed by the transform matrix
  8780. * @param transform transformation matrix to be applied to the resulting frustum plane
  8781. * @param frustumPlane the resuling frustum plane
  8782. */
  8783. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8784. /**
  8785. * Gets the top frustum plane transformed by the transform matrix
  8786. * @param transform transformation matrix to be applied to the resulting frustum plane
  8787. * @param frustumPlane the resuling frustum plane
  8788. */
  8789. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8790. /**
  8791. * Gets the bottom frustum plane transformed by the transform matrix
  8792. * @param transform transformation matrix to be applied to the resulting frustum plane
  8793. * @param frustumPlane the resuling frustum plane
  8794. */
  8795. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8796. /**
  8797. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8798. * @param transform transformation matrix to be applied to the resulting frustum planes
  8799. * @param frustumPlanes the resuling frustum planes
  8800. */
  8801. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8802. }
  8803. }
  8804. declare module "babylonjs/Maths/math.size" {
  8805. /**
  8806. * Interface for the size containing width and height
  8807. */
  8808. export interface ISize {
  8809. /**
  8810. * Width
  8811. */
  8812. width: number;
  8813. /**
  8814. * Heighht
  8815. */
  8816. height: number;
  8817. }
  8818. /**
  8819. * Size containing widht and height
  8820. */
  8821. export class Size implements ISize {
  8822. /**
  8823. * Width
  8824. */
  8825. width: number;
  8826. /**
  8827. * Height
  8828. */
  8829. height: number;
  8830. /**
  8831. * Creates a Size object from the given width and height (floats).
  8832. * @param width width of the new size
  8833. * @param height height of the new size
  8834. */
  8835. constructor(width: number, height: number);
  8836. /**
  8837. * Returns a string with the Size width and height
  8838. * @returns a string with the Size width and height
  8839. */
  8840. toString(): string;
  8841. /**
  8842. * "Size"
  8843. * @returns the string "Size"
  8844. */
  8845. getClassName(): string;
  8846. /**
  8847. * Returns the Size hash code.
  8848. * @returns a hash code for a unique width and height
  8849. */
  8850. getHashCode(): number;
  8851. /**
  8852. * Updates the current size from the given one.
  8853. * @param src the given size
  8854. */
  8855. copyFrom(src: Size): void;
  8856. /**
  8857. * Updates in place the current Size from the given floats.
  8858. * @param width width of the new size
  8859. * @param height height of the new size
  8860. * @returns the updated Size.
  8861. */
  8862. copyFromFloats(width: number, height: number): Size;
  8863. /**
  8864. * Updates in place the current Size from the given floats.
  8865. * @param width width to set
  8866. * @param height height to set
  8867. * @returns the updated Size.
  8868. */
  8869. set(width: number, height: number): Size;
  8870. /**
  8871. * Multiplies the width and height by numbers
  8872. * @param w factor to multiple the width by
  8873. * @param h factor to multiple the height by
  8874. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8875. */
  8876. multiplyByFloats(w: number, h: number): Size;
  8877. /**
  8878. * Clones the size
  8879. * @returns a new Size copied from the given one.
  8880. */
  8881. clone(): Size;
  8882. /**
  8883. * True if the current Size and the given one width and height are strictly equal.
  8884. * @param other the other size to compare against
  8885. * @returns True if the current Size and the given one width and height are strictly equal.
  8886. */
  8887. equals(other: Size): boolean;
  8888. /**
  8889. * The surface of the Size : width * height (float).
  8890. */
  8891. get surface(): number;
  8892. /**
  8893. * Create a new size of zero
  8894. * @returns a new Size set to (0.0, 0.0)
  8895. */
  8896. static Zero(): Size;
  8897. /**
  8898. * Sums the width and height of two sizes
  8899. * @param otherSize size to add to this size
  8900. * @returns a new Size set as the addition result of the current Size and the given one.
  8901. */
  8902. add(otherSize: Size): Size;
  8903. /**
  8904. * Subtracts the width and height of two
  8905. * @param otherSize size to subtract to this size
  8906. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8907. */
  8908. subtract(otherSize: Size): Size;
  8909. /**
  8910. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8911. * @param start starting size to lerp between
  8912. * @param end end size to lerp between
  8913. * @param amount amount to lerp between the start and end values
  8914. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8915. */
  8916. static Lerp(start: Size, end: Size, amount: number): Size;
  8917. }
  8918. }
  8919. declare module "babylonjs/Maths/math.vertexFormat" {
  8920. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8921. /**
  8922. * Contains position and normal vectors for a vertex
  8923. */
  8924. export class PositionNormalVertex {
  8925. /** the position of the vertex (defaut: 0,0,0) */
  8926. position: Vector3;
  8927. /** the normal of the vertex (defaut: 0,1,0) */
  8928. normal: Vector3;
  8929. /**
  8930. * Creates a PositionNormalVertex
  8931. * @param position the position of the vertex (defaut: 0,0,0)
  8932. * @param normal the normal of the vertex (defaut: 0,1,0)
  8933. */
  8934. constructor(
  8935. /** the position of the vertex (defaut: 0,0,0) */
  8936. position?: Vector3,
  8937. /** the normal of the vertex (defaut: 0,1,0) */
  8938. normal?: Vector3);
  8939. /**
  8940. * Clones the PositionNormalVertex
  8941. * @returns the cloned PositionNormalVertex
  8942. */
  8943. clone(): PositionNormalVertex;
  8944. }
  8945. /**
  8946. * Contains position, normal and uv vectors for a vertex
  8947. */
  8948. export class PositionNormalTextureVertex {
  8949. /** the position of the vertex (defaut: 0,0,0) */
  8950. position: Vector3;
  8951. /** the normal of the vertex (defaut: 0,1,0) */
  8952. normal: Vector3;
  8953. /** the uv of the vertex (default: 0,0) */
  8954. uv: Vector2;
  8955. /**
  8956. * Creates a PositionNormalTextureVertex
  8957. * @param position the position of the vertex (defaut: 0,0,0)
  8958. * @param normal the normal of the vertex (defaut: 0,1,0)
  8959. * @param uv the uv of the vertex (default: 0,0)
  8960. */
  8961. constructor(
  8962. /** the position of the vertex (defaut: 0,0,0) */
  8963. position?: Vector3,
  8964. /** the normal of the vertex (defaut: 0,1,0) */
  8965. normal?: Vector3,
  8966. /** the uv of the vertex (default: 0,0) */
  8967. uv?: Vector2);
  8968. /**
  8969. * Clones the PositionNormalTextureVertex
  8970. * @returns the cloned PositionNormalTextureVertex
  8971. */
  8972. clone(): PositionNormalTextureVertex;
  8973. }
  8974. }
  8975. declare module "babylonjs/Maths/math" {
  8976. export * from "babylonjs/Maths/math.axis";
  8977. export * from "babylonjs/Maths/math.color";
  8978. export * from "babylonjs/Maths/math.constants";
  8979. export * from "babylonjs/Maths/math.frustum";
  8980. export * from "babylonjs/Maths/math.path";
  8981. export * from "babylonjs/Maths/math.plane";
  8982. export * from "babylonjs/Maths/math.size";
  8983. export * from "babylonjs/Maths/math.vector";
  8984. export * from "babylonjs/Maths/math.vertexFormat";
  8985. export * from "babylonjs/Maths/math.viewport";
  8986. }
  8987. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  8988. /**
  8989. * Enum defining the type of animations supported by InputBlock
  8990. */
  8991. export enum AnimatedInputBlockTypes {
  8992. /** No animation */
  8993. None = 0,
  8994. /** Time based animation. Will only work for floats */
  8995. Time = 1
  8996. }
  8997. }
  8998. declare module "babylonjs/Lights/shadowLight" {
  8999. import { Camera } from "babylonjs/Cameras/camera";
  9000. import { Scene } from "babylonjs/scene";
  9001. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9003. import { Light } from "babylonjs/Lights/light";
  9004. /**
  9005. * Interface describing all the common properties and methods a shadow light needs to implement.
  9006. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9007. * as well as binding the different shadow properties to the effects.
  9008. */
  9009. export interface IShadowLight extends Light {
  9010. /**
  9011. * The light id in the scene (used in scene.findLighById for instance)
  9012. */
  9013. id: string;
  9014. /**
  9015. * The position the shdow will be casted from.
  9016. */
  9017. position: Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9020. */
  9021. direction: Vector3;
  9022. /**
  9023. * The transformed position. Position of the light in world space taking parenting in account.
  9024. */
  9025. transformedPosition: Vector3;
  9026. /**
  9027. * The transformed direction. Direction of the light in world space taking parenting in account.
  9028. */
  9029. transformedDirection: Vector3;
  9030. /**
  9031. * The friendly name of the light in the scene.
  9032. */
  9033. name: string;
  9034. /**
  9035. * Defines the shadow projection clipping minimum z value.
  9036. */
  9037. shadowMinZ: number;
  9038. /**
  9039. * Defines the shadow projection clipping maximum z value.
  9040. */
  9041. shadowMaxZ: number;
  9042. /**
  9043. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9044. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9045. */
  9046. computeTransformedInformation(): boolean;
  9047. /**
  9048. * Gets the scene the light belongs to.
  9049. * @returns The scene
  9050. */
  9051. getScene(): Scene;
  9052. /**
  9053. * Callback defining a custom Projection Matrix Builder.
  9054. * This can be used to override the default projection matrix computation.
  9055. */
  9056. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9057. /**
  9058. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9059. * @param matrix The materix to updated with the projection information
  9060. * @param viewMatrix The transform matrix of the light
  9061. * @param renderList The list of mesh to render in the map
  9062. * @returns The current light
  9063. */
  9064. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9065. /**
  9066. * Gets the current depth scale used in ESM.
  9067. * @returns The scale
  9068. */
  9069. getDepthScale(): number;
  9070. /**
  9071. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9072. * @returns true if a cube texture needs to be use
  9073. */
  9074. needCube(): boolean;
  9075. /**
  9076. * Detects if the projection matrix requires to be recomputed this frame.
  9077. * @returns true if it requires to be recomputed otherwise, false.
  9078. */
  9079. needProjectionMatrixCompute(): boolean;
  9080. /**
  9081. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9082. */
  9083. forceProjectionMatrixCompute(): void;
  9084. /**
  9085. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9086. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9087. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9088. */
  9089. getShadowDirection(faceIndex?: number): Vector3;
  9090. /**
  9091. * Gets the minZ used for shadow according to both the scene and the light.
  9092. * @param activeCamera The camera we are returning the min for
  9093. * @returns the depth min z
  9094. */
  9095. getDepthMinZ(activeCamera: Camera): number;
  9096. /**
  9097. * Gets the maxZ used for shadow according to both the scene and the light.
  9098. * @param activeCamera The camera we are returning the max for
  9099. * @returns the depth max z
  9100. */
  9101. getDepthMaxZ(activeCamera: Camera): number;
  9102. }
  9103. /**
  9104. * Base implementation IShadowLight
  9105. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9106. */
  9107. export abstract class ShadowLight extends Light implements IShadowLight {
  9108. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9109. protected _position: Vector3;
  9110. protected _setPosition(value: Vector3): void;
  9111. /**
  9112. * Sets the position the shadow will be casted from. Also use as the light position for both
  9113. * point and spot lights.
  9114. */
  9115. get position(): Vector3;
  9116. /**
  9117. * Sets the position the shadow will be casted from. Also use as the light position for both
  9118. * point and spot lights.
  9119. */
  9120. set position(value: Vector3);
  9121. protected _direction: Vector3;
  9122. protected _setDirection(value: Vector3): void;
  9123. /**
  9124. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9125. * Also use as the light direction on spot and directional lights.
  9126. */
  9127. get direction(): Vector3;
  9128. /**
  9129. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9130. * Also use as the light direction on spot and directional lights.
  9131. */
  9132. set direction(value: Vector3);
  9133. protected _shadowMinZ: number;
  9134. /**
  9135. * Gets the shadow projection clipping minimum z value.
  9136. */
  9137. get shadowMinZ(): number;
  9138. /**
  9139. * Sets the shadow projection clipping minimum z value.
  9140. */
  9141. set shadowMinZ(value: number);
  9142. protected _shadowMaxZ: number;
  9143. /**
  9144. * Sets the shadow projection clipping maximum z value.
  9145. */
  9146. get shadowMaxZ(): number;
  9147. /**
  9148. * Gets the shadow projection clipping maximum z value.
  9149. */
  9150. set shadowMaxZ(value: number);
  9151. /**
  9152. * Callback defining a custom Projection Matrix Builder.
  9153. * This can be used to override the default projection matrix computation.
  9154. */
  9155. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9156. /**
  9157. * The transformed position. Position of the light in world space taking parenting in account.
  9158. */
  9159. transformedPosition: Vector3;
  9160. /**
  9161. * The transformed direction. Direction of the light in world space taking parenting in account.
  9162. */
  9163. transformedDirection: Vector3;
  9164. private _needProjectionMatrixCompute;
  9165. /**
  9166. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9167. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9168. */
  9169. computeTransformedInformation(): boolean;
  9170. /**
  9171. * Return the depth scale used for the shadow map.
  9172. * @returns the depth scale.
  9173. */
  9174. getDepthScale(): number;
  9175. /**
  9176. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9177. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9178. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9179. */
  9180. getShadowDirection(faceIndex?: number): Vector3;
  9181. /**
  9182. * Returns the ShadowLight absolute position in the World.
  9183. * @returns the position vector in world space
  9184. */
  9185. getAbsolutePosition(): Vector3;
  9186. /**
  9187. * Sets the ShadowLight direction toward the passed target.
  9188. * @param target The point to target in local space
  9189. * @returns the updated ShadowLight direction
  9190. */
  9191. setDirectionToTarget(target: Vector3): Vector3;
  9192. /**
  9193. * Returns the light rotation in euler definition.
  9194. * @returns the x y z rotation in local space.
  9195. */
  9196. getRotation(): Vector3;
  9197. /**
  9198. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9199. * @returns true if a cube texture needs to be use
  9200. */
  9201. needCube(): boolean;
  9202. /**
  9203. * Detects if the projection matrix requires to be recomputed this frame.
  9204. * @returns true if it requires to be recomputed otherwise, false.
  9205. */
  9206. needProjectionMatrixCompute(): boolean;
  9207. /**
  9208. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9209. */
  9210. forceProjectionMatrixCompute(): void;
  9211. /** @hidden */
  9212. _initCache(): void;
  9213. /** @hidden */
  9214. _isSynchronized(): boolean;
  9215. /**
  9216. * Computes the world matrix of the node
  9217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9218. * @returns the world matrix
  9219. */
  9220. computeWorldMatrix(force?: boolean): Matrix;
  9221. /**
  9222. * Gets the minZ used for shadow according to both the scene and the light.
  9223. * @param activeCamera The camera we are returning the min for
  9224. * @returns the depth min z
  9225. */
  9226. getDepthMinZ(activeCamera: Camera): number;
  9227. /**
  9228. * Gets the maxZ used for shadow according to both the scene and the light.
  9229. * @param activeCamera The camera we are returning the max for
  9230. * @returns the depth max z
  9231. */
  9232. getDepthMaxZ(activeCamera: Camera): number;
  9233. /**
  9234. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9235. * @param matrix The materix to updated with the projection information
  9236. * @param viewMatrix The transform matrix of the light
  9237. * @param renderList The list of mesh to render in the map
  9238. * @returns The current light
  9239. */
  9240. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9241. }
  9242. }
  9243. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9244. /** @hidden */
  9245. export var packingFunctions: {
  9246. name: string;
  9247. shader: string;
  9248. };
  9249. }
  9250. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9251. /** @hidden */
  9252. export var bayerDitherFunctions: {
  9253. name: string;
  9254. shader: string;
  9255. };
  9256. }
  9257. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9258. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9259. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9260. /** @hidden */
  9261. export var shadowMapFragmentDeclaration: {
  9262. name: string;
  9263. shader: string;
  9264. };
  9265. }
  9266. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9267. /** @hidden */
  9268. export var clipPlaneFragmentDeclaration: {
  9269. name: string;
  9270. shader: string;
  9271. };
  9272. }
  9273. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9274. /** @hidden */
  9275. export var clipPlaneFragment: {
  9276. name: string;
  9277. shader: string;
  9278. };
  9279. }
  9280. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9281. /** @hidden */
  9282. export var shadowMapFragment: {
  9283. name: string;
  9284. shader: string;
  9285. };
  9286. }
  9287. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9288. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9289. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9290. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9291. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9292. /** @hidden */
  9293. export var shadowMapPixelShader: {
  9294. name: string;
  9295. shader: string;
  9296. };
  9297. }
  9298. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9299. /** @hidden */
  9300. export var bonesDeclaration: {
  9301. name: string;
  9302. shader: string;
  9303. };
  9304. }
  9305. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9306. /** @hidden */
  9307. export var morphTargetsVertexGlobalDeclaration: {
  9308. name: string;
  9309. shader: string;
  9310. };
  9311. }
  9312. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9313. /** @hidden */
  9314. export var morphTargetsVertexDeclaration: {
  9315. name: string;
  9316. shader: string;
  9317. };
  9318. }
  9319. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9320. /** @hidden */
  9321. export var instancesDeclaration: {
  9322. name: string;
  9323. shader: string;
  9324. };
  9325. }
  9326. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9327. /** @hidden */
  9328. export var helperFunctions: {
  9329. name: string;
  9330. shader: string;
  9331. };
  9332. }
  9333. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9334. /** @hidden */
  9335. export var shadowMapVertexDeclaration: {
  9336. name: string;
  9337. shader: string;
  9338. };
  9339. }
  9340. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9341. /** @hidden */
  9342. export var clipPlaneVertexDeclaration: {
  9343. name: string;
  9344. shader: string;
  9345. };
  9346. }
  9347. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9348. /** @hidden */
  9349. export var morphTargetsVertex: {
  9350. name: string;
  9351. shader: string;
  9352. };
  9353. }
  9354. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9355. /** @hidden */
  9356. export var instancesVertex: {
  9357. name: string;
  9358. shader: string;
  9359. };
  9360. }
  9361. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9362. /** @hidden */
  9363. export var bonesVertex: {
  9364. name: string;
  9365. shader: string;
  9366. };
  9367. }
  9368. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9369. /** @hidden */
  9370. export var shadowMapVertexNormalBias: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9376. /** @hidden */
  9377. export var shadowMapVertexMetric: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9383. /** @hidden */
  9384. export var clipPlaneVertex: {
  9385. name: string;
  9386. shader: string;
  9387. };
  9388. }
  9389. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9390. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9392. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9393. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9394. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9395. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9396. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9397. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9398. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9399. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9400. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9401. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9402. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9403. /** @hidden */
  9404. export var shadowMapVertexShader: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9410. /** @hidden */
  9411. export var depthBoxBlurPixelShader: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9417. /** @hidden */
  9418. export var shadowMapFragmentSoftTransparentShadow: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Materials/effectFallbacks" {
  9424. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9425. import { Effect } from "babylonjs/Materials/effect";
  9426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9427. /**
  9428. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9429. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9430. */
  9431. export class EffectFallbacks implements IEffectFallbacks {
  9432. private _defines;
  9433. private _currentRank;
  9434. private _maxRank;
  9435. private _mesh;
  9436. /**
  9437. * Removes the fallback from the bound mesh.
  9438. */
  9439. unBindMesh(): void;
  9440. /**
  9441. * Adds a fallback on the specified property.
  9442. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9443. * @param define The name of the define in the shader
  9444. */
  9445. addFallback(rank: number, define: string): void;
  9446. /**
  9447. * Sets the mesh to use CPU skinning when needing to fallback.
  9448. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9449. * @param mesh The mesh to use the fallbacks.
  9450. */
  9451. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9452. /**
  9453. * Checks to see if more fallbacks are still availible.
  9454. */
  9455. get hasMoreFallbacks(): boolean;
  9456. /**
  9457. * Removes the defines that should be removed when falling back.
  9458. * @param currentDefines defines the current define statements for the shader.
  9459. * @param effect defines the current effect we try to compile
  9460. * @returns The resulting defines with defines of the current rank removed.
  9461. */
  9462. reduce(currentDefines: string, effect: Effect): string;
  9463. }
  9464. }
  9465. declare module "babylonjs/Actions/action" {
  9466. import { Observable } from "babylonjs/Misc/observable";
  9467. import { Condition } from "babylonjs/Actions/condition";
  9468. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9469. import { Scene } from "babylonjs/scene";
  9470. import { ActionManager } from "babylonjs/Actions/actionManager";
  9471. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9472. import { Node } from "babylonjs/node";
  9473. /**
  9474. * Interface used to define Action
  9475. */
  9476. export interface IAction {
  9477. /**
  9478. * Trigger for the action
  9479. */
  9480. trigger: number;
  9481. /** Options of the trigger */
  9482. triggerOptions: any;
  9483. /**
  9484. * Gets the trigger parameters
  9485. * @returns the trigger parameters
  9486. */
  9487. getTriggerParameter(): any;
  9488. /**
  9489. * Internal only - executes current action event
  9490. * @hidden
  9491. */
  9492. _executeCurrent(evt?: ActionEvent): void;
  9493. /**
  9494. * Serialize placeholder for child classes
  9495. * @param parent of child
  9496. * @returns the serialized object
  9497. */
  9498. serialize(parent: any): any;
  9499. /**
  9500. * Internal only
  9501. * @hidden
  9502. */
  9503. _prepare(): void;
  9504. /**
  9505. * Internal only - manager for action
  9506. * @hidden
  9507. */
  9508. _actionManager: AbstractActionManager;
  9509. /**
  9510. * Adds action to chain of actions, may be a DoNothingAction
  9511. * @param action defines the next action to execute
  9512. * @returns The action passed in
  9513. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9514. */
  9515. then(action: IAction): IAction;
  9516. }
  9517. /**
  9518. * The action to be carried out following a trigger
  9519. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9520. */
  9521. export class Action implements IAction {
  9522. /** the trigger, with or without parameters, for the action */
  9523. triggerOptions: any;
  9524. /**
  9525. * Trigger for the action
  9526. */
  9527. trigger: number;
  9528. /**
  9529. * Internal only - manager for action
  9530. * @hidden
  9531. */
  9532. _actionManager: ActionManager;
  9533. private _nextActiveAction;
  9534. private _child;
  9535. private _condition?;
  9536. private _triggerParameter;
  9537. /**
  9538. * An event triggered prior to action being executed.
  9539. */
  9540. onBeforeExecuteObservable: Observable<Action>;
  9541. /**
  9542. * Creates a new Action
  9543. * @param triggerOptions the trigger, with or without parameters, for the action
  9544. * @param condition an optional determinant of action
  9545. */
  9546. constructor(
  9547. /** the trigger, with or without parameters, for the action */
  9548. triggerOptions: any, condition?: Condition);
  9549. /**
  9550. * Internal only
  9551. * @hidden
  9552. */
  9553. _prepare(): void;
  9554. /**
  9555. * Gets the trigger parameters
  9556. * @returns the trigger parameters
  9557. */
  9558. getTriggerParameter(): any;
  9559. /**
  9560. * Internal only - executes current action event
  9561. * @hidden
  9562. */
  9563. _executeCurrent(evt?: ActionEvent): void;
  9564. /**
  9565. * Execute placeholder for child classes
  9566. * @param evt optional action event
  9567. */
  9568. execute(evt?: ActionEvent): void;
  9569. /**
  9570. * Skips to next active action
  9571. */
  9572. skipToNextActiveAction(): void;
  9573. /**
  9574. * Adds action to chain of actions, may be a DoNothingAction
  9575. * @param action defines the next action to execute
  9576. * @returns The action passed in
  9577. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9578. */
  9579. then(action: Action): Action;
  9580. /**
  9581. * Internal only
  9582. * @hidden
  9583. */
  9584. _getProperty(propertyPath: string): string;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. _getEffectiveTarget(target: any, propertyPath: string): any;
  9590. /**
  9591. * Serialize placeholder for child classes
  9592. * @param parent of child
  9593. * @returns the serialized object
  9594. */
  9595. serialize(parent: any): any;
  9596. /**
  9597. * Internal only called by serialize
  9598. * @hidden
  9599. */
  9600. protected _serialize(serializedAction: any, parent?: any): any;
  9601. /**
  9602. * Internal only
  9603. * @hidden
  9604. */
  9605. static _SerializeValueAsString: (value: any) => string;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. static _GetTargetProperty: (target: Scene | Node) => {
  9611. name: string;
  9612. targetType: string;
  9613. value: string;
  9614. };
  9615. }
  9616. }
  9617. declare module "babylonjs/Actions/condition" {
  9618. import { ActionManager } from "babylonjs/Actions/actionManager";
  9619. /**
  9620. * A Condition applied to an Action
  9621. */
  9622. export class Condition {
  9623. /**
  9624. * Internal only - manager for action
  9625. * @hidden
  9626. */
  9627. _actionManager: ActionManager;
  9628. /**
  9629. * Internal only
  9630. * @hidden
  9631. */
  9632. _evaluationId: number;
  9633. /**
  9634. * Internal only
  9635. * @hidden
  9636. */
  9637. _currentResult: boolean;
  9638. /**
  9639. * Creates a new Condition
  9640. * @param actionManager the manager of the action the condition is applied to
  9641. */
  9642. constructor(actionManager: ActionManager);
  9643. /**
  9644. * Check if the current condition is valid
  9645. * @returns a boolean
  9646. */
  9647. isValid(): boolean;
  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. * @returns the serialized object
  9661. */
  9662. serialize(): any;
  9663. /**
  9664. * Internal only
  9665. * @hidden
  9666. */
  9667. protected _serialize(serializedCondition: any): any;
  9668. }
  9669. /**
  9670. * Defines specific conditional operators as extensions of Condition
  9671. */
  9672. export class ValueCondition extends Condition {
  9673. /** path to specify the property of the target the conditional operator uses */
  9674. propertyPath: string;
  9675. /** the value compared by the conditional operator against the current value of the property */
  9676. value: any;
  9677. /** the conditional operator, default ValueCondition.IsEqual */
  9678. operator: number;
  9679. /**
  9680. * Internal only
  9681. * @hidden
  9682. */
  9683. private static _IsEqual;
  9684. /**
  9685. * Internal only
  9686. * @hidden
  9687. */
  9688. private static _IsDifferent;
  9689. /**
  9690. * Internal only
  9691. * @hidden
  9692. */
  9693. private static _IsGreater;
  9694. /**
  9695. * Internal only
  9696. * @hidden
  9697. */
  9698. private static _IsLesser;
  9699. /**
  9700. * returns the number for IsEqual
  9701. */
  9702. static get IsEqual(): number;
  9703. /**
  9704. * Returns the number for IsDifferent
  9705. */
  9706. static get IsDifferent(): number;
  9707. /**
  9708. * Returns the number for IsGreater
  9709. */
  9710. static get IsGreater(): number;
  9711. /**
  9712. * Returns the number for IsLesser
  9713. */
  9714. static get IsLesser(): number;
  9715. /**
  9716. * Internal only The action manager for the condition
  9717. * @hidden
  9718. */
  9719. _actionManager: ActionManager;
  9720. /**
  9721. * Internal only
  9722. * @hidden
  9723. */
  9724. private _target;
  9725. /**
  9726. * Internal only
  9727. * @hidden
  9728. */
  9729. private _effectiveTarget;
  9730. /**
  9731. * Internal only
  9732. * @hidden
  9733. */
  9734. private _property;
  9735. /**
  9736. * Creates a new ValueCondition
  9737. * @param actionManager manager for the action the condition applies to
  9738. * @param target for the action
  9739. * @param propertyPath path to specify the property of the target the conditional operator uses
  9740. * @param value the value compared by the conditional operator against the current value of the property
  9741. * @param operator the conditional operator, default ValueCondition.IsEqual
  9742. */
  9743. constructor(actionManager: ActionManager, target: any,
  9744. /** path to specify the property of the target the conditional operator uses */
  9745. propertyPath: string,
  9746. /** the value compared by the conditional operator against the current value of the property */
  9747. value: any,
  9748. /** the conditional operator, default ValueCondition.IsEqual */
  9749. operator?: number);
  9750. /**
  9751. * Compares the given value with the property value for the specified conditional operator
  9752. * @returns the result of the comparison
  9753. */
  9754. isValid(): boolean;
  9755. /**
  9756. * Serialize the ValueCondition into a JSON compatible object
  9757. * @returns serialization object
  9758. */
  9759. serialize(): any;
  9760. /**
  9761. * Gets the name of the conditional operator for the ValueCondition
  9762. * @param operator the conditional operator
  9763. * @returns the name
  9764. */
  9765. static GetOperatorName(operator: number): string;
  9766. }
  9767. /**
  9768. * Defines a predicate condition as an extension of Condition
  9769. */
  9770. export class PredicateCondition extends Condition {
  9771. /** defines the predicate function used to validate the condition */
  9772. predicate: () => boolean;
  9773. /**
  9774. * Internal only - manager for action
  9775. * @hidden
  9776. */
  9777. _actionManager: ActionManager;
  9778. /**
  9779. * Creates a new PredicateCondition
  9780. * @param actionManager manager for the action the condition applies to
  9781. * @param predicate defines the predicate function used to validate the condition
  9782. */
  9783. constructor(actionManager: ActionManager,
  9784. /** defines the predicate function used to validate the condition */
  9785. predicate: () => boolean);
  9786. /**
  9787. * @returns the validity of the predicate condition
  9788. */
  9789. isValid(): boolean;
  9790. }
  9791. /**
  9792. * Defines a state condition as an extension of Condition
  9793. */
  9794. export class StateCondition extends Condition {
  9795. /** Value to compare with target state */
  9796. value: string;
  9797. /**
  9798. * Internal only - manager for action
  9799. * @hidden
  9800. */
  9801. _actionManager: ActionManager;
  9802. /**
  9803. * Internal only
  9804. * @hidden
  9805. */
  9806. private _target;
  9807. /**
  9808. * Creates a new StateCondition
  9809. * @param actionManager manager for the action the condition applies to
  9810. * @param target of the condition
  9811. * @param value to compare with target state
  9812. */
  9813. constructor(actionManager: ActionManager, target: any,
  9814. /** Value to compare with target state */
  9815. value: string);
  9816. /**
  9817. * Gets a boolean indicating if the current condition is met
  9818. * @returns the validity of the state
  9819. */
  9820. isValid(): boolean;
  9821. /**
  9822. * Serialize the StateCondition into a JSON compatible object
  9823. * @returns serialization object
  9824. */
  9825. serialize(): any;
  9826. }
  9827. }
  9828. declare module "babylonjs/Actions/directActions" {
  9829. import { Action } from "babylonjs/Actions/action";
  9830. import { Condition } from "babylonjs/Actions/condition";
  9831. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9832. /**
  9833. * This defines an action responsible to toggle a boolean once triggered.
  9834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9835. */
  9836. export class SwitchBooleanAction extends Action {
  9837. /**
  9838. * The path to the boolean property in the target object
  9839. */
  9840. propertyPath: string;
  9841. private _target;
  9842. private _effectiveTarget;
  9843. private _property;
  9844. /**
  9845. * Instantiate the action
  9846. * @param triggerOptions defines the trigger options
  9847. * @param target defines the object containing the boolean
  9848. * @param propertyPath defines the path to the boolean property in the target object
  9849. * @param condition defines the trigger related conditions
  9850. */
  9851. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9852. /** @hidden */
  9853. _prepare(): void;
  9854. /**
  9855. * Execute the action toggle the boolean value.
  9856. */
  9857. execute(): void;
  9858. /**
  9859. * Serializes the actions and its related information.
  9860. * @param parent defines the object to serialize in
  9861. * @returns the serialized object
  9862. */
  9863. serialize(parent: any): any;
  9864. }
  9865. /**
  9866. * This defines an action responsible to set a the state field of the target
  9867. * to a desired value once triggered.
  9868. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9869. */
  9870. export class SetStateAction extends Action {
  9871. /**
  9872. * The value to store in the state field.
  9873. */
  9874. value: string;
  9875. private _target;
  9876. /**
  9877. * Instantiate the action
  9878. * @param triggerOptions defines the trigger options
  9879. * @param target defines the object containing the state property
  9880. * @param value defines the value to store in the state field
  9881. * @param condition defines the trigger related conditions
  9882. */
  9883. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9884. /**
  9885. * Execute the action and store the value on the target state property.
  9886. */
  9887. execute(): void;
  9888. /**
  9889. * Serializes the actions and its related information.
  9890. * @param parent defines the object to serialize in
  9891. * @returns the serialized object
  9892. */
  9893. serialize(parent: any): any;
  9894. }
  9895. /**
  9896. * This defines an action responsible to set a property of the target
  9897. * to a desired value once triggered.
  9898. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9899. */
  9900. export class SetValueAction extends Action {
  9901. /**
  9902. * The path of the property to set in the target.
  9903. */
  9904. propertyPath: string;
  9905. /**
  9906. * The value to set in the property
  9907. */
  9908. value: any;
  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 property
  9916. * @param propertyPath defines the path of the property to set in the target
  9917. * @param value defines the value to set in the property
  9918. * @param condition defines the trigger related conditions
  9919. */
  9920. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9921. /** @hidden */
  9922. _prepare(): void;
  9923. /**
  9924. * Execute the action and set the targetted property to the desired value.
  9925. */
  9926. execute(): void;
  9927. /**
  9928. * Serializes the actions and its related information.
  9929. * @param parent defines the object to serialize in
  9930. * @returns the serialized object
  9931. */
  9932. serialize(parent: any): any;
  9933. }
  9934. /**
  9935. * This defines an action responsible to increment the target value
  9936. * to a desired value once triggered.
  9937. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9938. */
  9939. export class IncrementValueAction extends Action {
  9940. /**
  9941. * The path of the property to increment in the target.
  9942. */
  9943. propertyPath: string;
  9944. /**
  9945. * The value we should increment the property by.
  9946. */
  9947. value: any;
  9948. private _target;
  9949. private _effectiveTarget;
  9950. private _property;
  9951. /**
  9952. * Instantiate the action
  9953. * @param triggerOptions defines the trigger options
  9954. * @param target defines the object containing the property
  9955. * @param propertyPath defines the path of the property to increment in the target
  9956. * @param value defines the value value we should increment the property by
  9957. * @param condition defines the trigger related conditions
  9958. */
  9959. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9960. /** @hidden */
  9961. _prepare(): void;
  9962. /**
  9963. * Execute the action and increment the target of the value amount.
  9964. */
  9965. execute(): void;
  9966. /**
  9967. * Serializes the actions and its related information.
  9968. * @param parent defines the object to serialize in
  9969. * @returns the serialized object
  9970. */
  9971. serialize(parent: any): any;
  9972. }
  9973. /**
  9974. * This defines an action responsible to start an animation once triggered.
  9975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9976. */
  9977. export class PlayAnimationAction extends Action {
  9978. /**
  9979. * Where the animation should start (animation frame)
  9980. */
  9981. from: number;
  9982. /**
  9983. * Where the animation should stop (animation frame)
  9984. */
  9985. to: number;
  9986. /**
  9987. * Define if the animation should loop or stop after the first play.
  9988. */
  9989. loop?: boolean;
  9990. private _target;
  9991. /**
  9992. * Instantiate the action
  9993. * @param triggerOptions defines the trigger options
  9994. * @param target defines the target animation or animation name
  9995. * @param from defines from where the animation should start (animation frame)
  9996. * @param end defines where the animation should stop (animation frame)
  9997. * @param loop defines if the animation should loop or stop after the first play
  9998. * @param condition defines the trigger related conditions
  9999. */
  10000. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10001. /** @hidden */
  10002. _prepare(): void;
  10003. /**
  10004. * Execute the action and play the animation.
  10005. */
  10006. execute(): void;
  10007. /**
  10008. * Serializes the actions and its related information.
  10009. * @param parent defines the object to serialize in
  10010. * @returns the serialized object
  10011. */
  10012. serialize(parent: any): any;
  10013. }
  10014. /**
  10015. * This defines an action responsible to stop an animation once triggered.
  10016. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10017. */
  10018. export class StopAnimationAction extends Action {
  10019. private _target;
  10020. /**
  10021. * Instantiate the action
  10022. * @param triggerOptions defines the trigger options
  10023. * @param target defines the target animation or animation name
  10024. * @param condition defines the trigger related conditions
  10025. */
  10026. constructor(triggerOptions: any, target: any, condition?: Condition);
  10027. /** @hidden */
  10028. _prepare(): void;
  10029. /**
  10030. * Execute the action and stop the animation.
  10031. */
  10032. execute(): void;
  10033. /**
  10034. * Serializes the actions and its related information.
  10035. * @param parent defines the object to serialize in
  10036. * @returns the serialized object
  10037. */
  10038. serialize(parent: any): any;
  10039. }
  10040. /**
  10041. * This defines an action responsible that does nothing once triggered.
  10042. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10043. */
  10044. export class DoNothingAction extends Action {
  10045. /**
  10046. * Instantiate the action
  10047. * @param triggerOptions defines the trigger options
  10048. * @param condition defines the trigger related conditions
  10049. */
  10050. constructor(triggerOptions?: any, condition?: Condition);
  10051. /**
  10052. * Execute the action and do nothing.
  10053. */
  10054. execute(): void;
  10055. /**
  10056. * Serializes the actions and its related information.
  10057. * @param parent defines the object to serialize in
  10058. * @returns the serialized object
  10059. */
  10060. serialize(parent: any): any;
  10061. }
  10062. /**
  10063. * This defines an action responsible to trigger several actions once triggered.
  10064. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10065. */
  10066. export class CombineAction extends Action {
  10067. /**
  10068. * The list of aggregated animations to run.
  10069. */
  10070. children: Action[];
  10071. /**
  10072. * Instantiate the action
  10073. * @param triggerOptions defines the trigger options
  10074. * @param children defines the list of aggregated animations to run
  10075. * @param condition defines the trigger related conditions
  10076. */
  10077. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10078. /** @hidden */
  10079. _prepare(): void;
  10080. /**
  10081. * Execute the action and executes all the aggregated actions.
  10082. */
  10083. execute(evt: ActionEvent): void;
  10084. /**
  10085. * Serializes the actions and its related information.
  10086. * @param parent defines the object to serialize in
  10087. * @returns the serialized object
  10088. */
  10089. serialize(parent: any): any;
  10090. }
  10091. /**
  10092. * This defines an action responsible to run code (external event) once triggered.
  10093. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10094. */
  10095. export class ExecuteCodeAction extends Action {
  10096. /**
  10097. * The callback function to run.
  10098. */
  10099. func: (evt: ActionEvent) => void;
  10100. /**
  10101. * Instantiate the action
  10102. * @param triggerOptions defines the trigger options
  10103. * @param func defines the callback function to run
  10104. * @param condition defines the trigger related conditions
  10105. */
  10106. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10107. /**
  10108. * Execute the action and run the attached code.
  10109. */
  10110. execute(evt: ActionEvent): void;
  10111. }
  10112. /**
  10113. * This defines an action responsible to set the parent property of the target once triggered.
  10114. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10115. */
  10116. export class SetParentAction extends Action {
  10117. private _parent;
  10118. private _target;
  10119. /**
  10120. * Instantiate the action
  10121. * @param triggerOptions defines the trigger options
  10122. * @param target defines the target containing the parent property
  10123. * @param parent defines from where the animation should start (animation frame)
  10124. * @param condition defines the trigger related conditions
  10125. */
  10126. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10127. /** @hidden */
  10128. _prepare(): void;
  10129. /**
  10130. * Execute the action and set the parent property.
  10131. */
  10132. execute(): void;
  10133. /**
  10134. * Serializes the actions and its related information.
  10135. * @param parent defines the object to serialize in
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. }
  10140. }
  10141. declare module "babylonjs/Actions/actionManager" {
  10142. import { Nullable } from "babylonjs/types";
  10143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10144. import { Scene } from "babylonjs/scene";
  10145. import { IAction } from "babylonjs/Actions/action";
  10146. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10147. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10148. /**
  10149. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10150. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class ActionManager extends AbstractActionManager {
  10154. /**
  10155. * Nothing
  10156. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10157. */
  10158. static readonly NothingTrigger: number;
  10159. /**
  10160. * On pick
  10161. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10162. */
  10163. static readonly OnPickTrigger: number;
  10164. /**
  10165. * On left pick
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnLeftPickTrigger: number;
  10169. /**
  10170. * On right pick
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnRightPickTrigger: number;
  10174. /**
  10175. * On center pick
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnCenterPickTrigger: number;
  10179. /**
  10180. * On pick down
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPickDownTrigger: number;
  10184. /**
  10185. * On double pick
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnDoublePickTrigger: number;
  10189. /**
  10190. * On pick up
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnPickUpTrigger: number;
  10194. /**
  10195. * On pick out.
  10196. * This trigger will only be raised if you also declared a OnPickDown
  10197. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10198. */
  10199. static readonly OnPickOutTrigger: number;
  10200. /**
  10201. * On long press
  10202. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10203. */
  10204. static readonly OnLongPressTrigger: number;
  10205. /**
  10206. * On pointer over
  10207. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10208. */
  10209. static readonly OnPointerOverTrigger: number;
  10210. /**
  10211. * On pointer out
  10212. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10213. */
  10214. static readonly OnPointerOutTrigger: number;
  10215. /**
  10216. * On every frame
  10217. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10218. */
  10219. static readonly OnEveryFrameTrigger: number;
  10220. /**
  10221. * On intersection enter
  10222. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10223. */
  10224. static readonly OnIntersectionEnterTrigger: number;
  10225. /**
  10226. * On intersection exit
  10227. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10228. */
  10229. static readonly OnIntersectionExitTrigger: number;
  10230. /**
  10231. * On key down
  10232. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10233. */
  10234. static readonly OnKeyDownTrigger: number;
  10235. /**
  10236. * On key up
  10237. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10238. */
  10239. static readonly OnKeyUpTrigger: number;
  10240. private _scene;
  10241. /**
  10242. * Creates a new action manager
  10243. * @param scene defines the hosting scene
  10244. */
  10245. constructor(scene: Scene);
  10246. /**
  10247. * Releases all associated resources
  10248. */
  10249. dispose(): void;
  10250. /**
  10251. * Gets hosting scene
  10252. * @returns the hosting scene
  10253. */
  10254. getScene(): Scene;
  10255. /**
  10256. * Does this action manager handles actions of any of the given triggers
  10257. * @param triggers defines the triggers to be tested
  10258. * @return a boolean indicating whether one (or more) of the triggers is handled
  10259. */
  10260. hasSpecificTriggers(triggers: number[]): boolean;
  10261. /**
  10262. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10263. * speed.
  10264. * @param triggerA defines the trigger to be tested
  10265. * @param triggerB defines the trigger to be tested
  10266. * @return a boolean indicating whether one (or more) of the triggers is handled
  10267. */
  10268. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10269. /**
  10270. * Does this action manager handles actions of a given trigger
  10271. * @param trigger defines the trigger to be tested
  10272. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10273. * @return whether the trigger is handled
  10274. */
  10275. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10276. /**
  10277. * Does this action manager has pointer triggers
  10278. */
  10279. get hasPointerTriggers(): boolean;
  10280. /**
  10281. * Does this action manager has pick triggers
  10282. */
  10283. get hasPickTriggers(): boolean;
  10284. /**
  10285. * Registers an action to this action manager
  10286. * @param action defines the action to be registered
  10287. * @return the action amended (prepared) after registration
  10288. */
  10289. registerAction(action: IAction): Nullable<IAction>;
  10290. /**
  10291. * Unregisters an action to this action manager
  10292. * @param action defines the action to be unregistered
  10293. * @return a boolean indicating whether the action has been unregistered
  10294. */
  10295. unregisterAction(action: IAction): Boolean;
  10296. /**
  10297. * Process a specific trigger
  10298. * @param trigger defines the trigger to process
  10299. * @param evt defines the event details to be processed
  10300. */
  10301. processTrigger(trigger: number, evt?: IActionEvent): void;
  10302. /** @hidden */
  10303. _getEffectiveTarget(target: any, propertyPath: string): any;
  10304. /** @hidden */
  10305. _getProperty(propertyPath: string): string;
  10306. /**
  10307. * Serialize this manager to a JSON object
  10308. * @param name defines the property name to store this manager
  10309. * @returns a JSON representation of this manager
  10310. */
  10311. serialize(name: string): any;
  10312. /**
  10313. * Creates a new ActionManager from a JSON data
  10314. * @param parsedActions defines the JSON data to read from
  10315. * @param object defines the hosting mesh
  10316. * @param scene defines the hosting scene
  10317. */
  10318. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10319. /**
  10320. * Get a trigger name by index
  10321. * @param trigger defines the trigger index
  10322. * @returns a trigger name
  10323. */
  10324. static GetTriggerName(trigger: number): string;
  10325. }
  10326. }
  10327. declare module "babylonjs/Sprites/sprite" {
  10328. import { Vector3 } from "babylonjs/Maths/math.vector";
  10329. import { Nullable } from "babylonjs/types";
  10330. import { ActionManager } from "babylonjs/Actions/actionManager";
  10331. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10332. import { Color4 } from "babylonjs/Maths/math.color";
  10333. import { Observable } from "babylonjs/Misc/observable";
  10334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10335. import { Animation } from "babylonjs/Animations/animation";
  10336. /**
  10337. * Class used to represent a sprite
  10338. * @see https://doc.babylonjs.com/babylon101/sprites
  10339. */
  10340. export class Sprite implements IAnimatable {
  10341. /** defines the name */
  10342. name: string;
  10343. /** Gets or sets the current world position */
  10344. position: Vector3;
  10345. /** Gets or sets the main color */
  10346. color: Color4;
  10347. /** Gets or sets the width */
  10348. width: number;
  10349. /** Gets or sets the height */
  10350. height: number;
  10351. /** Gets or sets rotation angle */
  10352. angle: number;
  10353. /** Gets or sets the cell index in the sprite sheet */
  10354. cellIndex: number;
  10355. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10356. cellRef: string;
  10357. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10358. invertU: boolean;
  10359. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10360. invertV: boolean;
  10361. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10362. disposeWhenFinishedAnimating: boolean;
  10363. /** Gets the list of attached animations */
  10364. animations: Nullable<Array<Animation>>;
  10365. /** Gets or sets a boolean indicating if the sprite can be picked */
  10366. isPickable: boolean;
  10367. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10368. useAlphaForPicking: boolean;
  10369. /** @hidden */
  10370. _xOffset: number;
  10371. /** @hidden */
  10372. _yOffset: number;
  10373. /** @hidden */
  10374. _xSize: number;
  10375. /** @hidden */
  10376. _ySize: number;
  10377. /**
  10378. * Gets or sets the associated action manager
  10379. */
  10380. actionManager: Nullable<ActionManager>;
  10381. /**
  10382. * An event triggered when the control has been disposed
  10383. */
  10384. onDisposeObservable: Observable<Sprite>;
  10385. private _animationStarted;
  10386. private _loopAnimation;
  10387. private _fromIndex;
  10388. private _toIndex;
  10389. private _delay;
  10390. private _direction;
  10391. private _manager;
  10392. private _time;
  10393. private _onAnimationEnd;
  10394. /**
  10395. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10396. */
  10397. isVisible: boolean;
  10398. /**
  10399. * Gets or sets the sprite size
  10400. */
  10401. get size(): number;
  10402. set size(value: number);
  10403. /**
  10404. * Returns a boolean indicating if the animation is started
  10405. */
  10406. get animationStarted(): boolean;
  10407. /**
  10408. * Gets or sets the unique id of the sprite
  10409. */
  10410. uniqueId: number;
  10411. /**
  10412. * Gets the manager of this sprite
  10413. */
  10414. get manager(): ISpriteManager;
  10415. /**
  10416. * Creates a new Sprite
  10417. * @param name defines the name
  10418. * @param manager defines the manager
  10419. */
  10420. constructor(
  10421. /** defines the name */
  10422. name: string, manager: ISpriteManager);
  10423. /**
  10424. * Returns the string "Sprite"
  10425. * @returns "Sprite"
  10426. */
  10427. getClassName(): string;
  10428. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10429. get fromIndex(): number;
  10430. set fromIndex(value: number);
  10431. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10432. get toIndex(): number;
  10433. set toIndex(value: number);
  10434. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10435. get loopAnimation(): boolean;
  10436. set loopAnimation(value: boolean);
  10437. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10438. get delay(): number;
  10439. set delay(value: number);
  10440. /**
  10441. * Starts an animation
  10442. * @param from defines the initial key
  10443. * @param to defines the end key
  10444. * @param loop defines if the animation must loop
  10445. * @param delay defines the start delay (in ms)
  10446. * @param onAnimationEnd defines a callback to call when animation ends
  10447. */
  10448. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10449. /** Stops current animation (if any) */
  10450. stopAnimation(): void;
  10451. /** @hidden */
  10452. _animate(deltaTime: number): void;
  10453. /** Release associated resources */
  10454. dispose(): void;
  10455. /**
  10456. * Serializes the sprite to a JSON object
  10457. * @returns the JSON object
  10458. */
  10459. serialize(): any;
  10460. /**
  10461. * Parses a JSON object to create a new sprite
  10462. * @param parsedSprite The JSON object to parse
  10463. * @param manager defines the hosting manager
  10464. * @returns the new sprite
  10465. */
  10466. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10467. }
  10468. }
  10469. declare module "babylonjs/Collisions/pickingInfo" {
  10470. import { Nullable } from "babylonjs/types";
  10471. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10473. import { Sprite } from "babylonjs/Sprites/sprite";
  10474. import { Ray } from "babylonjs/Culling/ray";
  10475. /**
  10476. * Information about the result of picking within a scene
  10477. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10478. */
  10479. export class PickingInfo {
  10480. /** @hidden */
  10481. _pickingUnavailable: boolean;
  10482. /**
  10483. * If the pick collided with an object
  10484. */
  10485. hit: boolean;
  10486. /**
  10487. * Distance away where the pick collided
  10488. */
  10489. distance: number;
  10490. /**
  10491. * The location of pick collision
  10492. */
  10493. pickedPoint: Nullable<Vector3>;
  10494. /**
  10495. * The mesh corresponding the the pick collision
  10496. */
  10497. pickedMesh: Nullable<AbstractMesh>;
  10498. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10499. bu: number;
  10500. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10501. bv: number;
  10502. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10503. faceId: number;
  10504. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10505. subMeshFaceId: number;
  10506. /** Id of the the submesh that was picked */
  10507. subMeshId: number;
  10508. /** If a sprite was picked, this will be the sprite the pick collided with */
  10509. pickedSprite: Nullable<Sprite>;
  10510. /**
  10511. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10512. */
  10513. originMesh: Nullable<AbstractMesh>;
  10514. /**
  10515. * The ray that was used to perform the picking.
  10516. */
  10517. ray: Nullable<Ray>;
  10518. /**
  10519. * Gets the normal correspodning to the face the pick collided with
  10520. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10521. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10522. * @returns The normal correspodning to the face the pick collided with
  10523. */
  10524. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10525. /**
  10526. * Gets the texture coordinates of where the pick occured
  10527. * @returns the vector containing the coordnates of the texture
  10528. */
  10529. getTextureCoordinates(): Nullable<Vector2>;
  10530. }
  10531. }
  10532. declare module "babylonjs/Culling/ray" {
  10533. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10534. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10537. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10538. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10539. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10540. import { Plane } from "babylonjs/Maths/math.plane";
  10541. /**
  10542. * Class representing a ray with position and direction
  10543. */
  10544. export class Ray {
  10545. /** origin point */
  10546. origin: Vector3;
  10547. /** direction */
  10548. direction: Vector3;
  10549. /** length of the ray */
  10550. length: number;
  10551. private static readonly TmpVector3;
  10552. private _tmpRay;
  10553. /**
  10554. * Creates a new ray
  10555. * @param origin origin point
  10556. * @param direction direction
  10557. * @param length length of the ray
  10558. */
  10559. constructor(
  10560. /** origin point */
  10561. origin: Vector3,
  10562. /** direction */
  10563. direction: Vector3,
  10564. /** length of the ray */
  10565. length?: number);
  10566. /**
  10567. * Checks if the ray intersects a box
  10568. * This does not account for the ray lenght by design to improve perfs.
  10569. * @param minimum bound of the box
  10570. * @param maximum bound of the box
  10571. * @param intersectionTreshold extra extend to be added to the box in all direction
  10572. * @returns if the box was hit
  10573. */
  10574. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10575. /**
  10576. * Checks if the ray intersects a box
  10577. * This does not account for the ray lenght by design to improve perfs.
  10578. * @param box the bounding box to check
  10579. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10580. * @returns if the box was hit
  10581. */
  10582. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10583. /**
  10584. * If the ray hits a sphere
  10585. * @param sphere the bounding sphere to check
  10586. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10587. * @returns true if it hits the sphere
  10588. */
  10589. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10590. /**
  10591. * If the ray hits a triange
  10592. * @param vertex0 triangle vertex
  10593. * @param vertex1 triangle vertex
  10594. * @param vertex2 triangle vertex
  10595. * @returns intersection information if hit
  10596. */
  10597. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10598. /**
  10599. * Checks if ray intersects a plane
  10600. * @param plane the plane to check
  10601. * @returns the distance away it was hit
  10602. */
  10603. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10604. /**
  10605. * Calculate the intercept of a ray on a given axis
  10606. * @param axis to check 'x' | 'y' | 'z'
  10607. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10608. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10609. */
  10610. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10611. /**
  10612. * Checks if ray intersects a mesh
  10613. * @param mesh the mesh to check
  10614. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10615. * @returns picking info of the intersecton
  10616. */
  10617. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10618. /**
  10619. * Checks if ray intersects a mesh
  10620. * @param meshes the meshes to check
  10621. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10622. * @param results array to store result in
  10623. * @returns Array of picking infos
  10624. */
  10625. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10626. private _comparePickingInfo;
  10627. private static smallnum;
  10628. private static rayl;
  10629. /**
  10630. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10631. * @param sega the first point of the segment to test the intersection against
  10632. * @param segb the second point of the segment to test the intersection against
  10633. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10634. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10635. */
  10636. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10637. /**
  10638. * Update the ray from viewport position
  10639. * @param x position
  10640. * @param y y position
  10641. * @param viewportWidth viewport width
  10642. * @param viewportHeight viewport height
  10643. * @param world world matrix
  10644. * @param view view matrix
  10645. * @param projection projection matrix
  10646. * @returns this ray updated
  10647. */
  10648. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10649. /**
  10650. * Creates a ray with origin and direction of 0,0,0
  10651. * @returns the new ray
  10652. */
  10653. static Zero(): Ray;
  10654. /**
  10655. * Creates a new ray from screen space and viewport
  10656. * @param x position
  10657. * @param y y position
  10658. * @param viewportWidth viewport width
  10659. * @param viewportHeight viewport height
  10660. * @param world world matrix
  10661. * @param view view matrix
  10662. * @param projection projection matrix
  10663. * @returns new ray
  10664. */
  10665. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10666. /**
  10667. * 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
  10668. * transformed to the given world matrix.
  10669. * @param origin The origin point
  10670. * @param end The end point
  10671. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10672. * @returns the new ray
  10673. */
  10674. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10675. /**
  10676. * Transforms a ray by a matrix
  10677. * @param ray ray to transform
  10678. * @param matrix matrix to apply
  10679. * @returns the resulting new ray
  10680. */
  10681. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10682. /**
  10683. * Transforms a ray by a matrix
  10684. * @param ray ray to transform
  10685. * @param matrix matrix to apply
  10686. * @param result ray to store result in
  10687. */
  10688. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10689. /**
  10690. * Unproject a ray from screen space to object space
  10691. * @param sourceX defines the screen space x coordinate to use
  10692. * @param sourceY defines the screen space y coordinate to use
  10693. * @param viewportWidth defines the current width of the viewport
  10694. * @param viewportHeight defines the current height of the viewport
  10695. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10696. * @param view defines the view matrix to use
  10697. * @param projection defines the projection matrix to use
  10698. */
  10699. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10700. }
  10701. /**
  10702. * Type used to define predicate used to select faces when a mesh intersection is detected
  10703. */
  10704. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10705. module "babylonjs/scene" {
  10706. interface Scene {
  10707. /** @hidden */
  10708. _tempPickingRay: Nullable<Ray>;
  10709. /** @hidden */
  10710. _cachedRayForTransform: Ray;
  10711. /** @hidden */
  10712. _pickWithRayInverseMatrix: Matrix;
  10713. /** @hidden */
  10714. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10715. /** @hidden */
  10716. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10717. }
  10718. }
  10719. }
  10720. declare module "babylonjs/sceneComponent" {
  10721. import { Scene } from "babylonjs/scene";
  10722. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10723. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10724. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10725. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10726. import { Nullable } from "babylonjs/types";
  10727. import { Camera } from "babylonjs/Cameras/camera";
  10728. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10729. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10730. import { AbstractScene } from "babylonjs/abstractScene";
  10731. import { Mesh } from "babylonjs/Meshes/mesh";
  10732. /**
  10733. * Groups all the scene component constants in one place to ease maintenance.
  10734. * @hidden
  10735. */
  10736. export class SceneComponentConstants {
  10737. static readonly NAME_EFFECTLAYER: string;
  10738. static readonly NAME_LAYER: string;
  10739. static readonly NAME_LENSFLARESYSTEM: string;
  10740. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10741. static readonly NAME_PARTICLESYSTEM: string;
  10742. static readonly NAME_GAMEPAD: string;
  10743. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10744. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10745. static readonly NAME_PREPASSRENDERER: string;
  10746. static readonly NAME_DEPTHRENDERER: string;
  10747. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10748. static readonly NAME_SPRITE: string;
  10749. static readonly NAME_OUTLINERENDERER: string;
  10750. static readonly NAME_PROCEDURALTEXTURE: string;
  10751. static readonly NAME_SHADOWGENERATOR: string;
  10752. static readonly NAME_OCTREE: string;
  10753. static readonly NAME_PHYSICSENGINE: string;
  10754. static readonly NAME_AUDIO: string;
  10755. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10756. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10757. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10758. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10759. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10760. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10761. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10762. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10763. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10764. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10765. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10766. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10767. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10768. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10769. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10770. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10771. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10772. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10773. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10774. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10775. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10776. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10777. static readonly STEP_AFTERRENDER_AUDIO: number;
  10778. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10779. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10780. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10781. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10782. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10783. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10784. static readonly STEP_POINTERMOVE_SPRITE: number;
  10785. static readonly STEP_POINTERDOWN_SPRITE: number;
  10786. static readonly STEP_POINTERUP_SPRITE: number;
  10787. }
  10788. /**
  10789. * This represents a scene component.
  10790. *
  10791. * This is used to decouple the dependency the scene is having on the different workloads like
  10792. * layers, post processes...
  10793. */
  10794. export interface ISceneComponent {
  10795. /**
  10796. * The name of the component. Each component must have a unique name.
  10797. */
  10798. name: string;
  10799. /**
  10800. * The scene the component belongs to.
  10801. */
  10802. scene: Scene;
  10803. /**
  10804. * Register the component to one instance of a scene.
  10805. */
  10806. register(): void;
  10807. /**
  10808. * Rebuilds the elements related to this component in case of
  10809. * context lost for instance.
  10810. */
  10811. rebuild(): void;
  10812. /**
  10813. * Disposes the component and the associated ressources.
  10814. */
  10815. dispose(): void;
  10816. }
  10817. /**
  10818. * This represents a SERIALIZABLE scene component.
  10819. *
  10820. * This extends Scene Component to add Serialization methods on top.
  10821. */
  10822. export interface ISceneSerializableComponent extends ISceneComponent {
  10823. /**
  10824. * Adds all the elements from the container to the scene
  10825. * @param container the container holding the elements
  10826. */
  10827. addFromContainer(container: AbstractScene): void;
  10828. /**
  10829. * Removes all the elements in the container from the scene
  10830. * @param container contains the elements to remove
  10831. * @param dispose if the removed element should be disposed (default: false)
  10832. */
  10833. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10834. /**
  10835. * Serializes the component data to the specified json object
  10836. * @param serializationObject The object to serialize to
  10837. */
  10838. serialize(serializationObject: any): void;
  10839. }
  10840. /**
  10841. * Strong typing of a Mesh related stage step action
  10842. */
  10843. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10844. /**
  10845. * Strong typing of a Evaluate Sub Mesh related stage step action
  10846. */
  10847. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10848. /**
  10849. * Strong typing of a Active Mesh related stage step action
  10850. */
  10851. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10852. /**
  10853. * Strong typing of a Camera related stage step action
  10854. */
  10855. export type CameraStageAction = (camera: Camera) => void;
  10856. /**
  10857. * Strong typing of a Camera Frame buffer related stage step action
  10858. */
  10859. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10860. /**
  10861. * Strong typing of a Render Target related stage step action
  10862. */
  10863. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10864. /**
  10865. * Strong typing of a RenderingGroup related stage step action
  10866. */
  10867. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10868. /**
  10869. * Strong typing of a Mesh Render related stage step action
  10870. */
  10871. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10872. /**
  10873. * Strong typing of a simple stage step action
  10874. */
  10875. export type SimpleStageAction = () => void;
  10876. /**
  10877. * Strong typing of a render target action.
  10878. */
  10879. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10880. /**
  10881. * Strong typing of a pointer move action.
  10882. */
  10883. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10884. /**
  10885. * Strong typing of a pointer up/down action.
  10886. */
  10887. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10888. /**
  10889. * Representation of a stage in the scene (Basically a list of ordered steps)
  10890. * @hidden
  10891. */
  10892. export class Stage<T extends Function> extends Array<{
  10893. index: number;
  10894. component: ISceneComponent;
  10895. action: T;
  10896. }> {
  10897. /**
  10898. * Hide ctor from the rest of the world.
  10899. * @param items The items to add.
  10900. */
  10901. private constructor();
  10902. /**
  10903. * Creates a new Stage.
  10904. * @returns A new instance of a Stage
  10905. */
  10906. static Create<T extends Function>(): Stage<T>;
  10907. /**
  10908. * Registers a step in an ordered way in the targeted stage.
  10909. * @param index Defines the position to register the step in
  10910. * @param component Defines the component attached to the step
  10911. * @param action Defines the action to launch during the step
  10912. */
  10913. registerStep(index: number, component: ISceneComponent, action: T): void;
  10914. /**
  10915. * Clears all the steps from the stage.
  10916. */
  10917. clear(): void;
  10918. }
  10919. }
  10920. declare module "babylonjs/Sprites/spriteSceneComponent" {
  10921. import { Nullable } from "babylonjs/types";
  10922. import { Observable } from "babylonjs/Misc/observable";
  10923. import { Scene } from "babylonjs/scene";
  10924. import { Sprite } from "babylonjs/Sprites/sprite";
  10925. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  10926. import { Ray } from "babylonjs/Culling/ray";
  10927. import { Camera } from "babylonjs/Cameras/camera";
  10928. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10929. import { ISceneComponent } from "babylonjs/sceneComponent";
  10930. module "babylonjs/scene" {
  10931. interface Scene {
  10932. /** @hidden */
  10933. _pointerOverSprite: Nullable<Sprite>;
  10934. /** @hidden */
  10935. _pickedDownSprite: Nullable<Sprite>;
  10936. /** @hidden */
  10937. _tempSpritePickingRay: Nullable<Ray>;
  10938. /**
  10939. * All of the sprite managers added to this scene
  10940. * @see https://doc.babylonjs.com/babylon101/sprites
  10941. */
  10942. spriteManagers: Array<ISpriteManager>;
  10943. /**
  10944. * An event triggered when sprites rendering is about to start
  10945. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10946. */
  10947. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10948. /**
  10949. * An event triggered when sprites rendering is done
  10950. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10951. */
  10952. onAfterSpritesRenderingObservable: Observable<Scene>;
  10953. /** @hidden */
  10954. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10955. /** Launch a ray to try to pick a sprite in the scene
  10956. * @param x position on screen
  10957. * @param y position on screen
  10958. * @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
  10959. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10960. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10961. * @returns a PickingInfo
  10962. */
  10963. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10964. /** Use the given ray to pick a sprite in the scene
  10965. * @param ray The ray (in world space) to use to pick meshes
  10966. * @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
  10967. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10968. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10969. * @returns a PickingInfo
  10970. */
  10971. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10972. /** @hidden */
  10973. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10974. /** Launch a ray to try to pick sprites in the scene
  10975. * @param x position on screen
  10976. * @param y position on screen
  10977. * @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
  10978. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10979. * @returns a PickingInfo array
  10980. */
  10981. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10982. /** Use the given ray to pick sprites in the scene
  10983. * @param ray The ray (in world space) to use to pick meshes
  10984. * @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
  10985. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10986. * @returns a PickingInfo array
  10987. */
  10988. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10989. /**
  10990. * Force the sprite under the pointer
  10991. * @param sprite defines the sprite to use
  10992. */
  10993. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10994. /**
  10995. * Gets the sprite under the pointer
  10996. * @returns a Sprite or null if no sprite is under the pointer
  10997. */
  10998. getPointerOverSprite(): Nullable<Sprite>;
  10999. }
  11000. }
  11001. /**
  11002. * Defines the sprite scene component responsible to manage sprites
  11003. * in a given scene.
  11004. */
  11005. export class SpriteSceneComponent implements ISceneComponent {
  11006. /**
  11007. * The component name helpfull to identify the component in the list of scene components.
  11008. */
  11009. readonly name: string;
  11010. /**
  11011. * The scene the component belongs to.
  11012. */
  11013. scene: Scene;
  11014. /** @hidden */
  11015. private _spritePredicate;
  11016. /**
  11017. * Creates a new instance of the component for the given scene
  11018. * @param scene Defines the scene to register the component in
  11019. */
  11020. constructor(scene: Scene);
  11021. /**
  11022. * Registers the component in a given scene
  11023. */
  11024. register(): void;
  11025. /**
  11026. * Rebuilds the elements related to this component in case of
  11027. * context lost for instance.
  11028. */
  11029. rebuild(): void;
  11030. /**
  11031. * Disposes the component and the associated ressources.
  11032. */
  11033. dispose(): void;
  11034. private _pickSpriteButKeepRay;
  11035. private _pointerMove;
  11036. private _pointerDown;
  11037. private _pointerUp;
  11038. }
  11039. }
  11040. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11041. /** @hidden */
  11042. export var fogFragmentDeclaration: {
  11043. name: string;
  11044. shader: string;
  11045. };
  11046. }
  11047. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11048. /** @hidden */
  11049. export var fogFragment: {
  11050. name: string;
  11051. shader: string;
  11052. };
  11053. }
  11054. declare module "babylonjs/Shaders/sprites.fragment" {
  11055. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11056. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11057. /** @hidden */
  11058. export var spritesPixelShader: {
  11059. name: string;
  11060. shader: string;
  11061. };
  11062. }
  11063. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11064. /** @hidden */
  11065. export var fogVertexDeclaration: {
  11066. name: string;
  11067. shader: string;
  11068. };
  11069. }
  11070. declare module "babylonjs/Shaders/sprites.vertex" {
  11071. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11072. /** @hidden */
  11073. export var spritesVertexShader: {
  11074. name: string;
  11075. shader: string;
  11076. };
  11077. }
  11078. declare module "babylonjs/Sprites/spriteManager" {
  11079. import { IDisposable, Scene } from "babylonjs/scene";
  11080. import { Nullable } from "babylonjs/types";
  11081. import { Observable } from "babylonjs/Misc/observable";
  11082. import { Sprite } from "babylonjs/Sprites/sprite";
  11083. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11084. import { Camera } from "babylonjs/Cameras/camera";
  11085. import { Texture } from "babylonjs/Materials/Textures/texture";
  11086. import "babylonjs/Shaders/sprites.fragment";
  11087. import "babylonjs/Shaders/sprites.vertex";
  11088. import { Ray } from "babylonjs/Culling/ray";
  11089. /**
  11090. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11091. */
  11092. export interface ISpriteManager extends IDisposable {
  11093. /**
  11094. * Gets manager's name
  11095. */
  11096. name: string;
  11097. /**
  11098. * Restricts the camera to viewing objects with the same layerMask.
  11099. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11100. */
  11101. layerMask: number;
  11102. /**
  11103. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11104. */
  11105. isPickable: boolean;
  11106. /**
  11107. * Gets the hosting scene
  11108. */
  11109. scene: Scene;
  11110. /**
  11111. * Specifies the rendering group id for this mesh (0 by default)
  11112. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11113. */
  11114. renderingGroupId: number;
  11115. /**
  11116. * Defines the list of sprites managed by the manager.
  11117. */
  11118. sprites: Array<Sprite>;
  11119. /**
  11120. * Gets or sets the spritesheet texture
  11121. */
  11122. texture: Texture;
  11123. /** Defines the default width of a cell in the spritesheet */
  11124. cellWidth: number;
  11125. /** Defines the default height of a cell in the spritesheet */
  11126. cellHeight: number;
  11127. /**
  11128. * Tests the intersection of a sprite with a specific ray.
  11129. * @param ray The ray we are sending to test the collision
  11130. * @param camera The camera space we are sending rays in
  11131. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11132. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11133. * @returns picking info or null.
  11134. */
  11135. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11136. /**
  11137. * Intersects the sprites with a ray
  11138. * @param ray defines the ray to intersect with
  11139. * @param camera defines the current active camera
  11140. * @param predicate defines a predicate used to select candidate sprites
  11141. * @returns null if no hit or a PickingInfo array
  11142. */
  11143. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11144. /**
  11145. * Renders the list of sprites on screen.
  11146. */
  11147. render(): void;
  11148. }
  11149. /**
  11150. * Class used to manage multiple sprites on the same spritesheet
  11151. * @see https://doc.babylonjs.com/babylon101/sprites
  11152. */
  11153. export class SpriteManager implements ISpriteManager {
  11154. /** defines the manager's name */
  11155. name: string;
  11156. /** Define the Url to load snippets */
  11157. static SnippetUrl: string;
  11158. /** Snippet ID if the manager was created from the snippet server */
  11159. snippetId: string;
  11160. /** Gets the list of sprites */
  11161. sprites: Sprite[];
  11162. /** Gets or sets the rendering group id (0 by default) */
  11163. renderingGroupId: number;
  11164. /** Gets or sets camera layer mask */
  11165. layerMask: number;
  11166. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11167. fogEnabled: boolean;
  11168. /** Gets or sets a boolean indicating if the sprites are pickable */
  11169. isPickable: boolean;
  11170. /** Defines the default width of a cell in the spritesheet */
  11171. cellWidth: number;
  11172. /** Defines the default height of a cell in the spritesheet */
  11173. cellHeight: number;
  11174. /** Associative array from JSON sprite data file */
  11175. private _cellData;
  11176. /** Array of sprite names from JSON sprite data file */
  11177. private _spriteMap;
  11178. /** True when packed cell data from JSON file is ready*/
  11179. private _packedAndReady;
  11180. private _textureContent;
  11181. /**
  11182. * An event triggered when the manager is disposed.
  11183. */
  11184. onDisposeObservable: Observable<SpriteManager>;
  11185. private _onDisposeObserver;
  11186. /**
  11187. * Callback called when the manager is disposed
  11188. */
  11189. set onDispose(callback: () => void);
  11190. private _capacity;
  11191. private _fromPacked;
  11192. private _spriteTexture;
  11193. private _epsilon;
  11194. private _scene;
  11195. private _vertexData;
  11196. private _buffer;
  11197. private _vertexBuffers;
  11198. private _indexBuffer;
  11199. private _effectBase;
  11200. private _effectFog;
  11201. /**
  11202. * Gets or sets the unique id of the sprite
  11203. */
  11204. uniqueId: number;
  11205. /**
  11206. * Gets the array of sprites
  11207. */
  11208. get children(): Sprite[];
  11209. /**
  11210. * Gets the hosting scene
  11211. */
  11212. get scene(): Scene;
  11213. /**
  11214. * Gets the capacity of the manager
  11215. */
  11216. get capacity(): number;
  11217. /**
  11218. * Gets or sets the spritesheet texture
  11219. */
  11220. get texture(): Texture;
  11221. set texture(value: Texture);
  11222. private _blendMode;
  11223. /**
  11224. * Blend mode use to render the particle, it can be any of
  11225. * the static Constants.ALPHA_x properties provided in this class.
  11226. * Default value is Constants.ALPHA_COMBINE
  11227. */
  11228. get blendMode(): number;
  11229. set blendMode(blendMode: number);
  11230. /** Disables writing to the depth buffer when rendering the sprites.
  11231. * It can be handy to disable depth writing when using textures without alpha channel
  11232. * and setting some specific blend modes.
  11233. */
  11234. disableDepthWrite: boolean;
  11235. /**
  11236. * Creates a new sprite manager
  11237. * @param name defines the manager's name
  11238. * @param imgUrl defines the sprite sheet url
  11239. * @param capacity defines the maximum allowed number of sprites
  11240. * @param cellSize defines the size of a sprite cell
  11241. * @param scene defines the hosting scene
  11242. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11243. * @param samplingMode defines the smapling mode to use with spritesheet
  11244. * @param fromPacked set to false; do not alter
  11245. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11246. */
  11247. constructor(
  11248. /** defines the manager's name */
  11249. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11250. /**
  11251. * Returns the string "SpriteManager"
  11252. * @returns "SpriteManager"
  11253. */
  11254. getClassName(): string;
  11255. private _makePacked;
  11256. private _appendSpriteVertex;
  11257. private _checkTextureAlpha;
  11258. /**
  11259. * Intersects the sprites with a ray
  11260. * @param ray defines the ray to intersect with
  11261. * @param camera defines the current active camera
  11262. * @param predicate defines a predicate used to select candidate sprites
  11263. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11264. * @returns null if no hit or a PickingInfo
  11265. */
  11266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11267. /**
  11268. * Intersects the sprites with a ray
  11269. * @param ray defines the ray to intersect with
  11270. * @param camera defines the current active camera
  11271. * @param predicate defines a predicate used to select candidate sprites
  11272. * @returns null if no hit or a PickingInfo array
  11273. */
  11274. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11275. /**
  11276. * Render all child sprites
  11277. */
  11278. render(): void;
  11279. /**
  11280. * Release associated resources
  11281. */
  11282. dispose(): void;
  11283. /**
  11284. * Serializes the sprite manager to a JSON object
  11285. * @param serializeTexture defines if the texture must be serialized as well
  11286. * @returns the JSON object
  11287. */
  11288. serialize(serializeTexture?: boolean): any;
  11289. /**
  11290. * Parses a JSON object to create a new sprite manager.
  11291. * @param parsedManager The JSON object to parse
  11292. * @param scene The scene to create the sprite managerin
  11293. * @param rootUrl The root url to use to load external dependencies like texture
  11294. * @returns the new sprite manager
  11295. */
  11296. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11297. /**
  11298. * Creates a sprite manager from a snippet saved in a remote file
  11299. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11300. * @param url defines the url to load from
  11301. * @param scene defines the hosting scene
  11302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11303. * @returns a promise that will resolve to the new sprite manager
  11304. */
  11305. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11306. /**
  11307. * Creates a sprite manager from a snippet saved by the sprite editor
  11308. * @param snippetId defines the snippet to load
  11309. * @param scene defines the hosting scene
  11310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11311. * @returns a promise that will resolve to the new sprite manager
  11312. */
  11313. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11314. }
  11315. }
  11316. declare module "babylonjs/Misc/gradients" {
  11317. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11318. /** Interface used by value gradients (color, factor, ...) */
  11319. export interface IValueGradient {
  11320. /**
  11321. * Gets or sets the gradient value (between 0 and 1)
  11322. */
  11323. gradient: number;
  11324. }
  11325. /** Class used to store color4 gradient */
  11326. export class ColorGradient implements IValueGradient {
  11327. /**
  11328. * Gets or sets the gradient value (between 0 and 1)
  11329. */
  11330. gradient: number;
  11331. /**
  11332. * Gets or sets first associated color
  11333. */
  11334. color1: Color4;
  11335. /**
  11336. * Gets or sets second associated color
  11337. */
  11338. color2?: Color4 | undefined;
  11339. /**
  11340. * Creates a new color4 gradient
  11341. * @param gradient gets or sets the gradient value (between 0 and 1)
  11342. * @param color1 gets or sets first associated color
  11343. * @param color2 gets or sets first second color
  11344. */
  11345. constructor(
  11346. /**
  11347. * Gets or sets the gradient value (between 0 and 1)
  11348. */
  11349. gradient: number,
  11350. /**
  11351. * Gets or sets first associated color
  11352. */
  11353. color1: Color4,
  11354. /**
  11355. * Gets or sets second associated color
  11356. */
  11357. color2?: Color4 | undefined);
  11358. /**
  11359. * Will get a color picked randomly between color1 and color2.
  11360. * If color2 is undefined then color1 will be used
  11361. * @param result defines the target Color4 to store the result in
  11362. */
  11363. getColorToRef(result: Color4): void;
  11364. }
  11365. /** Class used to store color 3 gradient */
  11366. export class Color3Gradient implements IValueGradient {
  11367. /**
  11368. * Gets or sets the gradient value (between 0 and 1)
  11369. */
  11370. gradient: number;
  11371. /**
  11372. * Gets or sets the associated color
  11373. */
  11374. color: Color3;
  11375. /**
  11376. * Creates a new color3 gradient
  11377. * @param gradient gets or sets the gradient value (between 0 and 1)
  11378. * @param color gets or sets associated color
  11379. */
  11380. constructor(
  11381. /**
  11382. * Gets or sets the gradient value (between 0 and 1)
  11383. */
  11384. gradient: number,
  11385. /**
  11386. * Gets or sets the associated color
  11387. */
  11388. color: Color3);
  11389. }
  11390. /** Class used to store factor gradient */
  11391. export class FactorGradient implements IValueGradient {
  11392. /**
  11393. * Gets or sets the gradient value (between 0 and 1)
  11394. */
  11395. gradient: number;
  11396. /**
  11397. * Gets or sets first associated factor
  11398. */
  11399. factor1: number;
  11400. /**
  11401. * Gets or sets second associated factor
  11402. */
  11403. factor2?: number | undefined;
  11404. /**
  11405. * Creates a new factor gradient
  11406. * @param gradient gets or sets the gradient value (between 0 and 1)
  11407. * @param factor1 gets or sets first associated factor
  11408. * @param factor2 gets or sets second associated factor
  11409. */
  11410. constructor(
  11411. /**
  11412. * Gets or sets the gradient value (between 0 and 1)
  11413. */
  11414. gradient: number,
  11415. /**
  11416. * Gets or sets first associated factor
  11417. */
  11418. factor1: number,
  11419. /**
  11420. * Gets or sets second associated factor
  11421. */
  11422. factor2?: number | undefined);
  11423. /**
  11424. * Will get a number picked randomly between factor1 and factor2.
  11425. * If factor2 is undefined then factor1 will be used
  11426. * @returns the picked number
  11427. */
  11428. getFactor(): number;
  11429. }
  11430. /**
  11431. * Helper used to simplify some generic gradient tasks
  11432. */
  11433. export class GradientHelper {
  11434. /**
  11435. * Gets the current gradient from an array of IValueGradient
  11436. * @param ratio defines the current ratio to get
  11437. * @param gradients defines the array of IValueGradient
  11438. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11439. */
  11440. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11441. }
  11442. }
  11443. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11444. import { Nullable } from "babylonjs/types";
  11445. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11446. import { Scene } from "babylonjs/scene";
  11447. module "babylonjs/Engines/thinEngine" {
  11448. interface ThinEngine {
  11449. /**
  11450. * Creates a raw texture
  11451. * @param data defines the data to store in the texture
  11452. * @param width defines the width of the texture
  11453. * @param height defines the height of the texture
  11454. * @param format defines the format of the data
  11455. * @param generateMipMaps defines if the engine should generate the mip levels
  11456. * @param invertY defines if data must be stored with Y axis inverted
  11457. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11458. * @param compression defines the compression used (null by default)
  11459. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11460. * @returns the raw texture inside an InternalTexture
  11461. */
  11462. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11463. /**
  11464. * Update a raw texture
  11465. * @param texture defines the texture to update
  11466. * @param data defines the data to store in the texture
  11467. * @param format defines the format of the data
  11468. * @param invertY defines if data must be stored with Y axis inverted
  11469. */
  11470. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11471. /**
  11472. * Update a raw texture
  11473. * @param texture defines the texture to update
  11474. * @param data defines the data to store in the texture
  11475. * @param format defines the format of the data
  11476. * @param invertY defines if data must be stored with Y axis inverted
  11477. * @param compression defines the compression used (null by default)
  11478. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11479. */
  11480. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11481. /**
  11482. * Creates a new raw cube texture
  11483. * @param data defines the array of data to use to create each face
  11484. * @param size defines the size of the textures
  11485. * @param format defines the format of the data
  11486. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11487. * @param generateMipMaps defines if the engine should generate the mip levels
  11488. * @param invertY defines if data must be stored with Y axis inverted
  11489. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11490. * @param compression defines the compression used (null by default)
  11491. * @returns the cube texture as an InternalTexture
  11492. */
  11493. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11494. /**
  11495. * Update a raw cube texture
  11496. * @param texture defines the texture to udpdate
  11497. * @param data defines the data to store
  11498. * @param format defines the data format
  11499. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11500. * @param invertY defines if data must be stored with Y axis inverted
  11501. */
  11502. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11503. /**
  11504. * Update a raw cube texture
  11505. * @param texture defines the texture to udpdate
  11506. * @param data defines the data to store
  11507. * @param format defines the data format
  11508. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11509. * @param invertY defines if data must be stored with Y axis inverted
  11510. * @param compression defines the compression used (null by default)
  11511. */
  11512. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11513. /**
  11514. * Update a raw cube texture
  11515. * @param texture defines the texture to udpdate
  11516. * @param data defines the data to store
  11517. * @param format defines the data format
  11518. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11519. * @param invertY defines if data must be stored with Y axis inverted
  11520. * @param compression defines the compression used (null by default)
  11521. * @param level defines which level of the texture to update
  11522. */
  11523. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11524. /**
  11525. * Creates a new raw cube texture from a specified url
  11526. * @param url defines the url where the data is located
  11527. * @param scene defines the current scene
  11528. * @param size defines the size of the textures
  11529. * @param format defines the format of the data
  11530. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11531. * @param noMipmap defines if the engine should avoid generating the mip levels
  11532. * @param callback defines a callback used to extract texture data from loaded data
  11533. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11534. * @param onLoad defines a callback called when texture is loaded
  11535. * @param onError defines a callback called if there is an error
  11536. * @returns the cube texture as an InternalTexture
  11537. */
  11538. 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;
  11539. /**
  11540. * Creates a new raw cube texture from a specified url
  11541. * @param url defines the url where the data is located
  11542. * @param scene defines the current scene
  11543. * @param size defines the size of the textures
  11544. * @param format defines the format of the data
  11545. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11546. * @param noMipmap defines if the engine should avoid generating the mip levels
  11547. * @param callback defines a callback used to extract texture data from loaded data
  11548. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11549. * @param onLoad defines a callback called when texture is loaded
  11550. * @param onError defines a callback called if there is an error
  11551. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11552. * @param invertY defines if data must be stored with Y axis inverted
  11553. * @returns the cube texture as an InternalTexture
  11554. */
  11555. 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;
  11556. /**
  11557. * Creates a new raw 3D texture
  11558. * @param data defines the data used to create the texture
  11559. * @param width defines the width of the texture
  11560. * @param height defines the height of the texture
  11561. * @param depth defines the depth of the texture
  11562. * @param format defines the format of the texture
  11563. * @param generateMipMaps defines if the engine must generate mip levels
  11564. * @param invertY defines if data must be stored with Y axis inverted
  11565. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11566. * @param compression defines the compressed used (can be null)
  11567. * @param textureType defines the compressed used (can be null)
  11568. * @returns a new raw 3D texture (stored in an InternalTexture)
  11569. */
  11570. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11571. /**
  11572. * Update a raw 3D texture
  11573. * @param texture defines the texture to update
  11574. * @param data defines the data to store
  11575. * @param format defines the data format
  11576. * @param invertY defines if data must be stored with Y axis inverted
  11577. */
  11578. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11579. /**
  11580. * Update a raw 3D texture
  11581. * @param texture defines the texture to update
  11582. * @param data defines the data to store
  11583. * @param format defines the data format
  11584. * @param invertY defines if data must be stored with Y axis inverted
  11585. * @param compression defines the used compression (can be null)
  11586. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11587. */
  11588. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11589. /**
  11590. * Creates a new raw 2D array texture
  11591. * @param data defines the data used to create the texture
  11592. * @param width defines the width of the texture
  11593. * @param height defines the height of the texture
  11594. * @param depth defines the number of layers of the texture
  11595. * @param format defines the format of the texture
  11596. * @param generateMipMaps defines if the engine must generate mip levels
  11597. * @param invertY defines if data must be stored with Y axis inverted
  11598. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11599. * @param compression defines the compressed used (can be null)
  11600. * @param textureType defines the compressed used (can be null)
  11601. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11602. */
  11603. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11604. /**
  11605. * Update a raw 2D array texture
  11606. * @param texture defines the texture to update
  11607. * @param data defines the data to store
  11608. * @param format defines the data format
  11609. * @param invertY defines if data must be stored with Y axis inverted
  11610. */
  11611. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11612. /**
  11613. * Update a raw 2D array texture
  11614. * @param texture defines the texture to update
  11615. * @param data defines the data to store
  11616. * @param format defines the data format
  11617. * @param invertY defines if data must be stored with Y axis inverted
  11618. * @param compression defines the used compression (can be null)
  11619. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11620. */
  11621. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11622. }
  11623. }
  11624. }
  11625. declare module "babylonjs/Materials/Textures/rawTexture" {
  11626. import { Scene } from "babylonjs/scene";
  11627. import { Texture } from "babylonjs/Materials/Textures/texture";
  11628. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11629. /**
  11630. * Raw texture can help creating a texture directly from an array of data.
  11631. * This can be super useful if you either get the data from an uncompressed source or
  11632. * if you wish to create your texture pixel by pixel.
  11633. */
  11634. export class RawTexture extends Texture {
  11635. /**
  11636. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11637. */
  11638. format: number;
  11639. /**
  11640. * Instantiates a new RawTexture.
  11641. * Raw texture can help creating a texture directly from an array of data.
  11642. * This can be super useful if you either get the data from an uncompressed source or
  11643. * if you wish to create your texture pixel by pixel.
  11644. * @param data define the array of data to use to create the texture
  11645. * @param width define the width of the texture
  11646. * @param height define the height of the texture
  11647. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11648. * @param scene define the scene the texture belongs to
  11649. * @param generateMipMaps define whether mip maps should be generated or not
  11650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11653. */
  11654. constructor(data: ArrayBufferView, width: number, height: number,
  11655. /**
  11656. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11657. */
  11658. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11659. /**
  11660. * Updates the texture underlying data.
  11661. * @param data Define the new data of the texture
  11662. */
  11663. update(data: ArrayBufferView): void;
  11664. /**
  11665. * Creates a luminance texture from some data.
  11666. * @param data Define the texture data
  11667. * @param width Define the width of the texture
  11668. * @param height Define the height of the texture
  11669. * @param scene Define the scene the texture belongs to
  11670. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11671. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11672. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11673. * @returns the luminance texture
  11674. */
  11675. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11676. /**
  11677. * Creates a luminance alpha texture from some data.
  11678. * @param data Define the texture data
  11679. * @param width Define the width of the texture
  11680. * @param height Define the height of the texture
  11681. * @param scene Define the scene the texture belongs to
  11682. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11683. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11684. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11685. * @returns the luminance alpha texture
  11686. */
  11687. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11688. /**
  11689. * Creates an alpha texture from some data.
  11690. * @param data Define the texture data
  11691. * @param width Define the width of the texture
  11692. * @param height Define the height of the texture
  11693. * @param scene Define the scene the texture belongs to
  11694. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11695. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11696. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11697. * @returns the alpha texture
  11698. */
  11699. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11700. /**
  11701. * Creates a RGB texture from some data.
  11702. * @param data Define the texture data
  11703. * @param width Define the width of the texture
  11704. * @param height Define the height of the texture
  11705. * @param scene Define the scene the texture belongs to
  11706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11709. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11710. * @returns the RGB alpha texture
  11711. */
  11712. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11713. /**
  11714. * Creates a RGBA texture from some data.
  11715. * @param data Define the texture data
  11716. * @param width Define the width of the texture
  11717. * @param height Define the height of the texture
  11718. * @param scene Define the scene the texture belongs to
  11719. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11720. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11721. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11722. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11723. * @returns the RGBA texture
  11724. */
  11725. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11726. /**
  11727. * Creates a R texture from some data.
  11728. * @param data Define the texture data
  11729. * @param width Define the width of the texture
  11730. * @param height Define the height of the texture
  11731. * @param scene Define the scene the texture belongs to
  11732. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11733. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11734. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11735. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11736. * @returns the R texture
  11737. */
  11738. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11739. }
  11740. }
  11741. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11742. import { Scene } from "babylonjs/scene";
  11743. import { ISceneComponent } from "babylonjs/sceneComponent";
  11744. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11745. module "babylonjs/abstractScene" {
  11746. interface AbstractScene {
  11747. /**
  11748. * The list of procedural textures added to the scene
  11749. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11750. */
  11751. proceduralTextures: Array<ProceduralTexture>;
  11752. }
  11753. }
  11754. /**
  11755. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11756. * in a given scene.
  11757. */
  11758. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11759. /**
  11760. * The component name helpfull to identify the component in the list of scene components.
  11761. */
  11762. readonly name: string;
  11763. /**
  11764. * The scene the component belongs to.
  11765. */
  11766. scene: Scene;
  11767. /**
  11768. * Creates a new instance of the component for the given scene
  11769. * @param scene Defines the scene to register the component in
  11770. */
  11771. constructor(scene: Scene);
  11772. /**
  11773. * Registers the component in a given scene
  11774. */
  11775. register(): void;
  11776. /**
  11777. * Rebuilds the elements related to this component in case of
  11778. * context lost for instance.
  11779. */
  11780. rebuild(): void;
  11781. /**
  11782. * Disposes the component and the associated ressources.
  11783. */
  11784. dispose(): void;
  11785. private _beforeClear;
  11786. }
  11787. }
  11788. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11789. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11790. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11791. module "babylonjs/Engines/thinEngine" {
  11792. interface ThinEngine {
  11793. /**
  11794. * Creates a new render target cube texture
  11795. * @param size defines the size of the texture
  11796. * @param options defines the options used to create the texture
  11797. * @returns a new render target cube texture stored in an InternalTexture
  11798. */
  11799. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11800. }
  11801. }
  11802. }
  11803. declare module "babylonjs/Shaders/procedural.vertex" {
  11804. /** @hidden */
  11805. export var proceduralVertexShader: {
  11806. name: string;
  11807. shader: string;
  11808. };
  11809. }
  11810. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11811. import { Observable } from "babylonjs/Misc/observable";
  11812. import { Nullable } from "babylonjs/types";
  11813. import { Scene } from "babylonjs/scene";
  11814. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11815. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11816. import { Effect } from "babylonjs/Materials/effect";
  11817. import { Texture } from "babylonjs/Materials/Textures/texture";
  11818. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11819. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11820. import "babylonjs/Shaders/procedural.vertex";
  11821. /**
  11822. * 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.
  11823. * This is the base class of any Procedural texture and contains most of the shareable code.
  11824. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11825. */
  11826. export class ProceduralTexture extends Texture {
  11827. isCube: boolean;
  11828. /**
  11829. * Define if the texture is enabled or not (disabled texture will not render)
  11830. */
  11831. isEnabled: boolean;
  11832. /**
  11833. * Define if the texture must be cleared before rendering (default is true)
  11834. */
  11835. autoClear: boolean;
  11836. /**
  11837. * Callback called when the texture is generated
  11838. */
  11839. onGenerated: () => void;
  11840. /**
  11841. * Event raised when the texture is generated
  11842. */
  11843. onGeneratedObservable: Observable<ProceduralTexture>;
  11844. /** @hidden */
  11845. _generateMipMaps: boolean;
  11846. /** @hidden **/
  11847. _effect: Effect;
  11848. /** @hidden */
  11849. _textures: {
  11850. [key: string]: Texture;
  11851. };
  11852. /** @hidden */
  11853. protected _fallbackTexture: Nullable<Texture>;
  11854. private _size;
  11855. private _currentRefreshId;
  11856. private _frameId;
  11857. private _refreshRate;
  11858. private _vertexBuffers;
  11859. private _indexBuffer;
  11860. private _uniforms;
  11861. private _samplers;
  11862. private _fragment;
  11863. private _floats;
  11864. private _ints;
  11865. private _floatsArrays;
  11866. private _colors3;
  11867. private _colors4;
  11868. private _vectors2;
  11869. private _vectors3;
  11870. private _matrices;
  11871. private _fallbackTextureUsed;
  11872. private _fullEngine;
  11873. private _cachedDefines;
  11874. private _contentUpdateId;
  11875. private _contentData;
  11876. /**
  11877. * Instantiates a new procedural texture.
  11878. * 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.
  11879. * This is the base class of any Procedural texture and contains most of the shareable code.
  11880. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11881. * @param name Define the name of the texture
  11882. * @param size Define the size of the texture to create
  11883. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11884. * @param scene Define the scene the texture belongs to
  11885. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11886. * @param generateMipMaps Define if the texture should creates mip maps or not
  11887. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11888. */
  11889. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11890. /**
  11891. * The effect that is created when initializing the post process.
  11892. * @returns The created effect corresponding the the postprocess.
  11893. */
  11894. getEffect(): Effect;
  11895. /**
  11896. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11897. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11898. */
  11899. getContent(): Nullable<ArrayBufferView>;
  11900. private _createIndexBuffer;
  11901. /** @hidden */
  11902. _rebuild(): void;
  11903. /**
  11904. * Resets the texture in order to recreate its associated resources.
  11905. * This can be called in case of context loss
  11906. */
  11907. reset(): void;
  11908. protected _getDefines(): string;
  11909. /**
  11910. * Is the texture ready to be used ? (rendered at least once)
  11911. * @returns true if ready, otherwise, false.
  11912. */
  11913. isReady(): boolean;
  11914. /**
  11915. * Resets the refresh counter of the texture and start bak from scratch.
  11916. * Could be useful to regenerate the texture if it is setup to render only once.
  11917. */
  11918. resetRefreshCounter(): void;
  11919. /**
  11920. * Set the fragment shader to use in order to render the texture.
  11921. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11922. */
  11923. setFragment(fragment: any): void;
  11924. /**
  11925. * Define the refresh rate of the texture or the rendering frequency.
  11926. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11927. */
  11928. get refreshRate(): number;
  11929. set refreshRate(value: number);
  11930. /** @hidden */
  11931. _shouldRender(): boolean;
  11932. /**
  11933. * Get the size the texture is rendering at.
  11934. * @returns the size (texture is always squared)
  11935. */
  11936. getRenderSize(): number;
  11937. /**
  11938. * Resize the texture to new value.
  11939. * @param size Define the new size the texture should have
  11940. * @param generateMipMaps Define whether the new texture should create mip maps
  11941. */
  11942. resize(size: number, generateMipMaps: boolean): void;
  11943. private _checkUniform;
  11944. /**
  11945. * Set a texture in the shader program used to render.
  11946. * @param name Define the name of the uniform samplers as defined in the shader
  11947. * @param texture Define the texture to bind to this sampler
  11948. * @return the texture itself allowing "fluent" like uniform updates
  11949. */
  11950. setTexture(name: string, texture: Texture): ProceduralTexture;
  11951. /**
  11952. * Set a float in the shader.
  11953. * @param name Define the name of the uniform as defined in the shader
  11954. * @param value Define the value to give to the uniform
  11955. * @return the texture itself allowing "fluent" like uniform updates
  11956. */
  11957. setFloat(name: string, value: number): ProceduralTexture;
  11958. /**
  11959. * Set a int in the shader.
  11960. * @param name Define the name of the uniform as defined in the shader
  11961. * @param value Define the value to give to the uniform
  11962. * @return the texture itself allowing "fluent" like uniform updates
  11963. */
  11964. setInt(name: string, value: number): ProceduralTexture;
  11965. /**
  11966. * Set an array of floats in the shader.
  11967. * @param name Define the name of the uniform as defined in the shader
  11968. * @param value Define the value to give to the uniform
  11969. * @return the texture itself allowing "fluent" like uniform updates
  11970. */
  11971. setFloats(name: string, value: number[]): ProceduralTexture;
  11972. /**
  11973. * Set a vec3 in the shader from a Color3.
  11974. * @param name Define the name of the uniform as defined in the shader
  11975. * @param value Define the value to give to the uniform
  11976. * @return the texture itself allowing "fluent" like uniform updates
  11977. */
  11978. setColor3(name: string, value: Color3): ProceduralTexture;
  11979. /**
  11980. * Set a vec4 in the shader from a Color4.
  11981. * @param name Define the name of the uniform as defined in the shader
  11982. * @param value Define the value to give to the uniform
  11983. * @return the texture itself allowing "fluent" like uniform updates
  11984. */
  11985. setColor4(name: string, value: Color4): ProceduralTexture;
  11986. /**
  11987. * Set a vec2 in the shader from a Vector2.
  11988. * @param name Define the name of the uniform as defined in the shader
  11989. * @param value Define the value to give to the uniform
  11990. * @return the texture itself allowing "fluent" like uniform updates
  11991. */
  11992. setVector2(name: string, value: Vector2): ProceduralTexture;
  11993. /**
  11994. * Set a vec3 in the shader from a Vector3.
  11995. * @param name Define the name of the uniform as defined in the shader
  11996. * @param value Define the value to give to the uniform
  11997. * @return the texture itself allowing "fluent" like uniform updates
  11998. */
  11999. setVector3(name: string, value: Vector3): ProceduralTexture;
  12000. /**
  12001. * Set a mat4 in the shader from a MAtrix.
  12002. * @param name Define the name of the uniform as defined in the shader
  12003. * @param value Define the value to give to the uniform
  12004. * @return the texture itself allowing "fluent" like uniform updates
  12005. */
  12006. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12007. /**
  12008. * Render the texture to its associated render target.
  12009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12010. */
  12011. render(useCameraPostProcess?: boolean): void;
  12012. /**
  12013. * Clone the texture.
  12014. * @returns the cloned texture
  12015. */
  12016. clone(): ProceduralTexture;
  12017. /**
  12018. * Dispose the texture and release its asoociated resources.
  12019. */
  12020. dispose(): void;
  12021. }
  12022. }
  12023. declare module "babylonjs/Particles/baseParticleSystem" {
  12024. import { Nullable } from "babylonjs/types";
  12025. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12026. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12027. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12028. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12029. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12030. import { Scene } from "babylonjs/scene";
  12031. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12032. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12033. import { Texture } from "babylonjs/Materials/Textures/texture";
  12034. import { Color4 } from "babylonjs/Maths/math.color";
  12035. import { Animation } from "babylonjs/Animations/animation";
  12036. /**
  12037. * This represents the base class for particle system in Babylon.
  12038. * 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.
  12039. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12040. * @example https://doc.babylonjs.com/babylon101/particles
  12041. */
  12042. export class BaseParticleSystem {
  12043. /**
  12044. * Source color is added to the destination color without alpha affecting the result
  12045. */
  12046. static BLENDMODE_ONEONE: number;
  12047. /**
  12048. * Blend current color and particle color using particle’s alpha
  12049. */
  12050. static BLENDMODE_STANDARD: number;
  12051. /**
  12052. * Add current color and particle color multiplied by particle’s alpha
  12053. */
  12054. static BLENDMODE_ADD: number;
  12055. /**
  12056. * Multiply current color with particle color
  12057. */
  12058. static BLENDMODE_MULTIPLY: number;
  12059. /**
  12060. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12061. */
  12062. static BLENDMODE_MULTIPLYADD: number;
  12063. /**
  12064. * List of animations used by the particle system.
  12065. */
  12066. animations: Animation[];
  12067. /**
  12068. * Gets or sets the unique id of the particle system
  12069. */
  12070. uniqueId: number;
  12071. /**
  12072. * The id of the Particle system.
  12073. */
  12074. id: string;
  12075. /**
  12076. * The friendly name of the Particle system.
  12077. */
  12078. name: string;
  12079. /**
  12080. * Snippet ID if the particle system was created from the snippet server
  12081. */
  12082. snippetId: string;
  12083. /**
  12084. * The rendering group used by the Particle system to chose when to render.
  12085. */
  12086. renderingGroupId: number;
  12087. /**
  12088. * The emitter represents the Mesh or position we are attaching the particle system to.
  12089. */
  12090. emitter: Nullable<AbstractMesh | Vector3>;
  12091. /**
  12092. * The maximum number of particles to emit per frame
  12093. */
  12094. emitRate: number;
  12095. /**
  12096. * If you want to launch only a few particles at once, that can be done, as well.
  12097. */
  12098. manualEmitCount: number;
  12099. /**
  12100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12101. */
  12102. updateSpeed: number;
  12103. /**
  12104. * The amount of time the particle system is running (depends of the overall update speed).
  12105. */
  12106. targetStopDuration: number;
  12107. /**
  12108. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12109. */
  12110. disposeOnStop: boolean;
  12111. /**
  12112. * Minimum power of emitting particles.
  12113. */
  12114. minEmitPower: number;
  12115. /**
  12116. * Maximum power of emitting particles.
  12117. */
  12118. maxEmitPower: number;
  12119. /**
  12120. * Minimum life time of emitting particles.
  12121. */
  12122. minLifeTime: number;
  12123. /**
  12124. * Maximum life time of emitting particles.
  12125. */
  12126. maxLifeTime: number;
  12127. /**
  12128. * Minimum Size of emitting particles.
  12129. */
  12130. minSize: number;
  12131. /**
  12132. * Maximum Size of emitting particles.
  12133. */
  12134. maxSize: number;
  12135. /**
  12136. * Minimum scale of emitting particles on X axis.
  12137. */
  12138. minScaleX: number;
  12139. /**
  12140. * Maximum scale of emitting particles on X axis.
  12141. */
  12142. maxScaleX: number;
  12143. /**
  12144. * Minimum scale of emitting particles on Y axis.
  12145. */
  12146. minScaleY: number;
  12147. /**
  12148. * Maximum scale of emitting particles on Y axis.
  12149. */
  12150. maxScaleY: number;
  12151. /**
  12152. * Gets or sets the minimal initial rotation in radians.
  12153. */
  12154. minInitialRotation: number;
  12155. /**
  12156. * Gets or sets the maximal initial rotation in radians.
  12157. */
  12158. maxInitialRotation: number;
  12159. /**
  12160. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12161. */
  12162. minAngularSpeed: number;
  12163. /**
  12164. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12165. */
  12166. maxAngularSpeed: number;
  12167. /**
  12168. * The texture used to render each particle. (this can be a spritesheet)
  12169. */
  12170. particleTexture: Nullable<Texture>;
  12171. /**
  12172. * The layer mask we are rendering the particles through.
  12173. */
  12174. layerMask: number;
  12175. /**
  12176. * This can help using your own shader to render the particle system.
  12177. * The according effect will be created
  12178. */
  12179. customShader: any;
  12180. /**
  12181. * By default particle system starts as soon as they are created. This prevents the
  12182. * automatic start to happen and let you decide when to start emitting particles.
  12183. */
  12184. preventAutoStart: boolean;
  12185. private _noiseTexture;
  12186. /**
  12187. * Gets or sets a texture used to add random noise to particle positions
  12188. */
  12189. get noiseTexture(): Nullable<ProceduralTexture>;
  12190. set noiseTexture(value: Nullable<ProceduralTexture>);
  12191. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12192. noiseStrength: Vector3;
  12193. /**
  12194. * Callback triggered when the particle animation is ending.
  12195. */
  12196. onAnimationEnd: Nullable<() => void>;
  12197. /**
  12198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12199. */
  12200. blendMode: number;
  12201. /**
  12202. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12203. * to override the particles.
  12204. */
  12205. forceDepthWrite: boolean;
  12206. /** 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 */
  12207. preWarmCycles: number;
  12208. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12209. preWarmStepOffset: number;
  12210. /**
  12211. * 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)
  12212. */
  12213. spriteCellChangeSpeed: number;
  12214. /**
  12215. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12216. */
  12217. startSpriteCellID: number;
  12218. /**
  12219. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12220. */
  12221. endSpriteCellID: number;
  12222. /**
  12223. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12224. */
  12225. spriteCellWidth: number;
  12226. /**
  12227. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12228. */
  12229. spriteCellHeight: number;
  12230. /**
  12231. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12232. */
  12233. spriteRandomStartCell: boolean;
  12234. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12235. translationPivot: Vector2;
  12236. /** @hidden */
  12237. protected _isAnimationSheetEnabled: boolean;
  12238. /**
  12239. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12240. */
  12241. beginAnimationOnStart: boolean;
  12242. /**
  12243. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12244. */
  12245. beginAnimationFrom: number;
  12246. /**
  12247. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12248. */
  12249. beginAnimationTo: number;
  12250. /**
  12251. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12252. */
  12253. beginAnimationLoop: boolean;
  12254. /**
  12255. * Gets or sets a world offset applied to all particles
  12256. */
  12257. worldOffset: Vector3;
  12258. /**
  12259. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12260. */
  12261. get isAnimationSheetEnabled(): boolean;
  12262. set isAnimationSheetEnabled(value: boolean);
  12263. /**
  12264. * Get hosting scene
  12265. * @returns the scene
  12266. */
  12267. getScene(): Scene;
  12268. /**
  12269. * You can use gravity if you want to give an orientation to your particles.
  12270. */
  12271. gravity: Vector3;
  12272. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12273. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12274. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12275. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12276. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12277. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12278. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12279. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12280. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12281. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12282. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12283. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12284. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12285. /**
  12286. * Defines the delay in milliseconds before starting the system (0 by default)
  12287. */
  12288. startDelay: number;
  12289. /**
  12290. * Gets the current list of drag gradients.
  12291. * You must use addDragGradient and removeDragGradient to udpate this list
  12292. * @returns the list of drag gradients
  12293. */
  12294. getDragGradients(): Nullable<Array<FactorGradient>>;
  12295. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12296. limitVelocityDamping: number;
  12297. /**
  12298. * Gets the current list of limit velocity gradients.
  12299. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12300. * @returns the list of limit velocity gradients
  12301. */
  12302. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12303. /**
  12304. * Gets the current list of color gradients.
  12305. * You must use addColorGradient and removeColorGradient to udpate this list
  12306. * @returns the list of color gradients
  12307. */
  12308. getColorGradients(): Nullable<Array<ColorGradient>>;
  12309. /**
  12310. * Gets the current list of size gradients.
  12311. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12312. * @returns the list of size gradients
  12313. */
  12314. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12315. /**
  12316. * Gets the current list of color remap gradients.
  12317. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12318. * @returns the list of color remap gradients
  12319. */
  12320. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12321. /**
  12322. * Gets the current list of alpha remap gradients.
  12323. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12324. * @returns the list of alpha remap gradients
  12325. */
  12326. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12327. /**
  12328. * Gets the current list of life time gradients.
  12329. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12330. * @returns the list of life time gradients
  12331. */
  12332. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12333. /**
  12334. * Gets the current list of angular speed gradients.
  12335. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12336. * @returns the list of angular speed gradients
  12337. */
  12338. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12339. /**
  12340. * Gets the current list of velocity gradients.
  12341. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12342. * @returns the list of velocity gradients
  12343. */
  12344. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12345. /**
  12346. * Gets the current list of start size gradients.
  12347. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12348. * @returns the list of start size gradients
  12349. */
  12350. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12351. /**
  12352. * Gets the current list of emit rate gradients.
  12353. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12354. * @returns the list of emit rate gradients
  12355. */
  12356. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12357. /**
  12358. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12359. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12360. */
  12361. get direction1(): Vector3;
  12362. set direction1(value: Vector3);
  12363. /**
  12364. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12365. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12366. */
  12367. get direction2(): Vector3;
  12368. set direction2(value: Vector3);
  12369. /**
  12370. * 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.
  12371. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12372. */
  12373. get minEmitBox(): Vector3;
  12374. set minEmitBox(value: Vector3);
  12375. /**
  12376. * 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.
  12377. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12378. */
  12379. get maxEmitBox(): Vector3;
  12380. set maxEmitBox(value: Vector3);
  12381. /**
  12382. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12383. */
  12384. color1: Color4;
  12385. /**
  12386. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12387. */
  12388. color2: Color4;
  12389. /**
  12390. * Color the particle will have at the end of its lifetime
  12391. */
  12392. colorDead: Color4;
  12393. /**
  12394. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12395. */
  12396. textureMask: Color4;
  12397. /**
  12398. * The particle emitter type defines the emitter used by the particle system.
  12399. * It can be for example box, sphere, or cone...
  12400. */
  12401. particleEmitterType: IParticleEmitterType;
  12402. /** @hidden */
  12403. _isSubEmitter: boolean;
  12404. /**
  12405. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12406. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12407. */
  12408. billboardMode: number;
  12409. protected _isBillboardBased: boolean;
  12410. /**
  12411. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12412. */
  12413. get isBillboardBased(): boolean;
  12414. set isBillboardBased(value: boolean);
  12415. /**
  12416. * The scene the particle system belongs to.
  12417. */
  12418. protected _scene: Scene;
  12419. /**
  12420. * Local cache of defines for image processing.
  12421. */
  12422. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12423. /**
  12424. * Default configuration related to image processing available in the standard Material.
  12425. */
  12426. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  12427. /**
  12428. * Gets the image processing configuration used either in this material.
  12429. */
  12430. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  12431. /**
  12432. * Sets the Default image processing configuration used either in the this material.
  12433. *
  12434. * If sets to null, the scene one is in use.
  12435. */
  12436. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  12437. /**
  12438. * Attaches a new image processing configuration to the Standard Material.
  12439. * @param configuration
  12440. */
  12441. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12442. /** @hidden */
  12443. protected _reset(): void;
  12444. /** @hidden */
  12445. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12446. /**
  12447. * Instantiates a particle system.
  12448. * 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.
  12449. * @param name The name of the particle system
  12450. */
  12451. constructor(name: string);
  12452. /**
  12453. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12454. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12455. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12456. * @returns the emitter
  12457. */
  12458. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12459. /**
  12460. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12461. * @param radius The radius of the hemisphere to emit from
  12462. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12463. * @returns the emitter
  12464. */
  12465. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12466. /**
  12467. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12468. * @param radius The radius of the sphere to emit from
  12469. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12470. * @returns the emitter
  12471. */
  12472. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12473. /**
  12474. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12475. * @param radius The radius of the sphere to emit from
  12476. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12477. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12478. * @returns the emitter
  12479. */
  12480. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12481. /**
  12482. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12483. * @param radius The radius of the emission cylinder
  12484. * @param height The height of the emission cylinder
  12485. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12486. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12487. * @returns the emitter
  12488. */
  12489. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12490. /**
  12491. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12492. * @param radius The radius of the cylinder to emit from
  12493. * @param height The height of the emission cylinder
  12494. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12495. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12496. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12497. * @returns the emitter
  12498. */
  12499. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12500. /**
  12501. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12502. * @param radius The radius of the cone to emit from
  12503. * @param angle The base angle of the cone
  12504. * @returns the emitter
  12505. */
  12506. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12507. /**
  12508. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12509. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12510. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12511. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12512. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12513. * @returns the emitter
  12514. */
  12515. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12516. }
  12517. }
  12518. declare module "babylonjs/Particles/subEmitter" {
  12519. import { Scene } from "babylonjs/scene";
  12520. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12521. /**
  12522. * Type of sub emitter
  12523. */
  12524. export enum SubEmitterType {
  12525. /**
  12526. * Attached to the particle over it's lifetime
  12527. */
  12528. ATTACHED = 0,
  12529. /**
  12530. * Created when the particle dies
  12531. */
  12532. END = 1
  12533. }
  12534. /**
  12535. * Sub emitter class used to emit particles from an existing particle
  12536. */
  12537. export class SubEmitter {
  12538. /**
  12539. * the particle system to be used by the sub emitter
  12540. */
  12541. particleSystem: ParticleSystem;
  12542. /**
  12543. * Type of the submitter (Default: END)
  12544. */
  12545. type: SubEmitterType;
  12546. /**
  12547. * 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)
  12548. * Note: This only is supported when using an emitter of type Mesh
  12549. */
  12550. inheritDirection: boolean;
  12551. /**
  12552. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12553. */
  12554. inheritedVelocityAmount: number;
  12555. /**
  12556. * Creates a sub emitter
  12557. * @param particleSystem the particle system to be used by the sub emitter
  12558. */
  12559. constructor(
  12560. /**
  12561. * the particle system to be used by the sub emitter
  12562. */
  12563. particleSystem: ParticleSystem);
  12564. /**
  12565. * Clones the sub emitter
  12566. * @returns the cloned sub emitter
  12567. */
  12568. clone(): SubEmitter;
  12569. /**
  12570. * Serialize current object to a JSON object
  12571. * @returns the serialized object
  12572. */
  12573. serialize(): any;
  12574. /** @hidden */
  12575. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  12576. /**
  12577. * Creates a new SubEmitter from a serialized JSON version
  12578. * @param serializationObject defines the JSON object to read from
  12579. * @param scene defines the hosting scene
  12580. * @param rootUrl defines the rootUrl for data loading
  12581. * @returns a new SubEmitter
  12582. */
  12583. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  12584. /** Release associated resources */
  12585. dispose(): void;
  12586. }
  12587. }
  12588. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12589. /** @hidden */
  12590. export var imageProcessingDeclaration: {
  12591. name: string;
  12592. shader: string;
  12593. };
  12594. }
  12595. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12596. /** @hidden */
  12597. export var imageProcessingFunctions: {
  12598. name: string;
  12599. shader: string;
  12600. };
  12601. }
  12602. declare module "babylonjs/Shaders/particles.fragment" {
  12603. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12604. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12605. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12606. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12607. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12608. /** @hidden */
  12609. export var particlesPixelShader: {
  12610. name: string;
  12611. shader: string;
  12612. };
  12613. }
  12614. declare module "babylonjs/Shaders/particles.vertex" {
  12615. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12616. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12617. /** @hidden */
  12618. export var particlesVertexShader: {
  12619. name: string;
  12620. shader: string;
  12621. };
  12622. }
  12623. declare module "babylonjs/Particles/particleSystem" {
  12624. import { Nullable } from "babylonjs/types";
  12625. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12626. import { Observable } from "babylonjs/Misc/observable";
  12627. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12628. import { Effect } from "babylonjs/Materials/effect";
  12629. import { Scene, IDisposable } from "babylonjs/scene";
  12630. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12631. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12632. import { Particle } from "babylonjs/Particles/particle";
  12633. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12634. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12635. import "babylonjs/Shaders/particles.fragment";
  12636. import "babylonjs/Shaders/particles.vertex";
  12637. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12638. /**
  12639. * This represents a particle system in Babylon.
  12640. * 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.
  12641. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12642. * @example https://doc.babylonjs.com/babylon101/particles
  12643. */
  12644. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12645. /**
  12646. * Billboard mode will only apply to Y axis
  12647. */
  12648. static readonly BILLBOARDMODE_Y: number;
  12649. /**
  12650. * Billboard mode will apply to all axes
  12651. */
  12652. static readonly BILLBOARDMODE_ALL: number;
  12653. /**
  12654. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12655. */
  12656. static readonly BILLBOARDMODE_STRETCHED: number;
  12657. /**
  12658. * This function can be defined to provide custom update for active particles.
  12659. * This function will be called instead of regular update (age, position, color, etc.).
  12660. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12661. */
  12662. updateFunction: (particles: Particle[]) => void;
  12663. private _emitterWorldMatrix;
  12664. /**
  12665. * This function can be defined to specify initial direction for every new particle.
  12666. * It by default use the emitterType defined function
  12667. */
  12668. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12669. /**
  12670. * This function can be defined to specify initial position for every new particle.
  12671. * It by default use the emitterType defined function
  12672. */
  12673. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12674. /**
  12675. * @hidden
  12676. */
  12677. _inheritedVelocityOffset: Vector3;
  12678. /**
  12679. * An event triggered when the system is disposed
  12680. */
  12681. onDisposeObservable: Observable<IParticleSystem>;
  12682. private _onDisposeObserver;
  12683. /**
  12684. * Sets a callback that will be triggered when the system is disposed
  12685. */
  12686. set onDispose(callback: () => void);
  12687. private _particles;
  12688. private _epsilon;
  12689. private _capacity;
  12690. private _stockParticles;
  12691. private _newPartsExcess;
  12692. private _vertexData;
  12693. private _vertexBuffer;
  12694. private _vertexBuffers;
  12695. private _spriteBuffer;
  12696. private _indexBuffer;
  12697. private _effect;
  12698. private _customEffect;
  12699. private _cachedDefines;
  12700. private _scaledColorStep;
  12701. private _colorDiff;
  12702. private _scaledDirection;
  12703. private _scaledGravity;
  12704. private _currentRenderId;
  12705. private _alive;
  12706. private _useInstancing;
  12707. private _started;
  12708. private _stopped;
  12709. private _actualFrame;
  12710. private _scaledUpdateSpeed;
  12711. private _vertexBufferSize;
  12712. /** @hidden */
  12713. _currentEmitRateGradient: Nullable<FactorGradient>;
  12714. /** @hidden */
  12715. _currentEmitRate1: number;
  12716. /** @hidden */
  12717. _currentEmitRate2: number;
  12718. /** @hidden */
  12719. _currentStartSizeGradient: Nullable<FactorGradient>;
  12720. /** @hidden */
  12721. _currentStartSize1: number;
  12722. /** @hidden */
  12723. _currentStartSize2: number;
  12724. private readonly _rawTextureWidth;
  12725. private _rampGradientsTexture;
  12726. private _useRampGradients;
  12727. /** Gets or sets a boolean indicating that ramp gradients must be used
  12728. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12729. */
  12730. get useRampGradients(): boolean;
  12731. set useRampGradients(value: boolean);
  12732. /**
  12733. * 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.
  12734. * 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: [])
  12735. */
  12736. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12737. private _subEmitters;
  12738. /**
  12739. * @hidden
  12740. * If the particle systems emitter should be disposed when the particle system is disposed
  12741. */
  12742. _disposeEmitterOnDispose: boolean;
  12743. /**
  12744. * The current active Sub-systems, this property is used by the root particle system only.
  12745. */
  12746. activeSubSystems: Array<ParticleSystem>;
  12747. /**
  12748. * Specifies if the particles are updated in emitter local space or world space
  12749. */
  12750. isLocal: boolean;
  12751. private _rootParticleSystem;
  12752. /**
  12753. * Gets the current list of active particles
  12754. */
  12755. get particles(): Particle[];
  12756. /**
  12757. * Gets the number of particles active at the same time.
  12758. * @returns The number of active particles.
  12759. */
  12760. getActiveCount(): number;
  12761. /**
  12762. * Returns the string "ParticleSystem"
  12763. * @returns a string containing the class name
  12764. */
  12765. getClassName(): string;
  12766. /**
  12767. * Gets a boolean indicating that the system is stopping
  12768. * @returns true if the system is currently stopping
  12769. */
  12770. isStopping(): boolean;
  12771. /**
  12772. * Gets the custom effect used to render the particles
  12773. * @param blendMode Blend mode for which the effect should be retrieved
  12774. * @returns The effect
  12775. */
  12776. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12777. /**
  12778. * Sets the custom effect used to render the particles
  12779. * @param effect The effect to set
  12780. * @param blendMode Blend mode for which the effect should be set
  12781. */
  12782. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12783. /** @hidden */
  12784. private _onBeforeDrawParticlesObservable;
  12785. /**
  12786. * Observable that will be called just before the particles are drawn
  12787. */
  12788. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12789. /**
  12790. * Gets the name of the particle vertex shader
  12791. */
  12792. get vertexShaderName(): string;
  12793. /**
  12794. * Instantiates a particle system.
  12795. * 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.
  12796. * @param name The name of the particle system
  12797. * @param capacity The max number of particles alive at the same time
  12798. * @param scene The scene the particle system belongs to
  12799. * @param customEffect a custom effect used to change the way particles are rendered by default
  12800. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12801. * @param epsilon Offset used to render the particles
  12802. */
  12803. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12804. private _addFactorGradient;
  12805. private _removeFactorGradient;
  12806. /**
  12807. * Adds a new life time gradient
  12808. * @param gradient defines the gradient to use (between 0 and 1)
  12809. * @param factor defines the life time factor to affect to the specified gradient
  12810. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12811. * @returns the current particle system
  12812. */
  12813. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12814. /**
  12815. * Remove a specific life time gradient
  12816. * @param gradient defines the gradient to remove
  12817. * @returns the current particle system
  12818. */
  12819. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12820. /**
  12821. * Adds a new size gradient
  12822. * @param gradient defines the gradient to use (between 0 and 1)
  12823. * @param factor defines the size factor to affect to the specified gradient
  12824. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12825. * @returns the current particle system
  12826. */
  12827. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12828. /**
  12829. * Remove a specific size gradient
  12830. * @param gradient defines the gradient to remove
  12831. * @returns the current particle system
  12832. */
  12833. removeSizeGradient(gradient: number): IParticleSystem;
  12834. /**
  12835. * Adds a new color remap gradient
  12836. * @param gradient defines the gradient to use (between 0 and 1)
  12837. * @param min defines the color remap minimal range
  12838. * @param max defines the color remap maximal range
  12839. * @returns the current particle system
  12840. */
  12841. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12842. /**
  12843. * Remove a specific color remap gradient
  12844. * @param gradient defines the gradient to remove
  12845. * @returns the current particle system
  12846. */
  12847. removeColorRemapGradient(gradient: number): IParticleSystem;
  12848. /**
  12849. * Adds a new alpha remap gradient
  12850. * @param gradient defines the gradient to use (between 0 and 1)
  12851. * @param min defines the alpha remap minimal range
  12852. * @param max defines the alpha remap maximal range
  12853. * @returns the current particle system
  12854. */
  12855. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12856. /**
  12857. * Remove a specific alpha remap gradient
  12858. * @param gradient defines the gradient to remove
  12859. * @returns the current particle system
  12860. */
  12861. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12862. /**
  12863. * Adds a new angular speed gradient
  12864. * @param gradient defines the gradient to use (between 0 and 1)
  12865. * @param factor defines the angular speed to affect to the specified gradient
  12866. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12867. * @returns the current particle system
  12868. */
  12869. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12870. /**
  12871. * Remove a specific angular speed gradient
  12872. * @param gradient defines the gradient to remove
  12873. * @returns the current particle system
  12874. */
  12875. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12876. /**
  12877. * Adds a new velocity gradient
  12878. * @param gradient defines the gradient to use (between 0 and 1)
  12879. * @param factor defines the velocity to affect to the specified gradient
  12880. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12881. * @returns the current particle system
  12882. */
  12883. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12884. /**
  12885. * Remove a specific velocity gradient
  12886. * @param gradient defines the gradient to remove
  12887. * @returns the current particle system
  12888. */
  12889. removeVelocityGradient(gradient: number): IParticleSystem;
  12890. /**
  12891. * Adds a new limit velocity gradient
  12892. * @param gradient defines the gradient to use (between 0 and 1)
  12893. * @param factor defines the limit velocity value to affect to the specified gradient
  12894. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12895. * @returns the current particle system
  12896. */
  12897. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12898. /**
  12899. * Remove a specific limit velocity gradient
  12900. * @param gradient defines the gradient to remove
  12901. * @returns the current particle system
  12902. */
  12903. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12904. /**
  12905. * Adds a new drag gradient
  12906. * @param gradient defines the gradient to use (between 0 and 1)
  12907. * @param factor defines the drag value to affect to the specified gradient
  12908. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12909. * @returns the current particle system
  12910. */
  12911. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12912. /**
  12913. * Remove a specific drag gradient
  12914. * @param gradient defines the gradient to remove
  12915. * @returns the current particle system
  12916. */
  12917. removeDragGradient(gradient: number): IParticleSystem;
  12918. /**
  12919. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12920. * @param gradient defines the gradient to use (between 0 and 1)
  12921. * @param factor defines the emit rate value to affect to the specified gradient
  12922. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12923. * @returns the current particle system
  12924. */
  12925. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12926. /**
  12927. * Remove a specific emit rate gradient
  12928. * @param gradient defines the gradient to remove
  12929. * @returns the current particle system
  12930. */
  12931. removeEmitRateGradient(gradient: number): IParticleSystem;
  12932. /**
  12933. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12934. * @param gradient defines the gradient to use (between 0 and 1)
  12935. * @param factor defines the start size value to affect to the specified gradient
  12936. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12937. * @returns the current particle system
  12938. */
  12939. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12940. /**
  12941. * Remove a specific start size gradient
  12942. * @param gradient defines the gradient to remove
  12943. * @returns the current particle system
  12944. */
  12945. removeStartSizeGradient(gradient: number): IParticleSystem;
  12946. private _createRampGradientTexture;
  12947. /**
  12948. * Gets the current list of ramp gradients.
  12949. * You must use addRampGradient and removeRampGradient to udpate this list
  12950. * @returns the list of ramp gradients
  12951. */
  12952. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12953. /** Force the system to rebuild all gradients that need to be resync */
  12954. forceRefreshGradients(): void;
  12955. private _syncRampGradientTexture;
  12956. /**
  12957. * Adds a new ramp gradient used to remap particle colors
  12958. * @param gradient defines the gradient to use (between 0 and 1)
  12959. * @param color defines the color to affect to the specified gradient
  12960. * @returns the current particle system
  12961. */
  12962. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12963. /**
  12964. * Remove a specific ramp gradient
  12965. * @param gradient defines the gradient to remove
  12966. * @returns the current particle system
  12967. */
  12968. removeRampGradient(gradient: number): ParticleSystem;
  12969. /**
  12970. * Adds a new color gradient
  12971. * @param gradient defines the gradient to use (between 0 and 1)
  12972. * @param color1 defines the color to affect to the specified gradient
  12973. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12974. * @returns this particle system
  12975. */
  12976. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12977. /**
  12978. * Remove a specific color gradient
  12979. * @param gradient defines the gradient to remove
  12980. * @returns this particle system
  12981. */
  12982. removeColorGradient(gradient: number): IParticleSystem;
  12983. private _fetchR;
  12984. protected _reset(): void;
  12985. private _resetEffect;
  12986. private _createVertexBuffers;
  12987. private _createIndexBuffer;
  12988. /**
  12989. * Gets the maximum number of particles active at the same time.
  12990. * @returns The max number of active particles.
  12991. */
  12992. getCapacity(): number;
  12993. /**
  12994. * Gets whether there are still active particles in the system.
  12995. * @returns True if it is alive, otherwise false.
  12996. */
  12997. isAlive(): boolean;
  12998. /**
  12999. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13000. * @returns True if it has been started, otherwise false.
  13001. */
  13002. isStarted(): boolean;
  13003. private _prepareSubEmitterInternalArray;
  13004. /**
  13005. * Starts the particle system and begins to emit
  13006. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13007. */
  13008. start(delay?: number): void;
  13009. /**
  13010. * Stops the particle system.
  13011. * @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.
  13012. */
  13013. stop(stopSubEmitters?: boolean): void;
  13014. /**
  13015. * Remove all active particles
  13016. */
  13017. reset(): void;
  13018. /**
  13019. * @hidden (for internal use only)
  13020. */
  13021. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13022. /**
  13023. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13024. * Its lifetime will start back at 0.
  13025. */
  13026. recycleParticle: (particle: Particle) => void;
  13027. private _stopSubEmitters;
  13028. private _createParticle;
  13029. private _removeFromRoot;
  13030. private _emitFromParticle;
  13031. private _update;
  13032. /** @hidden */
  13033. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13034. /** @hidden */
  13035. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13036. /**
  13037. * Fill the defines array according to the current settings of the particle system
  13038. * @param defines Array to be updated
  13039. * @param blendMode blend mode to take into account when updating the array
  13040. */
  13041. fillDefines(defines: Array<string>, blendMode: number): void;
  13042. /**
  13043. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13044. * @param uniforms Uniforms array to fill
  13045. * @param attributes Attributes array to fill
  13046. * @param samplers Samplers array to fill
  13047. */
  13048. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13049. /** @hidden */
  13050. private _getEffect;
  13051. /**
  13052. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13053. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13054. */
  13055. animate(preWarmOnly?: boolean): void;
  13056. private _appendParticleVertices;
  13057. /**
  13058. * Rebuilds the particle system.
  13059. */
  13060. rebuild(): void;
  13061. /**
  13062. * Is this system ready to be used/rendered
  13063. * @return true if the system is ready
  13064. */
  13065. isReady(): boolean;
  13066. private _render;
  13067. /**
  13068. * Renders the particle system in its current state.
  13069. * @returns the current number of particles
  13070. */
  13071. render(): number;
  13072. /**
  13073. * Disposes the particle system and free the associated resources
  13074. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13075. */
  13076. dispose(disposeTexture?: boolean): void;
  13077. /**
  13078. * Clones the particle system.
  13079. * @param name The name of the cloned object
  13080. * @param newEmitter The new emitter to use
  13081. * @returns the cloned particle system
  13082. */
  13083. clone(name: string, newEmitter: any): ParticleSystem;
  13084. /**
  13085. * Serializes the particle system to a JSON object
  13086. * @param serializeTexture defines if the texture must be serialized as well
  13087. * @returns the JSON object
  13088. */
  13089. serialize(serializeTexture?: boolean): any;
  13090. /** @hidden */
  13091. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13092. /** @hidden */
  13093. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  13094. /**
  13095. * Parses a JSON object to create a particle system.
  13096. * @param parsedParticleSystem The JSON object to parse
  13097. * @param scene The scene to create the particle system in
  13098. * @param rootUrl The root url to use to load external dependencies like texture
  13099. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13100. * @returns the Parsed particle system
  13101. */
  13102. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13103. }
  13104. }
  13105. declare module "babylonjs/Particles/particle" {
  13106. import { Nullable } from "babylonjs/types";
  13107. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13108. import { Color4 } from "babylonjs/Maths/math.color";
  13109. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13110. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13111. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13112. /**
  13113. * A particle represents one of the element emitted by a particle system.
  13114. * This is mainly define by its coordinates, direction, velocity and age.
  13115. */
  13116. export class Particle {
  13117. /**
  13118. * The particle system the particle belongs to.
  13119. */
  13120. particleSystem: ParticleSystem;
  13121. private static _Count;
  13122. /**
  13123. * Unique ID of the particle
  13124. */
  13125. id: number;
  13126. /**
  13127. * The world position of the particle in the scene.
  13128. */
  13129. position: Vector3;
  13130. /**
  13131. * The world direction of the particle in the scene.
  13132. */
  13133. direction: Vector3;
  13134. /**
  13135. * The color of the particle.
  13136. */
  13137. color: Color4;
  13138. /**
  13139. * The color change of the particle per step.
  13140. */
  13141. colorStep: Color4;
  13142. /**
  13143. * Defines how long will the life of the particle be.
  13144. */
  13145. lifeTime: number;
  13146. /**
  13147. * The current age of the particle.
  13148. */
  13149. age: number;
  13150. /**
  13151. * The current size of the particle.
  13152. */
  13153. size: number;
  13154. /**
  13155. * The current scale of the particle.
  13156. */
  13157. scale: Vector2;
  13158. /**
  13159. * The current angle of the particle.
  13160. */
  13161. angle: number;
  13162. /**
  13163. * Defines how fast is the angle changing.
  13164. */
  13165. angularSpeed: number;
  13166. /**
  13167. * Defines the cell index used by the particle to be rendered from a sprite.
  13168. */
  13169. cellIndex: number;
  13170. /**
  13171. * The information required to support color remapping
  13172. */
  13173. remapData: Vector4;
  13174. /** @hidden */
  13175. _randomCellOffset?: number;
  13176. /** @hidden */
  13177. _initialDirection: Nullable<Vector3>;
  13178. /** @hidden */
  13179. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13180. /** @hidden */
  13181. _initialStartSpriteCellID: number;
  13182. /** @hidden */
  13183. _initialEndSpriteCellID: number;
  13184. /** @hidden */
  13185. _currentColorGradient: Nullable<ColorGradient>;
  13186. /** @hidden */
  13187. _currentColor1: Color4;
  13188. /** @hidden */
  13189. _currentColor2: Color4;
  13190. /** @hidden */
  13191. _currentSizeGradient: Nullable<FactorGradient>;
  13192. /** @hidden */
  13193. _currentSize1: number;
  13194. /** @hidden */
  13195. _currentSize2: number;
  13196. /** @hidden */
  13197. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13198. /** @hidden */
  13199. _currentAngularSpeed1: number;
  13200. /** @hidden */
  13201. _currentAngularSpeed2: number;
  13202. /** @hidden */
  13203. _currentVelocityGradient: Nullable<FactorGradient>;
  13204. /** @hidden */
  13205. _currentVelocity1: number;
  13206. /** @hidden */
  13207. _currentVelocity2: number;
  13208. /** @hidden */
  13209. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13210. /** @hidden */
  13211. _currentLimitVelocity1: number;
  13212. /** @hidden */
  13213. _currentLimitVelocity2: number;
  13214. /** @hidden */
  13215. _currentDragGradient: Nullable<FactorGradient>;
  13216. /** @hidden */
  13217. _currentDrag1: number;
  13218. /** @hidden */
  13219. _currentDrag2: number;
  13220. /** @hidden */
  13221. _randomNoiseCoordinates1: Vector3;
  13222. /** @hidden */
  13223. _randomNoiseCoordinates2: Vector3;
  13224. /** @hidden */
  13225. _localPosition?: Vector3;
  13226. /**
  13227. * Creates a new instance Particle
  13228. * @param particleSystem the particle system the particle belongs to
  13229. */
  13230. constructor(
  13231. /**
  13232. * The particle system the particle belongs to.
  13233. */
  13234. particleSystem: ParticleSystem);
  13235. private updateCellInfoFromSystem;
  13236. /**
  13237. * Defines how the sprite cell index is updated for the particle
  13238. */
  13239. updateCellIndex(): void;
  13240. /** @hidden */
  13241. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13242. /** @hidden */
  13243. _inheritParticleInfoToSubEmitters(): void;
  13244. /** @hidden */
  13245. _reset(): void;
  13246. /**
  13247. * Copy the properties of particle to another one.
  13248. * @param other the particle to copy the information to.
  13249. */
  13250. copyTo(other: Particle): void;
  13251. }
  13252. }
  13253. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13254. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13255. import { Effect } from "babylonjs/Materials/effect";
  13256. import { Particle } from "babylonjs/Particles/particle";
  13257. import { Scene } from "babylonjs/scene";
  13258. /**
  13259. * Particle emitter represents a volume emitting particles.
  13260. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13261. */
  13262. export interface IParticleEmitterType {
  13263. /**
  13264. * Called by the particle System when the direction is computed for the created particle.
  13265. * @param worldMatrix is the world matrix of the particle system
  13266. * @param directionToUpdate is the direction vector to update with the result
  13267. * @param particle is the particle we are computed the direction for
  13268. * @param isLocal defines if the direction should be set in local space
  13269. */
  13270. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13271. /**
  13272. * Called by the particle System when the position is computed for the created particle.
  13273. * @param worldMatrix is the world matrix of the particle system
  13274. * @param positionToUpdate is the position vector to update with the result
  13275. * @param particle is the particle we are computed the position for
  13276. * @param isLocal defines if the position should be set in local space
  13277. */
  13278. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13279. /**
  13280. * Clones the current emitter and returns a copy of it
  13281. * @returns the new emitter
  13282. */
  13283. clone(): IParticleEmitterType;
  13284. /**
  13285. * Called by the GPUParticleSystem to setup the update shader
  13286. * @param effect defines the update shader
  13287. */
  13288. applyToShader(effect: Effect): void;
  13289. /**
  13290. * Returns a string to use to update the GPU particles update shader
  13291. * @returns the effect defines string
  13292. */
  13293. getEffectDefines(): string;
  13294. /**
  13295. * Returns a string representing the class name
  13296. * @returns a string containing the class name
  13297. */
  13298. getClassName(): string;
  13299. /**
  13300. * Serializes the particle system to a JSON object.
  13301. * @returns the JSON object
  13302. */
  13303. serialize(): any;
  13304. /**
  13305. * Parse properties from a JSON object
  13306. * @param serializationObject defines the JSON object
  13307. * @param scene defines the hosting scene
  13308. */
  13309. parse(serializationObject: any, scene: Scene): void;
  13310. }
  13311. }
  13312. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13313. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13314. import { Effect } from "babylonjs/Materials/effect";
  13315. import { Particle } from "babylonjs/Particles/particle";
  13316. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13317. /**
  13318. * Particle emitter emitting particles from the inside of a box.
  13319. * It emits the particles randomly between 2 given directions.
  13320. */
  13321. export class BoxParticleEmitter implements IParticleEmitterType {
  13322. /**
  13323. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13324. */
  13325. direction1: Vector3;
  13326. /**
  13327. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13328. */
  13329. direction2: Vector3;
  13330. /**
  13331. * 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.
  13332. */
  13333. minEmitBox: Vector3;
  13334. /**
  13335. * 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.
  13336. */
  13337. maxEmitBox: Vector3;
  13338. /**
  13339. * Creates a new instance BoxParticleEmitter
  13340. */
  13341. constructor();
  13342. /**
  13343. * Called by the particle System when the direction is computed for the created particle.
  13344. * @param worldMatrix is the world matrix of the particle system
  13345. * @param directionToUpdate is the direction vector to update with the result
  13346. * @param particle is the particle we are computed the direction for
  13347. * @param isLocal defines if the direction should be set in local space
  13348. */
  13349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13350. /**
  13351. * Called by the particle System when the position is computed for the created particle.
  13352. * @param worldMatrix is the world matrix of the particle system
  13353. * @param positionToUpdate is the position vector to update with the result
  13354. * @param particle is the particle we are computed the position for
  13355. * @param isLocal defines if the position should be set in local space
  13356. */
  13357. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13358. /**
  13359. * Clones the current emitter and returns a copy of it
  13360. * @returns the new emitter
  13361. */
  13362. clone(): BoxParticleEmitter;
  13363. /**
  13364. * Called by the GPUParticleSystem to setup the update shader
  13365. * @param effect defines the update shader
  13366. */
  13367. applyToShader(effect: Effect): void;
  13368. /**
  13369. * Returns a string to use to update the GPU particles update shader
  13370. * @returns a string containng the defines string
  13371. */
  13372. getEffectDefines(): string;
  13373. /**
  13374. * Returns the string "BoxParticleEmitter"
  13375. * @returns a string containing the class name
  13376. */
  13377. getClassName(): string;
  13378. /**
  13379. * Serializes the particle system to a JSON object.
  13380. * @returns the JSON object
  13381. */
  13382. serialize(): any;
  13383. /**
  13384. * Parse properties from a JSON object
  13385. * @param serializationObject defines the JSON object
  13386. */
  13387. parse(serializationObject: any): void;
  13388. }
  13389. }
  13390. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13391. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13392. import { Effect } from "babylonjs/Materials/effect";
  13393. import { Particle } from "babylonjs/Particles/particle";
  13394. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13395. /**
  13396. * Particle emitter emitting particles from the inside of a cone.
  13397. * It emits the particles alongside the cone volume from the base to the particle.
  13398. * The emission direction might be randomized.
  13399. */
  13400. export class ConeParticleEmitter implements IParticleEmitterType {
  13401. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13402. directionRandomizer: number;
  13403. private _radius;
  13404. private _angle;
  13405. private _height;
  13406. /**
  13407. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13408. */
  13409. radiusRange: number;
  13410. /**
  13411. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13412. */
  13413. heightRange: number;
  13414. /**
  13415. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13416. */
  13417. emitFromSpawnPointOnly: boolean;
  13418. /**
  13419. * Gets or sets the radius of the emission cone
  13420. */
  13421. get radius(): number;
  13422. set radius(value: number);
  13423. /**
  13424. * Gets or sets the angle of the emission cone
  13425. */
  13426. get angle(): number;
  13427. set angle(value: number);
  13428. private _buildHeight;
  13429. /**
  13430. * Creates a new instance ConeParticleEmitter
  13431. * @param radius the radius of the emission cone (1 by default)
  13432. * @param angle the cone base angle (PI by default)
  13433. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13434. */
  13435. constructor(radius?: number, angle?: number,
  13436. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13437. directionRandomizer?: number);
  13438. /**
  13439. * Called by the particle System when the direction is computed for the created particle.
  13440. * @param worldMatrix is the world matrix of the particle system
  13441. * @param directionToUpdate is the direction vector to update with the result
  13442. * @param particle is the particle we are computed the direction for
  13443. * @param isLocal defines if the direction should be set in local space
  13444. */
  13445. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13446. /**
  13447. * Called by the particle System when the position is computed for the created particle.
  13448. * @param worldMatrix is the world matrix of the particle system
  13449. * @param positionToUpdate is the position vector to update with the result
  13450. * @param particle is the particle we are computed the position for
  13451. * @param isLocal defines if the position should be set in local space
  13452. */
  13453. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13454. /**
  13455. * Clones the current emitter and returns a copy of it
  13456. * @returns the new emitter
  13457. */
  13458. clone(): ConeParticleEmitter;
  13459. /**
  13460. * Called by the GPUParticleSystem to setup the update shader
  13461. * @param effect defines the update shader
  13462. */
  13463. applyToShader(effect: Effect): void;
  13464. /**
  13465. * Returns a string to use to update the GPU particles update shader
  13466. * @returns a string containng the defines string
  13467. */
  13468. getEffectDefines(): string;
  13469. /**
  13470. * Returns the string "ConeParticleEmitter"
  13471. * @returns a string containing the class name
  13472. */
  13473. getClassName(): string;
  13474. /**
  13475. * Serializes the particle system to a JSON object.
  13476. * @returns the JSON object
  13477. */
  13478. serialize(): any;
  13479. /**
  13480. * Parse properties from a JSON object
  13481. * @param serializationObject defines the JSON object
  13482. */
  13483. parse(serializationObject: any): void;
  13484. }
  13485. }
  13486. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13488. import { Effect } from "babylonjs/Materials/effect";
  13489. import { Particle } from "babylonjs/Particles/particle";
  13490. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13491. /**
  13492. * Particle emitter emitting particles from the inside of a cylinder.
  13493. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13494. */
  13495. export class CylinderParticleEmitter implements IParticleEmitterType {
  13496. /**
  13497. * The radius of the emission cylinder.
  13498. */
  13499. radius: number;
  13500. /**
  13501. * The height of the emission cylinder.
  13502. */
  13503. height: number;
  13504. /**
  13505. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13506. */
  13507. radiusRange: number;
  13508. /**
  13509. * How much to randomize the particle direction [0-1].
  13510. */
  13511. directionRandomizer: number;
  13512. /**
  13513. * Creates a new instance CylinderParticleEmitter
  13514. * @param radius the radius of the emission cylinder (1 by default)
  13515. * @param height the height of the emission cylinder (1 by default)
  13516. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13517. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13518. */
  13519. constructor(
  13520. /**
  13521. * The radius of the emission cylinder.
  13522. */
  13523. radius?: number,
  13524. /**
  13525. * The height of the emission cylinder.
  13526. */
  13527. height?: number,
  13528. /**
  13529. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13530. */
  13531. radiusRange?: number,
  13532. /**
  13533. * How much to randomize the particle direction [0-1].
  13534. */
  13535. directionRandomizer?: number);
  13536. /**
  13537. * Called by the particle System when the direction is computed for the created particle.
  13538. * @param worldMatrix is the world matrix of the particle system
  13539. * @param directionToUpdate is the direction vector to update with the result
  13540. * @param particle is the particle we are computed the direction for
  13541. * @param isLocal defines if the direction should be set in local space
  13542. */
  13543. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13544. /**
  13545. * Called by the particle System when the position is computed for the created particle.
  13546. * @param worldMatrix is the world matrix of the particle system
  13547. * @param positionToUpdate is the position vector to update with the result
  13548. * @param particle is the particle we are computed the position for
  13549. * @param isLocal defines if the position should be set in local space
  13550. */
  13551. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13552. /**
  13553. * Clones the current emitter and returns a copy of it
  13554. * @returns the new emitter
  13555. */
  13556. clone(): CylinderParticleEmitter;
  13557. /**
  13558. * Called by the GPUParticleSystem to setup the update shader
  13559. * @param effect defines the update shader
  13560. */
  13561. applyToShader(effect: Effect): void;
  13562. /**
  13563. * Returns a string to use to update the GPU particles update shader
  13564. * @returns a string containng the defines string
  13565. */
  13566. getEffectDefines(): string;
  13567. /**
  13568. * Returns the string "CylinderParticleEmitter"
  13569. * @returns a string containing the class name
  13570. */
  13571. getClassName(): string;
  13572. /**
  13573. * Serializes the particle system to a JSON object.
  13574. * @returns the JSON object
  13575. */
  13576. serialize(): any;
  13577. /**
  13578. * Parse properties from a JSON object
  13579. * @param serializationObject defines the JSON object
  13580. */
  13581. parse(serializationObject: any): void;
  13582. }
  13583. /**
  13584. * Particle emitter emitting particles from the inside of a cylinder.
  13585. * It emits the particles randomly between two vectors.
  13586. */
  13587. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13588. /**
  13589. * The min limit of the emission direction.
  13590. */
  13591. direction1: Vector3;
  13592. /**
  13593. * The max limit of the emission direction.
  13594. */
  13595. direction2: Vector3;
  13596. /**
  13597. * Creates a new instance CylinderDirectedParticleEmitter
  13598. * @param radius the radius of the emission cylinder (1 by default)
  13599. * @param height the height of the emission cylinder (1 by default)
  13600. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13601. * @param direction1 the min limit of the emission direction (up vector by default)
  13602. * @param direction2 the max limit of the emission direction (up vector by default)
  13603. */
  13604. constructor(radius?: number, height?: number, radiusRange?: number,
  13605. /**
  13606. * The min limit of the emission direction.
  13607. */
  13608. direction1?: Vector3,
  13609. /**
  13610. * The max limit of the emission direction.
  13611. */
  13612. direction2?: Vector3);
  13613. /**
  13614. * Called by the particle System when the direction is computed for the created particle.
  13615. * @param worldMatrix is the world matrix of the particle system
  13616. * @param directionToUpdate is the direction vector to update with the result
  13617. * @param particle is the particle we are computed the direction for
  13618. */
  13619. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13620. /**
  13621. * Clones the current emitter and returns a copy of it
  13622. * @returns the new emitter
  13623. */
  13624. clone(): CylinderDirectedParticleEmitter;
  13625. /**
  13626. * Called by the GPUParticleSystem to setup the update shader
  13627. * @param effect defines the update shader
  13628. */
  13629. applyToShader(effect: Effect): void;
  13630. /**
  13631. * Returns a string to use to update the GPU particles update shader
  13632. * @returns a string containng the defines string
  13633. */
  13634. getEffectDefines(): string;
  13635. /**
  13636. * Returns the string "CylinderDirectedParticleEmitter"
  13637. * @returns a string containing the class name
  13638. */
  13639. getClassName(): string;
  13640. /**
  13641. * Serializes the particle system to a JSON object.
  13642. * @returns the JSON object
  13643. */
  13644. serialize(): any;
  13645. /**
  13646. * Parse properties from a JSON object
  13647. * @param serializationObject defines the JSON object
  13648. */
  13649. parse(serializationObject: any): void;
  13650. }
  13651. }
  13652. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13653. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13654. import { Effect } from "babylonjs/Materials/effect";
  13655. import { Particle } from "babylonjs/Particles/particle";
  13656. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13657. /**
  13658. * Particle emitter emitting particles from the inside of a hemisphere.
  13659. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13660. */
  13661. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13662. /**
  13663. * The radius of the emission hemisphere.
  13664. */
  13665. radius: number;
  13666. /**
  13667. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13668. */
  13669. radiusRange: number;
  13670. /**
  13671. * How much to randomize the particle direction [0-1].
  13672. */
  13673. directionRandomizer: number;
  13674. /**
  13675. * Creates a new instance HemisphericParticleEmitter
  13676. * @param radius the radius of the emission hemisphere (1 by default)
  13677. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13678. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13679. */
  13680. constructor(
  13681. /**
  13682. * The radius of the emission hemisphere.
  13683. */
  13684. radius?: number,
  13685. /**
  13686. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13687. */
  13688. radiusRange?: number,
  13689. /**
  13690. * How much to randomize the particle direction [0-1].
  13691. */
  13692. directionRandomizer?: number);
  13693. /**
  13694. * Called by the particle System when the direction is computed for the created particle.
  13695. * @param worldMatrix is the world matrix of the particle system
  13696. * @param directionToUpdate is the direction vector to update with the result
  13697. * @param particle is the particle we are computed the direction for
  13698. * @param isLocal defines if the direction should be set in local space
  13699. */
  13700. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13701. /**
  13702. * Called by the particle System when the position is computed for the created particle.
  13703. * @param worldMatrix is the world matrix of the particle system
  13704. * @param positionToUpdate is the position vector to update with the result
  13705. * @param particle is the particle we are computed the position for
  13706. * @param isLocal defines if the position should be set in local space
  13707. */
  13708. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13709. /**
  13710. * Clones the current emitter and returns a copy of it
  13711. * @returns the new emitter
  13712. */
  13713. clone(): HemisphericParticleEmitter;
  13714. /**
  13715. * Called by the GPUParticleSystem to setup the update shader
  13716. * @param effect defines the update shader
  13717. */
  13718. applyToShader(effect: Effect): void;
  13719. /**
  13720. * Returns a string to use to update the GPU particles update shader
  13721. * @returns a string containng the defines string
  13722. */
  13723. getEffectDefines(): string;
  13724. /**
  13725. * Returns the string "HemisphericParticleEmitter"
  13726. * @returns a string containing the class name
  13727. */
  13728. getClassName(): string;
  13729. /**
  13730. * Serializes the particle system to a JSON object.
  13731. * @returns the JSON object
  13732. */
  13733. serialize(): any;
  13734. /**
  13735. * Parse properties from a JSON object
  13736. * @param serializationObject defines the JSON object
  13737. */
  13738. parse(serializationObject: any): void;
  13739. }
  13740. }
  13741. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  13742. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13743. import { Effect } from "babylonjs/Materials/effect";
  13744. import { Particle } from "babylonjs/Particles/particle";
  13745. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13746. /**
  13747. * Particle emitter emitting particles from a point.
  13748. * It emits the particles randomly between 2 given directions.
  13749. */
  13750. export class PointParticleEmitter implements IParticleEmitterType {
  13751. /**
  13752. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13753. */
  13754. direction1: Vector3;
  13755. /**
  13756. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13757. */
  13758. direction2: Vector3;
  13759. /**
  13760. * Creates a new instance PointParticleEmitter
  13761. */
  13762. constructor();
  13763. /**
  13764. * Called by the particle System when the direction is computed for the created particle.
  13765. * @param worldMatrix is the world matrix of the particle system
  13766. * @param directionToUpdate is the direction vector to update with the result
  13767. * @param particle is the particle we are computed the direction for
  13768. * @param isLocal defines if the direction should be set in local space
  13769. */
  13770. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13771. /**
  13772. * Called by the particle System when the position is computed for the created particle.
  13773. * @param worldMatrix is the world matrix of the particle system
  13774. * @param positionToUpdate is the position vector to update with the result
  13775. * @param particle is the particle we are computed the position for
  13776. * @param isLocal defines if the position should be set in local space
  13777. */
  13778. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13779. /**
  13780. * Clones the current emitter and returns a copy of it
  13781. * @returns the new emitter
  13782. */
  13783. clone(): PointParticleEmitter;
  13784. /**
  13785. * Called by the GPUParticleSystem to setup the update shader
  13786. * @param effect defines the update shader
  13787. */
  13788. applyToShader(effect: Effect): void;
  13789. /**
  13790. * Returns a string to use to update the GPU particles update shader
  13791. * @returns a string containng the defines string
  13792. */
  13793. getEffectDefines(): string;
  13794. /**
  13795. * Returns the string "PointParticleEmitter"
  13796. * @returns a string containing the class name
  13797. */
  13798. getClassName(): string;
  13799. /**
  13800. * Serializes the particle system to a JSON object.
  13801. * @returns the JSON object
  13802. */
  13803. serialize(): any;
  13804. /**
  13805. * Parse properties from a JSON object
  13806. * @param serializationObject defines the JSON object
  13807. */
  13808. parse(serializationObject: any): void;
  13809. }
  13810. }
  13811. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  13812. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13813. import { Effect } from "babylonjs/Materials/effect";
  13814. import { Particle } from "babylonjs/Particles/particle";
  13815. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13816. /**
  13817. * Particle emitter emitting particles from the inside of a sphere.
  13818. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13819. */
  13820. export class SphereParticleEmitter implements IParticleEmitterType {
  13821. /**
  13822. * The radius of the emission sphere.
  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. * Creates a new instance SphereParticleEmitter
  13835. * @param radius the radius of the emission sphere (1 by default)
  13836. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13837. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13838. */
  13839. constructor(
  13840. /**
  13841. * The radius of the emission sphere.
  13842. */
  13843. radius?: number,
  13844. /**
  13845. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13846. */
  13847. radiusRange?: number,
  13848. /**
  13849. * How much to randomize the particle direction [0-1].
  13850. */
  13851. directionRandomizer?: number);
  13852. /**
  13853. * Called by the particle System when the direction is computed for the created particle.
  13854. * @param worldMatrix is the world matrix of the particle system
  13855. * @param directionToUpdate is the direction vector to update with the result
  13856. * @param particle is the particle we are computed the direction for
  13857. * @param isLocal defines if the direction should be set in local space
  13858. */
  13859. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13860. /**
  13861. * Called by the particle System when the position is computed for the created particle.
  13862. * @param worldMatrix is the world matrix of the particle system
  13863. * @param positionToUpdate is the position vector to update with the result
  13864. * @param particle is the particle we are computed the position for
  13865. * @param isLocal defines if the position should be set in local space
  13866. */
  13867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13868. /**
  13869. * Clones the current emitter and returns a copy of it
  13870. * @returns the new emitter
  13871. */
  13872. clone(): SphereParticleEmitter;
  13873. /**
  13874. * Called by the GPUParticleSystem to setup the update shader
  13875. * @param effect defines the update shader
  13876. */
  13877. applyToShader(effect: Effect): void;
  13878. /**
  13879. * Returns a string to use to update the GPU particles update shader
  13880. * @returns a string containng the defines string
  13881. */
  13882. getEffectDefines(): string;
  13883. /**
  13884. * Returns the string "SphereParticleEmitter"
  13885. * @returns a string containing the class name
  13886. */
  13887. getClassName(): string;
  13888. /**
  13889. * Serializes the particle system to a JSON object.
  13890. * @returns the JSON object
  13891. */
  13892. serialize(): any;
  13893. /**
  13894. * Parse properties from a JSON object
  13895. * @param serializationObject defines the JSON object
  13896. */
  13897. parse(serializationObject: any): void;
  13898. }
  13899. /**
  13900. * Particle emitter emitting particles from the inside of a sphere.
  13901. * It emits the particles randomly between two vectors.
  13902. */
  13903. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13904. /**
  13905. * The min limit of the emission direction.
  13906. */
  13907. direction1: Vector3;
  13908. /**
  13909. * The max limit of the emission direction.
  13910. */
  13911. direction2: Vector3;
  13912. /**
  13913. * Creates a new instance SphereDirectedParticleEmitter
  13914. * @param radius the radius of the emission sphere (1 by default)
  13915. * @param direction1 the min limit of the emission direction (up vector by default)
  13916. * @param direction2 the max limit of the emission direction (up vector by default)
  13917. */
  13918. constructor(radius?: number,
  13919. /**
  13920. * The min limit of the emission direction.
  13921. */
  13922. direction1?: Vector3,
  13923. /**
  13924. * The max limit of the emission direction.
  13925. */
  13926. direction2?: Vector3);
  13927. /**
  13928. * Called by the particle System when the direction is computed for the created particle.
  13929. * @param worldMatrix is the world matrix of the particle system
  13930. * @param directionToUpdate is the direction vector to update with the result
  13931. * @param particle is the particle we are computed the direction for
  13932. */
  13933. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13934. /**
  13935. * Clones the current emitter and returns a copy of it
  13936. * @returns the new emitter
  13937. */
  13938. clone(): SphereDirectedParticleEmitter;
  13939. /**
  13940. * Called by the GPUParticleSystem to setup the update shader
  13941. * @param effect defines the update shader
  13942. */
  13943. applyToShader(effect: Effect): void;
  13944. /**
  13945. * Returns a string to use to update the GPU particles update shader
  13946. * @returns a string containng the defines string
  13947. */
  13948. getEffectDefines(): string;
  13949. /**
  13950. * Returns the string "SphereDirectedParticleEmitter"
  13951. * @returns a string containing the class name
  13952. */
  13953. getClassName(): string;
  13954. /**
  13955. * Serializes the particle system to a JSON object.
  13956. * @returns the JSON object
  13957. */
  13958. serialize(): any;
  13959. /**
  13960. * Parse properties from a JSON object
  13961. * @param serializationObject defines the JSON object
  13962. */
  13963. parse(serializationObject: any): void;
  13964. }
  13965. }
  13966. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13967. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13968. import { Effect } from "babylonjs/Materials/effect";
  13969. import { Particle } from "babylonjs/Particles/particle";
  13970. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13971. import { Nullable } from "babylonjs/types";
  13972. /**
  13973. * Particle emitter emitting particles from a custom list of positions.
  13974. */
  13975. export class CustomParticleEmitter implements IParticleEmitterType {
  13976. /**
  13977. * Gets or sets the position generator that will create the inital position of each particle.
  13978. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13979. */
  13980. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13981. /**
  13982. * Gets or sets the destination generator that will create the final destination of each particle.
  13983. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13984. */
  13985. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13986. /**
  13987. * Creates a new instance CustomParticleEmitter
  13988. */
  13989. constructor();
  13990. /**
  13991. * Called by the particle System when the direction is computed for the created particle.
  13992. * @param worldMatrix is the world matrix of the particle system
  13993. * @param directionToUpdate is the direction vector to update with the result
  13994. * @param particle is the particle we are computed the direction for
  13995. * @param isLocal defines if the direction should be set in local space
  13996. */
  13997. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13998. /**
  13999. * Called by the particle System when the position is computed for the created particle.
  14000. * @param worldMatrix is the world matrix of the particle system
  14001. * @param positionToUpdate is the position vector to update with the result
  14002. * @param particle is the particle we are computed the position for
  14003. * @param isLocal defines if the position should be set in local space
  14004. */
  14005. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14006. /**
  14007. * Clones the current emitter and returns a copy of it
  14008. * @returns the new emitter
  14009. */
  14010. clone(): CustomParticleEmitter;
  14011. /**
  14012. * Called by the GPUParticleSystem to setup the update shader
  14013. * @param effect defines the update shader
  14014. */
  14015. applyToShader(effect: Effect): void;
  14016. /**
  14017. * Returns a string to use to update the GPU particles update shader
  14018. * @returns a string containng the defines string
  14019. */
  14020. getEffectDefines(): string;
  14021. /**
  14022. * Returns the string "PointParticleEmitter"
  14023. * @returns a string containing the class name
  14024. */
  14025. getClassName(): string;
  14026. /**
  14027. * Serializes the particle system to a JSON object.
  14028. * @returns the JSON object
  14029. */
  14030. serialize(): any;
  14031. /**
  14032. * Parse properties from a JSON object
  14033. * @param serializationObject defines the JSON object
  14034. */
  14035. parse(serializationObject: any): void;
  14036. }
  14037. }
  14038. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14039. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14040. import { Effect } from "babylonjs/Materials/effect";
  14041. import { Particle } from "babylonjs/Particles/particle";
  14042. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14043. import { Nullable } from "babylonjs/types";
  14044. import { Scene } from "babylonjs/scene";
  14045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14046. /**
  14047. * Particle emitter emitting particles from the inside of a box.
  14048. * It emits the particles randomly between 2 given directions.
  14049. */
  14050. export class MeshParticleEmitter implements IParticleEmitterType {
  14051. private _indices;
  14052. private _positions;
  14053. private _normals;
  14054. private _storedNormal;
  14055. private _mesh;
  14056. /**
  14057. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14058. */
  14059. direction1: Vector3;
  14060. /**
  14061. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14062. */
  14063. direction2: Vector3;
  14064. /**
  14065. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14066. */
  14067. useMeshNormalsForDirection: boolean;
  14068. /** Defines the mesh to use as source */
  14069. get mesh(): Nullable<AbstractMesh>;
  14070. set mesh(value: Nullable<AbstractMesh>);
  14071. /**
  14072. * Creates a new instance MeshParticleEmitter
  14073. * @param mesh defines the mesh to use as source
  14074. */
  14075. constructor(mesh?: Nullable<AbstractMesh>);
  14076. /**
  14077. * Called by the particle System when the direction is computed for the created particle.
  14078. * @param worldMatrix is the world matrix of the particle system
  14079. * @param directionToUpdate is the direction vector to update with the result
  14080. * @param particle is the particle we are computed the direction for
  14081. * @param isLocal defines if the direction should be set in local space
  14082. */
  14083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14084. /**
  14085. * Called by the particle System when the position is computed for the created particle.
  14086. * @param worldMatrix is the world matrix of the particle system
  14087. * @param positionToUpdate is the position vector to update with the result
  14088. * @param particle is the particle we are computed the position for
  14089. * @param isLocal defines if the position should be set in local space
  14090. */
  14091. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14092. /**
  14093. * Clones the current emitter and returns a copy of it
  14094. * @returns the new emitter
  14095. */
  14096. clone(): MeshParticleEmitter;
  14097. /**
  14098. * Called by the GPUParticleSystem to setup the update shader
  14099. * @param effect defines the update shader
  14100. */
  14101. applyToShader(effect: Effect): void;
  14102. /**
  14103. * Returns a string to use to update the GPU particles update shader
  14104. * @returns a string containng the defines string
  14105. */
  14106. getEffectDefines(): string;
  14107. /**
  14108. * Returns the string "BoxParticleEmitter"
  14109. * @returns a string containing the class name
  14110. */
  14111. getClassName(): string;
  14112. /**
  14113. * Serializes the particle system to a JSON object.
  14114. * @returns the JSON object
  14115. */
  14116. serialize(): any;
  14117. /**
  14118. * Parse properties from a JSON object
  14119. * @param serializationObject defines the JSON object
  14120. * @param scene defines the hosting scene
  14121. */
  14122. parse(serializationObject: any, scene: Scene): void;
  14123. }
  14124. }
  14125. declare module "babylonjs/Particles/EmitterTypes/index" {
  14126. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14127. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14128. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14129. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14130. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14131. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14132. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14133. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14134. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14135. }
  14136. declare module "babylonjs/Particles/IParticleSystem" {
  14137. import { Nullable } from "babylonjs/types";
  14138. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  14139. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14142. import { Texture } from "babylonjs/Materials/Textures/texture";
  14143. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14144. import { Scene } from "babylonjs/scene";
  14145. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14146. import { Effect } from "babylonjs/Materials/effect";
  14147. import { Observable } from "babylonjs/Misc/observable";
  14148. import { Animation } from "babylonjs/Animations/animation";
  14149. /**
  14150. * Interface representing a particle system in Babylon.js.
  14151. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14152. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14153. */
  14154. export interface IParticleSystem {
  14155. /**
  14156. * List of animations used by the particle system.
  14157. */
  14158. animations: Animation[];
  14159. /**
  14160. * The id of the Particle system.
  14161. */
  14162. id: string;
  14163. /**
  14164. * The name of the Particle system.
  14165. */
  14166. name: string;
  14167. /**
  14168. * The emitter represents the Mesh or position we are attaching the particle system to.
  14169. */
  14170. emitter: Nullable<AbstractMesh | Vector3>;
  14171. /**
  14172. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14173. */
  14174. isBillboardBased: boolean;
  14175. /**
  14176. * The rendering group used by the Particle system to chose when to render.
  14177. */
  14178. renderingGroupId: number;
  14179. /**
  14180. * The layer mask we are rendering the particles through.
  14181. */
  14182. layerMask: number;
  14183. /**
  14184. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14185. */
  14186. updateSpeed: number;
  14187. /**
  14188. * The amount of time the particle system is running (depends of the overall update speed).
  14189. */
  14190. targetStopDuration: number;
  14191. /**
  14192. * The texture used to render each particle. (this can be a spritesheet)
  14193. */
  14194. particleTexture: Nullable<Texture>;
  14195. /**
  14196. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14197. */
  14198. blendMode: number;
  14199. /**
  14200. * Minimum life time of emitting particles.
  14201. */
  14202. minLifeTime: number;
  14203. /**
  14204. * Maximum life time of emitting particles.
  14205. */
  14206. maxLifeTime: number;
  14207. /**
  14208. * Minimum Size of emitting particles.
  14209. */
  14210. minSize: number;
  14211. /**
  14212. * Maximum Size of emitting particles.
  14213. */
  14214. maxSize: number;
  14215. /**
  14216. * Minimum scale of emitting particles on X axis.
  14217. */
  14218. minScaleX: number;
  14219. /**
  14220. * Maximum scale of emitting particles on X axis.
  14221. */
  14222. maxScaleX: number;
  14223. /**
  14224. * Minimum scale of emitting particles on Y axis.
  14225. */
  14226. minScaleY: number;
  14227. /**
  14228. * Maximum scale of emitting particles on Y axis.
  14229. */
  14230. maxScaleY: number;
  14231. /**
  14232. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14233. */
  14234. color1: Color4;
  14235. /**
  14236. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14237. */
  14238. color2: Color4;
  14239. /**
  14240. * Color the particle will have at the end of its lifetime.
  14241. */
  14242. colorDead: Color4;
  14243. /**
  14244. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14245. */
  14246. emitRate: number;
  14247. /**
  14248. * You can use gravity if you want to give an orientation to your particles.
  14249. */
  14250. gravity: Vector3;
  14251. /**
  14252. * Minimum power of emitting particles.
  14253. */
  14254. minEmitPower: number;
  14255. /**
  14256. * Maximum power of emitting particles.
  14257. */
  14258. maxEmitPower: number;
  14259. /**
  14260. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14261. */
  14262. minAngularSpeed: number;
  14263. /**
  14264. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14265. */
  14266. maxAngularSpeed: number;
  14267. /**
  14268. * Gets or sets the minimal initial rotation in radians.
  14269. */
  14270. minInitialRotation: number;
  14271. /**
  14272. * Gets or sets the maximal initial rotation in radians.
  14273. */
  14274. maxInitialRotation: number;
  14275. /**
  14276. * The particle emitter type defines the emitter used by the particle system.
  14277. * It can be for example box, sphere, or cone...
  14278. */
  14279. particleEmitterType: Nullable<IParticleEmitterType>;
  14280. /**
  14281. * Defines the delay in milliseconds before starting the system (0 by default)
  14282. */
  14283. startDelay: number;
  14284. /**
  14285. * 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
  14286. */
  14287. preWarmCycles: number;
  14288. /**
  14289. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14290. */
  14291. preWarmStepOffset: number;
  14292. /**
  14293. * 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)
  14294. */
  14295. spriteCellChangeSpeed: number;
  14296. /**
  14297. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14298. */
  14299. startSpriteCellID: number;
  14300. /**
  14301. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14302. */
  14303. endSpriteCellID: number;
  14304. /**
  14305. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14306. */
  14307. spriteCellWidth: number;
  14308. /**
  14309. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14310. */
  14311. spriteCellHeight: number;
  14312. /**
  14313. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14314. */
  14315. spriteRandomStartCell: boolean;
  14316. /**
  14317. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14318. */
  14319. isAnimationSheetEnabled: boolean;
  14320. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14321. translationPivot: Vector2;
  14322. /**
  14323. * Gets or sets a texture used to add random noise to particle positions
  14324. */
  14325. noiseTexture: Nullable<BaseTexture>;
  14326. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14327. noiseStrength: Vector3;
  14328. /**
  14329. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14330. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14331. */
  14332. billboardMode: number;
  14333. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14334. limitVelocityDamping: number;
  14335. /**
  14336. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14337. */
  14338. beginAnimationOnStart: boolean;
  14339. /**
  14340. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14341. */
  14342. beginAnimationFrom: number;
  14343. /**
  14344. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14345. */
  14346. beginAnimationTo: number;
  14347. /**
  14348. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14349. */
  14350. beginAnimationLoop: boolean;
  14351. /**
  14352. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14353. */
  14354. disposeOnStop: boolean;
  14355. /**
  14356. * Specifies if the particles are updated in emitter local space or world space
  14357. */
  14358. isLocal: boolean;
  14359. /** Snippet ID if the particle system was created from the snippet server */
  14360. snippetId: string;
  14361. /**
  14362. * Gets the maximum number of particles active at the same time.
  14363. * @returns The max number of active particles.
  14364. */
  14365. getCapacity(): number;
  14366. /**
  14367. * Gets the number of particles active at the same time.
  14368. * @returns The number of active particles.
  14369. */
  14370. getActiveCount(): number;
  14371. /**
  14372. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14373. * @returns True if it has been started, otherwise false.
  14374. */
  14375. isStarted(): boolean;
  14376. /**
  14377. * Animates the particle system for this frame.
  14378. */
  14379. animate(): void;
  14380. /**
  14381. * Renders the particle system in its current state.
  14382. * @returns the current number of particles
  14383. */
  14384. render(): number;
  14385. /**
  14386. * Dispose the particle system and frees its associated resources.
  14387. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14388. */
  14389. dispose(disposeTexture?: boolean): void;
  14390. /**
  14391. * An event triggered when the system is disposed
  14392. */
  14393. onDisposeObservable: Observable<IParticleSystem>;
  14394. /**
  14395. * Clones the particle system.
  14396. * @param name The name of the cloned object
  14397. * @param newEmitter The new emitter to use
  14398. * @returns the cloned particle system
  14399. */
  14400. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14401. /**
  14402. * Serializes the particle system to a JSON object
  14403. * @param serializeTexture defines if the texture must be serialized as well
  14404. * @returns the JSON object
  14405. */
  14406. serialize(serializeTexture: boolean): any;
  14407. /**
  14408. * Rebuild the particle system
  14409. */
  14410. rebuild(): void;
  14411. /** Force the system to rebuild all gradients that need to be resync */
  14412. forceRefreshGradients(): void;
  14413. /**
  14414. * Starts the particle system and begins to emit
  14415. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14416. */
  14417. start(delay?: number): void;
  14418. /**
  14419. * Stops the particle system.
  14420. */
  14421. stop(): void;
  14422. /**
  14423. * Remove all active particles
  14424. */
  14425. reset(): void;
  14426. /**
  14427. * Gets a boolean indicating that the system is stopping
  14428. * @returns true if the system is currently stopping
  14429. */
  14430. isStopping(): boolean;
  14431. /**
  14432. * Is this system ready to be used/rendered
  14433. * @return true if the system is ready
  14434. */
  14435. isReady(): boolean;
  14436. /**
  14437. * Returns the string "ParticleSystem"
  14438. * @returns a string containing the class name
  14439. */
  14440. getClassName(): string;
  14441. /**
  14442. * Gets the custom effect used to render the particles
  14443. * @param blendMode Blend mode for which the effect should be retrieved
  14444. * @returns The effect
  14445. */
  14446. getCustomEffect(blendMode: number): Nullable<Effect>;
  14447. /**
  14448. * Sets the custom effect used to render the particles
  14449. * @param effect The effect to set
  14450. * @param blendMode Blend mode for which the effect should be set
  14451. */
  14452. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14453. /**
  14454. * Fill the defines array according to the current settings of the particle system
  14455. * @param defines Array to be updated
  14456. * @param blendMode blend mode to take into account when updating the array
  14457. */
  14458. fillDefines(defines: Array<string>, blendMode: number): void;
  14459. /**
  14460. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14461. * @param uniforms Uniforms array to fill
  14462. * @param attributes Attributes array to fill
  14463. * @param samplers Samplers array to fill
  14464. */
  14465. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14466. /**
  14467. * Observable that will be called just before the particles are drawn
  14468. */
  14469. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14470. /**
  14471. * Gets the name of the particle vertex shader
  14472. */
  14473. vertexShaderName: string;
  14474. /**
  14475. * Adds a new color gradient
  14476. * @param gradient defines the gradient to use (between 0 and 1)
  14477. * @param color1 defines the color to affect to the specified gradient
  14478. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14479. * @returns the current particle system
  14480. */
  14481. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14482. /**
  14483. * Remove a specific color gradient
  14484. * @param gradient defines the gradient to remove
  14485. * @returns the current particle system
  14486. */
  14487. removeColorGradient(gradient: number): IParticleSystem;
  14488. /**
  14489. * Adds a new size gradient
  14490. * @param gradient defines the gradient to use (between 0 and 1)
  14491. * @param factor defines the size factor to affect to the specified gradient
  14492. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14493. * @returns the current particle system
  14494. */
  14495. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14496. /**
  14497. * Remove a specific size gradient
  14498. * @param gradient defines the gradient to remove
  14499. * @returns the current particle system
  14500. */
  14501. removeSizeGradient(gradient: number): IParticleSystem;
  14502. /**
  14503. * Gets the current list of color gradients.
  14504. * You must use addColorGradient and removeColorGradient to udpate this list
  14505. * @returns the list of color gradients
  14506. */
  14507. getColorGradients(): Nullable<Array<ColorGradient>>;
  14508. /**
  14509. * Gets the current list of size gradients.
  14510. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14511. * @returns the list of size gradients
  14512. */
  14513. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14514. /**
  14515. * Gets the current list of angular speed gradients.
  14516. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14517. * @returns the list of angular speed gradients
  14518. */
  14519. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14520. /**
  14521. * Adds a new angular speed gradient
  14522. * @param gradient defines the gradient to use (between 0 and 1)
  14523. * @param factor defines the angular speed to affect to the specified gradient
  14524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14525. * @returns the current particle system
  14526. */
  14527. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14528. /**
  14529. * Remove a specific angular speed gradient
  14530. * @param gradient defines the gradient to remove
  14531. * @returns the current particle system
  14532. */
  14533. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14534. /**
  14535. * Gets the current list of velocity gradients.
  14536. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14537. * @returns the list of velocity gradients
  14538. */
  14539. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14540. /**
  14541. * Adds a new velocity gradient
  14542. * @param gradient defines the gradient to use (between 0 and 1)
  14543. * @param factor defines the velocity to affect to the specified gradient
  14544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14545. * @returns the current particle system
  14546. */
  14547. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14548. /**
  14549. * Remove a specific velocity gradient
  14550. * @param gradient defines the gradient to remove
  14551. * @returns the current particle system
  14552. */
  14553. removeVelocityGradient(gradient: number): IParticleSystem;
  14554. /**
  14555. * Gets the current list of limit velocity gradients.
  14556. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14557. * @returns the list of limit velocity gradients
  14558. */
  14559. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14560. /**
  14561. * Adds a new limit velocity gradient
  14562. * @param gradient defines the gradient to use (between 0 and 1)
  14563. * @param factor defines the limit velocity to affect to the specified gradient
  14564. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14565. * @returns the current particle system
  14566. */
  14567. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14568. /**
  14569. * Remove a specific limit velocity gradient
  14570. * @param gradient defines the gradient to remove
  14571. * @returns the current particle system
  14572. */
  14573. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14574. /**
  14575. * Adds a new drag gradient
  14576. * @param gradient defines the gradient to use (between 0 and 1)
  14577. * @param factor defines the drag to affect to the specified gradient
  14578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14579. * @returns the current particle system
  14580. */
  14581. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14582. /**
  14583. * Remove a specific drag gradient
  14584. * @param gradient defines the gradient to remove
  14585. * @returns the current particle system
  14586. */
  14587. removeDragGradient(gradient: number): IParticleSystem;
  14588. /**
  14589. * Gets the current list of drag gradients.
  14590. * You must use addDragGradient and removeDragGradient to udpate this list
  14591. * @returns the list of drag gradients
  14592. */
  14593. getDragGradients(): Nullable<Array<FactorGradient>>;
  14594. /**
  14595. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14596. * @param gradient defines the gradient to use (between 0 and 1)
  14597. * @param factor defines the emit rate to affect to the specified gradient
  14598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14599. * @returns the current particle system
  14600. */
  14601. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14602. /**
  14603. * Remove a specific emit rate gradient
  14604. * @param gradient defines the gradient to remove
  14605. * @returns the current particle system
  14606. */
  14607. removeEmitRateGradient(gradient: number): IParticleSystem;
  14608. /**
  14609. * Gets the current list of emit rate gradients.
  14610. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14611. * @returns the list of emit rate gradients
  14612. */
  14613. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14614. /**
  14615. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14616. * @param gradient defines the gradient to use (between 0 and 1)
  14617. * @param factor defines the start size to affect to the specified gradient
  14618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14619. * @returns the current particle system
  14620. */
  14621. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14622. /**
  14623. * Remove a specific start size gradient
  14624. * @param gradient defines the gradient to remove
  14625. * @returns the current particle system
  14626. */
  14627. removeStartSizeGradient(gradient: number): IParticleSystem;
  14628. /**
  14629. * Gets the current list of start size gradients.
  14630. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14631. * @returns the list of start size gradients
  14632. */
  14633. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14634. /**
  14635. * Adds a new life time gradient
  14636. * @param gradient defines the gradient to use (between 0 and 1)
  14637. * @param factor defines the life time factor to affect to the specified gradient
  14638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14639. * @returns the current particle system
  14640. */
  14641. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14642. /**
  14643. * Remove a specific life time gradient
  14644. * @param gradient defines the gradient to remove
  14645. * @returns the current particle system
  14646. */
  14647. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14648. /**
  14649. * Gets the current list of life time gradients.
  14650. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14651. * @returns the list of life time gradients
  14652. */
  14653. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14654. /**
  14655. * Gets the current list of color gradients.
  14656. * You must use addColorGradient and removeColorGradient to udpate this list
  14657. * @returns the list of color gradients
  14658. */
  14659. getColorGradients(): Nullable<Array<ColorGradient>>;
  14660. /**
  14661. * Adds a new ramp gradient used to remap particle colors
  14662. * @param gradient defines the gradient to use (between 0 and 1)
  14663. * @param color defines the color to affect to the specified gradient
  14664. * @returns the current particle system
  14665. */
  14666. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14667. /**
  14668. * Gets the current list of ramp gradients.
  14669. * You must use addRampGradient and removeRampGradient to udpate this list
  14670. * @returns the list of ramp gradients
  14671. */
  14672. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14673. /** Gets or sets a boolean indicating that ramp gradients must be used
  14674. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14675. */
  14676. useRampGradients: boolean;
  14677. /**
  14678. * Adds a new color remap gradient
  14679. * @param gradient defines the gradient to use (between 0 and 1)
  14680. * @param min defines the color remap minimal range
  14681. * @param max defines the color remap maximal range
  14682. * @returns the current particle system
  14683. */
  14684. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14685. /**
  14686. * Gets the current list of color remap gradients.
  14687. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14688. * @returns the list of color remap gradients
  14689. */
  14690. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14691. /**
  14692. * Adds a new alpha remap gradient
  14693. * @param gradient defines the gradient to use (between 0 and 1)
  14694. * @param min defines the alpha remap minimal range
  14695. * @param max defines the alpha remap maximal range
  14696. * @returns the current particle system
  14697. */
  14698. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14699. /**
  14700. * Gets the current list of alpha remap gradients.
  14701. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14702. * @returns the list of alpha remap gradients
  14703. */
  14704. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14705. /**
  14706. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14707. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14708. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14709. * @returns the emitter
  14710. */
  14711. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14712. /**
  14713. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14714. * @param radius The radius of the hemisphere to emit from
  14715. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14716. * @returns the emitter
  14717. */
  14718. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14719. /**
  14720. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14721. * @param radius The radius of the sphere to emit from
  14722. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14723. * @returns the emitter
  14724. */
  14725. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14726. /**
  14727. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14728. * @param radius The radius of the sphere to emit from
  14729. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14730. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14731. * @returns the emitter
  14732. */
  14733. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14734. /**
  14735. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14736. * @param radius The radius of the emission cylinder
  14737. * @param height The height of the emission cylinder
  14738. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14739. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14740. * @returns the emitter
  14741. */
  14742. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14743. /**
  14744. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14745. * @param radius The radius of the cylinder to emit from
  14746. * @param height The height of the emission cylinder
  14747. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14748. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14749. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14750. * @returns the emitter
  14751. */
  14752. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14753. /**
  14754. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14755. * @param radius The radius of the cone to emit from
  14756. * @param angle The base angle of the cone
  14757. * @returns the emitter
  14758. */
  14759. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14760. /**
  14761. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14762. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14763. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14764. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14765. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14766. * @returns the emitter
  14767. */
  14768. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14769. /**
  14770. * Get hosting scene
  14771. * @returns the scene
  14772. */
  14773. getScene(): Scene;
  14774. }
  14775. }
  14776. declare module "babylonjs/Meshes/transformNode" {
  14777. import { DeepImmutable } from "babylonjs/types";
  14778. import { Observable } from "babylonjs/Misc/observable";
  14779. import { Nullable } from "babylonjs/types";
  14780. import { Camera } from "babylonjs/Cameras/camera";
  14781. import { Scene } from "babylonjs/scene";
  14782. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14783. import { Node } from "babylonjs/node";
  14784. import { Bone } from "babylonjs/Bones/bone";
  14785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14786. import { Space } from "babylonjs/Maths/math.axis";
  14787. /**
  14788. * 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.
  14789. * @see https://doc.babylonjs.com/how_to/transformnode
  14790. */
  14791. export class TransformNode extends Node {
  14792. /**
  14793. * Object will not rotate to face the camera
  14794. */
  14795. static BILLBOARDMODE_NONE: number;
  14796. /**
  14797. * Object will rotate to face the camera but only on the x axis
  14798. */
  14799. static BILLBOARDMODE_X: number;
  14800. /**
  14801. * Object will rotate to face the camera but only on the y axis
  14802. */
  14803. static BILLBOARDMODE_Y: number;
  14804. /**
  14805. * Object will rotate to face the camera but only on the z axis
  14806. */
  14807. static BILLBOARDMODE_Z: number;
  14808. /**
  14809. * Object will rotate to face the camera
  14810. */
  14811. static BILLBOARDMODE_ALL: number;
  14812. /**
  14813. * Object will rotate to face the camera's position instead of orientation
  14814. */
  14815. static BILLBOARDMODE_USE_POSITION: number;
  14816. private static _TmpRotation;
  14817. private static _TmpScaling;
  14818. private static _TmpTranslation;
  14819. private _forward;
  14820. private _forwardInverted;
  14821. private _up;
  14822. private _right;
  14823. private _rightInverted;
  14824. private _position;
  14825. private _rotation;
  14826. private _rotationQuaternion;
  14827. protected _scaling: Vector3;
  14828. protected _isDirty: boolean;
  14829. private _transformToBoneReferal;
  14830. private _isAbsoluteSynced;
  14831. private _billboardMode;
  14832. /**
  14833. * Gets or sets the billboard mode. Default is 0.
  14834. *
  14835. * | Value | Type | Description |
  14836. * | --- | --- | --- |
  14837. * | 0 | BILLBOARDMODE_NONE | |
  14838. * | 1 | BILLBOARDMODE_X | |
  14839. * | 2 | BILLBOARDMODE_Y | |
  14840. * | 4 | BILLBOARDMODE_Z | |
  14841. * | 7 | BILLBOARDMODE_ALL | |
  14842. *
  14843. */
  14844. get billboardMode(): number;
  14845. set billboardMode(value: number);
  14846. private _preserveParentRotationForBillboard;
  14847. /**
  14848. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14849. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14850. */
  14851. get preserveParentRotationForBillboard(): boolean;
  14852. set preserveParentRotationForBillboard(value: boolean);
  14853. /**
  14854. * 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
  14855. */
  14856. scalingDeterminant: number;
  14857. private _infiniteDistance;
  14858. /**
  14859. * Gets or sets the distance of the object to max, often used by skybox
  14860. */
  14861. get infiniteDistance(): boolean;
  14862. set infiniteDistance(value: boolean);
  14863. /**
  14864. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14865. * By default the system will update normals to compensate
  14866. */
  14867. ignoreNonUniformScaling: boolean;
  14868. /**
  14869. * 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
  14870. */
  14871. reIntegrateRotationIntoRotationQuaternion: boolean;
  14872. /** @hidden */
  14873. _poseMatrix: Nullable<Matrix>;
  14874. /** @hidden */
  14875. _localMatrix: Matrix;
  14876. private _usePivotMatrix;
  14877. private _absolutePosition;
  14878. private _absoluteScaling;
  14879. private _absoluteRotationQuaternion;
  14880. private _pivotMatrix;
  14881. private _pivotMatrixInverse;
  14882. protected _postMultiplyPivotMatrix: boolean;
  14883. protected _isWorldMatrixFrozen: boolean;
  14884. /** @hidden */
  14885. _indexInSceneTransformNodesArray: number;
  14886. /**
  14887. * An event triggered after the world matrix is updated
  14888. */
  14889. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14890. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14891. /**
  14892. * Gets a string identifying the name of the class
  14893. * @returns "TransformNode" string
  14894. */
  14895. getClassName(): string;
  14896. /**
  14897. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14898. */
  14899. get position(): Vector3;
  14900. set position(newPosition: Vector3);
  14901. /**
  14902. * 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)).
  14903. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14904. */
  14905. get rotation(): Vector3;
  14906. set rotation(newRotation: Vector3);
  14907. /**
  14908. * 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)).
  14909. */
  14910. get scaling(): Vector3;
  14911. set scaling(newScaling: Vector3);
  14912. /**
  14913. * 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).
  14914. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14915. */
  14916. get rotationQuaternion(): Nullable<Quaternion>;
  14917. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14918. /**
  14919. * The forward direction of that transform in world space.
  14920. */
  14921. get forward(): Vector3;
  14922. /**
  14923. * The up direction of that transform in world space.
  14924. */
  14925. get up(): Vector3;
  14926. /**
  14927. * The right direction of that transform in world space.
  14928. */
  14929. get right(): Vector3;
  14930. /**
  14931. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14932. * @param matrix the matrix to copy the pose from
  14933. * @returns this TransformNode.
  14934. */
  14935. updatePoseMatrix(matrix: Matrix): TransformNode;
  14936. /**
  14937. * Returns the mesh Pose matrix.
  14938. * @returns the pose matrix
  14939. */
  14940. getPoseMatrix(): Matrix;
  14941. /** @hidden */
  14942. _isSynchronized(): boolean;
  14943. /** @hidden */
  14944. _initCache(): void;
  14945. /**
  14946. * Flag the transform node as dirty (Forcing it to update everything)
  14947. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14948. * @returns this transform node
  14949. */
  14950. markAsDirty(property: string): TransformNode;
  14951. /**
  14952. * Returns the current mesh absolute position.
  14953. * Returns a Vector3.
  14954. */
  14955. get absolutePosition(): Vector3;
  14956. /**
  14957. * Returns the current mesh absolute scaling.
  14958. * Returns a Vector3.
  14959. */
  14960. get absoluteScaling(): Vector3;
  14961. /**
  14962. * Returns the current mesh absolute rotation.
  14963. * Returns a Quaternion.
  14964. */
  14965. get absoluteRotationQuaternion(): Quaternion;
  14966. /**
  14967. * Sets a new matrix to apply before all other transformation
  14968. * @param matrix defines the transform matrix
  14969. * @returns the current TransformNode
  14970. */
  14971. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14972. /**
  14973. * Sets a new pivot matrix to the current node
  14974. * @param matrix defines the new pivot matrix to use
  14975. * @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
  14976. * @returns the current TransformNode
  14977. */
  14978. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14979. /**
  14980. * Returns the mesh pivot matrix.
  14981. * Default : Identity.
  14982. * @returns the matrix
  14983. */
  14984. getPivotMatrix(): Matrix;
  14985. /**
  14986. * Instantiate (when possible) or clone that node with its hierarchy
  14987. * @param newParent defines the new parent to use for the instance (or clone)
  14988. * @param options defines options to configure how copy is done
  14989. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14990. * @returns an instance (or a clone) of the current node with its hiearchy
  14991. */
  14992. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14993. doNotInstantiate: boolean;
  14994. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14995. /**
  14996. * Prevents the World matrix to be computed any longer
  14997. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14998. * @returns the TransformNode.
  14999. */
  15000. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15001. /**
  15002. * Allows back the World matrix computation.
  15003. * @returns the TransformNode.
  15004. */
  15005. unfreezeWorldMatrix(): this;
  15006. /**
  15007. * True if the World matrix has been frozen.
  15008. */
  15009. get isWorldMatrixFrozen(): boolean;
  15010. /**
  15011. * Retuns the mesh absolute position in the World.
  15012. * @returns a Vector3.
  15013. */
  15014. getAbsolutePosition(): Vector3;
  15015. /**
  15016. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15017. * @param absolutePosition the absolute position to set
  15018. * @returns the TransformNode.
  15019. */
  15020. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15021. /**
  15022. * Sets the mesh position in its local space.
  15023. * @param vector3 the position to set in localspace
  15024. * @returns the TransformNode.
  15025. */
  15026. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15027. /**
  15028. * Returns the mesh position in the local space from the current World matrix values.
  15029. * @returns a new Vector3.
  15030. */
  15031. getPositionExpressedInLocalSpace(): Vector3;
  15032. /**
  15033. * Translates the mesh along the passed Vector3 in its local space.
  15034. * @param vector3 the distance to translate in localspace
  15035. * @returns the TransformNode.
  15036. */
  15037. locallyTranslate(vector3: Vector3): TransformNode;
  15038. private static _lookAtVectorCache;
  15039. /**
  15040. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15041. * @param targetPoint the position (must be in same space as current mesh) to look at
  15042. * @param yawCor optional yaw (y-axis) correction in radians
  15043. * @param pitchCor optional pitch (x-axis) correction in radians
  15044. * @param rollCor optional roll (z-axis) correction in radians
  15045. * @param space the choosen space of the target
  15046. * @returns the TransformNode.
  15047. */
  15048. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15049. /**
  15050. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15051. * This Vector3 is expressed in the World space.
  15052. * @param localAxis axis to rotate
  15053. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15054. */
  15055. getDirection(localAxis: Vector3): Vector3;
  15056. /**
  15057. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15058. * localAxis is expressed in the mesh local space.
  15059. * result is computed in the Wordl space from the mesh World matrix.
  15060. * @param localAxis axis to rotate
  15061. * @param result the resulting transformnode
  15062. * @returns this TransformNode.
  15063. */
  15064. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15065. /**
  15066. * Sets this transform node rotation to the given local axis.
  15067. * @param localAxis the axis in local space
  15068. * @param yawCor optional yaw (y-axis) correction in radians
  15069. * @param pitchCor optional pitch (x-axis) correction in radians
  15070. * @param rollCor optional roll (z-axis) correction in radians
  15071. * @returns this TransformNode
  15072. */
  15073. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15074. /**
  15075. * Sets a new pivot point to the current node
  15076. * @param point defines the new pivot point to use
  15077. * @param space defines if the point is in world or local space (local by default)
  15078. * @returns the current TransformNode
  15079. */
  15080. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15081. /**
  15082. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15083. * @returns the pivot point
  15084. */
  15085. getPivotPoint(): Vector3;
  15086. /**
  15087. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15088. * @param result the vector3 to store the result
  15089. * @returns this TransformNode.
  15090. */
  15091. getPivotPointToRef(result: Vector3): TransformNode;
  15092. /**
  15093. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15094. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15095. */
  15096. getAbsolutePivotPoint(): Vector3;
  15097. /**
  15098. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15099. * @param result vector3 to store the result
  15100. * @returns this TransformNode.
  15101. */
  15102. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15103. /**
  15104. * Defines the passed node as the parent of the current node.
  15105. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15106. * @see https://doc.babylonjs.com/how_to/parenting
  15107. * @param node the node ot set as the parent
  15108. * @returns this TransformNode.
  15109. */
  15110. setParent(node: Nullable<Node>): TransformNode;
  15111. private _nonUniformScaling;
  15112. /**
  15113. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15114. */
  15115. get nonUniformScaling(): boolean;
  15116. /** @hidden */
  15117. _updateNonUniformScalingState(value: boolean): boolean;
  15118. /**
  15119. * Attach the current TransformNode to another TransformNode associated with a bone
  15120. * @param bone Bone affecting the TransformNode
  15121. * @param affectedTransformNode TransformNode associated with the bone
  15122. * @returns this object
  15123. */
  15124. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15125. /**
  15126. * Detach the transform node if its associated with a bone
  15127. * @returns this object
  15128. */
  15129. detachFromBone(): TransformNode;
  15130. private static _rotationAxisCache;
  15131. /**
  15132. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15133. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15134. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15135. * The passed axis is also normalized.
  15136. * @param axis the axis to rotate around
  15137. * @param amount the amount to rotate in radians
  15138. * @param space Space to rotate in (Default: local)
  15139. * @returns the TransformNode.
  15140. */
  15141. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15142. /**
  15143. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15144. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15145. * The passed axis is also normalized. .
  15146. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15147. * @param point the point to rotate around
  15148. * @param axis the axis to rotate around
  15149. * @param amount the amount to rotate in radians
  15150. * @returns the TransformNode
  15151. */
  15152. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15153. /**
  15154. * Translates the mesh along the axis vector for the passed distance in the given space.
  15155. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15156. * @param axis the axis to translate in
  15157. * @param distance the distance to translate
  15158. * @param space Space to rotate in (Default: local)
  15159. * @returns the TransformNode.
  15160. */
  15161. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15162. /**
  15163. * Adds a rotation step to the mesh current rotation.
  15164. * x, y, z are Euler angles expressed in radians.
  15165. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15166. * This means this rotation is made in the mesh local space only.
  15167. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15168. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15169. * ```javascript
  15170. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15171. * ```
  15172. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15173. * 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.
  15174. * @param x Rotation to add
  15175. * @param y Rotation to add
  15176. * @param z Rotation to add
  15177. * @returns the TransformNode.
  15178. */
  15179. addRotation(x: number, y: number, z: number): TransformNode;
  15180. /**
  15181. * @hidden
  15182. */
  15183. protected _getEffectiveParent(): Nullable<Node>;
  15184. /**
  15185. * Computes the world matrix of the node
  15186. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15187. * @returns the world matrix
  15188. */
  15189. computeWorldMatrix(force?: boolean): Matrix;
  15190. /**
  15191. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15192. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15193. */
  15194. resetLocalMatrix(independentOfChildren?: boolean): void;
  15195. protected _afterComputeWorldMatrix(): void;
  15196. /**
  15197. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15198. * @param func callback function to add
  15199. *
  15200. * @returns the TransformNode.
  15201. */
  15202. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15203. /**
  15204. * Removes a registered callback function.
  15205. * @param func callback function to remove
  15206. * @returns the TransformNode.
  15207. */
  15208. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15209. /**
  15210. * Gets the position of the current mesh in camera space
  15211. * @param camera defines the camera to use
  15212. * @returns a position
  15213. */
  15214. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15215. /**
  15216. * Returns the distance from the mesh to the active camera
  15217. * @param camera defines the camera to use
  15218. * @returns the distance
  15219. */
  15220. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15221. /**
  15222. * Clone the current transform node
  15223. * @param name Name of the new clone
  15224. * @param newParent New parent for the clone
  15225. * @param doNotCloneChildren Do not clone children hierarchy
  15226. * @returns the new transform node
  15227. */
  15228. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15229. /**
  15230. * Serializes the objects information.
  15231. * @param currentSerializationObject defines the object to serialize in
  15232. * @returns the serialized object
  15233. */
  15234. serialize(currentSerializationObject?: any): any;
  15235. /**
  15236. * Returns a new TransformNode object parsed from the source provided.
  15237. * @param parsedTransformNode is the source.
  15238. * @param scene the scne the object belongs to
  15239. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15240. * @returns a new TransformNode object parsed from the source provided.
  15241. */
  15242. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15243. /**
  15244. * Get all child-transformNodes of this node
  15245. * @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
  15246. * @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
  15247. * @returns an array of TransformNode
  15248. */
  15249. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15250. /**
  15251. * Releases resources associated with this transform node.
  15252. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15253. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15254. */
  15255. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15256. /**
  15257. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15258. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15259. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15260. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15261. * @returns the current mesh
  15262. */
  15263. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15264. private _syncAbsoluteScalingAndRotation;
  15265. }
  15266. }
  15267. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15268. /**
  15269. * Class used to override all child animations of a given target
  15270. */
  15271. export class AnimationPropertiesOverride {
  15272. /**
  15273. * Gets or sets a value indicating if animation blending must be used
  15274. */
  15275. enableBlending: boolean;
  15276. /**
  15277. * Gets or sets the blending speed to use when enableBlending is true
  15278. */
  15279. blendingSpeed: number;
  15280. /**
  15281. * Gets or sets the default loop mode to use
  15282. */
  15283. loopMode: number;
  15284. }
  15285. }
  15286. declare module "babylonjs/Bones/bone" {
  15287. import { Skeleton } from "babylonjs/Bones/skeleton";
  15288. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15289. import { Nullable } from "babylonjs/types";
  15290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15291. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15292. import { Node } from "babylonjs/node";
  15293. import { Space } from "babylonjs/Maths/math.axis";
  15294. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15295. /**
  15296. * Class used to store bone information
  15297. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15298. */
  15299. export class Bone extends Node {
  15300. /**
  15301. * defines the bone name
  15302. */
  15303. name: string;
  15304. private static _tmpVecs;
  15305. private static _tmpQuat;
  15306. private static _tmpMats;
  15307. /**
  15308. * Gets the list of child bones
  15309. */
  15310. children: Bone[];
  15311. /** Gets the animations associated with this bone */
  15312. animations: import("babylonjs/Animations/animation").Animation[];
  15313. /**
  15314. * Gets or sets bone length
  15315. */
  15316. length: number;
  15317. /**
  15318. * @hidden Internal only
  15319. * Set this value to map this bone to a different index in the transform matrices
  15320. * Set this value to -1 to exclude the bone from the transform matrices
  15321. */
  15322. _index: Nullable<number>;
  15323. private _skeleton;
  15324. private _localMatrix;
  15325. private _restPose;
  15326. private _baseMatrix;
  15327. private _absoluteTransform;
  15328. private _invertedAbsoluteTransform;
  15329. private _parent;
  15330. private _scalingDeterminant;
  15331. private _worldTransform;
  15332. private _localScaling;
  15333. private _localRotation;
  15334. private _localPosition;
  15335. private _needToDecompose;
  15336. private _needToCompose;
  15337. /** @hidden */
  15338. _linkedTransformNode: Nullable<TransformNode>;
  15339. /** @hidden */
  15340. _waitingTransformNodeId: Nullable<string>;
  15341. /** @hidden */
  15342. get _matrix(): Matrix;
  15343. /** @hidden */
  15344. set _matrix(value: Matrix);
  15345. /**
  15346. * Create a new bone
  15347. * @param name defines the bone name
  15348. * @param skeleton defines the parent skeleton
  15349. * @param parentBone defines the parent (can be null if the bone is the root)
  15350. * @param localMatrix defines the local matrix
  15351. * @param restPose defines the rest pose matrix
  15352. * @param baseMatrix defines the base matrix
  15353. * @param index defines index of the bone in the hiearchy
  15354. */
  15355. constructor(
  15356. /**
  15357. * defines the bone name
  15358. */
  15359. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15360. /**
  15361. * Gets the current object class name.
  15362. * @return the class name
  15363. */
  15364. getClassName(): string;
  15365. /**
  15366. * Gets the parent skeleton
  15367. * @returns a skeleton
  15368. */
  15369. getSkeleton(): Skeleton;
  15370. /**
  15371. * Gets parent bone
  15372. * @returns a bone or null if the bone is the root of the bone hierarchy
  15373. */
  15374. getParent(): Nullable<Bone>;
  15375. /**
  15376. * Returns an array containing the root bones
  15377. * @returns an array containing the root bones
  15378. */
  15379. getChildren(): Array<Bone>;
  15380. /**
  15381. * Gets the node index in matrix array generated for rendering
  15382. * @returns the node index
  15383. */
  15384. getIndex(): number;
  15385. /**
  15386. * Sets the parent bone
  15387. * @param parent defines the parent (can be null if the bone is the root)
  15388. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15389. */
  15390. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15391. /**
  15392. * Gets the local matrix
  15393. * @returns a matrix
  15394. */
  15395. getLocalMatrix(): Matrix;
  15396. /**
  15397. * Gets the base matrix (initial matrix which remains unchanged)
  15398. * @returns a matrix
  15399. */
  15400. getBaseMatrix(): Matrix;
  15401. /**
  15402. * Gets the rest pose matrix
  15403. * @returns a matrix
  15404. */
  15405. getRestPose(): Matrix;
  15406. /**
  15407. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15408. */
  15409. getWorldMatrix(): Matrix;
  15410. /**
  15411. * Sets the local matrix to rest pose matrix
  15412. */
  15413. returnToRest(): void;
  15414. /**
  15415. * Gets the inverse of the absolute transform matrix.
  15416. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15417. * @returns a matrix
  15418. */
  15419. getInvertedAbsoluteTransform(): Matrix;
  15420. /**
  15421. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15422. * @returns a matrix
  15423. */
  15424. getAbsoluteTransform(): Matrix;
  15425. /**
  15426. * Links with the given transform node.
  15427. * The local matrix of this bone is copied from the transform node every frame.
  15428. * @param transformNode defines the transform node to link to
  15429. */
  15430. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15431. /**
  15432. * Gets the node used to drive the bone's transformation
  15433. * @returns a transform node or null
  15434. */
  15435. getTransformNode(): Nullable<TransformNode>;
  15436. /** Gets or sets current position (in local space) */
  15437. get position(): Vector3;
  15438. set position(newPosition: Vector3);
  15439. /** Gets or sets current rotation (in local space) */
  15440. get rotation(): Vector3;
  15441. set rotation(newRotation: Vector3);
  15442. /** Gets or sets current rotation quaternion (in local space) */
  15443. get rotationQuaternion(): Quaternion;
  15444. set rotationQuaternion(newRotation: Quaternion);
  15445. /** Gets or sets current scaling (in local space) */
  15446. get scaling(): Vector3;
  15447. set scaling(newScaling: Vector3);
  15448. /**
  15449. * Gets the animation properties override
  15450. */
  15451. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15452. private _decompose;
  15453. private _compose;
  15454. /**
  15455. * Update the base and local matrices
  15456. * @param matrix defines the new base or local matrix
  15457. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15458. * @param updateLocalMatrix defines if the local matrix should be updated
  15459. */
  15460. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15461. /** @hidden */
  15462. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15463. /**
  15464. * Flag the bone as dirty (Forcing it to update everything)
  15465. */
  15466. markAsDirty(): void;
  15467. /** @hidden */
  15468. _markAsDirtyAndCompose(): void;
  15469. private _markAsDirtyAndDecompose;
  15470. /**
  15471. * Translate the bone in local or world space
  15472. * @param vec The amount to translate the bone
  15473. * @param space The space that the translation is in
  15474. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15475. */
  15476. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15477. /**
  15478. * Set the postion of the bone in local or world space
  15479. * @param position The position to set the bone
  15480. * @param space The space that the position is in
  15481. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15482. */
  15483. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15484. /**
  15485. * Set the absolute position of the bone (world space)
  15486. * @param position The position to set the bone
  15487. * @param mesh The mesh that this bone is attached to
  15488. */
  15489. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15490. /**
  15491. * Scale the bone on the x, y and z axes (in local space)
  15492. * @param x The amount to scale the bone on the x axis
  15493. * @param y The amount to scale the bone on the y axis
  15494. * @param z The amount to scale the bone on the z axis
  15495. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15496. */
  15497. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15498. /**
  15499. * Set the bone scaling in local space
  15500. * @param scale defines the scaling vector
  15501. */
  15502. setScale(scale: Vector3): void;
  15503. /**
  15504. * Gets the current scaling in local space
  15505. * @returns the current scaling vector
  15506. */
  15507. getScale(): Vector3;
  15508. /**
  15509. * Gets the current scaling in local space and stores it in a target vector
  15510. * @param result defines the target vector
  15511. */
  15512. getScaleToRef(result: Vector3): void;
  15513. /**
  15514. * Set the yaw, pitch, and roll of the bone in local or world space
  15515. * @param yaw The rotation of the bone on the y axis
  15516. * @param pitch The rotation of the bone on the x axis
  15517. * @param roll The rotation of the bone on the z axis
  15518. * @param space The space that the axes of rotation are in
  15519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15520. */
  15521. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15522. /**
  15523. * Add a rotation to the bone on an axis in local or world space
  15524. * @param axis The axis to rotate the bone on
  15525. * @param amount The amount to rotate the bone
  15526. * @param space The space that the axis is in
  15527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15528. */
  15529. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15530. /**
  15531. * Set the rotation of the bone to a particular axis angle in local or world space
  15532. * @param axis The axis to rotate the bone on
  15533. * @param angle The angle that the bone should be rotated to
  15534. * @param space The space that the axis is in
  15535. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15536. */
  15537. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15538. /**
  15539. * Set the euler rotation of the bone in local of world space
  15540. * @param rotation The euler rotation that the bone should be set to
  15541. * @param space The space that the rotation is in
  15542. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15543. */
  15544. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15545. /**
  15546. * Set the quaternion rotation of the bone in local of world space
  15547. * @param quat The quaternion rotation that the bone should be set to
  15548. * @param space The space that the rotation is in
  15549. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15550. */
  15551. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15552. /**
  15553. * Set the rotation matrix of the bone in local of world space
  15554. * @param rotMat The rotation matrix that the bone should be set to
  15555. * @param space The space that the rotation is in
  15556. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15557. */
  15558. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15559. private _rotateWithMatrix;
  15560. private _getNegativeRotationToRef;
  15561. /**
  15562. * Get the position of the bone in local or world space
  15563. * @param space The space that the returned position is in
  15564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15565. * @returns The position of the bone
  15566. */
  15567. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15568. /**
  15569. * Copy the position of the bone to a vector3 in local or world space
  15570. * @param space The space that the returned position is in
  15571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15572. * @param result The vector3 to copy the position to
  15573. */
  15574. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15575. /**
  15576. * Get the absolute position of the bone (world space)
  15577. * @param mesh The mesh that this bone is attached to
  15578. * @returns The absolute position of the bone
  15579. */
  15580. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15581. /**
  15582. * Copy the absolute position of the bone (world space) to the result param
  15583. * @param mesh The mesh that this bone is attached to
  15584. * @param result The vector3 to copy the absolute position to
  15585. */
  15586. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15587. /**
  15588. * Compute the absolute transforms of this bone and its children
  15589. */
  15590. computeAbsoluteTransforms(): void;
  15591. /**
  15592. * Get the world direction from an axis that is in the local space of the bone
  15593. * @param localAxis The local direction that is used to compute the world direction
  15594. * @param mesh The mesh that this bone is attached to
  15595. * @returns The world direction
  15596. */
  15597. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15598. /**
  15599. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15600. * @param localAxis The local direction that is used to compute the world direction
  15601. * @param mesh The mesh that this bone is attached to
  15602. * @param result The vector3 that the world direction will be copied to
  15603. */
  15604. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15605. /**
  15606. * Get the euler rotation of the bone in local or world space
  15607. * @param space The space that the rotation should be in
  15608. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15609. * @returns The euler rotation
  15610. */
  15611. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15612. /**
  15613. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15614. * @param space The space that the rotation should be in
  15615. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15616. * @param result The vector3 that the rotation should be copied to
  15617. */
  15618. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15619. /**
  15620. * Get the quaternion rotation of the bone in either local or world space
  15621. * @param space The space that the rotation should be in
  15622. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15623. * @returns The quaternion rotation
  15624. */
  15625. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15626. /**
  15627. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15628. * @param space The space that the rotation should be in
  15629. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15630. * @param result The quaternion that the rotation should be copied to
  15631. */
  15632. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15633. /**
  15634. * Get the rotation matrix of the bone in local or world space
  15635. * @param space The space that the rotation should be in
  15636. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15637. * @returns The rotation matrix
  15638. */
  15639. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15640. /**
  15641. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15642. * @param space The space that the rotation should be in
  15643. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15644. * @param result The quaternion that the rotation should be copied to
  15645. */
  15646. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15647. /**
  15648. * Get the world position of a point that is in the local space of the bone
  15649. * @param position The local position
  15650. * @param mesh The mesh that this bone is attached to
  15651. * @returns The world position
  15652. */
  15653. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15654. /**
  15655. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15656. * @param position The local position
  15657. * @param mesh The mesh that this bone is attached to
  15658. * @param result The vector3 that the world position should be copied to
  15659. */
  15660. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15661. /**
  15662. * Get the local position of a point that is in world space
  15663. * @param position The world position
  15664. * @param mesh The mesh that this bone is attached to
  15665. * @returns The local position
  15666. */
  15667. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15668. /**
  15669. * Get the local position of a point that is in world space and copy it to the result param
  15670. * @param position The world position
  15671. * @param mesh The mesh that this bone is attached to
  15672. * @param result The vector3 that the local position should be copied to
  15673. */
  15674. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15675. }
  15676. }
  15677. declare module "babylonjs/Animations/runtimeAnimation" {
  15678. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15679. import { Animatable } from "babylonjs/Animations/animatable";
  15680. import { Scene } from "babylonjs/scene";
  15681. /**
  15682. * Defines a runtime animation
  15683. */
  15684. export class RuntimeAnimation {
  15685. private _events;
  15686. /**
  15687. * The current frame of the runtime animation
  15688. */
  15689. private _currentFrame;
  15690. /**
  15691. * The animation used by the runtime animation
  15692. */
  15693. private _animation;
  15694. /**
  15695. * The target of the runtime animation
  15696. */
  15697. private _target;
  15698. /**
  15699. * The initiating animatable
  15700. */
  15701. private _host;
  15702. /**
  15703. * The original value of the runtime animation
  15704. */
  15705. private _originalValue;
  15706. /**
  15707. * The original blend value of the runtime animation
  15708. */
  15709. private _originalBlendValue;
  15710. /**
  15711. * The offsets cache of the runtime animation
  15712. */
  15713. private _offsetsCache;
  15714. /**
  15715. * The high limits cache of the runtime animation
  15716. */
  15717. private _highLimitsCache;
  15718. /**
  15719. * Specifies if the runtime animation has been stopped
  15720. */
  15721. private _stopped;
  15722. /**
  15723. * The blending factor of the runtime animation
  15724. */
  15725. private _blendingFactor;
  15726. /**
  15727. * The BabylonJS scene
  15728. */
  15729. private _scene;
  15730. /**
  15731. * The current value of the runtime animation
  15732. */
  15733. private _currentValue;
  15734. /** @hidden */
  15735. _animationState: _IAnimationState;
  15736. /**
  15737. * The active target of the runtime animation
  15738. */
  15739. private _activeTargets;
  15740. private _currentActiveTarget;
  15741. private _directTarget;
  15742. /**
  15743. * The target path of the runtime animation
  15744. */
  15745. private _targetPath;
  15746. /**
  15747. * The weight of the runtime animation
  15748. */
  15749. private _weight;
  15750. /**
  15751. * The ratio offset of the runtime animation
  15752. */
  15753. private _ratioOffset;
  15754. /**
  15755. * The previous delay of the runtime animation
  15756. */
  15757. private _previousDelay;
  15758. /**
  15759. * The previous ratio of the runtime animation
  15760. */
  15761. private _previousRatio;
  15762. private _enableBlending;
  15763. private _keys;
  15764. private _minFrame;
  15765. private _maxFrame;
  15766. private _minValue;
  15767. private _maxValue;
  15768. private _targetIsArray;
  15769. /**
  15770. * Gets the current frame of the runtime animation
  15771. */
  15772. get currentFrame(): number;
  15773. /**
  15774. * Gets the weight of the runtime animation
  15775. */
  15776. get weight(): number;
  15777. /**
  15778. * Gets the current value of the runtime animation
  15779. */
  15780. get currentValue(): any;
  15781. /**
  15782. * Gets the target path of the runtime animation
  15783. */
  15784. get targetPath(): string;
  15785. /**
  15786. * Gets the actual target of the runtime animation
  15787. */
  15788. get target(): any;
  15789. /**
  15790. * Gets the additive state of the runtime animation
  15791. */
  15792. get isAdditive(): boolean;
  15793. /** @hidden */
  15794. _onLoop: () => void;
  15795. /**
  15796. * Create a new RuntimeAnimation object
  15797. * @param target defines the target of the animation
  15798. * @param animation defines the source animation object
  15799. * @param scene defines the hosting scene
  15800. * @param host defines the initiating Animatable
  15801. */
  15802. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15803. private _preparePath;
  15804. /**
  15805. * Gets the animation from the runtime animation
  15806. */
  15807. get animation(): Animation;
  15808. /**
  15809. * Resets the runtime animation to the beginning
  15810. * @param restoreOriginal defines whether to restore the target property to the original value
  15811. */
  15812. reset(restoreOriginal?: boolean): void;
  15813. /**
  15814. * Specifies if the runtime animation is stopped
  15815. * @returns Boolean specifying if the runtime animation is stopped
  15816. */
  15817. isStopped(): boolean;
  15818. /**
  15819. * Disposes of the runtime animation
  15820. */
  15821. dispose(): void;
  15822. /**
  15823. * Apply the interpolated value to the target
  15824. * @param currentValue defines the value computed by the animation
  15825. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15826. */
  15827. setValue(currentValue: any, weight: number): void;
  15828. private _getOriginalValues;
  15829. private _setValue;
  15830. /**
  15831. * Gets the loop pmode of the runtime animation
  15832. * @returns Loop Mode
  15833. */
  15834. private _getCorrectLoopMode;
  15835. /**
  15836. * Move the current animation to a given frame
  15837. * @param frame defines the frame to move to
  15838. */
  15839. goToFrame(frame: number): void;
  15840. /**
  15841. * @hidden Internal use only
  15842. */
  15843. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15844. /**
  15845. * Execute the current animation
  15846. * @param delay defines the delay to add to the current frame
  15847. * @param from defines the lower bound of the animation range
  15848. * @param to defines the upper bound of the animation range
  15849. * @param loop defines if the current animation must loop
  15850. * @param speedRatio defines the current speed ratio
  15851. * @param weight defines the weight of the animation (default is -1 so no weight)
  15852. * @param onLoop optional callback called when animation loops
  15853. * @returns a boolean indicating if the animation is running
  15854. */
  15855. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15856. }
  15857. }
  15858. declare module "babylonjs/Animations/animatable" {
  15859. import { Animation } from "babylonjs/Animations/animation";
  15860. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  15861. import { Nullable } from "babylonjs/types";
  15862. import { Observable } from "babylonjs/Misc/observable";
  15863. import { Scene } from "babylonjs/scene";
  15864. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  15865. import { Node } from "babylonjs/node";
  15866. /**
  15867. * Class used to store an actual running animation
  15868. */
  15869. export class Animatable {
  15870. /** defines the target object */
  15871. target: any;
  15872. /** defines the starting frame number (default is 0) */
  15873. fromFrame: number;
  15874. /** defines the ending frame number (default is 100) */
  15875. toFrame: number;
  15876. /** defines if the animation must loop (default is false) */
  15877. loopAnimation: boolean;
  15878. /** defines a callback to call when animation ends if it is not looping */
  15879. onAnimationEnd?: (() => void) | null | undefined;
  15880. /** defines a callback to call when animation loops */
  15881. onAnimationLoop?: (() => void) | null | undefined;
  15882. /** defines whether the animation should be evaluated additively */
  15883. isAdditive: boolean;
  15884. private _localDelayOffset;
  15885. private _pausedDelay;
  15886. private _runtimeAnimations;
  15887. private _paused;
  15888. private _scene;
  15889. private _speedRatio;
  15890. private _weight;
  15891. private _syncRoot;
  15892. /**
  15893. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15894. * This will only apply for non looping animation (default is true)
  15895. */
  15896. disposeOnEnd: boolean;
  15897. /**
  15898. * Gets a boolean indicating if the animation has started
  15899. */
  15900. animationStarted: boolean;
  15901. /**
  15902. * Observer raised when the animation ends
  15903. */
  15904. onAnimationEndObservable: Observable<Animatable>;
  15905. /**
  15906. * Observer raised when the animation loops
  15907. */
  15908. onAnimationLoopObservable: Observable<Animatable>;
  15909. /**
  15910. * Gets the root Animatable used to synchronize and normalize animations
  15911. */
  15912. get syncRoot(): Nullable<Animatable>;
  15913. /**
  15914. * Gets the current frame of the first RuntimeAnimation
  15915. * Used to synchronize Animatables
  15916. */
  15917. get masterFrame(): number;
  15918. /**
  15919. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15920. */
  15921. get weight(): number;
  15922. set weight(value: number);
  15923. /**
  15924. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15925. */
  15926. get speedRatio(): number;
  15927. set speedRatio(value: number);
  15928. /**
  15929. * Creates a new Animatable
  15930. * @param scene defines the hosting scene
  15931. * @param target defines the target object
  15932. * @param fromFrame defines the starting frame number (default is 0)
  15933. * @param toFrame defines the ending frame number (default is 100)
  15934. * @param loopAnimation defines if the animation must loop (default is false)
  15935. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15936. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15937. * @param animations defines a group of animation to add to the new Animatable
  15938. * @param onAnimationLoop defines a callback to call when animation loops
  15939. * @param isAdditive defines whether the animation should be evaluated additively
  15940. */
  15941. constructor(scene: Scene,
  15942. /** defines the target object */
  15943. target: any,
  15944. /** defines the starting frame number (default is 0) */
  15945. fromFrame?: number,
  15946. /** defines the ending frame number (default is 100) */
  15947. toFrame?: number,
  15948. /** defines if the animation must loop (default is false) */
  15949. loopAnimation?: boolean, speedRatio?: number,
  15950. /** defines a callback to call when animation ends if it is not looping */
  15951. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15952. /** defines a callback to call when animation loops */
  15953. onAnimationLoop?: (() => void) | null | undefined,
  15954. /** defines whether the animation should be evaluated additively */
  15955. isAdditive?: boolean);
  15956. /**
  15957. * Synchronize and normalize current Animatable with a source Animatable
  15958. * This is useful when using animation weights and when animations are not of the same length
  15959. * @param root defines the root Animatable to synchronize with
  15960. * @returns the current Animatable
  15961. */
  15962. syncWith(root: Animatable): Animatable;
  15963. /**
  15964. * Gets the list of runtime animations
  15965. * @returns an array of RuntimeAnimation
  15966. */
  15967. getAnimations(): RuntimeAnimation[];
  15968. /**
  15969. * Adds more animations to the current animatable
  15970. * @param target defines the target of the animations
  15971. * @param animations defines the new animations to add
  15972. */
  15973. appendAnimations(target: any, animations: Animation[]): void;
  15974. /**
  15975. * Gets the source animation for a specific property
  15976. * @param property defines the propertyu to look for
  15977. * @returns null or the source animation for the given property
  15978. */
  15979. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15980. /**
  15981. * Gets the runtime animation for a specific property
  15982. * @param property defines the propertyu to look for
  15983. * @returns null or the runtime animation for the given property
  15984. */
  15985. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15986. /**
  15987. * Resets the animatable to its original state
  15988. */
  15989. reset(): void;
  15990. /**
  15991. * Allows the animatable to blend with current running animations
  15992. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15993. * @param blendingSpeed defines the blending speed to use
  15994. */
  15995. enableBlending(blendingSpeed: number): void;
  15996. /**
  15997. * Disable animation blending
  15998. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15999. */
  16000. disableBlending(): void;
  16001. /**
  16002. * Jump directly to a given frame
  16003. * @param frame defines the frame to jump to
  16004. */
  16005. goToFrame(frame: number): void;
  16006. /**
  16007. * Pause the animation
  16008. */
  16009. pause(): void;
  16010. /**
  16011. * Restart the animation
  16012. */
  16013. restart(): void;
  16014. private _raiseOnAnimationEnd;
  16015. /**
  16016. * Stop and delete the current animation
  16017. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16018. * @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)
  16019. */
  16020. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16021. /**
  16022. * Wait asynchronously for the animation to end
  16023. * @returns a promise which will be fullfilled when the animation ends
  16024. */
  16025. waitAsync(): Promise<Animatable>;
  16026. /** @hidden */
  16027. _animate(delay: number): boolean;
  16028. }
  16029. module "babylonjs/scene" {
  16030. interface Scene {
  16031. /** @hidden */
  16032. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16033. /** @hidden */
  16034. _processLateAnimationBindingsForMatrices(holder: {
  16035. totalWeight: number;
  16036. totalAdditiveWeight: number;
  16037. animations: RuntimeAnimation[];
  16038. additiveAnimations: RuntimeAnimation[];
  16039. originalValue: Matrix;
  16040. }): any;
  16041. /** @hidden */
  16042. _processLateAnimationBindingsForQuaternions(holder: {
  16043. totalWeight: number;
  16044. totalAdditiveWeight: number;
  16045. animations: RuntimeAnimation[];
  16046. additiveAnimations: RuntimeAnimation[];
  16047. originalValue: Quaternion;
  16048. }, refQuaternion: Quaternion): Quaternion;
  16049. /** @hidden */
  16050. _processLateAnimationBindings(): void;
  16051. /**
  16052. * Will start the animation sequence of a given target
  16053. * @param target defines the target
  16054. * @param from defines from which frame should animation start
  16055. * @param to defines until which frame should animation run.
  16056. * @param weight defines the weight to apply to the animation (1.0 by default)
  16057. * @param loop defines if the animation loops
  16058. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16059. * @param onAnimationEnd defines the function to be executed when the animation ends
  16060. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16061. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16062. * @param onAnimationLoop defines the callback to call when an animation loops
  16063. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16064. * @returns the animatable object created for this animation
  16065. */
  16066. 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;
  16067. /**
  16068. * Will start the animation sequence of a given target
  16069. * @param target defines the target
  16070. * @param from defines from which frame should animation start
  16071. * @param to defines until which frame should animation run.
  16072. * @param loop defines if the animation loops
  16073. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16074. * @param onAnimationEnd defines the function to be executed when the animation ends
  16075. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16076. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16077. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16078. * @param onAnimationLoop defines the callback to call when an animation loops
  16079. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16080. * @returns the animatable object created for this animation
  16081. */
  16082. 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;
  16083. /**
  16084. * Will start the animation sequence of a given target and its hierarchy
  16085. * @param target defines the target
  16086. * @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.
  16087. * @param from defines from which frame should animation start
  16088. * @param to defines until which frame should animation run.
  16089. * @param loop defines if the animation loops
  16090. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16091. * @param onAnimationEnd defines the function to be executed when the animation ends
  16092. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16093. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16094. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16095. * @param onAnimationLoop defines the callback to call when an animation loops
  16096. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16097. * @returns the list of created animatables
  16098. */
  16099. 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[];
  16100. /**
  16101. * Begin a new animation on a given node
  16102. * @param target defines the target where the animation will take place
  16103. * @param animations defines the list of animations to start
  16104. * @param from defines the initial value
  16105. * @param to defines the final value
  16106. * @param loop defines if you want animation to loop (off by default)
  16107. * @param speedRatio defines the speed ratio to apply to all animations
  16108. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16109. * @param onAnimationLoop defines the callback to call when an animation loops
  16110. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16111. * @returns the list of created animatables
  16112. */
  16113. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16114. /**
  16115. * Begin a new animation on a given node and its hierarchy
  16116. * @param target defines the root node where the animation will take place
  16117. * @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.
  16118. * @param animations defines the list of animations to start
  16119. * @param from defines the initial value
  16120. * @param to defines the final value
  16121. * @param loop defines if you want animation to loop (off by default)
  16122. * @param speedRatio defines the speed ratio to apply to all animations
  16123. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16124. * @param onAnimationLoop defines the callback to call when an animation loops
  16125. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16126. * @returns the list of animatables created for all nodes
  16127. */
  16128. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16129. /**
  16130. * Gets the animatable associated with a specific target
  16131. * @param target defines the target of the animatable
  16132. * @returns the required animatable if found
  16133. */
  16134. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16135. /**
  16136. * Gets all animatables associated with a given target
  16137. * @param target defines the target to look animatables for
  16138. * @returns an array of Animatables
  16139. */
  16140. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16141. /**
  16142. * Stops and removes all animations that have been applied to the scene
  16143. */
  16144. stopAllAnimations(): void;
  16145. /**
  16146. * Gets the current delta time used by animation engine
  16147. */
  16148. deltaTime: number;
  16149. }
  16150. }
  16151. module "babylonjs/Bones/bone" {
  16152. interface Bone {
  16153. /**
  16154. * Copy an animation range from another bone
  16155. * @param source defines the source bone
  16156. * @param rangeName defines the range name to copy
  16157. * @param frameOffset defines the frame offset
  16158. * @param rescaleAsRequired defines if rescaling must be applied if required
  16159. * @param skelDimensionsRatio defines the scaling ratio
  16160. * @returns true if operation was successful
  16161. */
  16162. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16163. }
  16164. }
  16165. }
  16166. declare module "babylonjs/Bones/skeleton" {
  16167. import { Bone } from "babylonjs/Bones/bone";
  16168. import { Observable } from "babylonjs/Misc/observable";
  16169. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16170. import { Scene } from "babylonjs/scene";
  16171. import { Nullable } from "babylonjs/types";
  16172. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16173. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16174. import { Animatable } from "babylonjs/Animations/animatable";
  16175. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16176. import { Animation } from "babylonjs/Animations/animation";
  16177. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16178. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16179. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16180. /**
  16181. * Class used to handle skinning animations
  16182. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16183. */
  16184. export class Skeleton implements IAnimatable {
  16185. /** defines the skeleton name */
  16186. name: string;
  16187. /** defines the skeleton Id */
  16188. id: string;
  16189. /**
  16190. * Defines the list of child bones
  16191. */
  16192. bones: Bone[];
  16193. /**
  16194. * Defines an estimate of the dimension of the skeleton at rest
  16195. */
  16196. dimensionsAtRest: Vector3;
  16197. /**
  16198. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16199. */
  16200. needInitialSkinMatrix: boolean;
  16201. /**
  16202. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16203. */
  16204. overrideMesh: Nullable<AbstractMesh>;
  16205. /**
  16206. * Gets the list of animations attached to this skeleton
  16207. */
  16208. animations: Array<Animation>;
  16209. private _scene;
  16210. private _isDirty;
  16211. private _transformMatrices;
  16212. private _transformMatrixTexture;
  16213. private _meshesWithPoseMatrix;
  16214. private _animatables;
  16215. private _identity;
  16216. private _synchronizedWithMesh;
  16217. private _ranges;
  16218. private _lastAbsoluteTransformsUpdateId;
  16219. private _canUseTextureForBones;
  16220. private _uniqueId;
  16221. /** @hidden */
  16222. _numBonesWithLinkedTransformNode: number;
  16223. /** @hidden */
  16224. _hasWaitingData: Nullable<boolean>;
  16225. /**
  16226. * Specifies if the skeleton should be serialized
  16227. */
  16228. doNotSerialize: boolean;
  16229. private _useTextureToStoreBoneMatrices;
  16230. /**
  16231. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16232. * Please note that this option is not available if the hardware does not support it
  16233. */
  16234. get useTextureToStoreBoneMatrices(): boolean;
  16235. set useTextureToStoreBoneMatrices(value: boolean);
  16236. private _animationPropertiesOverride;
  16237. /**
  16238. * Gets or sets the animation properties override
  16239. */
  16240. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16241. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16242. /**
  16243. * List of inspectable custom properties (used by the Inspector)
  16244. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16245. */
  16246. inspectableCustomProperties: IInspectable[];
  16247. /**
  16248. * An observable triggered before computing the skeleton's matrices
  16249. */
  16250. onBeforeComputeObservable: Observable<Skeleton>;
  16251. /**
  16252. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16253. */
  16254. get isUsingTextureForMatrices(): boolean;
  16255. /**
  16256. * Gets the unique ID of this skeleton
  16257. */
  16258. get uniqueId(): number;
  16259. /**
  16260. * Creates a new skeleton
  16261. * @param name defines the skeleton name
  16262. * @param id defines the skeleton Id
  16263. * @param scene defines the hosting scene
  16264. */
  16265. constructor(
  16266. /** defines the skeleton name */
  16267. name: string,
  16268. /** defines the skeleton Id */
  16269. id: string, scene: Scene);
  16270. /**
  16271. * Gets the current object class name.
  16272. * @return the class name
  16273. */
  16274. getClassName(): string;
  16275. /**
  16276. * Returns an array containing the root bones
  16277. * @returns an array containing the root bones
  16278. */
  16279. getChildren(): Array<Bone>;
  16280. /**
  16281. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16282. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16283. * @returns a Float32Array containing matrices data
  16284. */
  16285. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16286. /**
  16287. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16288. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16289. * @returns a raw texture containing the data
  16290. */
  16291. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16292. /**
  16293. * Gets the current hosting scene
  16294. * @returns a scene object
  16295. */
  16296. getScene(): Scene;
  16297. /**
  16298. * Gets a string representing the current skeleton data
  16299. * @param fullDetails defines a boolean indicating if we want a verbose version
  16300. * @returns a string representing the current skeleton data
  16301. */
  16302. toString(fullDetails?: boolean): string;
  16303. /**
  16304. * Get bone's index searching by name
  16305. * @param name defines bone's name to search for
  16306. * @return the indice of the bone. Returns -1 if not found
  16307. */
  16308. getBoneIndexByName(name: string): number;
  16309. /**
  16310. * Creater a new animation range
  16311. * @param name defines the name of the range
  16312. * @param from defines the start key
  16313. * @param to defines the end key
  16314. */
  16315. createAnimationRange(name: string, from: number, to: number): void;
  16316. /**
  16317. * Delete a specific animation range
  16318. * @param name defines the name of the range
  16319. * @param deleteFrames defines if frames must be removed as well
  16320. */
  16321. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16322. /**
  16323. * Gets a specific animation range
  16324. * @param name defines the name of the range to look for
  16325. * @returns the requested animation range or null if not found
  16326. */
  16327. getAnimationRange(name: string): Nullable<AnimationRange>;
  16328. /**
  16329. * Gets the list of all animation ranges defined on this skeleton
  16330. * @returns an array
  16331. */
  16332. getAnimationRanges(): Nullable<AnimationRange>[];
  16333. /**
  16334. * Copy animation range from a source skeleton.
  16335. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16336. * @param source defines the source skeleton
  16337. * @param name defines the name of the range to copy
  16338. * @param rescaleAsRequired defines if rescaling must be applied if required
  16339. * @returns true if operation was successful
  16340. */
  16341. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16342. /**
  16343. * Forces the skeleton to go to rest pose
  16344. */
  16345. returnToRest(): void;
  16346. private _getHighestAnimationFrame;
  16347. /**
  16348. * Begin a specific animation range
  16349. * @param name defines the name of the range to start
  16350. * @param loop defines if looping must be turned on (false by default)
  16351. * @param speedRatio defines the speed ratio to apply (1 by default)
  16352. * @param onAnimationEnd defines a callback which will be called when animation will end
  16353. * @returns a new animatable
  16354. */
  16355. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16356. /**
  16357. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16358. * @param skeleton defines the Skeleton containing the animation range to convert
  16359. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16360. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16361. * @returns the original skeleton
  16362. */
  16363. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16364. /** @hidden */
  16365. _markAsDirty(): void;
  16366. /** @hidden */
  16367. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16368. /** @hidden */
  16369. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16370. private _computeTransformMatrices;
  16371. /**
  16372. * Build all resources required to render a skeleton
  16373. */
  16374. prepare(): void;
  16375. /**
  16376. * Gets the list of animatables currently running for this skeleton
  16377. * @returns an array of animatables
  16378. */
  16379. getAnimatables(): IAnimatable[];
  16380. /**
  16381. * Clone the current skeleton
  16382. * @param name defines the name of the new skeleton
  16383. * @param id defines the id of the new skeleton
  16384. * @returns the new skeleton
  16385. */
  16386. clone(name: string, id?: string): Skeleton;
  16387. /**
  16388. * Enable animation blending for this skeleton
  16389. * @param blendingSpeed defines the blending speed to apply
  16390. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16391. */
  16392. enableBlending(blendingSpeed?: number): void;
  16393. /**
  16394. * Releases all resources associated with the current skeleton
  16395. */
  16396. dispose(): void;
  16397. /**
  16398. * Serialize the skeleton in a JSON object
  16399. * @returns a JSON object
  16400. */
  16401. serialize(): any;
  16402. /**
  16403. * Creates a new skeleton from serialized data
  16404. * @param parsedSkeleton defines the serialized data
  16405. * @param scene defines the hosting scene
  16406. * @returns a new skeleton
  16407. */
  16408. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16409. /**
  16410. * Compute all node absolute transforms
  16411. * @param forceUpdate defines if computation must be done even if cache is up to date
  16412. */
  16413. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16414. /**
  16415. * Gets the root pose matrix
  16416. * @returns a matrix
  16417. */
  16418. getPoseMatrix(): Nullable<Matrix>;
  16419. /**
  16420. * Sorts bones per internal index
  16421. */
  16422. sortBones(): void;
  16423. private _sortBones;
  16424. }
  16425. }
  16426. declare module "babylonjs/Meshes/instancedMesh" {
  16427. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16428. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16429. import { Camera } from "babylonjs/Cameras/camera";
  16430. import { Node } from "babylonjs/node";
  16431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16432. import { Mesh } from "babylonjs/Meshes/mesh";
  16433. import { Material } from "babylonjs/Materials/material";
  16434. import { Skeleton } from "babylonjs/Bones/skeleton";
  16435. import { Light } from "babylonjs/Lights/light";
  16436. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16437. /**
  16438. * Creates an instance based on a source mesh.
  16439. */
  16440. export class InstancedMesh extends AbstractMesh {
  16441. private _sourceMesh;
  16442. private _currentLOD;
  16443. /** @hidden */
  16444. _indexInSourceMeshInstanceArray: number;
  16445. constructor(name: string, source: Mesh);
  16446. /**
  16447. * Returns the string "InstancedMesh".
  16448. */
  16449. getClassName(): string;
  16450. /** Gets the list of lights affecting that mesh */
  16451. get lightSources(): Light[];
  16452. _resyncLightSources(): void;
  16453. _resyncLightSource(light: Light): void;
  16454. _removeLightSource(light: Light, dispose: boolean): void;
  16455. /**
  16456. * If the source mesh receives shadows
  16457. */
  16458. get receiveShadows(): boolean;
  16459. /**
  16460. * The material of the source mesh
  16461. */
  16462. get material(): Nullable<Material>;
  16463. /**
  16464. * Visibility of the source mesh
  16465. */
  16466. get visibility(): number;
  16467. /**
  16468. * Skeleton of the source mesh
  16469. */
  16470. get skeleton(): Nullable<Skeleton>;
  16471. /**
  16472. * Rendering ground id of the source mesh
  16473. */
  16474. get renderingGroupId(): number;
  16475. set renderingGroupId(value: number);
  16476. /**
  16477. * Returns the total number of vertices (integer).
  16478. */
  16479. getTotalVertices(): number;
  16480. /**
  16481. * Returns a positive integer : the total number of indices in this mesh geometry.
  16482. * @returns the numner of indices or zero if the mesh has no geometry.
  16483. */
  16484. getTotalIndices(): number;
  16485. /**
  16486. * The source mesh of the instance
  16487. */
  16488. get sourceMesh(): Mesh;
  16489. /**
  16490. * Creates a new InstancedMesh object from the mesh model.
  16491. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16492. * @param name defines the name of the new instance
  16493. * @returns a new InstancedMesh
  16494. */
  16495. createInstance(name: string): InstancedMesh;
  16496. /**
  16497. * Is this node ready to be used/rendered
  16498. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16499. * @return {boolean} is it ready
  16500. */
  16501. isReady(completeCheck?: boolean): boolean;
  16502. /**
  16503. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16504. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16505. * @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.
  16506. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16507. */
  16508. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16509. /**
  16510. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16511. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16512. * The `data` are either a numeric array either a Float32Array.
  16513. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16514. * 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).
  16515. * Note that a new underlying VertexBuffer object is created each call.
  16516. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16517. *
  16518. * Possible `kind` values :
  16519. * - VertexBuffer.PositionKind
  16520. * - VertexBuffer.UVKind
  16521. * - VertexBuffer.UV2Kind
  16522. * - VertexBuffer.UV3Kind
  16523. * - VertexBuffer.UV4Kind
  16524. * - VertexBuffer.UV5Kind
  16525. * - VertexBuffer.UV6Kind
  16526. * - VertexBuffer.ColorKind
  16527. * - VertexBuffer.MatricesIndicesKind
  16528. * - VertexBuffer.MatricesIndicesExtraKind
  16529. * - VertexBuffer.MatricesWeightsKind
  16530. * - VertexBuffer.MatricesWeightsExtraKind
  16531. *
  16532. * Returns the Mesh.
  16533. */
  16534. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16535. /**
  16536. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16537. * If the mesh has no geometry, it is simply returned as it is.
  16538. * The `data` are either a numeric array either a Float32Array.
  16539. * No new underlying VertexBuffer object is created.
  16540. * 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.
  16541. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16542. *
  16543. * Possible `kind` values :
  16544. * - VertexBuffer.PositionKind
  16545. * - VertexBuffer.UVKind
  16546. * - VertexBuffer.UV2Kind
  16547. * - VertexBuffer.UV3Kind
  16548. * - VertexBuffer.UV4Kind
  16549. * - VertexBuffer.UV5Kind
  16550. * - VertexBuffer.UV6Kind
  16551. * - VertexBuffer.ColorKind
  16552. * - VertexBuffer.MatricesIndicesKind
  16553. * - VertexBuffer.MatricesIndicesExtraKind
  16554. * - VertexBuffer.MatricesWeightsKind
  16555. * - VertexBuffer.MatricesWeightsExtraKind
  16556. *
  16557. * Returns the Mesh.
  16558. */
  16559. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16560. /**
  16561. * Sets the mesh indices.
  16562. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16563. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16564. * This method creates a new index buffer each call.
  16565. * Returns the Mesh.
  16566. */
  16567. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16568. /**
  16569. * Boolean : True if the mesh owns the requested kind of data.
  16570. */
  16571. isVerticesDataPresent(kind: string): boolean;
  16572. /**
  16573. * Returns an array of indices (IndicesArray).
  16574. */
  16575. getIndices(): Nullable<IndicesArray>;
  16576. get _positions(): Nullable<Vector3[]>;
  16577. /**
  16578. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16579. * This means the mesh underlying bounding box and sphere are recomputed.
  16580. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16581. * @returns the current mesh
  16582. */
  16583. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16584. /** @hidden */
  16585. _preActivate(): InstancedMesh;
  16586. /** @hidden */
  16587. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16588. /** @hidden */
  16589. _postActivate(): void;
  16590. getWorldMatrix(): Matrix;
  16591. get isAnInstance(): boolean;
  16592. /**
  16593. * Returns the current associated LOD AbstractMesh.
  16594. */
  16595. getLOD(camera: Camera): AbstractMesh;
  16596. /** @hidden */
  16597. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16598. /** @hidden */
  16599. _syncSubMeshes(): InstancedMesh;
  16600. /** @hidden */
  16601. _generatePointsArray(): boolean;
  16602. /**
  16603. * Creates a new InstancedMesh from the current mesh.
  16604. * - name (string) : the cloned mesh name
  16605. * - newParent (optional Node) : the optional Node to parent the clone to.
  16606. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16607. *
  16608. * Returns the clone.
  16609. */
  16610. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16611. /**
  16612. * Disposes the InstancedMesh.
  16613. * Returns nothing.
  16614. */
  16615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16616. }
  16617. module "babylonjs/Meshes/mesh" {
  16618. interface Mesh {
  16619. /**
  16620. * Register a custom buffer that will be instanced
  16621. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16622. * @param kind defines the buffer kind
  16623. * @param stride defines the stride in floats
  16624. */
  16625. registerInstancedBuffer(kind: string, stride: number): void;
  16626. /**
  16627. * true to use the edge renderer for all instances of this mesh
  16628. */
  16629. edgesShareWithInstances: boolean;
  16630. /** @hidden */
  16631. _userInstancedBuffersStorage: {
  16632. data: {
  16633. [key: string]: Float32Array;
  16634. };
  16635. sizes: {
  16636. [key: string]: number;
  16637. };
  16638. vertexBuffers: {
  16639. [key: string]: Nullable<VertexBuffer>;
  16640. };
  16641. strides: {
  16642. [key: string]: number;
  16643. };
  16644. };
  16645. }
  16646. }
  16647. module "babylonjs/Meshes/abstractMesh" {
  16648. interface AbstractMesh {
  16649. /**
  16650. * Object used to store instanced buffers defined by user
  16651. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16652. */
  16653. instancedBuffers: {
  16654. [key: string]: any;
  16655. };
  16656. }
  16657. }
  16658. }
  16659. declare module "babylonjs/Materials/shaderMaterial" {
  16660. import { Nullable } from "babylonjs/types";
  16661. import { Scene } from "babylonjs/scene";
  16662. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16664. import { Mesh } from "babylonjs/Meshes/mesh";
  16665. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16666. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16667. import { Effect } from "babylonjs/Materials/effect";
  16668. import { Material } from "babylonjs/Materials/material";
  16669. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16670. /**
  16671. * Defines the options associated with the creation of a shader material.
  16672. */
  16673. export interface IShaderMaterialOptions {
  16674. /**
  16675. * Does the material work in alpha blend mode
  16676. */
  16677. needAlphaBlending: boolean;
  16678. /**
  16679. * Does the material work in alpha test mode
  16680. */
  16681. needAlphaTesting: boolean;
  16682. /**
  16683. * The list of attribute names used in the shader
  16684. */
  16685. attributes: string[];
  16686. /**
  16687. * The list of unifrom names used in the shader
  16688. */
  16689. uniforms: string[];
  16690. /**
  16691. * The list of UBO names used in the shader
  16692. */
  16693. uniformBuffers: string[];
  16694. /**
  16695. * The list of sampler names used in the shader
  16696. */
  16697. samplers: string[];
  16698. /**
  16699. * The list of defines used in the shader
  16700. */
  16701. defines: string[];
  16702. }
  16703. /**
  16704. * 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.
  16705. *
  16706. * This returned material effects how the mesh will look based on the code in the shaders.
  16707. *
  16708. * @see https://doc.babylonjs.com/how_to/shader_material
  16709. */
  16710. export class ShaderMaterial extends Material {
  16711. private _shaderPath;
  16712. private _options;
  16713. private _textures;
  16714. private _textureArrays;
  16715. private _floats;
  16716. private _ints;
  16717. private _floatsArrays;
  16718. private _colors3;
  16719. private _colors3Arrays;
  16720. private _colors4;
  16721. private _colors4Arrays;
  16722. private _vectors2;
  16723. private _vectors3;
  16724. private _vectors4;
  16725. private _matrices;
  16726. private _matrixArrays;
  16727. private _matrices3x3;
  16728. private _matrices2x2;
  16729. private _vectors2Arrays;
  16730. private _vectors3Arrays;
  16731. private _vectors4Arrays;
  16732. private _cachedWorldViewMatrix;
  16733. private _cachedWorldViewProjectionMatrix;
  16734. private _renderId;
  16735. private _multiview;
  16736. private _cachedDefines;
  16737. /** Define the Url to load snippets */
  16738. static SnippetUrl: string;
  16739. /** Snippet ID if the material was created from the snippet server */
  16740. snippetId: string;
  16741. /**
  16742. * Instantiate a new shader material.
  16743. * 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.
  16744. * This returned material effects how the mesh will look based on the code in the shaders.
  16745. * @see https://doc.babylonjs.com/how_to/shader_material
  16746. * @param name Define the name of the material in the scene
  16747. * @param scene Define the scene the material belongs to
  16748. * @param shaderPath Defines the route to the shader code in one of three ways:
  16749. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16750. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16751. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16752. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16753. * @param options Define the options used to create the shader
  16754. */
  16755. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16756. /**
  16757. * Gets the shader path used to define the shader code
  16758. * It can be modified to trigger a new compilation
  16759. */
  16760. get shaderPath(): any;
  16761. /**
  16762. * Sets the shader path used to define the shader code
  16763. * It can be modified to trigger a new compilation
  16764. */
  16765. set shaderPath(shaderPath: any);
  16766. /**
  16767. * Gets the options used to compile the shader.
  16768. * They can be modified to trigger a new compilation
  16769. */
  16770. get options(): IShaderMaterialOptions;
  16771. /**
  16772. * Gets the current class name of the material e.g. "ShaderMaterial"
  16773. * Mainly use in serialization.
  16774. * @returns the class name
  16775. */
  16776. getClassName(): string;
  16777. /**
  16778. * Specifies if the material will require alpha blending
  16779. * @returns a boolean specifying if alpha blending is needed
  16780. */
  16781. needAlphaBlending(): boolean;
  16782. /**
  16783. * Specifies if this material should be rendered in alpha test mode
  16784. * @returns a boolean specifying if an alpha test is needed.
  16785. */
  16786. needAlphaTesting(): boolean;
  16787. private _checkUniform;
  16788. /**
  16789. * Set a texture in the shader.
  16790. * @param name Define the name of the uniform samplers as defined in the shader
  16791. * @param texture Define the texture to bind to this sampler
  16792. * @return the material itself allowing "fluent" like uniform updates
  16793. */
  16794. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16795. /**
  16796. * Set a texture array in the shader.
  16797. * @param name Define the name of the uniform sampler array as defined in the shader
  16798. * @param textures Define the list of textures to bind to this sampler
  16799. * @return the material itself allowing "fluent" like uniform updates
  16800. */
  16801. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16802. /**
  16803. * Set a float in the shader.
  16804. * @param name Define the name of the uniform as defined in the shader
  16805. * @param value Define the value to give to the uniform
  16806. * @return the material itself allowing "fluent" like uniform updates
  16807. */
  16808. setFloat(name: string, value: number): ShaderMaterial;
  16809. /**
  16810. * Set a int in the shader.
  16811. * @param name Define the name of the uniform as defined in the shader
  16812. * @param value Define the value to give to the uniform
  16813. * @return the material itself allowing "fluent" like uniform updates
  16814. */
  16815. setInt(name: string, value: number): ShaderMaterial;
  16816. /**
  16817. * Set an array of floats in the shader.
  16818. * @param name Define the name of the uniform as defined in the shader
  16819. * @param value Define the value to give to the uniform
  16820. * @return the material itself allowing "fluent" like uniform updates
  16821. */
  16822. setFloats(name: string, value: number[]): ShaderMaterial;
  16823. /**
  16824. * Set a vec3 in the shader from a Color3.
  16825. * @param name Define the name of the uniform as defined in the shader
  16826. * @param value Define the value to give to the uniform
  16827. * @return the material itself allowing "fluent" like uniform updates
  16828. */
  16829. setColor3(name: string, value: Color3): ShaderMaterial;
  16830. /**
  16831. * Set a vec3 array in the shader from a Color3 array.
  16832. * @param name Define the name of the uniform as defined in the shader
  16833. * @param value Define the value to give to the uniform
  16834. * @return the material itself allowing "fluent" like uniform updates
  16835. */
  16836. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16837. /**
  16838. * Set a vec4 in the shader from a Color4.
  16839. * @param name Define the name of the uniform as defined in the shader
  16840. * @param value Define the value to give to the uniform
  16841. * @return the material itself allowing "fluent" like uniform updates
  16842. */
  16843. setColor4(name: string, value: Color4): ShaderMaterial;
  16844. /**
  16845. * Set a vec4 array in the shader from a Color4 array.
  16846. * @param name Define the name of the uniform as defined in the shader
  16847. * @param value Define the value to give to the uniform
  16848. * @return the material itself allowing "fluent" like uniform updates
  16849. */
  16850. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16851. /**
  16852. * Set a vec2 in the shader from a Vector2.
  16853. * @param name Define the name of the uniform as defined in the shader
  16854. * @param value Define the value to give to the uniform
  16855. * @return the material itself allowing "fluent" like uniform updates
  16856. */
  16857. setVector2(name: string, value: Vector2): ShaderMaterial;
  16858. /**
  16859. * Set a vec3 in the shader from a Vector3.
  16860. * @param name Define the name of the uniform as defined in the shader
  16861. * @param value Define the value to give to the uniform
  16862. * @return the material itself allowing "fluent" like uniform updates
  16863. */
  16864. setVector3(name: string, value: Vector3): ShaderMaterial;
  16865. /**
  16866. * Set a vec4 in the shader from a Vector4.
  16867. * @param name Define the name of the uniform as defined in the shader
  16868. * @param value Define the value to give to the uniform
  16869. * @return the material itself allowing "fluent" like uniform updates
  16870. */
  16871. setVector4(name: string, value: Vector4): ShaderMaterial;
  16872. /**
  16873. * Set a mat4 in the shader from a Matrix.
  16874. * @param name Define the name of the uniform as defined in the shader
  16875. * @param value Define the value to give to the uniform
  16876. * @return the material itself allowing "fluent" like uniform updates
  16877. */
  16878. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16879. /**
  16880. * Set a float32Array in the shader from a matrix array.
  16881. * @param name Define the name of the uniform as defined in the shader
  16882. * @param value Define the value to give to the uniform
  16883. * @return the material itself allowing "fluent" like uniform updates
  16884. */
  16885. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16886. /**
  16887. * Set a mat3 in the shader from a Float32Array.
  16888. * @param name Define the name of the uniform as defined in the shader
  16889. * @param value Define the value to give to the uniform
  16890. * @return the material itself allowing "fluent" like uniform updates
  16891. */
  16892. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  16893. /**
  16894. * Set a mat2 in the shader from a Float32Array.
  16895. * @param name Define the name of the uniform as defined in the shader
  16896. * @param value Define the value to give to the uniform
  16897. * @return the material itself allowing "fluent" like uniform updates
  16898. */
  16899. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  16900. /**
  16901. * Set a vec2 array in the shader from a number array.
  16902. * @param name Define the name of the uniform as defined in the shader
  16903. * @param value Define the value to give to the uniform
  16904. * @return the material itself allowing "fluent" like uniform updates
  16905. */
  16906. setArray2(name: string, value: number[]): ShaderMaterial;
  16907. /**
  16908. * Set a vec3 array in the shader from a number array.
  16909. * @param name Define the name of the uniform as defined in the shader
  16910. * @param value Define the value to give to the uniform
  16911. * @return the material itself allowing "fluent" like uniform updates
  16912. */
  16913. setArray3(name: string, value: number[]): ShaderMaterial;
  16914. /**
  16915. * Set a vec4 array in the shader from a number array.
  16916. * @param name Define the name of the uniform as defined in the shader
  16917. * @param value Define the value to give to the uniform
  16918. * @return the material itself allowing "fluent" like uniform updates
  16919. */
  16920. setArray4(name: string, value: number[]): ShaderMaterial;
  16921. private _checkCache;
  16922. /**
  16923. * Specifies that the submesh is ready to be used
  16924. * @param mesh defines the mesh to check
  16925. * @param subMesh defines which submesh to check
  16926. * @param useInstances specifies that instances should be used
  16927. * @returns a boolean indicating that the submesh is ready or not
  16928. */
  16929. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16930. /**
  16931. * Checks if the material is ready to render the requested mesh
  16932. * @param mesh Define the mesh to render
  16933. * @param useInstances Define whether or not the material is used with instances
  16934. * @returns true if ready, otherwise false
  16935. */
  16936. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16937. /**
  16938. * Binds the world matrix to the material
  16939. * @param world defines the world transformation matrix
  16940. * @param effectOverride - If provided, use this effect instead of internal effect
  16941. */
  16942. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16943. /**
  16944. * Binds the submesh to this material by preparing the effect and shader to draw
  16945. * @param world defines the world transformation matrix
  16946. * @param mesh defines the mesh containing the submesh
  16947. * @param subMesh defines the submesh to bind the material to
  16948. */
  16949. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16950. /**
  16951. * Binds the material to the mesh
  16952. * @param world defines the world transformation matrix
  16953. * @param mesh defines the mesh to bind the material to
  16954. * @param effectOverride - If provided, use this effect instead of internal effect
  16955. */
  16956. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16957. protected _afterBind(mesh?: Mesh): void;
  16958. /**
  16959. * Gets the active textures from the material
  16960. * @returns an array of textures
  16961. */
  16962. getActiveTextures(): BaseTexture[];
  16963. /**
  16964. * Specifies if the material uses a texture
  16965. * @param texture defines the texture to check against the material
  16966. * @returns a boolean specifying if the material uses the texture
  16967. */
  16968. hasTexture(texture: BaseTexture): boolean;
  16969. /**
  16970. * Makes a duplicate of the material, and gives it a new name
  16971. * @param name defines the new name for the duplicated material
  16972. * @returns the cloned material
  16973. */
  16974. clone(name: string): ShaderMaterial;
  16975. /**
  16976. * Disposes the material
  16977. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16978. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16979. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16980. */
  16981. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16982. /**
  16983. * Serializes this material in a JSON representation
  16984. * @returns the serialized material object
  16985. */
  16986. serialize(): any;
  16987. /**
  16988. * Creates a shader material from parsed shader material data
  16989. * @param source defines the JSON represnetation of the material
  16990. * @param scene defines the hosting scene
  16991. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16992. * @returns a new material
  16993. */
  16994. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16995. /**
  16996. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16997. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16998. * @param url defines the url to load from
  16999. * @param scene defines the hosting scene
  17000. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17001. * @returns a promise that will resolve to the new ShaderMaterial
  17002. */
  17003. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17004. /**
  17005. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17006. * @param snippetId defines the snippet to load
  17007. * @param scene defines the hosting scene
  17008. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17009. * @returns a promise that will resolve to the new ShaderMaterial
  17010. */
  17011. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17012. }
  17013. }
  17014. declare module "babylonjs/Shaders/color.fragment" {
  17015. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17016. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17017. /** @hidden */
  17018. export var colorPixelShader: {
  17019. name: string;
  17020. shader: string;
  17021. };
  17022. }
  17023. declare module "babylonjs/Shaders/color.vertex" {
  17024. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17025. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17026. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17027. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17028. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17029. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17030. /** @hidden */
  17031. export var colorVertexShader: {
  17032. name: string;
  17033. shader: string;
  17034. };
  17035. }
  17036. declare module "babylonjs/Meshes/linesMesh" {
  17037. import { Nullable } from "babylonjs/types";
  17038. import { Scene } from "babylonjs/scene";
  17039. import { Color3 } from "babylonjs/Maths/math.color";
  17040. import { Node } from "babylonjs/node";
  17041. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17042. import { Mesh } from "babylonjs/Meshes/mesh";
  17043. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17044. import { Effect } from "babylonjs/Materials/effect";
  17045. import { Material } from "babylonjs/Materials/material";
  17046. import "babylonjs/Shaders/color.fragment";
  17047. import "babylonjs/Shaders/color.vertex";
  17048. /**
  17049. * Line mesh
  17050. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17051. */
  17052. export class LinesMesh extends Mesh {
  17053. /**
  17054. * If vertex color should be applied to the mesh
  17055. */
  17056. readonly useVertexColor?: boolean | undefined;
  17057. /**
  17058. * If vertex alpha should be applied to the mesh
  17059. */
  17060. readonly useVertexAlpha?: boolean | undefined;
  17061. /**
  17062. * Color of the line (Default: White)
  17063. */
  17064. color: Color3;
  17065. /**
  17066. * Alpha of the line (Default: 1)
  17067. */
  17068. alpha: number;
  17069. /**
  17070. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17071. * This margin is expressed in world space coordinates, so its value may vary.
  17072. * Default value is 0.1
  17073. */
  17074. intersectionThreshold: number;
  17075. private _colorShader;
  17076. private color4;
  17077. /**
  17078. * Creates a new LinesMesh
  17079. * @param name defines the name
  17080. * @param scene defines the hosting scene
  17081. * @param parent defines the parent mesh if any
  17082. * @param source defines the optional source LinesMesh used to clone data from
  17083. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17084. * When false, achieved by calling a clone(), also passing False.
  17085. * This will make creation of children, recursive.
  17086. * @param useVertexColor defines if this LinesMesh supports vertex color
  17087. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17088. */
  17089. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17090. /**
  17091. * If vertex color should be applied to the mesh
  17092. */
  17093. useVertexColor?: boolean | undefined,
  17094. /**
  17095. * If vertex alpha should be applied to the mesh
  17096. */
  17097. useVertexAlpha?: boolean | undefined);
  17098. private _addClipPlaneDefine;
  17099. private _removeClipPlaneDefine;
  17100. isReady(): boolean;
  17101. /**
  17102. * Returns the string "LineMesh"
  17103. */
  17104. getClassName(): string;
  17105. /**
  17106. * @hidden
  17107. */
  17108. get material(): Material;
  17109. /**
  17110. * @hidden
  17111. */
  17112. set material(value: Material);
  17113. /**
  17114. * @hidden
  17115. */
  17116. get checkCollisions(): boolean;
  17117. /** @hidden */
  17118. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17119. /** @hidden */
  17120. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17121. /**
  17122. * Disposes of the line mesh
  17123. * @param doNotRecurse If children should be disposed
  17124. */
  17125. dispose(doNotRecurse?: boolean): void;
  17126. /**
  17127. * Returns a new LineMesh object cloned from the current one.
  17128. */
  17129. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17130. /**
  17131. * Creates a new InstancedLinesMesh object from the mesh model.
  17132. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17133. * @param name defines the name of the new instance
  17134. * @returns a new InstancedLinesMesh
  17135. */
  17136. createInstance(name: string): InstancedLinesMesh;
  17137. }
  17138. /**
  17139. * Creates an instance based on a source LinesMesh
  17140. */
  17141. export class InstancedLinesMesh extends InstancedMesh {
  17142. /**
  17143. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17144. * This margin is expressed in world space coordinates, so its value may vary.
  17145. * Initilized with the intersectionThreshold value of the source LinesMesh
  17146. */
  17147. intersectionThreshold: number;
  17148. constructor(name: string, source: LinesMesh);
  17149. /**
  17150. * Returns the string "InstancedLinesMesh".
  17151. */
  17152. getClassName(): string;
  17153. }
  17154. }
  17155. declare module "babylonjs/Shaders/line.fragment" {
  17156. /** @hidden */
  17157. export var linePixelShader: {
  17158. name: string;
  17159. shader: string;
  17160. };
  17161. }
  17162. declare module "babylonjs/Shaders/line.vertex" {
  17163. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17164. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17165. /** @hidden */
  17166. export var lineVertexShader: {
  17167. name: string;
  17168. shader: string;
  17169. };
  17170. }
  17171. declare module "babylonjs/Rendering/edgesRenderer" {
  17172. import { Nullable } from "babylonjs/types";
  17173. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17175. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17176. import { IDisposable } from "babylonjs/scene";
  17177. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17178. import "babylonjs/Shaders/line.fragment";
  17179. import "babylonjs/Shaders/line.vertex";
  17180. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17181. import { SmartArray } from "babylonjs/Misc/smartArray";
  17182. module "babylonjs/scene" {
  17183. interface Scene {
  17184. /** @hidden */
  17185. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17186. }
  17187. }
  17188. module "babylonjs/Meshes/abstractMesh" {
  17189. interface AbstractMesh {
  17190. /**
  17191. * Gets the edgesRenderer associated with the mesh
  17192. */
  17193. edgesRenderer: Nullable<EdgesRenderer>;
  17194. }
  17195. }
  17196. module "babylonjs/Meshes/linesMesh" {
  17197. interface LinesMesh {
  17198. /**
  17199. * Enables the edge rendering mode on the mesh.
  17200. * This mode makes the mesh edges visible
  17201. * @param epsilon defines the maximal distance between two angles to detect a face
  17202. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17203. * @returns the currentAbstractMesh
  17204. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17205. */
  17206. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17207. }
  17208. }
  17209. module "babylonjs/Meshes/linesMesh" {
  17210. interface InstancedLinesMesh {
  17211. /**
  17212. * Enables the edge rendering mode on the mesh.
  17213. * This mode makes the mesh edges visible
  17214. * @param epsilon defines the maximal distance between two angles to detect a face
  17215. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17216. * @returns the current InstancedLinesMesh
  17217. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17218. */
  17219. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17220. }
  17221. }
  17222. /**
  17223. * Defines the minimum contract an Edges renderer should follow.
  17224. */
  17225. export interface IEdgesRenderer extends IDisposable {
  17226. /**
  17227. * Gets or sets a boolean indicating if the edgesRenderer is active
  17228. */
  17229. isEnabled: boolean;
  17230. /**
  17231. * Renders the edges of the attached mesh,
  17232. */
  17233. render(): void;
  17234. /**
  17235. * Checks wether or not the edges renderer is ready to render.
  17236. * @return true if ready, otherwise false.
  17237. */
  17238. isReady(): boolean;
  17239. /**
  17240. * List of instances to render in case the source mesh has instances
  17241. */
  17242. customInstances: SmartArray<Matrix>;
  17243. }
  17244. /**
  17245. * Defines the additional options of the edges renderer
  17246. */
  17247. export interface IEdgesRendererOptions {
  17248. /**
  17249. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17250. * If not defined, the default value is true
  17251. */
  17252. useAlternateEdgeFinder?: boolean;
  17253. /**
  17254. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17255. * If not defined, the default value is true.
  17256. * 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)
  17257. * This option is used only if useAlternateEdgeFinder = true
  17258. */
  17259. useFastVertexMerger?: boolean;
  17260. /**
  17261. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17262. * The default value is 1e-6
  17263. * This option is used only if useAlternateEdgeFinder = true
  17264. */
  17265. epsilonVertexMerge?: number;
  17266. /**
  17267. * 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
  17268. * 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.
  17269. * This option is used only if useAlternateEdgeFinder = true
  17270. */
  17271. applyTessellation?: boolean;
  17272. /**
  17273. * 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
  17274. * The default value is 1e-6
  17275. * This option is used only if useAlternateEdgeFinder = true
  17276. */
  17277. epsilonVertexAligned?: number;
  17278. }
  17279. /**
  17280. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17281. */
  17282. export class EdgesRenderer implements IEdgesRenderer {
  17283. /**
  17284. * Define the size of the edges with an orthographic camera
  17285. */
  17286. edgesWidthScalerForOrthographic: number;
  17287. /**
  17288. * Define the size of the edges with a perspective camera
  17289. */
  17290. edgesWidthScalerForPerspective: number;
  17291. protected _source: AbstractMesh;
  17292. protected _linesPositions: number[];
  17293. protected _linesNormals: number[];
  17294. protected _linesIndices: number[];
  17295. protected _epsilon: number;
  17296. protected _indicesCount: number;
  17297. protected _lineShader: ShaderMaterial;
  17298. protected _ib: DataBuffer;
  17299. protected _buffers: {
  17300. [key: string]: Nullable<VertexBuffer>;
  17301. };
  17302. protected _buffersForInstances: {
  17303. [key: string]: Nullable<VertexBuffer>;
  17304. };
  17305. protected _checkVerticesInsteadOfIndices: boolean;
  17306. protected _options: Nullable<IEdgesRendererOptions>;
  17307. private _meshRebuildObserver;
  17308. private _meshDisposeObserver;
  17309. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17310. isEnabled: boolean;
  17311. /**
  17312. * List of instances to render in case the source mesh has instances
  17313. */
  17314. customInstances: SmartArray<Matrix>;
  17315. private static GetShader;
  17316. /**
  17317. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17318. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17319. * @param source Mesh used to create edges
  17320. * @param epsilon sum of angles in adjacency to check for edge
  17321. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17322. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17323. * @param options The options to apply when generating the edges
  17324. */
  17325. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17326. protected _prepareRessources(): void;
  17327. /** @hidden */
  17328. _rebuild(): void;
  17329. /**
  17330. * Releases the required resources for the edges renderer
  17331. */
  17332. dispose(): void;
  17333. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17334. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17335. /**
  17336. * Checks if the pair of p0 and p1 is en edge
  17337. * @param faceIndex
  17338. * @param edge
  17339. * @param faceNormals
  17340. * @param p0
  17341. * @param p1
  17342. * @private
  17343. */
  17344. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17345. /**
  17346. * push line into the position, normal and index buffer
  17347. * @protected
  17348. */
  17349. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17350. /**
  17351. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17352. */
  17353. private _tessellateTriangle;
  17354. private _generateEdgesLinesAlternate;
  17355. /**
  17356. * Generates lines edges from adjacencjes
  17357. * @private
  17358. */
  17359. _generateEdgesLines(): void;
  17360. /**
  17361. * Checks wether or not the edges renderer is ready to render.
  17362. * @return true if ready, otherwise false.
  17363. */
  17364. isReady(): boolean;
  17365. /**
  17366. * Renders the edges of the attached mesh,
  17367. */
  17368. render(): void;
  17369. }
  17370. /**
  17371. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17372. */
  17373. export class LineEdgesRenderer extends EdgesRenderer {
  17374. /**
  17375. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17376. * @param source LineMesh used to generate edges
  17377. * @param epsilon not important (specified angle for edge detection)
  17378. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17379. */
  17380. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17381. /**
  17382. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17383. */
  17384. _generateEdgesLines(): void;
  17385. }
  17386. }
  17387. declare module "babylonjs/Rendering/renderingGroup" {
  17388. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17389. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17390. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17391. import { Nullable } from "babylonjs/types";
  17392. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17393. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17394. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17395. import { Material } from "babylonjs/Materials/material";
  17396. import { Scene } from "babylonjs/scene";
  17397. /**
  17398. * This represents the object necessary to create a rendering group.
  17399. * This is exclusively used and created by the rendering manager.
  17400. * To modify the behavior, you use the available helpers in your scene or meshes.
  17401. * @hidden
  17402. */
  17403. export class RenderingGroup {
  17404. index: number;
  17405. private static _zeroVector;
  17406. private _scene;
  17407. private _opaqueSubMeshes;
  17408. private _transparentSubMeshes;
  17409. private _alphaTestSubMeshes;
  17410. private _depthOnlySubMeshes;
  17411. private _particleSystems;
  17412. private _spriteManagers;
  17413. private _opaqueSortCompareFn;
  17414. private _alphaTestSortCompareFn;
  17415. private _transparentSortCompareFn;
  17416. private _renderOpaque;
  17417. private _renderAlphaTest;
  17418. private _renderTransparent;
  17419. /** @hidden */
  17420. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17421. onBeforeTransparentRendering: () => void;
  17422. /**
  17423. * Set the opaque sort comparison function.
  17424. * If null the sub meshes will be render in the order they were created
  17425. */
  17426. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17427. /**
  17428. * Set the alpha test sort comparison function.
  17429. * If null the sub meshes will be render in the order they were created
  17430. */
  17431. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17432. /**
  17433. * Set the transparent sort comparison function.
  17434. * If null the sub meshes will be render in the order they were created
  17435. */
  17436. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17437. /**
  17438. * Creates a new rendering group.
  17439. * @param index The rendering group index
  17440. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17441. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17442. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17443. */
  17444. 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>);
  17445. /**
  17446. * Render all the sub meshes contained in the group.
  17447. * @param customRenderFunction Used to override the default render behaviour of the group.
  17448. * @returns true if rendered some submeshes.
  17449. */
  17450. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17451. /**
  17452. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17453. * @param subMeshes The submeshes to render
  17454. */
  17455. private renderOpaqueSorted;
  17456. /**
  17457. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17458. * @param subMeshes The submeshes to render
  17459. */
  17460. private renderAlphaTestSorted;
  17461. /**
  17462. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17463. * @param subMeshes The submeshes to render
  17464. */
  17465. private renderTransparentSorted;
  17466. /**
  17467. * Renders the submeshes in a specified order.
  17468. * @param subMeshes The submeshes to sort before render
  17469. * @param sortCompareFn The comparison function use to sort
  17470. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17471. * @param transparent Specifies to activate blending if true
  17472. */
  17473. private static renderSorted;
  17474. /**
  17475. * Renders the submeshes in the order they were dispatched (no sort applied).
  17476. * @param subMeshes The submeshes to render
  17477. */
  17478. private static renderUnsorted;
  17479. /**
  17480. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17481. * are rendered back to front if in the same alpha index.
  17482. *
  17483. * @param a The first submesh
  17484. * @param b The second submesh
  17485. * @returns The result of the comparison
  17486. */
  17487. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17488. /**
  17489. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17490. * are rendered back to front.
  17491. *
  17492. * @param a The first submesh
  17493. * @param b The second submesh
  17494. * @returns The result of the comparison
  17495. */
  17496. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17497. /**
  17498. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17499. * are rendered front to back (prevent overdraw).
  17500. *
  17501. * @param a The first submesh
  17502. * @param b The second submesh
  17503. * @returns The result of the comparison
  17504. */
  17505. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17506. /**
  17507. * Resets the different lists of submeshes to prepare a new frame.
  17508. */
  17509. prepare(): void;
  17510. dispose(): void;
  17511. /**
  17512. * Inserts the submesh in its correct queue depending on its material.
  17513. * @param subMesh The submesh to dispatch
  17514. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17515. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17516. */
  17517. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17518. dispatchSprites(spriteManager: ISpriteManager): void;
  17519. dispatchParticles(particleSystem: IParticleSystem): void;
  17520. private _renderParticles;
  17521. private _renderSprites;
  17522. }
  17523. }
  17524. declare module "babylonjs/Rendering/renderingManager" {
  17525. import { Nullable } from "babylonjs/types";
  17526. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17527. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17528. import { SmartArray } from "babylonjs/Misc/smartArray";
  17529. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17530. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17531. import { Material } from "babylonjs/Materials/material";
  17532. import { Scene } from "babylonjs/scene";
  17533. import { Camera } from "babylonjs/Cameras/camera";
  17534. /**
  17535. * Interface describing the different options available in the rendering manager
  17536. * regarding Auto Clear between groups.
  17537. */
  17538. export interface IRenderingManagerAutoClearSetup {
  17539. /**
  17540. * Defines whether or not autoclear is enable.
  17541. */
  17542. autoClear: boolean;
  17543. /**
  17544. * Defines whether or not to autoclear the depth buffer.
  17545. */
  17546. depth: boolean;
  17547. /**
  17548. * Defines whether or not to autoclear the stencil buffer.
  17549. */
  17550. stencil: boolean;
  17551. }
  17552. /**
  17553. * This class is used by the onRenderingGroupObservable
  17554. */
  17555. export class RenderingGroupInfo {
  17556. /**
  17557. * The Scene that being rendered
  17558. */
  17559. scene: Scene;
  17560. /**
  17561. * The camera currently used for the rendering pass
  17562. */
  17563. camera: Nullable<Camera>;
  17564. /**
  17565. * The ID of the renderingGroup being processed
  17566. */
  17567. renderingGroupId: number;
  17568. }
  17569. /**
  17570. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17571. * It is enable to manage the different groups as well as the different necessary sort functions.
  17572. * This should not be used directly aside of the few static configurations
  17573. */
  17574. export class RenderingManager {
  17575. /**
  17576. * The max id used for rendering groups (not included)
  17577. */
  17578. static MAX_RENDERINGGROUPS: number;
  17579. /**
  17580. * The min id used for rendering groups (included)
  17581. */
  17582. static MIN_RENDERINGGROUPS: number;
  17583. /**
  17584. * Used to globally prevent autoclearing scenes.
  17585. */
  17586. static AUTOCLEAR: boolean;
  17587. /**
  17588. * @hidden
  17589. */
  17590. _useSceneAutoClearSetup: boolean;
  17591. private _scene;
  17592. private _renderingGroups;
  17593. private _depthStencilBufferAlreadyCleaned;
  17594. private _autoClearDepthStencil;
  17595. private _customOpaqueSortCompareFn;
  17596. private _customAlphaTestSortCompareFn;
  17597. private _customTransparentSortCompareFn;
  17598. private _renderingGroupInfo;
  17599. /**
  17600. * Instantiates a new rendering group for a particular scene
  17601. * @param scene Defines the scene the groups belongs to
  17602. */
  17603. constructor(scene: Scene);
  17604. private _clearDepthStencilBuffer;
  17605. /**
  17606. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17607. * @hidden
  17608. */
  17609. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17610. /**
  17611. * Resets the different information of the group to prepare a new frame
  17612. * @hidden
  17613. */
  17614. reset(): void;
  17615. /**
  17616. * Dispose and release the group and its associated resources.
  17617. * @hidden
  17618. */
  17619. dispose(): void;
  17620. /**
  17621. * Clear the info related to rendering groups preventing retention points during dispose.
  17622. */
  17623. freeRenderingGroups(): void;
  17624. private _prepareRenderingGroup;
  17625. /**
  17626. * Add a sprite manager to the rendering manager in order to render it this frame.
  17627. * @param spriteManager Define the sprite manager to render
  17628. */
  17629. dispatchSprites(spriteManager: ISpriteManager): void;
  17630. /**
  17631. * Add a particle system to the rendering manager in order to render it this frame.
  17632. * @param particleSystem Define the particle system to render
  17633. */
  17634. dispatchParticles(particleSystem: IParticleSystem): void;
  17635. /**
  17636. * Add a submesh to the manager in order to render it this frame
  17637. * @param subMesh The submesh to dispatch
  17638. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17639. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17640. */
  17641. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17642. /**
  17643. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17644. * This allowed control for front to back rendering or reversly depending of the special needs.
  17645. *
  17646. * @param renderingGroupId The rendering group id corresponding to its index
  17647. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17648. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17649. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17650. */
  17651. 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;
  17652. /**
  17653. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17654. *
  17655. * @param renderingGroupId The rendering group id corresponding to its index
  17656. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17657. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17658. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17659. */
  17660. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17661. /**
  17662. * Gets the current auto clear configuration for one rendering group of the rendering
  17663. * manager.
  17664. * @param index the rendering group index to get the information for
  17665. * @returns The auto clear setup for the requested rendering group
  17666. */
  17667. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17668. }
  17669. }
  17670. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17671. import { SmartArray } from "babylonjs/Misc/smartArray";
  17672. import { Nullable } from "babylonjs/types";
  17673. import { Scene } from "babylonjs/scene";
  17674. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17675. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17676. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17677. import { Mesh } from "babylonjs/Meshes/mesh";
  17678. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17679. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17680. import { Effect } from "babylonjs/Materials/effect";
  17681. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17682. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17683. import "babylonjs/Shaders/shadowMap.fragment";
  17684. import "babylonjs/Shaders/shadowMap.vertex";
  17685. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17686. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17687. import { Observable } from "babylonjs/Misc/observable";
  17688. /**
  17689. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17690. */
  17691. export interface ICustomShaderOptions {
  17692. /**
  17693. * Gets or sets the custom shader name to use
  17694. */
  17695. shaderName: string;
  17696. /**
  17697. * The list of attribute names used in the shader
  17698. */
  17699. attributes?: string[];
  17700. /**
  17701. * The list of unifrom names used in the shader
  17702. */
  17703. uniforms?: string[];
  17704. /**
  17705. * The list of sampler names used in the shader
  17706. */
  17707. samplers?: string[];
  17708. /**
  17709. * The list of defines used in the shader
  17710. */
  17711. defines?: string[];
  17712. }
  17713. /**
  17714. * Interface to implement to create a shadow generator compatible with BJS.
  17715. */
  17716. export interface IShadowGenerator {
  17717. /**
  17718. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17719. * @returns The render target texture if present otherwise, null
  17720. */
  17721. getShadowMap(): Nullable<RenderTargetTexture>;
  17722. /**
  17723. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17724. * @param subMesh The submesh we want to render in the shadow map
  17725. * @param useInstances Defines wether will draw in the map using instances
  17726. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17727. * @returns true if ready otherwise, false
  17728. */
  17729. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17730. /**
  17731. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17732. * @param defines Defines of the material we want to update
  17733. * @param lightIndex Index of the light in the enabled light list of the material
  17734. */
  17735. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17736. /**
  17737. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17738. * defined in the generator but impacting the effect).
  17739. * It implies the unifroms available on the materials are the standard BJS ones.
  17740. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17741. * @param effect The effect we are binfing the information for
  17742. */
  17743. bindShadowLight(lightIndex: string, effect: Effect): void;
  17744. /**
  17745. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17746. * (eq to shadow prjection matrix * light transform matrix)
  17747. * @returns The transform matrix used to create the shadow map
  17748. */
  17749. getTransformMatrix(): Matrix;
  17750. /**
  17751. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17752. * Cube and 2D textures for instance.
  17753. */
  17754. recreateShadowMap(): void;
  17755. /**
  17756. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17757. * @param onCompiled Callback triggered at the and of the effects compilation
  17758. * @param options Sets of optional options forcing the compilation with different modes
  17759. */
  17760. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17761. useInstances: boolean;
  17762. }>): void;
  17763. /**
  17764. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17765. * @param options Sets of optional options forcing the compilation with different modes
  17766. * @returns A promise that resolves when the compilation completes
  17767. */
  17768. forceCompilationAsync(options?: Partial<{
  17769. useInstances: boolean;
  17770. }>): Promise<void>;
  17771. /**
  17772. * Serializes the shadow generator setup to a json object.
  17773. * @returns The serialized JSON object
  17774. */
  17775. serialize(): any;
  17776. /**
  17777. * Disposes the Shadow map and related Textures and effects.
  17778. */
  17779. dispose(): void;
  17780. }
  17781. /**
  17782. * Default implementation IShadowGenerator.
  17783. * This is the main object responsible of generating shadows in the framework.
  17784. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17785. */
  17786. export class ShadowGenerator implements IShadowGenerator {
  17787. /**
  17788. * Name of the shadow generator class
  17789. */
  17790. static CLASSNAME: string;
  17791. /**
  17792. * Shadow generator mode None: no filtering applied.
  17793. */
  17794. static readonly FILTER_NONE: number;
  17795. /**
  17796. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17797. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17798. */
  17799. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17800. /**
  17801. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17802. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17803. */
  17804. static readonly FILTER_POISSONSAMPLING: number;
  17805. /**
  17806. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17807. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17808. */
  17809. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17810. /**
  17811. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17812. * edge artifacts on steep falloff.
  17813. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17814. */
  17815. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17816. /**
  17817. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17818. * edge artifacts on steep falloff.
  17819. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17820. */
  17821. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17822. /**
  17823. * Shadow generator mode PCF: Percentage Closer Filtering
  17824. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17825. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17826. */
  17827. static readonly FILTER_PCF: number;
  17828. /**
  17829. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17830. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17831. * Contact Hardening
  17832. */
  17833. static readonly FILTER_PCSS: number;
  17834. /**
  17835. * Reserved for PCF and PCSS
  17836. * Highest Quality.
  17837. *
  17838. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17839. *
  17840. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17841. */
  17842. static readonly QUALITY_HIGH: number;
  17843. /**
  17844. * Reserved for PCF and PCSS
  17845. * Good tradeoff for quality/perf cross devices
  17846. *
  17847. * Execute PCF on a 3*3 kernel.
  17848. *
  17849. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17850. */
  17851. static readonly QUALITY_MEDIUM: number;
  17852. /**
  17853. * Reserved for PCF and PCSS
  17854. * The lowest quality but the fastest.
  17855. *
  17856. * Execute PCF on a 1*1 kernel.
  17857. *
  17858. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17859. */
  17860. static readonly QUALITY_LOW: number;
  17861. /** Gets or sets the custom shader name to use */
  17862. customShaderOptions: ICustomShaderOptions;
  17863. /**
  17864. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17865. */
  17866. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17867. /**
  17868. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17869. */
  17870. onAfterShadowMapRenderObservable: Observable<Effect>;
  17871. /**
  17872. * Observable triggered before a mesh is rendered in the shadow map.
  17873. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17874. */
  17875. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17876. /**
  17877. * Observable triggered after a mesh is rendered in the shadow map.
  17878. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17879. */
  17880. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17881. protected _bias: number;
  17882. /**
  17883. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17884. */
  17885. get bias(): number;
  17886. /**
  17887. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17888. */
  17889. set bias(bias: number);
  17890. protected _normalBias: number;
  17891. /**
  17892. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17893. */
  17894. get normalBias(): number;
  17895. /**
  17896. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17897. */
  17898. set normalBias(normalBias: number);
  17899. protected _blurBoxOffset: number;
  17900. /**
  17901. * Gets the blur box offset: offset applied during the blur pass.
  17902. * Only useful if useKernelBlur = false
  17903. */
  17904. get blurBoxOffset(): number;
  17905. /**
  17906. * Sets the blur box offset: offset applied during the blur pass.
  17907. * Only useful if useKernelBlur = false
  17908. */
  17909. set blurBoxOffset(value: number);
  17910. protected _blurScale: number;
  17911. /**
  17912. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17913. * 2 means half of the size.
  17914. */
  17915. get blurScale(): number;
  17916. /**
  17917. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17918. * 2 means half of the size.
  17919. */
  17920. set blurScale(value: number);
  17921. protected _blurKernel: number;
  17922. /**
  17923. * Gets the blur kernel: kernel size of the blur pass.
  17924. * Only useful if useKernelBlur = true
  17925. */
  17926. get blurKernel(): number;
  17927. /**
  17928. * Sets the blur kernel: kernel size of the blur pass.
  17929. * Only useful if useKernelBlur = true
  17930. */
  17931. set blurKernel(value: number);
  17932. protected _useKernelBlur: boolean;
  17933. /**
  17934. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17935. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17936. */
  17937. get useKernelBlur(): boolean;
  17938. /**
  17939. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17940. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17941. */
  17942. set useKernelBlur(value: boolean);
  17943. protected _depthScale: number;
  17944. /**
  17945. * Gets the depth scale used in ESM mode.
  17946. */
  17947. get depthScale(): number;
  17948. /**
  17949. * Sets the depth scale used in ESM mode.
  17950. * This can override the scale stored on the light.
  17951. */
  17952. set depthScale(value: number);
  17953. protected _validateFilter(filter: number): number;
  17954. protected _filter: number;
  17955. /**
  17956. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17957. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17958. */
  17959. get filter(): number;
  17960. /**
  17961. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17962. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17963. */
  17964. set filter(value: number);
  17965. /**
  17966. * Gets if the current filter is set to Poisson Sampling.
  17967. */
  17968. get usePoissonSampling(): boolean;
  17969. /**
  17970. * Sets the current filter to Poisson Sampling.
  17971. */
  17972. set usePoissonSampling(value: boolean);
  17973. /**
  17974. * Gets if the current filter is set to ESM.
  17975. */
  17976. get useExponentialShadowMap(): boolean;
  17977. /**
  17978. * Sets the current filter is to ESM.
  17979. */
  17980. set useExponentialShadowMap(value: boolean);
  17981. /**
  17982. * Gets if the current filter is set to filtered ESM.
  17983. */
  17984. get useBlurExponentialShadowMap(): boolean;
  17985. /**
  17986. * Gets if the current filter is set to filtered ESM.
  17987. */
  17988. set useBlurExponentialShadowMap(value: boolean);
  17989. /**
  17990. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17991. * exponential to prevent steep falloff artifacts).
  17992. */
  17993. get useCloseExponentialShadowMap(): boolean;
  17994. /**
  17995. * Sets the current filter to "close ESM" (using the inverse of the
  17996. * exponential to prevent steep falloff artifacts).
  17997. */
  17998. set useCloseExponentialShadowMap(value: boolean);
  17999. /**
  18000. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18001. * exponential to prevent steep falloff artifacts).
  18002. */
  18003. get useBlurCloseExponentialShadowMap(): boolean;
  18004. /**
  18005. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18006. * exponential to prevent steep falloff artifacts).
  18007. */
  18008. set useBlurCloseExponentialShadowMap(value: boolean);
  18009. /**
  18010. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18011. */
  18012. get usePercentageCloserFiltering(): boolean;
  18013. /**
  18014. * Sets the current filter to "PCF" (percentage closer filtering).
  18015. */
  18016. set usePercentageCloserFiltering(value: boolean);
  18017. protected _filteringQuality: number;
  18018. /**
  18019. * Gets the PCF or PCSS Quality.
  18020. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18021. */
  18022. get filteringQuality(): number;
  18023. /**
  18024. * Sets the PCF or PCSS Quality.
  18025. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18026. */
  18027. set filteringQuality(filteringQuality: number);
  18028. /**
  18029. * Gets if the current filter is set to "PCSS" (contact hardening).
  18030. */
  18031. get useContactHardeningShadow(): boolean;
  18032. /**
  18033. * Sets the current filter to "PCSS" (contact hardening).
  18034. */
  18035. set useContactHardeningShadow(value: boolean);
  18036. protected _contactHardeningLightSizeUVRatio: number;
  18037. /**
  18038. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18039. * Using a ratio helps keeping shape stability independently of the map size.
  18040. *
  18041. * It does not account for the light projection as it was having too much
  18042. * instability during the light setup or during light position changes.
  18043. *
  18044. * Only valid if useContactHardeningShadow is true.
  18045. */
  18046. get contactHardeningLightSizeUVRatio(): number;
  18047. /**
  18048. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18049. * Using a ratio helps keeping shape stability independently of the map size.
  18050. *
  18051. * It does not account for the light projection as it was having too much
  18052. * instability during the light setup or during light position changes.
  18053. *
  18054. * Only valid if useContactHardeningShadow is true.
  18055. */
  18056. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18057. protected _darkness: number;
  18058. /** Gets or sets the actual darkness of a shadow */
  18059. get darkness(): number;
  18060. set darkness(value: number);
  18061. /**
  18062. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18063. * 0 means strongest and 1 would means no shadow.
  18064. * @returns the darkness.
  18065. */
  18066. getDarkness(): number;
  18067. /**
  18068. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18069. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18070. * @returns the shadow generator allowing fluent coding.
  18071. */
  18072. setDarkness(darkness: number): ShadowGenerator;
  18073. protected _transparencyShadow: boolean;
  18074. /** Gets or sets the ability to have transparent shadow */
  18075. get transparencyShadow(): boolean;
  18076. set transparencyShadow(value: boolean);
  18077. /**
  18078. * Sets the ability to have transparent shadow (boolean).
  18079. * @param transparent True if transparent else False
  18080. * @returns the shadow generator allowing fluent coding
  18081. */
  18082. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18083. /**
  18084. * Enables or disables shadows with varying strength based on the transparency
  18085. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18086. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18087. * mesh.visibility * alphaTexture.a
  18088. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18089. */
  18090. enableSoftTransparentShadow: boolean;
  18091. protected _shadowMap: Nullable<RenderTargetTexture>;
  18092. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18093. /**
  18094. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18095. * @returns The render target texture if present otherwise, null
  18096. */
  18097. getShadowMap(): Nullable<RenderTargetTexture>;
  18098. /**
  18099. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18100. * @returns The render target texture if the shadow map is present otherwise, null
  18101. */
  18102. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18103. /**
  18104. * Gets the class name of that object
  18105. * @returns "ShadowGenerator"
  18106. */
  18107. getClassName(): string;
  18108. /**
  18109. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18110. * @param mesh Mesh to add
  18111. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18112. * @returns the Shadow Generator itself
  18113. */
  18114. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18115. /**
  18116. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18117. * @param mesh Mesh to remove
  18118. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18119. * @returns the Shadow Generator itself
  18120. */
  18121. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18122. /**
  18123. * Controls the extent to which the shadows fade out at the edge of the frustum
  18124. */
  18125. frustumEdgeFalloff: number;
  18126. protected _light: IShadowLight;
  18127. /**
  18128. * Returns the associated light object.
  18129. * @returns the light generating the shadow
  18130. */
  18131. getLight(): IShadowLight;
  18132. /**
  18133. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18134. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18135. * It might on the other hand introduce peter panning.
  18136. */
  18137. forceBackFacesOnly: boolean;
  18138. protected _scene: Scene;
  18139. protected _lightDirection: Vector3;
  18140. protected _effect: Effect;
  18141. protected _viewMatrix: Matrix;
  18142. protected _projectionMatrix: Matrix;
  18143. protected _transformMatrix: Matrix;
  18144. protected _cachedPosition: Vector3;
  18145. protected _cachedDirection: Vector3;
  18146. protected _cachedDefines: string;
  18147. protected _currentRenderID: number;
  18148. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18149. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18150. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18151. protected _blurPostProcesses: PostProcess[];
  18152. protected _mapSize: number;
  18153. protected _currentFaceIndex: number;
  18154. protected _currentFaceIndexCache: number;
  18155. protected _textureType: number;
  18156. protected _defaultTextureMatrix: Matrix;
  18157. protected _storedUniqueId: Nullable<number>;
  18158. /** @hidden */
  18159. static _SceneComponentInitialization: (scene: Scene) => void;
  18160. /**
  18161. * Creates a ShadowGenerator object.
  18162. * A ShadowGenerator is the required tool to use the shadows.
  18163. * Each light casting shadows needs to use its own ShadowGenerator.
  18164. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18165. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18166. * @param light The light object generating the shadows.
  18167. * @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.
  18168. */
  18169. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18170. protected _initializeGenerator(): void;
  18171. protected _createTargetRenderTexture(): void;
  18172. protected _initializeShadowMap(): void;
  18173. protected _initializeBlurRTTAndPostProcesses(): void;
  18174. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18175. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18176. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18177. protected _applyFilterValues(): void;
  18178. /**
  18179. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18180. * @param onCompiled Callback triggered at the and of the effects compilation
  18181. * @param options Sets of optional options forcing the compilation with different modes
  18182. */
  18183. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18184. useInstances: boolean;
  18185. }>): void;
  18186. /**
  18187. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18188. * @param options Sets of optional options forcing the compilation with different modes
  18189. * @returns A promise that resolves when the compilation completes
  18190. */
  18191. forceCompilationAsync(options?: Partial<{
  18192. useInstances: boolean;
  18193. }>): Promise<void>;
  18194. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18195. private _prepareShadowDefines;
  18196. /**
  18197. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18198. * @param subMesh The submesh we want to render in the shadow map
  18199. * @param useInstances Defines wether will draw in the map using instances
  18200. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18201. * @returns true if ready otherwise, false
  18202. */
  18203. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18204. /**
  18205. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18206. * @param defines Defines of the material we want to update
  18207. * @param lightIndex Index of the light in the enabled light list of the material
  18208. */
  18209. prepareDefines(defines: any, lightIndex: number): void;
  18210. /**
  18211. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18212. * defined in the generator but impacting the effect).
  18213. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18214. * @param effect The effect we are binfing the information for
  18215. */
  18216. bindShadowLight(lightIndex: string, effect: Effect): void;
  18217. /**
  18218. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18219. * (eq to shadow prjection matrix * light transform matrix)
  18220. * @returns The transform matrix used to create the shadow map
  18221. */
  18222. getTransformMatrix(): Matrix;
  18223. /**
  18224. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18225. * Cube and 2D textures for instance.
  18226. */
  18227. recreateShadowMap(): void;
  18228. protected _disposeBlurPostProcesses(): void;
  18229. protected _disposeRTTandPostProcesses(): void;
  18230. /**
  18231. * Disposes the ShadowGenerator.
  18232. * Returns nothing.
  18233. */
  18234. dispose(): void;
  18235. /**
  18236. * Serializes the shadow generator setup to a json object.
  18237. * @returns The serialized JSON object
  18238. */
  18239. serialize(): any;
  18240. /**
  18241. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18242. * @param parsedShadowGenerator The JSON object to parse
  18243. * @param scene The scene to create the shadow map for
  18244. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18245. * @returns The parsed shadow generator
  18246. */
  18247. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18248. }
  18249. }
  18250. declare module "babylonjs/Lights/light" {
  18251. import { Nullable } from "babylonjs/types";
  18252. import { Scene } from "babylonjs/scene";
  18253. import { Vector3 } from "babylonjs/Maths/math.vector";
  18254. import { Color3 } from "babylonjs/Maths/math.color";
  18255. import { Node } from "babylonjs/node";
  18256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18257. import { Effect } from "babylonjs/Materials/effect";
  18258. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18259. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18260. /**
  18261. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18262. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18263. * 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.
  18264. */
  18265. export abstract class Light extends Node {
  18266. /**
  18267. * Falloff Default: light is falling off following the material specification:
  18268. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18269. */
  18270. static readonly FALLOFF_DEFAULT: number;
  18271. /**
  18272. * Falloff Physical: light is falling off following the inverse squared distance law.
  18273. */
  18274. static readonly FALLOFF_PHYSICAL: number;
  18275. /**
  18276. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18277. * to enhance interoperability with other engines.
  18278. */
  18279. static readonly FALLOFF_GLTF: number;
  18280. /**
  18281. * Falloff Standard: light is falling off like in the standard material
  18282. * to enhance interoperability with other materials.
  18283. */
  18284. static readonly FALLOFF_STANDARD: number;
  18285. /**
  18286. * If every light affecting the material is in this lightmapMode,
  18287. * material.lightmapTexture adds or multiplies
  18288. * (depends on material.useLightmapAsShadowmap)
  18289. * after every other light calculations.
  18290. */
  18291. static readonly LIGHTMAP_DEFAULT: number;
  18292. /**
  18293. * material.lightmapTexture as only diffuse lighting from this light
  18294. * adds only specular lighting from this light
  18295. * adds dynamic shadows
  18296. */
  18297. static readonly LIGHTMAP_SPECULAR: number;
  18298. /**
  18299. * material.lightmapTexture as only lighting
  18300. * no light calculation from this light
  18301. * only adds dynamic shadows from this light
  18302. */
  18303. static readonly LIGHTMAP_SHADOWSONLY: number;
  18304. /**
  18305. * Each light type uses the default quantity according to its type:
  18306. * point/spot lights use luminous intensity
  18307. * directional lights use illuminance
  18308. */
  18309. static readonly INTENSITYMODE_AUTOMATIC: number;
  18310. /**
  18311. * lumen (lm)
  18312. */
  18313. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18314. /**
  18315. * candela (lm/sr)
  18316. */
  18317. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18318. /**
  18319. * lux (lm/m^2)
  18320. */
  18321. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18322. /**
  18323. * nit (cd/m^2)
  18324. */
  18325. static readonly INTENSITYMODE_LUMINANCE: number;
  18326. /**
  18327. * Light type const id of the point light.
  18328. */
  18329. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18330. /**
  18331. * Light type const id of the directional light.
  18332. */
  18333. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18334. /**
  18335. * Light type const id of the spot light.
  18336. */
  18337. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18338. /**
  18339. * Light type const id of the hemispheric light.
  18340. */
  18341. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18342. /**
  18343. * Diffuse gives the basic color to an object.
  18344. */
  18345. diffuse: Color3;
  18346. /**
  18347. * Specular produces a highlight color on an object.
  18348. * Note: This is note affecting PBR materials.
  18349. */
  18350. specular: Color3;
  18351. /**
  18352. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18353. * falling off base on range or angle.
  18354. * This can be set to any values in Light.FALLOFF_x.
  18355. *
  18356. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18357. * other types of materials.
  18358. */
  18359. falloffType: number;
  18360. /**
  18361. * Strength of the light.
  18362. * Note: By default it is define in the framework own unit.
  18363. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18364. */
  18365. intensity: number;
  18366. private _range;
  18367. protected _inverseSquaredRange: number;
  18368. /**
  18369. * Defines how far from the source the light is impacting in scene units.
  18370. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18371. */
  18372. get range(): number;
  18373. /**
  18374. * Defines how far from the source the light is impacting in scene units.
  18375. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18376. */
  18377. set range(value: number);
  18378. /**
  18379. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18380. * of light.
  18381. */
  18382. private _photometricScale;
  18383. private _intensityMode;
  18384. /**
  18385. * Gets the photometric scale used to interpret the intensity.
  18386. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18387. */
  18388. get intensityMode(): number;
  18389. /**
  18390. * Sets the photometric scale used to interpret the intensity.
  18391. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18392. */
  18393. set intensityMode(value: number);
  18394. private _radius;
  18395. /**
  18396. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18397. */
  18398. get radius(): number;
  18399. /**
  18400. * sets the light radius used by PBR Materials to simulate soft area lights.
  18401. */
  18402. set radius(value: number);
  18403. private _renderPriority;
  18404. /**
  18405. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18406. * exceeding the number allowed of the materials.
  18407. */
  18408. renderPriority: number;
  18409. private _shadowEnabled;
  18410. /**
  18411. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18412. * the current shadow generator.
  18413. */
  18414. get shadowEnabled(): boolean;
  18415. /**
  18416. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18417. * the current shadow generator.
  18418. */
  18419. set shadowEnabled(value: boolean);
  18420. private _includedOnlyMeshes;
  18421. /**
  18422. * Gets the only meshes impacted by this light.
  18423. */
  18424. get includedOnlyMeshes(): AbstractMesh[];
  18425. /**
  18426. * Sets the only meshes impacted by this light.
  18427. */
  18428. set includedOnlyMeshes(value: AbstractMesh[]);
  18429. private _excludedMeshes;
  18430. /**
  18431. * Gets the meshes not impacted by this light.
  18432. */
  18433. get excludedMeshes(): AbstractMesh[];
  18434. /**
  18435. * Sets the meshes not impacted by this light.
  18436. */
  18437. set excludedMeshes(value: AbstractMesh[]);
  18438. private _excludeWithLayerMask;
  18439. /**
  18440. * Gets the layer id use to find what meshes are not impacted by the light.
  18441. * Inactive if 0
  18442. */
  18443. get excludeWithLayerMask(): number;
  18444. /**
  18445. * Sets the layer id use to find what meshes are not impacted by the light.
  18446. * Inactive if 0
  18447. */
  18448. set excludeWithLayerMask(value: number);
  18449. private _includeOnlyWithLayerMask;
  18450. /**
  18451. * Gets the layer id use to find what meshes are impacted by the light.
  18452. * Inactive if 0
  18453. */
  18454. get includeOnlyWithLayerMask(): number;
  18455. /**
  18456. * Sets the layer id use to find what meshes are impacted by the light.
  18457. * Inactive if 0
  18458. */
  18459. set includeOnlyWithLayerMask(value: number);
  18460. private _lightmapMode;
  18461. /**
  18462. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18463. */
  18464. get lightmapMode(): number;
  18465. /**
  18466. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18467. */
  18468. set lightmapMode(value: number);
  18469. /**
  18470. * Shadow generator associted to the light.
  18471. * @hidden Internal use only.
  18472. */
  18473. _shadowGenerator: Nullable<IShadowGenerator>;
  18474. /**
  18475. * @hidden Internal use only.
  18476. */
  18477. _excludedMeshesIds: string[];
  18478. /**
  18479. * @hidden Internal use only.
  18480. */
  18481. _includedOnlyMeshesIds: string[];
  18482. /**
  18483. * The current light unifom buffer.
  18484. * @hidden Internal use only.
  18485. */
  18486. _uniformBuffer: UniformBuffer;
  18487. /** @hidden */
  18488. _renderId: number;
  18489. /**
  18490. * Creates a Light object in the scene.
  18491. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18492. * @param name The firendly name of the light
  18493. * @param scene The scene the light belongs too
  18494. */
  18495. constructor(name: string, scene: Scene);
  18496. protected abstract _buildUniformLayout(): void;
  18497. /**
  18498. * Sets the passed Effect "effect" with the Light information.
  18499. * @param effect The effect to update
  18500. * @param lightIndex The index of the light in the effect to update
  18501. * @returns The light
  18502. */
  18503. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18504. /**
  18505. * Sets the passed Effect "effect" with the Light textures.
  18506. * @param effect The effect to update
  18507. * @param lightIndex The index of the light in the effect to update
  18508. * @returns The light
  18509. */
  18510. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18511. /**
  18512. * Binds the lights information from the scene to the effect for the given mesh.
  18513. * @param lightIndex Light index
  18514. * @param scene The scene where the light belongs to
  18515. * @param effect The effect we are binding the data to
  18516. * @param useSpecular Defines if specular is supported
  18517. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18518. */
  18519. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18520. /**
  18521. * Sets the passed Effect "effect" with the Light information.
  18522. * @param effect The effect to update
  18523. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18524. * @returns The light
  18525. */
  18526. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18527. /**
  18528. * Returns the string "Light".
  18529. * @returns the class name
  18530. */
  18531. getClassName(): string;
  18532. /** @hidden */
  18533. readonly _isLight: boolean;
  18534. /**
  18535. * Converts the light information to a readable string for debug purpose.
  18536. * @param fullDetails Supports for multiple levels of logging within scene loading
  18537. * @returns the human readable light info
  18538. */
  18539. toString(fullDetails?: boolean): string;
  18540. /** @hidden */
  18541. protected _syncParentEnabledState(): void;
  18542. /**
  18543. * Set the enabled state of this node.
  18544. * @param value - the new enabled state
  18545. */
  18546. setEnabled(value: boolean): void;
  18547. /**
  18548. * Returns the Light associated shadow generator if any.
  18549. * @return the associated shadow generator.
  18550. */
  18551. getShadowGenerator(): Nullable<IShadowGenerator>;
  18552. /**
  18553. * Returns a Vector3, the absolute light position in the World.
  18554. * @returns the world space position of the light
  18555. */
  18556. getAbsolutePosition(): Vector3;
  18557. /**
  18558. * Specifies if the light will affect the passed mesh.
  18559. * @param mesh The mesh to test against the light
  18560. * @return true the mesh is affected otherwise, false.
  18561. */
  18562. canAffectMesh(mesh: AbstractMesh): boolean;
  18563. /**
  18564. * Sort function to order lights for rendering.
  18565. * @param a First Light object to compare to second.
  18566. * @param b Second Light object to compare first.
  18567. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18568. */
  18569. static CompareLightsPriority(a: Light, b: Light): number;
  18570. /**
  18571. * Releases resources associated with this node.
  18572. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18573. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18574. */
  18575. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18576. /**
  18577. * Returns the light type ID (integer).
  18578. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18579. */
  18580. getTypeID(): number;
  18581. /**
  18582. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18583. * @returns the scaled intensity in intensity mode unit
  18584. */
  18585. getScaledIntensity(): number;
  18586. /**
  18587. * Returns a new Light object, named "name", from the current one.
  18588. * @param name The name of the cloned light
  18589. * @param newParent The parent of this light, if it has one
  18590. * @returns the new created light
  18591. */
  18592. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18593. /**
  18594. * Serializes the current light into a Serialization object.
  18595. * @returns the serialized object.
  18596. */
  18597. serialize(): any;
  18598. /**
  18599. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18600. * This new light is named "name" and added to the passed scene.
  18601. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18602. * @param name The friendly name of the light
  18603. * @param scene The scene the new light will belong to
  18604. * @returns the constructor function
  18605. */
  18606. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18607. /**
  18608. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18609. * @param parsedLight The JSON representation of the light
  18610. * @param scene The scene to create the parsed light in
  18611. * @returns the created light after parsing
  18612. */
  18613. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18614. private _hookArrayForExcluded;
  18615. private _hookArrayForIncludedOnly;
  18616. private _resyncMeshes;
  18617. /**
  18618. * Forces the meshes to update their light related information in their rendering used effects
  18619. * @hidden Internal Use Only
  18620. */
  18621. _markMeshesAsLightDirty(): void;
  18622. /**
  18623. * Recomputes the cached photometric scale if needed.
  18624. */
  18625. private _computePhotometricScale;
  18626. /**
  18627. * Returns the Photometric Scale according to the light type and intensity mode.
  18628. */
  18629. private _getPhotometricScale;
  18630. /**
  18631. * Reorder the light in the scene according to their defined priority.
  18632. * @hidden Internal Use Only
  18633. */
  18634. _reorderLightsInScene(): void;
  18635. /**
  18636. * Prepares the list of defines specific to the light type.
  18637. * @param defines the list of defines
  18638. * @param lightIndex defines the index of the light for the effect
  18639. */
  18640. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18641. }
  18642. }
  18643. declare module "babylonjs/Cameras/targetCamera" {
  18644. import { Nullable } from "babylonjs/types";
  18645. import { Camera } from "babylonjs/Cameras/camera";
  18646. import { Scene } from "babylonjs/scene";
  18647. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18648. /**
  18649. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18650. * This is the base of the follow, arc rotate cameras and Free camera
  18651. * @see https://doc.babylonjs.com/features/cameras
  18652. */
  18653. export class TargetCamera extends Camera {
  18654. private static _RigCamTransformMatrix;
  18655. private static _TargetTransformMatrix;
  18656. private static _TargetFocalPoint;
  18657. private _tmpUpVector;
  18658. private _tmpTargetVector;
  18659. /**
  18660. * Define the current direction the camera is moving to
  18661. */
  18662. cameraDirection: Vector3;
  18663. /**
  18664. * Define the current rotation the camera is rotating to
  18665. */
  18666. cameraRotation: Vector2;
  18667. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18668. ignoreParentScaling: boolean;
  18669. /**
  18670. * When set, the up vector of the camera will be updated by the rotation of the camera
  18671. */
  18672. updateUpVectorFromRotation: boolean;
  18673. private _tmpQuaternion;
  18674. /**
  18675. * Define the current rotation of the camera
  18676. */
  18677. rotation: Vector3;
  18678. /**
  18679. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18680. */
  18681. rotationQuaternion: Quaternion;
  18682. /**
  18683. * Define the current speed of the camera
  18684. */
  18685. speed: number;
  18686. /**
  18687. * Add constraint to the camera to prevent it to move freely in all directions and
  18688. * around all axis.
  18689. */
  18690. noRotationConstraint: boolean;
  18691. /**
  18692. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18693. * panning
  18694. */
  18695. invertRotation: boolean;
  18696. /**
  18697. * Speed multiplier for inverse camera panning
  18698. */
  18699. inverseRotationSpeed: number;
  18700. /**
  18701. * Define the current target of the camera as an object or a position.
  18702. */
  18703. lockedTarget: any;
  18704. /** @hidden */
  18705. _currentTarget: Vector3;
  18706. /** @hidden */
  18707. _initialFocalDistance: number;
  18708. /** @hidden */
  18709. _viewMatrix: Matrix;
  18710. /** @hidden */
  18711. _camMatrix: Matrix;
  18712. /** @hidden */
  18713. _cameraTransformMatrix: Matrix;
  18714. /** @hidden */
  18715. _cameraRotationMatrix: Matrix;
  18716. /** @hidden */
  18717. _referencePoint: Vector3;
  18718. /** @hidden */
  18719. _transformedReferencePoint: Vector3;
  18720. /** @hidden */
  18721. _reset: () => void;
  18722. private _defaultUp;
  18723. /**
  18724. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18725. * This is the base of the follow, arc rotate cameras and Free camera
  18726. * @see https://doc.babylonjs.com/features/cameras
  18727. * @param name Defines the name of the camera in the scene
  18728. * @param position Defines the start position of the camera in the scene
  18729. * @param scene Defines the scene the camera belongs to
  18730. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18731. */
  18732. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18733. /**
  18734. * Gets the position in front of the camera at a given distance.
  18735. * @param distance The distance from the camera we want the position to be
  18736. * @returns the position
  18737. */
  18738. getFrontPosition(distance: number): Vector3;
  18739. /** @hidden */
  18740. _getLockedTargetPosition(): Nullable<Vector3>;
  18741. private _storedPosition;
  18742. private _storedRotation;
  18743. private _storedRotationQuaternion;
  18744. /**
  18745. * Store current camera state of the camera (fov, position, rotation, etc..)
  18746. * @returns the camera
  18747. */
  18748. storeState(): Camera;
  18749. /**
  18750. * Restored camera state. You must call storeState() first
  18751. * @returns whether it was successful or not
  18752. * @hidden
  18753. */
  18754. _restoreStateValues(): boolean;
  18755. /** @hidden */
  18756. _initCache(): void;
  18757. /** @hidden */
  18758. _updateCache(ignoreParentClass?: boolean): void;
  18759. /** @hidden */
  18760. _isSynchronizedViewMatrix(): boolean;
  18761. /** @hidden */
  18762. _computeLocalCameraSpeed(): number;
  18763. /**
  18764. * Defines the target the camera should look at.
  18765. * @param target Defines the new target as a Vector or a mesh
  18766. */
  18767. setTarget(target: Vector3): void;
  18768. /**
  18769. * Return the current target position of the camera. This value is expressed in local space.
  18770. * @returns the target position
  18771. */
  18772. getTarget(): Vector3;
  18773. /** @hidden */
  18774. _decideIfNeedsToMove(): boolean;
  18775. /** @hidden */
  18776. _updatePosition(): void;
  18777. /** @hidden */
  18778. _checkInputs(): void;
  18779. protected _updateCameraRotationMatrix(): void;
  18780. /**
  18781. * 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)
  18782. * @returns the current camera
  18783. */
  18784. private _rotateUpVectorWithCameraRotationMatrix;
  18785. private _cachedRotationZ;
  18786. private _cachedQuaternionRotationZ;
  18787. /** @hidden */
  18788. _getViewMatrix(): Matrix;
  18789. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18790. /**
  18791. * @hidden
  18792. */
  18793. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18794. /**
  18795. * @hidden
  18796. */
  18797. _updateRigCameras(): void;
  18798. private _getRigCamPositionAndTarget;
  18799. /**
  18800. * Gets the current object class name.
  18801. * @return the class name
  18802. */
  18803. getClassName(): string;
  18804. }
  18805. }
  18806. declare module "babylonjs/Events/keyboardEvents" {
  18807. /**
  18808. * Gather the list of keyboard event types as constants.
  18809. */
  18810. export class KeyboardEventTypes {
  18811. /**
  18812. * The keydown event is fired when a key becomes active (pressed).
  18813. */
  18814. static readonly KEYDOWN: number;
  18815. /**
  18816. * The keyup event is fired when a key has been released.
  18817. */
  18818. static readonly KEYUP: number;
  18819. }
  18820. /**
  18821. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18822. */
  18823. export class KeyboardInfo {
  18824. /**
  18825. * Defines the type of event (KeyboardEventTypes)
  18826. */
  18827. type: number;
  18828. /**
  18829. * Defines the related dom event
  18830. */
  18831. event: KeyboardEvent;
  18832. /**
  18833. * Instantiates a new keyboard info.
  18834. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18835. * @param type Defines the type of event (KeyboardEventTypes)
  18836. * @param event Defines the related dom event
  18837. */
  18838. constructor(
  18839. /**
  18840. * Defines the type of event (KeyboardEventTypes)
  18841. */
  18842. type: number,
  18843. /**
  18844. * Defines the related dom event
  18845. */
  18846. event: KeyboardEvent);
  18847. }
  18848. /**
  18849. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18850. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18851. */
  18852. export class KeyboardInfoPre extends KeyboardInfo {
  18853. /**
  18854. * Defines the type of event (KeyboardEventTypes)
  18855. */
  18856. type: number;
  18857. /**
  18858. * Defines the related dom event
  18859. */
  18860. event: KeyboardEvent;
  18861. /**
  18862. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18863. */
  18864. skipOnPointerObservable: boolean;
  18865. /**
  18866. * Instantiates a new keyboard pre info.
  18867. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18868. * @param type Defines the type of event (KeyboardEventTypes)
  18869. * @param event Defines the related dom event
  18870. */
  18871. constructor(
  18872. /**
  18873. * Defines the type of event (KeyboardEventTypes)
  18874. */
  18875. type: number,
  18876. /**
  18877. * Defines the related dom event
  18878. */
  18879. event: KeyboardEvent);
  18880. }
  18881. }
  18882. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  18883. import { Nullable } from "babylonjs/types";
  18884. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18885. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18886. /**
  18887. * Manage the keyboard inputs to control the movement of a free camera.
  18888. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18889. */
  18890. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18891. /**
  18892. * Defines the camera the input is attached to.
  18893. */
  18894. camera: FreeCamera;
  18895. /**
  18896. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18897. */
  18898. keysUp: number[];
  18899. /**
  18900. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18901. */
  18902. keysUpward: number[];
  18903. /**
  18904. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18905. */
  18906. keysDown: number[];
  18907. /**
  18908. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18909. */
  18910. keysDownward: number[];
  18911. /**
  18912. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18913. */
  18914. keysLeft: number[];
  18915. /**
  18916. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18917. */
  18918. keysRight: number[];
  18919. private _keys;
  18920. private _onCanvasBlurObserver;
  18921. private _onKeyboardObserver;
  18922. private _engine;
  18923. private _scene;
  18924. /**
  18925. * Attach the input controls to a specific dom element to get the input from.
  18926. * @param element Defines the element the controls should be listened from
  18927. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18928. */
  18929. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18930. /**
  18931. * Detach the current controls from the specified dom element.
  18932. * @param element Defines the element to stop listening the inputs from
  18933. */
  18934. detachControl(element: Nullable<HTMLElement>): void;
  18935. /**
  18936. * Update the current camera state depending on the inputs that have been used this frame.
  18937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18938. */
  18939. checkInputs(): void;
  18940. /**
  18941. * Gets the class name of the current intput.
  18942. * @returns the class name
  18943. */
  18944. getClassName(): string;
  18945. /** @hidden */
  18946. _onLostFocus(): void;
  18947. /**
  18948. * Get the friendly name associated with the input class.
  18949. * @returns the input friendly name
  18950. */
  18951. getSimpleName(): string;
  18952. }
  18953. }
  18954. declare module "babylonjs/Events/pointerEvents" {
  18955. import { Nullable } from "babylonjs/types";
  18956. import { Vector2 } from "babylonjs/Maths/math.vector";
  18957. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18958. import { Ray } from "babylonjs/Culling/ray";
  18959. /**
  18960. * Gather the list of pointer event types as constants.
  18961. */
  18962. export class PointerEventTypes {
  18963. /**
  18964. * 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.
  18965. */
  18966. static readonly POINTERDOWN: number;
  18967. /**
  18968. * The pointerup event is fired when a pointer is no longer active.
  18969. */
  18970. static readonly POINTERUP: number;
  18971. /**
  18972. * The pointermove event is fired when a pointer changes coordinates.
  18973. */
  18974. static readonly POINTERMOVE: number;
  18975. /**
  18976. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18977. */
  18978. static readonly POINTERWHEEL: number;
  18979. /**
  18980. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18981. */
  18982. static readonly POINTERPICK: number;
  18983. /**
  18984. * The pointertap event is fired when a the object has been touched and released without drag.
  18985. */
  18986. static readonly POINTERTAP: number;
  18987. /**
  18988. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18989. */
  18990. static readonly POINTERDOUBLETAP: number;
  18991. }
  18992. /**
  18993. * Base class of pointer info types.
  18994. */
  18995. export class PointerInfoBase {
  18996. /**
  18997. * Defines the type of event (PointerEventTypes)
  18998. */
  18999. type: number;
  19000. /**
  19001. * Defines the related dom event
  19002. */
  19003. event: PointerEvent | MouseWheelEvent;
  19004. /**
  19005. * Instantiates the base class of pointers info.
  19006. * @param type Defines the type of event (PointerEventTypes)
  19007. * @param event Defines the related dom event
  19008. */
  19009. constructor(
  19010. /**
  19011. * Defines the type of event (PointerEventTypes)
  19012. */
  19013. type: number,
  19014. /**
  19015. * Defines the related dom event
  19016. */
  19017. event: PointerEvent | MouseWheelEvent);
  19018. }
  19019. /**
  19020. * This class is used to store pointer related info for the onPrePointerObservable event.
  19021. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19022. */
  19023. export class PointerInfoPre extends PointerInfoBase {
  19024. /**
  19025. * Ray from a pointer if availible (eg. 6dof controller)
  19026. */
  19027. ray: Nullable<Ray>;
  19028. /**
  19029. * Defines the local position of the pointer on the canvas.
  19030. */
  19031. localPosition: Vector2;
  19032. /**
  19033. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19034. */
  19035. skipOnPointerObservable: boolean;
  19036. /**
  19037. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19038. * @param type Defines the type of event (PointerEventTypes)
  19039. * @param event Defines the related dom event
  19040. * @param localX Defines the local x coordinates of the pointer when the event occured
  19041. * @param localY Defines the local y coordinates of the pointer when the event occured
  19042. */
  19043. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19044. }
  19045. /**
  19046. * This type contains all the data related to a pointer event in Babylon.js.
  19047. * 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.
  19048. */
  19049. export class PointerInfo extends PointerInfoBase {
  19050. /**
  19051. * Defines the picking info associated to the info (if any)\
  19052. */
  19053. pickInfo: Nullable<PickingInfo>;
  19054. /**
  19055. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19056. * @param type Defines the type of event (PointerEventTypes)
  19057. * @param event Defines the related dom event
  19058. * @param pickInfo Defines the picking info associated to the info (if any)\
  19059. */
  19060. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19061. /**
  19062. * Defines the picking info associated to the info (if any)\
  19063. */
  19064. pickInfo: Nullable<PickingInfo>);
  19065. }
  19066. /**
  19067. * Data relating to a touch event on the screen.
  19068. */
  19069. export interface PointerTouch {
  19070. /**
  19071. * X coordinate of touch.
  19072. */
  19073. x: number;
  19074. /**
  19075. * Y coordinate of touch.
  19076. */
  19077. y: number;
  19078. /**
  19079. * Id of touch. Unique for each finger.
  19080. */
  19081. pointerId: number;
  19082. /**
  19083. * Event type passed from DOM.
  19084. */
  19085. type: any;
  19086. }
  19087. }
  19088. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19089. import { Observable } from "babylonjs/Misc/observable";
  19090. import { Nullable } from "babylonjs/types";
  19091. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19092. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19093. /**
  19094. * Manage the mouse inputs to control the movement of a free camera.
  19095. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19096. */
  19097. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19098. /**
  19099. * Define if touch is enabled in the mouse input
  19100. */
  19101. touchEnabled: boolean;
  19102. /**
  19103. * Defines the camera the input is attached to.
  19104. */
  19105. camera: FreeCamera;
  19106. /**
  19107. * Defines the buttons associated with the input to handle camera move.
  19108. */
  19109. buttons: number[];
  19110. /**
  19111. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19112. */
  19113. angularSensibility: number;
  19114. private _pointerInput;
  19115. private _onMouseMove;
  19116. private _observer;
  19117. private previousPosition;
  19118. /**
  19119. * Observable for when a pointer move event occurs containing the move offset
  19120. */
  19121. onPointerMovedObservable: Observable<{
  19122. offsetX: number;
  19123. offsetY: number;
  19124. }>;
  19125. /**
  19126. * @hidden
  19127. * If the camera should be rotated automatically based on pointer movement
  19128. */
  19129. _allowCameraRotation: boolean;
  19130. /**
  19131. * Manage the mouse inputs to control the movement of a free camera.
  19132. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19133. * @param touchEnabled Defines if touch is enabled or not
  19134. */
  19135. constructor(
  19136. /**
  19137. * Define if touch is enabled in the mouse input
  19138. */
  19139. touchEnabled?: boolean);
  19140. /**
  19141. * Attach the input controls to a specific dom element to get the input from.
  19142. * @param element Defines the element the controls should be listened from
  19143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19144. */
  19145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19146. /**
  19147. * Called on JS contextmenu event.
  19148. * Override this method to provide functionality.
  19149. */
  19150. protected onContextMenu(evt: PointerEvent): void;
  19151. /**
  19152. * Detach the current controls from the specified dom element.
  19153. * @param element Defines the element to stop listening the inputs from
  19154. */
  19155. detachControl(element: Nullable<HTMLElement>): void;
  19156. /**
  19157. * Gets the class name of the current intput.
  19158. * @returns the class name
  19159. */
  19160. getClassName(): string;
  19161. /**
  19162. * Get the friendly name associated with the input class.
  19163. * @returns the input friendly name
  19164. */
  19165. getSimpleName(): string;
  19166. }
  19167. }
  19168. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19169. import { Nullable } from "babylonjs/types";
  19170. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19171. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19172. /**
  19173. * Manage the touch inputs to control the movement of a free camera.
  19174. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19175. */
  19176. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19177. /**
  19178. * Defines the camera the input is attached to.
  19179. */
  19180. camera: FreeCamera;
  19181. /**
  19182. * Defines the touch sensibility for rotation.
  19183. * The higher the faster.
  19184. */
  19185. touchAngularSensibility: number;
  19186. /**
  19187. * Defines the touch sensibility for move.
  19188. * The higher the faster.
  19189. */
  19190. touchMoveSensibility: number;
  19191. private _offsetX;
  19192. private _offsetY;
  19193. private _pointerPressed;
  19194. private _pointerInput;
  19195. private _observer;
  19196. private _onLostFocus;
  19197. /**
  19198. * Attach the input controls to a specific dom element to get the input from.
  19199. * @param element Defines the element the controls should be listened from
  19200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19201. */
  19202. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19203. /**
  19204. * Detach the current controls from the specified dom element.
  19205. * @param element Defines the element to stop listening the inputs from
  19206. */
  19207. detachControl(element: Nullable<HTMLElement>): void;
  19208. /**
  19209. * Update the current camera state depending on the inputs that have been used this frame.
  19210. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19211. */
  19212. checkInputs(): void;
  19213. /**
  19214. * Gets the class name of the current intput.
  19215. * @returns the class name
  19216. */
  19217. getClassName(): string;
  19218. /**
  19219. * Get the friendly name associated with the input class.
  19220. * @returns the input friendly name
  19221. */
  19222. getSimpleName(): string;
  19223. }
  19224. }
  19225. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19226. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19227. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19228. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19229. import { Nullable } from "babylonjs/types";
  19230. /**
  19231. * Default Inputs manager for the FreeCamera.
  19232. * It groups all the default supported inputs for ease of use.
  19233. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19234. */
  19235. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19236. /**
  19237. * @hidden
  19238. */
  19239. _mouseInput: Nullable<FreeCameraMouseInput>;
  19240. /**
  19241. * Instantiates a new FreeCameraInputsManager.
  19242. * @param camera Defines the camera the inputs belong to
  19243. */
  19244. constructor(camera: FreeCamera);
  19245. /**
  19246. * Add keyboard input support to the input manager.
  19247. * @returns the current input manager
  19248. */
  19249. addKeyboard(): FreeCameraInputsManager;
  19250. /**
  19251. * Add mouse input support to the input manager.
  19252. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19253. * @returns the current input manager
  19254. */
  19255. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19256. /**
  19257. * Removes the mouse input support from the manager
  19258. * @returns the current input manager
  19259. */
  19260. removeMouse(): FreeCameraInputsManager;
  19261. /**
  19262. * Add touch input support to the input manager.
  19263. * @returns the current input manager
  19264. */
  19265. addTouch(): FreeCameraInputsManager;
  19266. /**
  19267. * Remove all attached input methods from a camera
  19268. */
  19269. clear(): void;
  19270. }
  19271. }
  19272. declare module "babylonjs/Cameras/freeCamera" {
  19273. import { Vector3 } from "babylonjs/Maths/math.vector";
  19274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19275. import { Scene } from "babylonjs/scene";
  19276. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19277. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19278. /**
  19279. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19280. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19281. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19282. */
  19283. export class FreeCamera extends TargetCamera {
  19284. /**
  19285. * Define the collision ellipsoid of the camera.
  19286. * This is helpful to simulate a camera body like the player body around the camera
  19287. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19288. */
  19289. ellipsoid: Vector3;
  19290. /**
  19291. * Define an offset for the position of the ellipsoid around the camera.
  19292. * This can be helpful to determine the center of the body near the gravity center of the body
  19293. * instead of its head.
  19294. */
  19295. ellipsoidOffset: Vector3;
  19296. /**
  19297. * Enable or disable collisions of the camera with the rest of the scene objects.
  19298. */
  19299. checkCollisions: boolean;
  19300. /**
  19301. * Enable or disable gravity on the camera.
  19302. */
  19303. applyGravity: boolean;
  19304. /**
  19305. * Define the input manager associated to the camera.
  19306. */
  19307. inputs: FreeCameraInputsManager;
  19308. /**
  19309. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19310. * Higher values reduce sensitivity.
  19311. */
  19312. get angularSensibility(): number;
  19313. /**
  19314. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19315. * Higher values reduce sensitivity.
  19316. */
  19317. set angularSensibility(value: number);
  19318. /**
  19319. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19320. */
  19321. get keysUp(): number[];
  19322. set keysUp(value: number[]);
  19323. /**
  19324. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19325. */
  19326. get keysUpward(): number[];
  19327. set keysUpward(value: number[]);
  19328. /**
  19329. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19330. */
  19331. get keysDown(): number[];
  19332. set keysDown(value: number[]);
  19333. /**
  19334. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19335. */
  19336. get keysDownward(): number[];
  19337. set keysDownward(value: number[]);
  19338. /**
  19339. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19340. */
  19341. get keysLeft(): number[];
  19342. set keysLeft(value: number[]);
  19343. /**
  19344. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19345. */
  19346. get keysRight(): number[];
  19347. set keysRight(value: number[]);
  19348. /**
  19349. * Event raised when the camera collide with a mesh in the scene.
  19350. */
  19351. onCollide: (collidedMesh: AbstractMesh) => void;
  19352. private _collider;
  19353. private _needMoveForGravity;
  19354. private _oldPosition;
  19355. private _diffPosition;
  19356. private _newPosition;
  19357. /** @hidden */
  19358. _localDirection: Vector3;
  19359. /** @hidden */
  19360. _transformedDirection: Vector3;
  19361. /**
  19362. * Instantiates a Free Camera.
  19363. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19364. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19365. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19366. * @param name Define the name of the camera in the scene
  19367. * @param position Define the start position of the camera in the scene
  19368. * @param scene Define the scene the camera belongs to
  19369. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19370. */
  19371. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19372. /**
  19373. * Attached controls to the current camera.
  19374. * @param element Defines the element the controls should be listened from
  19375. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19376. */
  19377. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19378. /**
  19379. * Detach the current controls from the camera.
  19380. * The camera will stop reacting to inputs.
  19381. * @param element Defines the element to stop listening the inputs from
  19382. */
  19383. detachControl(element: HTMLElement): void;
  19384. private _collisionMask;
  19385. /**
  19386. * Define a collision mask to limit the list of object the camera can collide with
  19387. */
  19388. get collisionMask(): number;
  19389. set collisionMask(mask: number);
  19390. /** @hidden */
  19391. _collideWithWorld(displacement: Vector3): void;
  19392. private _onCollisionPositionChange;
  19393. /** @hidden */
  19394. _checkInputs(): void;
  19395. /** @hidden */
  19396. _decideIfNeedsToMove(): boolean;
  19397. /** @hidden */
  19398. _updatePosition(): void;
  19399. /**
  19400. * Destroy the camera and release the current resources hold by it.
  19401. */
  19402. dispose(): void;
  19403. /**
  19404. * Gets the current object class name.
  19405. * @return the class name
  19406. */
  19407. getClassName(): string;
  19408. }
  19409. }
  19410. declare module "babylonjs/Gamepads/gamepad" {
  19411. import { Observable } from "babylonjs/Misc/observable";
  19412. /**
  19413. * Represents a gamepad control stick position
  19414. */
  19415. export class StickValues {
  19416. /**
  19417. * The x component of the control stick
  19418. */
  19419. x: number;
  19420. /**
  19421. * The y component of the control stick
  19422. */
  19423. y: number;
  19424. /**
  19425. * Initializes the gamepad x and y control stick values
  19426. * @param x The x component of the gamepad control stick value
  19427. * @param y The y component of the gamepad control stick value
  19428. */
  19429. constructor(
  19430. /**
  19431. * The x component of the control stick
  19432. */
  19433. x: number,
  19434. /**
  19435. * The y component of the control stick
  19436. */
  19437. y: number);
  19438. }
  19439. /**
  19440. * An interface which manages callbacks for gamepad button changes
  19441. */
  19442. export interface GamepadButtonChanges {
  19443. /**
  19444. * Called when a gamepad has been changed
  19445. */
  19446. changed: boolean;
  19447. /**
  19448. * Called when a gamepad press event has been triggered
  19449. */
  19450. pressChanged: boolean;
  19451. /**
  19452. * Called when a touch event has been triggered
  19453. */
  19454. touchChanged: boolean;
  19455. /**
  19456. * Called when a value has changed
  19457. */
  19458. valueChanged: boolean;
  19459. }
  19460. /**
  19461. * Represents a gamepad
  19462. */
  19463. export class Gamepad {
  19464. /**
  19465. * The id of the gamepad
  19466. */
  19467. id: string;
  19468. /**
  19469. * The index of the gamepad
  19470. */
  19471. index: number;
  19472. /**
  19473. * The browser gamepad
  19474. */
  19475. browserGamepad: any;
  19476. /**
  19477. * Specifies what type of gamepad this represents
  19478. */
  19479. type: number;
  19480. private _leftStick;
  19481. private _rightStick;
  19482. /** @hidden */
  19483. _isConnected: boolean;
  19484. private _leftStickAxisX;
  19485. private _leftStickAxisY;
  19486. private _rightStickAxisX;
  19487. private _rightStickAxisY;
  19488. /**
  19489. * Triggered when the left control stick has been changed
  19490. */
  19491. private _onleftstickchanged;
  19492. /**
  19493. * Triggered when the right control stick has been changed
  19494. */
  19495. private _onrightstickchanged;
  19496. /**
  19497. * Represents a gamepad controller
  19498. */
  19499. static GAMEPAD: number;
  19500. /**
  19501. * Represents a generic controller
  19502. */
  19503. static GENERIC: number;
  19504. /**
  19505. * Represents an XBox controller
  19506. */
  19507. static XBOX: number;
  19508. /**
  19509. * Represents a pose-enabled controller
  19510. */
  19511. static POSE_ENABLED: number;
  19512. /**
  19513. * Represents an Dual Shock controller
  19514. */
  19515. static DUALSHOCK: number;
  19516. /**
  19517. * Specifies whether the left control stick should be Y-inverted
  19518. */
  19519. protected _invertLeftStickY: boolean;
  19520. /**
  19521. * Specifies if the gamepad has been connected
  19522. */
  19523. get isConnected(): boolean;
  19524. /**
  19525. * Initializes the gamepad
  19526. * @param id The id of the gamepad
  19527. * @param index The index of the gamepad
  19528. * @param browserGamepad The browser gamepad
  19529. * @param leftStickX The x component of the left joystick
  19530. * @param leftStickY The y component of the left joystick
  19531. * @param rightStickX The x component of the right joystick
  19532. * @param rightStickY The y component of the right joystick
  19533. */
  19534. constructor(
  19535. /**
  19536. * The id of the gamepad
  19537. */
  19538. id: string,
  19539. /**
  19540. * The index of the gamepad
  19541. */
  19542. index: number,
  19543. /**
  19544. * The browser gamepad
  19545. */
  19546. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19547. /**
  19548. * Callback triggered when the left joystick has changed
  19549. * @param callback
  19550. */
  19551. onleftstickchanged(callback: (values: StickValues) => void): void;
  19552. /**
  19553. * Callback triggered when the right joystick has changed
  19554. * @param callback
  19555. */
  19556. onrightstickchanged(callback: (values: StickValues) => void): void;
  19557. /**
  19558. * Gets the left joystick
  19559. */
  19560. get leftStick(): StickValues;
  19561. /**
  19562. * Sets the left joystick values
  19563. */
  19564. set leftStick(newValues: StickValues);
  19565. /**
  19566. * Gets the right joystick
  19567. */
  19568. get rightStick(): StickValues;
  19569. /**
  19570. * Sets the right joystick value
  19571. */
  19572. set rightStick(newValues: StickValues);
  19573. /**
  19574. * Updates the gamepad joystick positions
  19575. */
  19576. update(): void;
  19577. /**
  19578. * Disposes the gamepad
  19579. */
  19580. dispose(): void;
  19581. }
  19582. /**
  19583. * Represents a generic gamepad
  19584. */
  19585. export class GenericPad extends Gamepad {
  19586. private _buttons;
  19587. private _onbuttondown;
  19588. private _onbuttonup;
  19589. /**
  19590. * Observable triggered when a button has been pressed
  19591. */
  19592. onButtonDownObservable: Observable<number>;
  19593. /**
  19594. * Observable triggered when a button has been released
  19595. */
  19596. onButtonUpObservable: Observable<number>;
  19597. /**
  19598. * Callback triggered when a button has been pressed
  19599. * @param callback Called when a button has been pressed
  19600. */
  19601. onbuttondown(callback: (buttonPressed: number) => void): void;
  19602. /**
  19603. * Callback triggered when a button has been released
  19604. * @param callback Called when a button has been released
  19605. */
  19606. onbuttonup(callback: (buttonReleased: number) => void): void;
  19607. /**
  19608. * Initializes the generic gamepad
  19609. * @param id The id of the generic gamepad
  19610. * @param index The index of the generic gamepad
  19611. * @param browserGamepad The browser gamepad
  19612. */
  19613. constructor(id: string, index: number, browserGamepad: any);
  19614. private _setButtonValue;
  19615. /**
  19616. * Updates the generic gamepad
  19617. */
  19618. update(): void;
  19619. /**
  19620. * Disposes the generic gamepad
  19621. */
  19622. dispose(): void;
  19623. }
  19624. }
  19625. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19626. import { Observable } from "babylonjs/Misc/observable";
  19627. import { Nullable } from "babylonjs/types";
  19628. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19629. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19631. import { Ray } from "babylonjs/Culling/ray";
  19632. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19633. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19634. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19635. /**
  19636. * Defines the types of pose enabled controllers that are supported
  19637. */
  19638. export enum PoseEnabledControllerType {
  19639. /**
  19640. * HTC Vive
  19641. */
  19642. VIVE = 0,
  19643. /**
  19644. * Oculus Rift
  19645. */
  19646. OCULUS = 1,
  19647. /**
  19648. * Windows mixed reality
  19649. */
  19650. WINDOWS = 2,
  19651. /**
  19652. * Samsung gear VR
  19653. */
  19654. GEAR_VR = 3,
  19655. /**
  19656. * Google Daydream
  19657. */
  19658. DAYDREAM = 4,
  19659. /**
  19660. * Generic
  19661. */
  19662. GENERIC = 5
  19663. }
  19664. /**
  19665. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19666. */
  19667. export interface MutableGamepadButton {
  19668. /**
  19669. * Value of the button/trigger
  19670. */
  19671. value: number;
  19672. /**
  19673. * If the button/trigger is currently touched
  19674. */
  19675. touched: boolean;
  19676. /**
  19677. * If the button/trigger is currently pressed
  19678. */
  19679. pressed: boolean;
  19680. }
  19681. /**
  19682. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19683. * @hidden
  19684. */
  19685. export interface ExtendedGamepadButton extends GamepadButton {
  19686. /**
  19687. * If the button/trigger is currently pressed
  19688. */
  19689. readonly pressed: boolean;
  19690. /**
  19691. * If the button/trigger is currently touched
  19692. */
  19693. readonly touched: boolean;
  19694. /**
  19695. * Value of the button/trigger
  19696. */
  19697. readonly value: number;
  19698. }
  19699. /** @hidden */
  19700. export interface _GamePadFactory {
  19701. /**
  19702. * Returns whether or not the current gamepad can be created for this type of controller.
  19703. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19704. * @returns true if it can be created, otherwise false
  19705. */
  19706. canCreate(gamepadInfo: any): boolean;
  19707. /**
  19708. * Creates a new instance of the Gamepad.
  19709. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19710. * @returns the new gamepad instance
  19711. */
  19712. create(gamepadInfo: any): Gamepad;
  19713. }
  19714. /**
  19715. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19716. */
  19717. export class PoseEnabledControllerHelper {
  19718. /** @hidden */
  19719. static _ControllerFactories: _GamePadFactory[];
  19720. /** @hidden */
  19721. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19722. /**
  19723. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19724. * @param vrGamepad the gamepad to initialized
  19725. * @returns a vr controller of the type the gamepad identified as
  19726. */
  19727. static InitiateController(vrGamepad: any): Gamepad;
  19728. }
  19729. /**
  19730. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19731. */
  19732. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19733. /**
  19734. * If the controller is used in a webXR session
  19735. */
  19736. isXR: boolean;
  19737. private _deviceRoomPosition;
  19738. private _deviceRoomRotationQuaternion;
  19739. /**
  19740. * The device position in babylon space
  19741. */
  19742. devicePosition: Vector3;
  19743. /**
  19744. * The device rotation in babylon space
  19745. */
  19746. deviceRotationQuaternion: Quaternion;
  19747. /**
  19748. * The scale factor of the device in babylon space
  19749. */
  19750. deviceScaleFactor: number;
  19751. /**
  19752. * (Likely devicePosition should be used instead) The device position in its room space
  19753. */
  19754. position: Vector3;
  19755. /**
  19756. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19757. */
  19758. rotationQuaternion: Quaternion;
  19759. /**
  19760. * The type of controller (Eg. Windows mixed reality)
  19761. */
  19762. controllerType: PoseEnabledControllerType;
  19763. protected _calculatedPosition: Vector3;
  19764. private _calculatedRotation;
  19765. /**
  19766. * The raw pose from the device
  19767. */
  19768. rawPose: DevicePose;
  19769. private _trackPosition;
  19770. private _maxRotationDistFromHeadset;
  19771. private _draggedRoomRotation;
  19772. /**
  19773. * @hidden
  19774. */
  19775. _disableTrackPosition(fixedPosition: Vector3): void;
  19776. /**
  19777. * Internal, the mesh attached to the controller
  19778. * @hidden
  19779. */
  19780. _mesh: Nullable<AbstractMesh>;
  19781. private _poseControlledCamera;
  19782. private _leftHandSystemQuaternion;
  19783. /**
  19784. * Internal, matrix used to convert room space to babylon space
  19785. * @hidden
  19786. */
  19787. _deviceToWorld: Matrix;
  19788. /**
  19789. * Node to be used when casting a ray from the controller
  19790. * @hidden
  19791. */
  19792. _pointingPoseNode: Nullable<TransformNode>;
  19793. /**
  19794. * Name of the child mesh that can be used to cast a ray from the controller
  19795. */
  19796. static readonly POINTING_POSE: string;
  19797. /**
  19798. * Creates a new PoseEnabledController from a gamepad
  19799. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19800. */
  19801. constructor(browserGamepad: any);
  19802. private _workingMatrix;
  19803. /**
  19804. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19805. */
  19806. update(): void;
  19807. /**
  19808. * Updates only the pose device and mesh without doing any button event checking
  19809. */
  19810. protected _updatePoseAndMesh(): void;
  19811. /**
  19812. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19813. * @param poseData raw pose fromthe device
  19814. */
  19815. updateFromDevice(poseData: DevicePose): void;
  19816. /**
  19817. * @hidden
  19818. */
  19819. _meshAttachedObservable: Observable<AbstractMesh>;
  19820. /**
  19821. * Attaches a mesh to the controller
  19822. * @param mesh the mesh to be attached
  19823. */
  19824. attachToMesh(mesh: AbstractMesh): void;
  19825. /**
  19826. * Attaches the controllers mesh to a camera
  19827. * @param camera the camera the mesh should be attached to
  19828. */
  19829. attachToPoseControlledCamera(camera: TargetCamera): void;
  19830. /**
  19831. * Disposes of the controller
  19832. */
  19833. dispose(): void;
  19834. /**
  19835. * The mesh that is attached to the controller
  19836. */
  19837. get mesh(): Nullable<AbstractMesh>;
  19838. /**
  19839. * Gets the ray of the controller in the direction the controller is pointing
  19840. * @param length the length the resulting ray should be
  19841. * @returns a ray in the direction the controller is pointing
  19842. */
  19843. getForwardRay(length?: number): Ray;
  19844. }
  19845. }
  19846. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19847. import { Observable } from "babylonjs/Misc/observable";
  19848. import { Scene } from "babylonjs/scene";
  19849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19850. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19851. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19852. import { Nullable } from "babylonjs/types";
  19853. /**
  19854. * Defines the WebVRController object that represents controllers tracked in 3D space
  19855. */
  19856. export abstract class WebVRController extends PoseEnabledController {
  19857. /**
  19858. * Internal, the default controller model for the controller
  19859. */
  19860. protected _defaultModel: Nullable<AbstractMesh>;
  19861. /**
  19862. * Fired when the trigger state has changed
  19863. */
  19864. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19865. /**
  19866. * Fired when the main button state has changed
  19867. */
  19868. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19869. /**
  19870. * Fired when the secondary button state has changed
  19871. */
  19872. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19873. /**
  19874. * Fired when the pad state has changed
  19875. */
  19876. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19877. /**
  19878. * Fired when controllers stick values have changed
  19879. */
  19880. onPadValuesChangedObservable: Observable<StickValues>;
  19881. /**
  19882. * Array of button availible on the controller
  19883. */
  19884. protected _buttons: Array<MutableGamepadButton>;
  19885. private _onButtonStateChange;
  19886. /**
  19887. * Fired when a controller button's state has changed
  19888. * @param callback the callback containing the button that was modified
  19889. */
  19890. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19891. /**
  19892. * X and Y axis corresponding to the controllers joystick
  19893. */
  19894. pad: StickValues;
  19895. /**
  19896. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19897. */
  19898. hand: string;
  19899. /**
  19900. * The default controller model for the controller
  19901. */
  19902. get defaultModel(): Nullable<AbstractMesh>;
  19903. /**
  19904. * Creates a new WebVRController from a gamepad
  19905. * @param vrGamepad the gamepad that the WebVRController should be created from
  19906. */
  19907. constructor(vrGamepad: any);
  19908. /**
  19909. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19910. */
  19911. update(): void;
  19912. /**
  19913. * Function to be called when a button is modified
  19914. */
  19915. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19916. /**
  19917. * Loads a mesh and attaches it to the controller
  19918. * @param scene the scene the mesh should be added to
  19919. * @param meshLoaded callback for when the mesh has been loaded
  19920. */
  19921. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19922. private _setButtonValue;
  19923. private _changes;
  19924. private _checkChanges;
  19925. /**
  19926. * Disposes of th webVRCOntroller
  19927. */
  19928. dispose(): void;
  19929. }
  19930. }
  19931. declare module "babylonjs/Lights/hemisphericLight" {
  19932. import { Nullable } from "babylonjs/types";
  19933. import { Scene } from "babylonjs/scene";
  19934. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19935. import { Color3 } from "babylonjs/Maths/math.color";
  19936. import { Effect } from "babylonjs/Materials/effect";
  19937. import { Light } from "babylonjs/Lights/light";
  19938. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19939. /**
  19940. * The HemisphericLight simulates the ambient environment light,
  19941. * so the passed direction is the light reflection direction, not the incoming direction.
  19942. */
  19943. export class HemisphericLight extends Light {
  19944. /**
  19945. * The groundColor is the light in the opposite direction to the one specified during creation.
  19946. * 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.
  19947. */
  19948. groundColor: Color3;
  19949. /**
  19950. * The light reflection direction, not the incoming direction.
  19951. */
  19952. direction: Vector3;
  19953. /**
  19954. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19955. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19956. * The HemisphericLight can't cast shadows.
  19957. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19958. * @param name The friendly name of the light
  19959. * @param direction The direction of the light reflection
  19960. * @param scene The scene the light belongs to
  19961. */
  19962. constructor(name: string, direction: Vector3, scene: Scene);
  19963. protected _buildUniformLayout(): void;
  19964. /**
  19965. * Returns the string "HemisphericLight".
  19966. * @return The class name
  19967. */
  19968. getClassName(): string;
  19969. /**
  19970. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19971. * Returns the updated direction.
  19972. * @param target The target the direction should point to
  19973. * @return The computed direction
  19974. */
  19975. setDirectionToTarget(target: Vector3): Vector3;
  19976. /**
  19977. * Returns the shadow generator associated to the light.
  19978. * @returns Always null for hemispheric lights because it does not support shadows.
  19979. */
  19980. getShadowGenerator(): Nullable<IShadowGenerator>;
  19981. /**
  19982. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19983. * @param effect The effect to update
  19984. * @param lightIndex The index of the light in the effect to update
  19985. * @returns The hemispheric light
  19986. */
  19987. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19989. /**
  19990. * Computes the world matrix of the node
  19991. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19992. * @param useWasUpdatedFlag defines a reserved property
  19993. * @returns the world matrix
  19994. */
  19995. computeWorldMatrix(): Matrix;
  19996. /**
  19997. * Returns the integer 3.
  19998. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19999. */
  20000. getTypeID(): number;
  20001. /**
  20002. * Prepares the list of defines specific to the light type.
  20003. * @param defines the list of defines
  20004. * @param lightIndex defines the index of the light for the effect
  20005. */
  20006. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20007. }
  20008. }
  20009. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20010. /** @hidden */
  20011. export var vrMultiviewToSingleviewPixelShader: {
  20012. name: string;
  20013. shader: string;
  20014. };
  20015. }
  20016. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20017. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20018. import { Scene } from "babylonjs/scene";
  20019. /**
  20020. * Renders to multiple views with a single draw call
  20021. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20022. */
  20023. export class MultiviewRenderTarget extends RenderTargetTexture {
  20024. /**
  20025. * Creates a multiview render target
  20026. * @param scene scene used with the render target
  20027. * @param size the size of the render target (used for each view)
  20028. */
  20029. constructor(scene: Scene, size?: number | {
  20030. width: number;
  20031. height: number;
  20032. } | {
  20033. ratio: number;
  20034. });
  20035. /**
  20036. * @hidden
  20037. * @param faceIndex the face index, if its a cube texture
  20038. */
  20039. _bindFrameBuffer(faceIndex?: number): void;
  20040. /**
  20041. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20042. * @returns the view count
  20043. */
  20044. getViewCount(): number;
  20045. }
  20046. }
  20047. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20048. import { Camera } from "babylonjs/Cameras/camera";
  20049. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20050. import { Nullable } from "babylonjs/types";
  20051. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20052. import { Matrix } from "babylonjs/Maths/math.vector";
  20053. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20054. module "babylonjs/Engines/engine" {
  20055. interface Engine {
  20056. /**
  20057. * Creates a new multiview render target
  20058. * @param width defines the width of the texture
  20059. * @param height defines the height of the texture
  20060. * @returns the created multiview texture
  20061. */
  20062. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20063. /**
  20064. * Binds a multiview framebuffer to be drawn to
  20065. * @param multiviewTexture texture to bind
  20066. */
  20067. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20068. }
  20069. }
  20070. module "babylonjs/Cameras/camera" {
  20071. interface Camera {
  20072. /**
  20073. * @hidden
  20074. * 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)
  20075. */
  20076. _useMultiviewToSingleView: boolean;
  20077. /**
  20078. * @hidden
  20079. * 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)
  20080. */
  20081. _multiviewTexture: Nullable<RenderTargetTexture>;
  20082. /**
  20083. * @hidden
  20084. * ensures the multiview texture of the camera exists and has the specified width/height
  20085. * @param width height to set on the multiview texture
  20086. * @param height width to set on the multiview texture
  20087. */
  20088. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20089. }
  20090. }
  20091. module "babylonjs/scene" {
  20092. interface Scene {
  20093. /** @hidden */
  20094. _transformMatrixR: Matrix;
  20095. /** @hidden */
  20096. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20097. /** @hidden */
  20098. _createMultiviewUbo(): void;
  20099. /** @hidden */
  20100. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20101. /** @hidden */
  20102. _renderMultiviewToSingleView(camera: Camera): void;
  20103. }
  20104. }
  20105. }
  20106. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20107. import { Camera } from "babylonjs/Cameras/camera";
  20108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20109. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20110. import "babylonjs/Engines/Extensions/engine.multiview";
  20111. /**
  20112. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20113. * This will not be used for webXR as it supports displaying texture arrays directly
  20114. */
  20115. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20116. /**
  20117. * Initializes a VRMultiviewToSingleview
  20118. * @param name name of the post process
  20119. * @param camera camera to be applied to
  20120. * @param scaleFactor scaling factor to the size of the output texture
  20121. */
  20122. constructor(name: string, camera: Camera, scaleFactor: number);
  20123. }
  20124. }
  20125. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20126. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20127. import { Nullable } from "babylonjs/types";
  20128. import { Size } from "babylonjs/Maths/math.size";
  20129. import { Observable } from "babylonjs/Misc/observable";
  20130. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20131. /**
  20132. * Interface used to define additional presentation attributes
  20133. */
  20134. export interface IVRPresentationAttributes {
  20135. /**
  20136. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20137. */
  20138. highRefreshRate: boolean;
  20139. /**
  20140. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20141. */
  20142. foveationLevel: number;
  20143. }
  20144. module "babylonjs/Engines/engine" {
  20145. interface Engine {
  20146. /** @hidden */
  20147. _vrDisplay: any;
  20148. /** @hidden */
  20149. _vrSupported: boolean;
  20150. /** @hidden */
  20151. _oldSize: Size;
  20152. /** @hidden */
  20153. _oldHardwareScaleFactor: number;
  20154. /** @hidden */
  20155. _vrExclusivePointerMode: boolean;
  20156. /** @hidden */
  20157. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20158. /** @hidden */
  20159. _onVRDisplayPointerRestricted: () => void;
  20160. /** @hidden */
  20161. _onVRDisplayPointerUnrestricted: () => void;
  20162. /** @hidden */
  20163. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20164. /** @hidden */
  20165. _onVrDisplayDisconnect: Nullable<() => void>;
  20166. /** @hidden */
  20167. _onVrDisplayPresentChange: Nullable<() => void>;
  20168. /**
  20169. * Observable signaled when VR display mode changes
  20170. */
  20171. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20172. /**
  20173. * Observable signaled when VR request present is complete
  20174. */
  20175. onVRRequestPresentComplete: Observable<boolean>;
  20176. /**
  20177. * Observable signaled when VR request present starts
  20178. */
  20179. onVRRequestPresentStart: Observable<Engine>;
  20180. /**
  20181. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20182. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20183. */
  20184. isInVRExclusivePointerMode: boolean;
  20185. /**
  20186. * Gets a boolean indicating if a webVR device was detected
  20187. * @returns true if a webVR device was detected
  20188. */
  20189. isVRDevicePresent(): boolean;
  20190. /**
  20191. * Gets the current webVR device
  20192. * @returns the current webVR device (or null)
  20193. */
  20194. getVRDevice(): any;
  20195. /**
  20196. * Initializes a webVR display and starts listening to display change events
  20197. * The onVRDisplayChangedObservable will be notified upon these changes
  20198. * @returns A promise containing a VRDisplay and if vr is supported
  20199. */
  20200. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20201. /** @hidden */
  20202. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20203. /**
  20204. * Gets or sets the presentation attributes used to configure VR rendering
  20205. */
  20206. vrPresentationAttributes?: IVRPresentationAttributes;
  20207. /**
  20208. * Call this function to switch to webVR mode
  20209. * Will do nothing if webVR is not supported or if there is no webVR device
  20210. * @param options the webvr options provided to the camera. mainly used for multiview
  20211. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20212. */
  20213. enableVR(options: WebVROptions): void;
  20214. /** @hidden */
  20215. _onVRFullScreenTriggered(): void;
  20216. }
  20217. }
  20218. }
  20219. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20220. import { Nullable } from "babylonjs/types";
  20221. import { Observable } from "babylonjs/Misc/observable";
  20222. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20223. import { Scene } from "babylonjs/scene";
  20224. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20225. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20226. import { Node } from "babylonjs/node";
  20227. import { Ray } from "babylonjs/Culling/ray";
  20228. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20229. import "babylonjs/Engines/Extensions/engine.webVR";
  20230. /**
  20231. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20232. * IMPORTANT!! The data is right-hand data.
  20233. * @export
  20234. * @interface DevicePose
  20235. */
  20236. export interface DevicePose {
  20237. /**
  20238. * The position of the device, values in array are [x,y,z].
  20239. */
  20240. readonly position: Nullable<Float32Array>;
  20241. /**
  20242. * The linearVelocity of the device, values in array are [x,y,z].
  20243. */
  20244. readonly linearVelocity: Nullable<Float32Array>;
  20245. /**
  20246. * The linearAcceleration of the device, values in array are [x,y,z].
  20247. */
  20248. readonly linearAcceleration: Nullable<Float32Array>;
  20249. /**
  20250. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20251. */
  20252. readonly orientation: Nullable<Float32Array>;
  20253. /**
  20254. * The angularVelocity of the device, values in array are [x,y,z].
  20255. */
  20256. readonly angularVelocity: Nullable<Float32Array>;
  20257. /**
  20258. * The angularAcceleration of the device, values in array are [x,y,z].
  20259. */
  20260. readonly angularAcceleration: Nullable<Float32Array>;
  20261. }
  20262. /**
  20263. * Interface representing a pose controlled object in Babylon.
  20264. * A pose controlled object has both regular pose values as well as pose values
  20265. * from an external device such as a VR head mounted display
  20266. */
  20267. export interface PoseControlled {
  20268. /**
  20269. * The position of the object in babylon space.
  20270. */
  20271. position: Vector3;
  20272. /**
  20273. * The rotation quaternion of the object in babylon space.
  20274. */
  20275. rotationQuaternion: Quaternion;
  20276. /**
  20277. * The position of the device in babylon space.
  20278. */
  20279. devicePosition?: Vector3;
  20280. /**
  20281. * The rotation quaternion of the device in babylon space.
  20282. */
  20283. deviceRotationQuaternion: Quaternion;
  20284. /**
  20285. * The raw pose coming from the device.
  20286. */
  20287. rawPose: Nullable<DevicePose>;
  20288. /**
  20289. * The scale of the device to be used when translating from device space to babylon space.
  20290. */
  20291. deviceScaleFactor: number;
  20292. /**
  20293. * Updates the poseControlled values based on the input device pose.
  20294. * @param poseData the pose data to update the object with
  20295. */
  20296. updateFromDevice(poseData: DevicePose): void;
  20297. }
  20298. /**
  20299. * Set of options to customize the webVRCamera
  20300. */
  20301. export interface WebVROptions {
  20302. /**
  20303. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20304. */
  20305. trackPosition?: boolean;
  20306. /**
  20307. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20308. */
  20309. positionScale?: number;
  20310. /**
  20311. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20312. */
  20313. displayName?: string;
  20314. /**
  20315. * Should the native controller meshes be initialized. (default: true)
  20316. */
  20317. controllerMeshes?: boolean;
  20318. /**
  20319. * Creating a default HemiLight only on controllers. (default: true)
  20320. */
  20321. defaultLightingOnControllers?: boolean;
  20322. /**
  20323. * If you don't want to use the default VR button of the helper. (default: false)
  20324. */
  20325. useCustomVRButton?: boolean;
  20326. /**
  20327. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20328. */
  20329. customVRButton?: HTMLButtonElement;
  20330. /**
  20331. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20332. */
  20333. rayLength?: number;
  20334. /**
  20335. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20336. */
  20337. defaultHeight?: number;
  20338. /**
  20339. * If multiview should be used if availible (default: false)
  20340. */
  20341. useMultiview?: boolean;
  20342. }
  20343. /**
  20344. * This represents a WebVR camera.
  20345. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20346. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20347. */
  20348. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20349. private webVROptions;
  20350. /**
  20351. * @hidden
  20352. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20353. */
  20354. _vrDevice: any;
  20355. /**
  20356. * The rawPose of the vrDevice.
  20357. */
  20358. rawPose: Nullable<DevicePose>;
  20359. private _onVREnabled;
  20360. private _specsVersion;
  20361. private _attached;
  20362. private _frameData;
  20363. protected _descendants: Array<Node>;
  20364. private _deviceRoomPosition;
  20365. /** @hidden */
  20366. _deviceRoomRotationQuaternion: Quaternion;
  20367. private _standingMatrix;
  20368. /**
  20369. * Represents device position in babylon space.
  20370. */
  20371. devicePosition: Vector3;
  20372. /**
  20373. * Represents device rotation in babylon space.
  20374. */
  20375. deviceRotationQuaternion: Quaternion;
  20376. /**
  20377. * The scale of the device to be used when translating from device space to babylon space.
  20378. */
  20379. deviceScaleFactor: number;
  20380. private _deviceToWorld;
  20381. private _worldToDevice;
  20382. /**
  20383. * References to the webVR controllers for the vrDevice.
  20384. */
  20385. controllers: Array<WebVRController>;
  20386. /**
  20387. * Emits an event when a controller is attached.
  20388. */
  20389. onControllersAttachedObservable: Observable<WebVRController[]>;
  20390. /**
  20391. * Emits an event when a controller's mesh has been loaded;
  20392. */
  20393. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20394. /**
  20395. * Emits an event when the HMD's pose has been updated.
  20396. */
  20397. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20398. private _poseSet;
  20399. /**
  20400. * If the rig cameras be used as parent instead of this camera.
  20401. */
  20402. rigParenting: boolean;
  20403. private _lightOnControllers;
  20404. private _defaultHeight?;
  20405. /**
  20406. * Instantiates a WebVRFreeCamera.
  20407. * @param name The name of the WebVRFreeCamera
  20408. * @param position The starting anchor position for the camera
  20409. * @param scene The scene the camera belongs to
  20410. * @param webVROptions a set of customizable options for the webVRCamera
  20411. */
  20412. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20413. /**
  20414. * Gets the device distance from the ground in meters.
  20415. * @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.
  20416. */
  20417. deviceDistanceToRoomGround(): number;
  20418. /**
  20419. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20420. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20421. */
  20422. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20423. /**
  20424. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20425. * @returns A promise with a boolean set to if the standing matrix is supported.
  20426. */
  20427. useStandingMatrixAsync(): Promise<boolean>;
  20428. /**
  20429. * Disposes the camera
  20430. */
  20431. dispose(): void;
  20432. /**
  20433. * Gets a vrController by name.
  20434. * @param name The name of the controller to retreive
  20435. * @returns the controller matching the name specified or null if not found
  20436. */
  20437. getControllerByName(name: string): Nullable<WebVRController>;
  20438. private _leftController;
  20439. /**
  20440. * The controller corresponding to the users left hand.
  20441. */
  20442. get leftController(): Nullable<WebVRController>;
  20443. private _rightController;
  20444. /**
  20445. * The controller corresponding to the users right hand.
  20446. */
  20447. get rightController(): Nullable<WebVRController>;
  20448. /**
  20449. * Casts a ray forward from the vrCamera's gaze.
  20450. * @param length Length of the ray (default: 100)
  20451. * @returns the ray corresponding to the gaze
  20452. */
  20453. getForwardRay(length?: number): Ray;
  20454. /**
  20455. * @hidden
  20456. * Updates the camera based on device's frame data
  20457. */
  20458. _checkInputs(): void;
  20459. /**
  20460. * Updates the poseControlled values based on the input device pose.
  20461. * @param poseData Pose coming from the device
  20462. */
  20463. updateFromDevice(poseData: DevicePose): void;
  20464. private _htmlElementAttached;
  20465. private _detachIfAttached;
  20466. /**
  20467. * WebVR's attach control will start broadcasting frames to the device.
  20468. * Note that in certain browsers (chrome for example) this function must be called
  20469. * within a user-interaction callback. Example:
  20470. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20471. *
  20472. * @param element html element to attach the vrDevice to
  20473. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20474. */
  20475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20476. /**
  20477. * Detaches the camera from the html element and disables VR
  20478. *
  20479. * @param element html element to detach from
  20480. */
  20481. detachControl(element: HTMLElement): void;
  20482. /**
  20483. * @returns the name of this class
  20484. */
  20485. getClassName(): string;
  20486. /**
  20487. * Calls resetPose on the vrDisplay
  20488. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20489. */
  20490. resetToCurrentRotation(): void;
  20491. /**
  20492. * @hidden
  20493. * Updates the rig cameras (left and right eye)
  20494. */
  20495. _updateRigCameras(): void;
  20496. private _workingVector;
  20497. private _oneVector;
  20498. private _workingMatrix;
  20499. private updateCacheCalled;
  20500. private _correctPositionIfNotTrackPosition;
  20501. /**
  20502. * @hidden
  20503. * Updates the cached values of the camera
  20504. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20505. */
  20506. _updateCache(ignoreParentClass?: boolean): void;
  20507. /**
  20508. * @hidden
  20509. * Get current device position in babylon world
  20510. */
  20511. _computeDevicePosition(): void;
  20512. /**
  20513. * Updates the current device position and rotation in the babylon world
  20514. */
  20515. update(): void;
  20516. /**
  20517. * @hidden
  20518. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20519. * @returns an identity matrix
  20520. */
  20521. _getViewMatrix(): Matrix;
  20522. private _tmpMatrix;
  20523. /**
  20524. * This function is called by the two RIG cameras.
  20525. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20526. * @hidden
  20527. */
  20528. _getWebVRViewMatrix(): Matrix;
  20529. /** @hidden */
  20530. _getWebVRProjectionMatrix(): Matrix;
  20531. private _onGamepadConnectedObserver;
  20532. private _onGamepadDisconnectedObserver;
  20533. private _updateCacheWhenTrackingDisabledObserver;
  20534. /**
  20535. * Initializes the controllers and their meshes
  20536. */
  20537. initControllers(): void;
  20538. }
  20539. }
  20540. declare module "babylonjs/Materials/materialHelper" {
  20541. import { Nullable } from "babylonjs/types";
  20542. import { Scene } from "babylonjs/scene";
  20543. import { Engine } from "babylonjs/Engines/engine";
  20544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20545. import { Light } from "babylonjs/Lights/light";
  20546. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20547. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20548. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20549. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20550. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20551. /**
  20552. * "Static Class" containing the most commonly used helper while dealing with material for
  20553. * rendering purpose.
  20554. *
  20555. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20556. *
  20557. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20558. */
  20559. export class MaterialHelper {
  20560. /**
  20561. * Bind the current view position to an effect.
  20562. * @param effect The effect to be bound
  20563. * @param scene The scene the eyes position is used from
  20564. * @param variableName name of the shader variable that will hold the eye position
  20565. */
  20566. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20567. /**
  20568. * Helps preparing the defines values about the UVs in used in the effect.
  20569. * UVs are shared as much as we can accross channels in the shaders.
  20570. * @param texture The texture we are preparing the UVs for
  20571. * @param defines The defines to update
  20572. * @param key The channel key "diffuse", "specular"... used in the shader
  20573. */
  20574. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20575. /**
  20576. * Binds a texture matrix value to its corrsponding uniform
  20577. * @param texture The texture to bind the matrix for
  20578. * @param uniformBuffer The uniform buffer receivin the data
  20579. * @param key The channel key "diffuse", "specular"... used in the shader
  20580. */
  20581. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20582. /**
  20583. * Gets the current status of the fog (should it be enabled?)
  20584. * @param mesh defines the mesh to evaluate for fog support
  20585. * @param scene defines the hosting scene
  20586. * @returns true if fog must be enabled
  20587. */
  20588. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20589. /**
  20590. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20591. * @param mesh defines the current mesh
  20592. * @param scene defines the current scene
  20593. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20594. * @param pointsCloud defines if point cloud rendering has to be turned on
  20595. * @param fogEnabled defines if fog has to be turned on
  20596. * @param alphaTest defines if alpha testing has to be turned on
  20597. * @param defines defines the current list of defines
  20598. */
  20599. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20600. /**
  20601. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20602. * @param scene defines the current scene
  20603. * @param engine defines the current engine
  20604. * @param defines specifies the list of active defines
  20605. * @param useInstances defines if instances have to be turned on
  20606. * @param useClipPlane defines if clip plane have to be turned on
  20607. * @param useInstances defines if instances have to be turned on
  20608. * @param useThinInstances defines if thin instances have to be turned on
  20609. */
  20610. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20611. /**
  20612. * Prepares the defines for bones
  20613. * @param mesh The mesh containing the geometry data we will draw
  20614. * @param defines The defines to update
  20615. */
  20616. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20617. /**
  20618. * Prepares the defines for morph targets
  20619. * @param mesh The mesh containing the geometry data we will draw
  20620. * @param defines The defines to update
  20621. */
  20622. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20623. /**
  20624. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20625. * @param mesh The mesh containing the geometry data we will draw
  20626. * @param defines The defines to update
  20627. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20628. * @param useBones Precise whether bones should be used or not (override mesh info)
  20629. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20630. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20631. * @returns false if defines are considered not dirty and have not been checked
  20632. */
  20633. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20634. /**
  20635. * Prepares the defines related to multiview
  20636. * @param scene The scene we are intending to draw
  20637. * @param defines The defines to update
  20638. */
  20639. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20640. /**
  20641. * Prepares the defines related to the prepass
  20642. * @param scene The scene we are intending to draw
  20643. * @param defines The defines to update
  20644. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  20645. */
  20646. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  20647. /**
  20648. * Prepares the defines related to the light information passed in parameter
  20649. * @param scene The scene we are intending to draw
  20650. * @param mesh The mesh the effect is compiling for
  20651. * @param light The light the effect is compiling for
  20652. * @param lightIndex The index of the light
  20653. * @param defines The defines to update
  20654. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20655. * @param state Defines the current state regarding what is needed (normals, etc...)
  20656. */
  20657. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20658. needNormals: boolean;
  20659. needRebuild: boolean;
  20660. shadowEnabled: boolean;
  20661. specularEnabled: boolean;
  20662. lightmapMode: boolean;
  20663. }): void;
  20664. /**
  20665. * Prepares the defines related to the light information passed in parameter
  20666. * @param scene The scene we are intending to draw
  20667. * @param mesh The mesh the effect is compiling for
  20668. * @param defines The defines to update
  20669. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20670. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20671. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20672. * @returns true if normals will be required for the rest of the effect
  20673. */
  20674. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20675. /**
  20676. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20677. * @param lightIndex defines the light index
  20678. * @param uniformsList The uniform list
  20679. * @param samplersList The sampler list
  20680. * @param projectedLightTexture defines if projected texture must be used
  20681. * @param uniformBuffersList defines an optional list of uniform buffers
  20682. */
  20683. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20684. /**
  20685. * Prepares the uniforms and samplers list to be used in the effect
  20686. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20687. * @param samplersList The sampler list
  20688. * @param defines The defines helping in the list generation
  20689. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20690. */
  20691. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20692. /**
  20693. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20694. * @param defines The defines to update while falling back
  20695. * @param fallbacks The authorized effect fallbacks
  20696. * @param maxSimultaneousLights The maximum number of lights allowed
  20697. * @param rank the current rank of the Effect
  20698. * @returns The newly affected rank
  20699. */
  20700. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20701. private static _TmpMorphInfluencers;
  20702. /**
  20703. * Prepares the list of attributes required for morph targets according to the effect defines.
  20704. * @param attribs The current list of supported attribs
  20705. * @param mesh The mesh to prepare the morph targets attributes for
  20706. * @param influencers The number of influencers
  20707. */
  20708. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20709. /**
  20710. * Prepares the list of attributes required for morph targets according to the effect defines.
  20711. * @param attribs The current list of supported attribs
  20712. * @param mesh The mesh to prepare the morph targets attributes for
  20713. * @param defines The current Defines of the effect
  20714. */
  20715. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20716. /**
  20717. * Prepares the list of attributes required for bones according to the effect defines.
  20718. * @param attribs The current list of supported attribs
  20719. * @param mesh The mesh to prepare the bones attributes for
  20720. * @param defines The current Defines of the effect
  20721. * @param fallbacks The current efffect fallback strategy
  20722. */
  20723. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20724. /**
  20725. * Check and prepare the list of attributes required for instances according to the effect defines.
  20726. * @param attribs The current list of supported attribs
  20727. * @param defines The current MaterialDefines of the effect
  20728. */
  20729. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20730. /**
  20731. * Add the list of attributes required for instances to the attribs array.
  20732. * @param attribs The current list of supported attribs
  20733. */
  20734. static PushAttributesForInstances(attribs: string[]): void;
  20735. /**
  20736. * Binds the light information to the effect.
  20737. * @param light The light containing the generator
  20738. * @param effect The effect we are binding the data to
  20739. * @param lightIndex The light index in the effect used to render
  20740. */
  20741. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20742. /**
  20743. * Binds the lights information from the scene to the effect for the given mesh.
  20744. * @param light Light to bind
  20745. * @param lightIndex Light index
  20746. * @param scene The scene where the light belongs to
  20747. * @param effect The effect we are binding the data to
  20748. * @param useSpecular Defines if specular is supported
  20749. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20750. */
  20751. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20752. /**
  20753. * Binds the lights information from the scene to the effect for the given mesh.
  20754. * @param scene The scene the lights belongs to
  20755. * @param mesh The mesh we are binding the information to render
  20756. * @param effect The effect we are binding the data to
  20757. * @param defines The generated defines for the effect
  20758. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20759. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20760. */
  20761. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20762. private static _tempFogColor;
  20763. /**
  20764. * Binds the fog information from the scene to the effect for the given mesh.
  20765. * @param scene The scene the lights belongs to
  20766. * @param mesh The mesh we are binding the information to render
  20767. * @param effect The effect we are binding the data to
  20768. * @param linearSpace Defines if the fog effect is applied in linear space
  20769. */
  20770. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20771. /**
  20772. * Binds the bones information from the mesh to the effect.
  20773. * @param mesh The mesh we are binding the information to render
  20774. * @param effect The effect we are binding the data to
  20775. */
  20776. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  20777. /**
  20778. * Binds the morph targets information from the mesh to the effect.
  20779. * @param abstractMesh The mesh we are binding the information to render
  20780. * @param effect The effect we are binding the data to
  20781. */
  20782. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20783. /**
  20784. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20785. * @param defines The generated defines used in the effect
  20786. * @param effect The effect we are binding the data to
  20787. * @param scene The scene we are willing to render with logarithmic scale for
  20788. */
  20789. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20790. /**
  20791. * Binds the clip plane information from the scene to the effect.
  20792. * @param scene The scene the clip plane information are extracted from
  20793. * @param effect The effect we are binding the data to
  20794. */
  20795. static BindClipPlane(effect: Effect, scene: Scene): void;
  20796. }
  20797. }
  20798. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  20799. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20800. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20801. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  20802. import { Nullable } from "babylonjs/types";
  20803. import { Effect } from "babylonjs/Materials/effect";
  20804. import { Matrix } from "babylonjs/Maths/math.vector";
  20805. import { Scene } from "babylonjs/scene";
  20806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  20807. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  20808. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20809. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  20810. import { Observable } from "babylonjs/Misc/observable";
  20811. /**
  20812. * Block used to expose an input value
  20813. */
  20814. export class InputBlock extends NodeMaterialBlock {
  20815. private _mode;
  20816. private _associatedVariableName;
  20817. private _storedValue;
  20818. private _valueCallback;
  20819. private _type;
  20820. private _animationType;
  20821. /** Gets or set a value used to limit the range of float values */
  20822. min: number;
  20823. /** Gets or set a value used to limit the range of float values */
  20824. max: number;
  20825. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20826. isBoolean: boolean;
  20827. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20828. matrixMode: number;
  20829. /** @hidden */
  20830. _systemValue: Nullable<NodeMaterialSystemValues>;
  20831. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  20832. visibleInInspector: boolean;
  20833. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20834. isConstant: boolean;
  20835. /** Gets or sets the group to use to display this block in the Inspector */
  20836. groupInInspector: string;
  20837. /** Gets an observable raised when the value is changed */
  20838. onValueChangedObservable: Observable<InputBlock>;
  20839. /**
  20840. * Gets or sets the connection point type (default is float)
  20841. */
  20842. get type(): NodeMaterialBlockConnectionPointTypes;
  20843. /**
  20844. * Creates a new InputBlock
  20845. * @param name defines the block name
  20846. * @param target defines the target of that block (Vertex by default)
  20847. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20848. */
  20849. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20850. /**
  20851. * Gets the output component
  20852. */
  20853. get output(): NodeMaterialConnectionPoint;
  20854. /**
  20855. * Set the source of this connection point to a vertex attribute
  20856. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20857. * @returns the current connection point
  20858. */
  20859. setAsAttribute(attributeName?: string): InputBlock;
  20860. /**
  20861. * Set the source of this connection point to a system value
  20862. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20863. * @returns the current connection point
  20864. */
  20865. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20866. /**
  20867. * Gets or sets the value of that point.
  20868. * Please note that this value will be ignored if valueCallback is defined
  20869. */
  20870. get value(): any;
  20871. set value(value: any);
  20872. /**
  20873. * Gets or sets a callback used to get the value of that point.
  20874. * Please note that setting this value will force the connection point to ignore the value property
  20875. */
  20876. get valueCallback(): () => any;
  20877. set valueCallback(value: () => any);
  20878. /**
  20879. * Gets or sets the associated variable name in the shader
  20880. */
  20881. get associatedVariableName(): string;
  20882. set associatedVariableName(value: string);
  20883. /** Gets or sets the type of animation applied to the input */
  20884. get animationType(): AnimatedInputBlockTypes;
  20885. set animationType(value: AnimatedInputBlockTypes);
  20886. /**
  20887. * Gets a boolean indicating that this connection point not defined yet
  20888. */
  20889. get isUndefined(): boolean;
  20890. /**
  20891. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20892. * In this case the connection point name must be the name of the uniform to use.
  20893. * Can only be set on inputs
  20894. */
  20895. get isUniform(): boolean;
  20896. set isUniform(value: boolean);
  20897. /**
  20898. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20899. * In this case the connection point name must be the name of the attribute to use
  20900. * Can only be set on inputs
  20901. */
  20902. get isAttribute(): boolean;
  20903. set isAttribute(value: boolean);
  20904. /**
  20905. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20906. * Can only be set on exit points
  20907. */
  20908. get isVarying(): boolean;
  20909. set isVarying(value: boolean);
  20910. /**
  20911. * Gets a boolean indicating that the current connection point is a system value
  20912. */
  20913. get isSystemValue(): boolean;
  20914. /**
  20915. * Gets or sets the current well known value or null if not defined as a system value
  20916. */
  20917. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20918. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20919. /**
  20920. * Gets the current class name
  20921. * @returns the class name
  20922. */
  20923. getClassName(): string;
  20924. /**
  20925. * Animate the input if animationType !== None
  20926. * @param scene defines the rendering scene
  20927. */
  20928. animate(scene: Scene): void;
  20929. private _emitDefine;
  20930. initialize(state: NodeMaterialBuildState): void;
  20931. /**
  20932. * Set the input block to its default value (based on its type)
  20933. */
  20934. setDefaultValue(): void;
  20935. private _emitConstant;
  20936. /** @hidden */
  20937. get _noContextSwitch(): boolean;
  20938. private _emit;
  20939. /** @hidden */
  20940. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20941. /** @hidden */
  20942. _transmit(effect: Effect, scene: Scene): void;
  20943. protected _buildBlock(state: NodeMaterialBuildState): void;
  20944. protected _dumpPropertiesCode(): string;
  20945. dispose(): void;
  20946. serialize(): any;
  20947. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20948. }
  20949. }
  20950. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  20951. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  20952. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  20953. import { Nullable } from "babylonjs/types";
  20954. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  20955. import { Observable } from "babylonjs/Misc/observable";
  20956. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  20957. /**
  20958. * Enum used to define the compatibility state between two connection points
  20959. */
  20960. export enum NodeMaterialConnectionPointCompatibilityStates {
  20961. /** Points are compatibles */
  20962. Compatible = 0,
  20963. /** Points are incompatible because of their types */
  20964. TypeIncompatible = 1,
  20965. /** Points are incompatible because of their targets (vertex vs fragment) */
  20966. TargetIncompatible = 2
  20967. }
  20968. /**
  20969. * Defines the direction of a connection point
  20970. */
  20971. export enum NodeMaterialConnectionPointDirection {
  20972. /** Input */
  20973. Input = 0,
  20974. /** Output */
  20975. Output = 1
  20976. }
  20977. /**
  20978. * Defines a connection point for a block
  20979. */
  20980. export class NodeMaterialConnectionPoint {
  20981. /** @hidden */
  20982. _ownerBlock: NodeMaterialBlock;
  20983. /** @hidden */
  20984. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20985. private _endpoints;
  20986. private _associatedVariableName;
  20987. private _direction;
  20988. /** @hidden */
  20989. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20990. /** @hidden */
  20991. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20992. private _type;
  20993. /** @hidden */
  20994. _enforceAssociatedVariableName: boolean;
  20995. /** Gets the direction of the point */
  20996. get direction(): NodeMaterialConnectionPointDirection;
  20997. /** Indicates that this connection point needs dual validation before being connected to another point */
  20998. needDualDirectionValidation: boolean;
  20999. /**
  21000. * Gets or sets the additional types supported by this connection point
  21001. */
  21002. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21003. /**
  21004. * Gets or sets the additional types excluded by this connection point
  21005. */
  21006. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21007. /**
  21008. * Observable triggered when this point is connected
  21009. */
  21010. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21011. /**
  21012. * Gets or sets the associated variable name in the shader
  21013. */
  21014. get associatedVariableName(): string;
  21015. set associatedVariableName(value: string);
  21016. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21017. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21018. /**
  21019. * Gets or sets the connection point type (default is float)
  21020. */
  21021. get type(): NodeMaterialBlockConnectionPointTypes;
  21022. set type(value: NodeMaterialBlockConnectionPointTypes);
  21023. /**
  21024. * Gets or sets the connection point name
  21025. */
  21026. name: string;
  21027. /**
  21028. * Gets or sets the connection point name
  21029. */
  21030. displayName: string;
  21031. /**
  21032. * Gets or sets a boolean indicating that this connection point can be omitted
  21033. */
  21034. isOptional: boolean;
  21035. /**
  21036. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21037. */
  21038. isExposedOnFrame: boolean;
  21039. /**
  21040. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21041. */
  21042. define: string;
  21043. /** @hidden */
  21044. _prioritizeVertex: boolean;
  21045. private _target;
  21046. /** Gets or sets the target of that connection point */
  21047. get target(): NodeMaterialBlockTargets;
  21048. set target(value: NodeMaterialBlockTargets);
  21049. /**
  21050. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21051. */
  21052. get isConnected(): boolean;
  21053. /**
  21054. * Gets a boolean indicating that the current point is connected to an input block
  21055. */
  21056. get isConnectedToInputBlock(): boolean;
  21057. /**
  21058. * Gets a the connected input block (if any)
  21059. */
  21060. get connectInputBlock(): Nullable<InputBlock>;
  21061. /** Get the other side of the connection (if any) */
  21062. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21063. /** Get the block that owns this connection point */
  21064. get ownerBlock(): NodeMaterialBlock;
  21065. /** Get the block connected on the other side of this connection (if any) */
  21066. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21067. /** Get the block connected on the endpoints of this connection (if any) */
  21068. get connectedBlocks(): Array<NodeMaterialBlock>;
  21069. /** Gets the list of connected endpoints */
  21070. get endpoints(): NodeMaterialConnectionPoint[];
  21071. /** Gets a boolean indicating if that output point is connected to at least one input */
  21072. get hasEndpoints(): boolean;
  21073. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21074. get isConnectedInVertexShader(): boolean;
  21075. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21076. get isConnectedInFragmentShader(): boolean;
  21077. /**
  21078. * Creates a block suitable to be used as an input for this input point.
  21079. * If null is returned, a block based on the point type will be created.
  21080. * @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
  21081. */
  21082. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21083. /**
  21084. * Creates a new connection point
  21085. * @param name defines the connection point name
  21086. * @param ownerBlock defines the block hosting this connection point
  21087. * @param direction defines the direction of the connection point
  21088. */
  21089. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21090. /**
  21091. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21092. * @returns the class name
  21093. */
  21094. getClassName(): string;
  21095. /**
  21096. * Gets a boolean indicating if the current point can be connected to another point
  21097. * @param connectionPoint defines the other connection point
  21098. * @returns a boolean
  21099. */
  21100. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21101. /**
  21102. * Gets a number indicating if the current point can be connected to another point
  21103. * @param connectionPoint defines the other connection point
  21104. * @returns a number defining the compatibility state
  21105. */
  21106. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21107. /**
  21108. * Connect this point to another connection point
  21109. * @param connectionPoint defines the other connection point
  21110. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21111. * @returns the current connection point
  21112. */
  21113. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21114. /**
  21115. * Disconnect this point from one of his endpoint
  21116. * @param endpoint defines the other connection point
  21117. * @returns the current connection point
  21118. */
  21119. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21120. /**
  21121. * Serializes this point in a JSON representation
  21122. * @param isInput defines if the connection point is an input (default is true)
  21123. * @returns the serialized point object
  21124. */
  21125. serialize(isInput?: boolean): any;
  21126. /**
  21127. * Release resources
  21128. */
  21129. dispose(): void;
  21130. }
  21131. }
  21132. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21133. /**
  21134. * Enum used to define the material modes
  21135. */
  21136. export enum NodeMaterialModes {
  21137. /** Regular material */
  21138. Material = 0,
  21139. /** For post process */
  21140. PostProcess = 1,
  21141. /** For particle system */
  21142. Particle = 2
  21143. }
  21144. }
  21145. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21146. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21147. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21148. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21151. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21152. import { Effect } from "babylonjs/Materials/effect";
  21153. import { Mesh } from "babylonjs/Meshes/mesh";
  21154. import { Nullable } from "babylonjs/types";
  21155. import { Texture } from "babylonjs/Materials/Textures/texture";
  21156. import { Scene } from "babylonjs/scene";
  21157. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21158. /**
  21159. * Block used to read a texture from a sampler
  21160. */
  21161. export class TextureBlock extends NodeMaterialBlock {
  21162. private _defineName;
  21163. private _linearDefineName;
  21164. private _gammaDefineName;
  21165. private _tempTextureRead;
  21166. private _samplerName;
  21167. private _transformedUVName;
  21168. private _textureTransformName;
  21169. private _textureInfoName;
  21170. private _mainUVName;
  21171. private _mainUVDefineName;
  21172. private _fragmentOnly;
  21173. /**
  21174. * Gets or sets the texture associated with the node
  21175. */
  21176. texture: Nullable<Texture>;
  21177. /**
  21178. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21179. */
  21180. convertToGammaSpace: boolean;
  21181. /**
  21182. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21183. */
  21184. convertToLinearSpace: boolean;
  21185. /**
  21186. * Create a new TextureBlock
  21187. * @param name defines the block name
  21188. */
  21189. constructor(name: string, fragmentOnly?: boolean);
  21190. /**
  21191. * Gets the current class name
  21192. * @returns the class name
  21193. */
  21194. getClassName(): string;
  21195. /**
  21196. * Gets the uv input component
  21197. */
  21198. get uv(): NodeMaterialConnectionPoint;
  21199. /**
  21200. * Gets the rgba output component
  21201. */
  21202. get rgba(): NodeMaterialConnectionPoint;
  21203. /**
  21204. * Gets the rgb output component
  21205. */
  21206. get rgb(): NodeMaterialConnectionPoint;
  21207. /**
  21208. * Gets the r output component
  21209. */
  21210. get r(): NodeMaterialConnectionPoint;
  21211. /**
  21212. * Gets the g output component
  21213. */
  21214. get g(): NodeMaterialConnectionPoint;
  21215. /**
  21216. * Gets the b output component
  21217. */
  21218. get b(): NodeMaterialConnectionPoint;
  21219. /**
  21220. * Gets the a output component
  21221. */
  21222. get a(): NodeMaterialConnectionPoint;
  21223. get target(): NodeMaterialBlockTargets;
  21224. autoConfigure(material: NodeMaterial): void;
  21225. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21226. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21227. isReady(): boolean;
  21228. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21229. private get _isMixed();
  21230. private _injectVertexCode;
  21231. private _writeTextureRead;
  21232. private _writeOutput;
  21233. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21234. protected _dumpPropertiesCode(): string;
  21235. serialize(): any;
  21236. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21237. }
  21238. }
  21239. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21240. /** @hidden */
  21241. export var reflectionFunction: {
  21242. name: string;
  21243. shader: string;
  21244. };
  21245. }
  21246. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21247. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21248. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21249. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21250. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21252. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21253. import { Effect } from "babylonjs/Materials/effect";
  21254. import { Mesh } from "babylonjs/Meshes/mesh";
  21255. import { Nullable } from "babylonjs/types";
  21256. import { Scene } from "babylonjs/scene";
  21257. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21258. /**
  21259. * Base block used to read a reflection texture from a sampler
  21260. */
  21261. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21262. /** @hidden */
  21263. _define3DName: string;
  21264. /** @hidden */
  21265. _defineCubicName: string;
  21266. /** @hidden */
  21267. _defineExplicitName: string;
  21268. /** @hidden */
  21269. _defineProjectionName: string;
  21270. /** @hidden */
  21271. _defineLocalCubicName: string;
  21272. /** @hidden */
  21273. _defineSphericalName: string;
  21274. /** @hidden */
  21275. _definePlanarName: string;
  21276. /** @hidden */
  21277. _defineEquirectangularName: string;
  21278. /** @hidden */
  21279. _defineMirroredEquirectangularFixedName: string;
  21280. /** @hidden */
  21281. _defineEquirectangularFixedName: string;
  21282. /** @hidden */
  21283. _defineSkyboxName: string;
  21284. /** @hidden */
  21285. _defineOppositeZ: string;
  21286. /** @hidden */
  21287. _cubeSamplerName: string;
  21288. /** @hidden */
  21289. _2DSamplerName: string;
  21290. protected _positionUVWName: string;
  21291. protected _directionWName: string;
  21292. protected _reflectionVectorName: string;
  21293. /** @hidden */
  21294. _reflectionCoordsName: string;
  21295. /** @hidden */
  21296. _reflectionMatrixName: string;
  21297. protected _reflectionColorName: string;
  21298. /**
  21299. * Gets or sets the texture associated with the node
  21300. */
  21301. texture: Nullable<BaseTexture>;
  21302. /**
  21303. * Create a new ReflectionTextureBaseBlock
  21304. * @param name defines the block name
  21305. */
  21306. constructor(name: string);
  21307. /**
  21308. * Gets the current class name
  21309. * @returns the class name
  21310. */
  21311. getClassName(): string;
  21312. /**
  21313. * Gets the world position input component
  21314. */
  21315. abstract get position(): NodeMaterialConnectionPoint;
  21316. /**
  21317. * Gets the world position input component
  21318. */
  21319. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21320. /**
  21321. * Gets the world normal input component
  21322. */
  21323. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21324. /**
  21325. * Gets the world input component
  21326. */
  21327. abstract get world(): NodeMaterialConnectionPoint;
  21328. /**
  21329. * Gets the camera (or eye) position component
  21330. */
  21331. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21332. /**
  21333. * Gets the view input component
  21334. */
  21335. abstract get view(): NodeMaterialConnectionPoint;
  21336. protected _getTexture(): Nullable<BaseTexture>;
  21337. autoConfigure(material: NodeMaterial): void;
  21338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21339. isReady(): boolean;
  21340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21341. /**
  21342. * Gets the code to inject in the vertex shader
  21343. * @param state current state of the node material building
  21344. * @returns the shader code
  21345. */
  21346. handleVertexSide(state: NodeMaterialBuildState): string;
  21347. /**
  21348. * Handles the inits for the fragment code path
  21349. * @param state node material build state
  21350. */
  21351. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21352. /**
  21353. * Generates the reflection coords code for the fragment code path
  21354. * @param worldNormalVarName name of the world normal variable
  21355. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21356. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21357. * @returns the shader code
  21358. */
  21359. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21360. /**
  21361. * Generates the reflection color code for the fragment code path
  21362. * @param lodVarName name of the lod variable
  21363. * @param swizzleLookupTexture swizzle to use for the final color variable
  21364. * @returns the shader code
  21365. */
  21366. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21367. /**
  21368. * Generates the code corresponding to the connected output points
  21369. * @param state node material build state
  21370. * @param varName name of the variable to output
  21371. * @returns the shader code
  21372. */
  21373. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21374. protected _buildBlock(state: NodeMaterialBuildState): this;
  21375. protected _dumpPropertiesCode(): string;
  21376. serialize(): any;
  21377. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21378. }
  21379. }
  21380. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21382. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21383. import { Nullable } from "babylonjs/types";
  21384. /**
  21385. * Defines a connection point to be used for points with a custom object type
  21386. */
  21387. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21388. private _blockType;
  21389. private _blockName;
  21390. private _nameForCheking?;
  21391. /**
  21392. * Creates a new connection point
  21393. * @param name defines the connection point name
  21394. * @param ownerBlock defines the block hosting this connection point
  21395. * @param direction defines the direction of the connection point
  21396. */
  21397. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21398. /**
  21399. * Gets a number indicating if the current point can be connected to another point
  21400. * @param connectionPoint defines the other connection point
  21401. * @returns a number defining the compatibility state
  21402. */
  21403. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21404. /**
  21405. * Creates a block suitable to be used as an input for this input point.
  21406. * If null is returned, a block based on the point type will be created.
  21407. * @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
  21408. */
  21409. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21410. }
  21411. }
  21412. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21413. /**
  21414. * Enum defining the type of properties that can be edited in the property pages in the NME
  21415. */
  21416. export enum PropertyTypeForEdition {
  21417. /** property is a boolean */
  21418. Boolean = 0,
  21419. /** property is a float */
  21420. Float = 1,
  21421. /** property is a Vector2 */
  21422. Vector2 = 2,
  21423. /** property is a list of values */
  21424. List = 3
  21425. }
  21426. /**
  21427. * Interface that defines an option in a variable of type list
  21428. */
  21429. export interface IEditablePropertyListOption {
  21430. /** label of the option */
  21431. "label": string;
  21432. /** value of the option */
  21433. "value": number;
  21434. }
  21435. /**
  21436. * Interface that defines the options available for an editable property
  21437. */
  21438. export interface IEditablePropertyOption {
  21439. /** min value */
  21440. "min"?: number;
  21441. /** max value */
  21442. "max"?: number;
  21443. /** notifiers: indicates which actions to take when the property is changed */
  21444. "notifiers"?: {
  21445. /** the material should be rebuilt */
  21446. "rebuild"?: boolean;
  21447. /** the preview should be updated */
  21448. "update"?: boolean;
  21449. };
  21450. /** list of the options for a variable of type list */
  21451. "options"?: IEditablePropertyListOption[];
  21452. }
  21453. /**
  21454. * Interface that describes an editable property
  21455. */
  21456. export interface IPropertyDescriptionForEdition {
  21457. /** name of the property */
  21458. "propertyName": string;
  21459. /** display name of the property */
  21460. "displayName": string;
  21461. /** type of the property */
  21462. "type": PropertyTypeForEdition;
  21463. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21464. "groupName": string;
  21465. /** options for the property */
  21466. "options": IEditablePropertyOption;
  21467. }
  21468. /**
  21469. * Decorator that flags a property in a node material block as being editable
  21470. */
  21471. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21472. }
  21473. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21476. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21477. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21478. import { Nullable } from "babylonjs/types";
  21479. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21480. import { Mesh } from "babylonjs/Meshes/mesh";
  21481. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21482. import { Effect } from "babylonjs/Materials/effect";
  21483. import { Scene } from "babylonjs/scene";
  21484. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21485. /**
  21486. * Block used to implement the refraction part of the sub surface module of the PBR material
  21487. */
  21488. export class RefractionBlock extends NodeMaterialBlock {
  21489. /** @hidden */
  21490. _define3DName: string;
  21491. /** @hidden */
  21492. _refractionMatrixName: string;
  21493. /** @hidden */
  21494. _defineLODRefractionAlpha: string;
  21495. /** @hidden */
  21496. _defineLinearSpecularRefraction: string;
  21497. /** @hidden */
  21498. _defineOppositeZ: string;
  21499. /** @hidden */
  21500. _cubeSamplerName: string;
  21501. /** @hidden */
  21502. _2DSamplerName: string;
  21503. /** @hidden */
  21504. _vRefractionMicrosurfaceInfosName: string;
  21505. /** @hidden */
  21506. _vRefractionInfosName: string;
  21507. private _scene;
  21508. /**
  21509. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21510. * Materials half opaque for instance using refraction could benefit from this control.
  21511. */
  21512. linkRefractionWithTransparency: boolean;
  21513. /**
  21514. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21515. */
  21516. invertRefractionY: boolean;
  21517. /**
  21518. * Gets or sets the texture associated with the node
  21519. */
  21520. texture: Nullable<BaseTexture>;
  21521. /**
  21522. * Create a new RefractionBlock
  21523. * @param name defines the block name
  21524. */
  21525. constructor(name: string);
  21526. /**
  21527. * Gets the current class name
  21528. * @returns the class name
  21529. */
  21530. getClassName(): string;
  21531. /**
  21532. * Gets the intensity input component
  21533. */
  21534. get intensity(): NodeMaterialConnectionPoint;
  21535. /**
  21536. * Gets the index of refraction input component
  21537. */
  21538. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21539. /**
  21540. * Gets the tint at distance input component
  21541. */
  21542. get tintAtDistance(): NodeMaterialConnectionPoint;
  21543. /**
  21544. * Gets the view input component
  21545. */
  21546. get view(): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Gets the refraction object output component
  21549. */
  21550. get refraction(): NodeMaterialConnectionPoint;
  21551. /**
  21552. * Returns true if the block has a texture
  21553. */
  21554. get hasTexture(): boolean;
  21555. protected _getTexture(): Nullable<BaseTexture>;
  21556. autoConfigure(material: NodeMaterial): void;
  21557. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21558. isReady(): boolean;
  21559. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21560. /**
  21561. * Gets the main code of the block (fragment side)
  21562. * @param state current state of the node material building
  21563. * @returns the shader code
  21564. */
  21565. getCode(state: NodeMaterialBuildState): string;
  21566. protected _buildBlock(state: NodeMaterialBuildState): this;
  21567. protected _dumpPropertiesCode(): string;
  21568. serialize(): any;
  21569. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21570. }
  21571. }
  21572. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21573. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21574. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21575. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21576. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21577. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21578. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21579. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21580. import { Nullable } from "babylonjs/types";
  21581. import { Scene } from "babylonjs/scene";
  21582. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21583. /**
  21584. * Base block used as input for post process
  21585. */
  21586. export class CurrentScreenBlock extends NodeMaterialBlock {
  21587. private _samplerName;
  21588. private _linearDefineName;
  21589. private _gammaDefineName;
  21590. private _mainUVName;
  21591. private _tempTextureRead;
  21592. /**
  21593. * Gets or sets the texture associated with the node
  21594. */
  21595. texture: Nullable<BaseTexture>;
  21596. /**
  21597. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21598. */
  21599. convertToGammaSpace: boolean;
  21600. /**
  21601. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21602. */
  21603. convertToLinearSpace: boolean;
  21604. /**
  21605. * Create a new CurrentScreenBlock
  21606. * @param name defines the block name
  21607. */
  21608. constructor(name: string);
  21609. /**
  21610. * Gets the current class name
  21611. * @returns the class name
  21612. */
  21613. getClassName(): string;
  21614. /**
  21615. * Gets the uv input component
  21616. */
  21617. get uv(): NodeMaterialConnectionPoint;
  21618. /**
  21619. * Gets the rgba output component
  21620. */
  21621. get rgba(): NodeMaterialConnectionPoint;
  21622. /**
  21623. * Gets the rgb output component
  21624. */
  21625. get rgb(): NodeMaterialConnectionPoint;
  21626. /**
  21627. * Gets the r output component
  21628. */
  21629. get r(): NodeMaterialConnectionPoint;
  21630. /**
  21631. * Gets the g output component
  21632. */
  21633. get g(): NodeMaterialConnectionPoint;
  21634. /**
  21635. * Gets the b output component
  21636. */
  21637. get b(): NodeMaterialConnectionPoint;
  21638. /**
  21639. * Gets the a output component
  21640. */
  21641. get a(): NodeMaterialConnectionPoint;
  21642. /**
  21643. * Initialize the block and prepare the context for build
  21644. * @param state defines the state that will be used for the build
  21645. */
  21646. initialize(state: NodeMaterialBuildState): void;
  21647. get target(): NodeMaterialBlockTargets;
  21648. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21649. isReady(): boolean;
  21650. private _injectVertexCode;
  21651. private _writeTextureRead;
  21652. private _writeOutput;
  21653. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21654. serialize(): any;
  21655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21656. }
  21657. }
  21658. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21663. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21665. import { Nullable } from "babylonjs/types";
  21666. import { Scene } from "babylonjs/scene";
  21667. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21668. /**
  21669. * Base block used for the particle texture
  21670. */
  21671. export class ParticleTextureBlock extends NodeMaterialBlock {
  21672. private _samplerName;
  21673. private _linearDefineName;
  21674. private _gammaDefineName;
  21675. private _tempTextureRead;
  21676. /**
  21677. * Gets or sets the texture associated with the node
  21678. */
  21679. texture: Nullable<BaseTexture>;
  21680. /**
  21681. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21682. */
  21683. convertToGammaSpace: boolean;
  21684. /**
  21685. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21686. */
  21687. convertToLinearSpace: boolean;
  21688. /**
  21689. * Create a new ParticleTextureBlock
  21690. * @param name defines the block name
  21691. */
  21692. constructor(name: string);
  21693. /**
  21694. * Gets the current class name
  21695. * @returns the class name
  21696. */
  21697. getClassName(): string;
  21698. /**
  21699. * Gets the uv input component
  21700. */
  21701. get uv(): NodeMaterialConnectionPoint;
  21702. /**
  21703. * Gets the rgba output component
  21704. */
  21705. get rgba(): NodeMaterialConnectionPoint;
  21706. /**
  21707. * Gets the rgb output component
  21708. */
  21709. get rgb(): NodeMaterialConnectionPoint;
  21710. /**
  21711. * Gets the r output component
  21712. */
  21713. get r(): NodeMaterialConnectionPoint;
  21714. /**
  21715. * Gets the g output component
  21716. */
  21717. get g(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the b output component
  21720. */
  21721. get b(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the a output component
  21724. */
  21725. get a(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Initialize the block and prepare the context for build
  21728. * @param state defines the state that will be used for the build
  21729. */
  21730. initialize(state: NodeMaterialBuildState): void;
  21731. autoConfigure(material: NodeMaterial): void;
  21732. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21733. isReady(): boolean;
  21734. private _writeOutput;
  21735. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21736. serialize(): any;
  21737. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21738. }
  21739. }
  21740. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  21741. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21743. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21744. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  21745. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  21746. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  21747. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  21748. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  21749. import { Scene } from "babylonjs/scene";
  21750. /**
  21751. * Class used to store shared data between 2 NodeMaterialBuildState
  21752. */
  21753. export class NodeMaterialBuildStateSharedData {
  21754. /**
  21755. * Gets the list of emitted varyings
  21756. */
  21757. temps: string[];
  21758. /**
  21759. * Gets the list of emitted varyings
  21760. */
  21761. varyings: string[];
  21762. /**
  21763. * Gets the varying declaration string
  21764. */
  21765. varyingDeclaration: string;
  21766. /**
  21767. * Input blocks
  21768. */
  21769. inputBlocks: InputBlock[];
  21770. /**
  21771. * Input blocks
  21772. */
  21773. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21774. /**
  21775. * Bindable blocks (Blocks that need to set data to the effect)
  21776. */
  21777. bindableBlocks: NodeMaterialBlock[];
  21778. /**
  21779. * List of blocks that can provide a compilation fallback
  21780. */
  21781. blocksWithFallbacks: NodeMaterialBlock[];
  21782. /**
  21783. * List of blocks that can provide a define update
  21784. */
  21785. blocksWithDefines: NodeMaterialBlock[];
  21786. /**
  21787. * List of blocks that can provide a repeatable content
  21788. */
  21789. repeatableContentBlocks: NodeMaterialBlock[];
  21790. /**
  21791. * List of blocks that can provide a dynamic list of uniforms
  21792. */
  21793. dynamicUniformBlocks: NodeMaterialBlock[];
  21794. /**
  21795. * List of blocks that can block the isReady function for the material
  21796. */
  21797. blockingBlocks: NodeMaterialBlock[];
  21798. /**
  21799. * Gets the list of animated inputs
  21800. */
  21801. animatedInputs: InputBlock[];
  21802. /**
  21803. * Build Id used to avoid multiple recompilations
  21804. */
  21805. buildId: number;
  21806. /** List of emitted variables */
  21807. variableNames: {
  21808. [key: string]: number;
  21809. };
  21810. /** List of emitted defines */
  21811. defineNames: {
  21812. [key: string]: number;
  21813. };
  21814. /** Should emit comments? */
  21815. emitComments: boolean;
  21816. /** Emit build activity */
  21817. verbose: boolean;
  21818. /** Gets or sets the hosting scene */
  21819. scene: Scene;
  21820. /**
  21821. * Gets the compilation hints emitted at compilation time
  21822. */
  21823. hints: {
  21824. needWorldViewMatrix: boolean;
  21825. needWorldViewProjectionMatrix: boolean;
  21826. needAlphaBlending: boolean;
  21827. needAlphaTesting: boolean;
  21828. };
  21829. /**
  21830. * List of compilation checks
  21831. */
  21832. checks: {
  21833. emitVertex: boolean;
  21834. emitFragment: boolean;
  21835. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21836. };
  21837. /**
  21838. * Is vertex program allowed to be empty?
  21839. */
  21840. allowEmptyVertexProgram: boolean;
  21841. /** Creates a new shared data */
  21842. constructor();
  21843. /**
  21844. * Emits console errors and exceptions if there is a failing check
  21845. */
  21846. emitErrors(): void;
  21847. }
  21848. }
  21849. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  21850. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21851. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21852. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  21853. /**
  21854. * Class used to store node based material build state
  21855. */
  21856. export class NodeMaterialBuildState {
  21857. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21858. supportUniformBuffers: boolean;
  21859. /**
  21860. * Gets the list of emitted attributes
  21861. */
  21862. attributes: string[];
  21863. /**
  21864. * Gets the list of emitted uniforms
  21865. */
  21866. uniforms: string[];
  21867. /**
  21868. * Gets the list of emitted constants
  21869. */
  21870. constants: string[];
  21871. /**
  21872. * Gets the list of emitted samplers
  21873. */
  21874. samplers: string[];
  21875. /**
  21876. * Gets the list of emitted functions
  21877. */
  21878. functions: {
  21879. [key: string]: string;
  21880. };
  21881. /**
  21882. * Gets the list of emitted extensions
  21883. */
  21884. extensions: {
  21885. [key: string]: string;
  21886. };
  21887. /**
  21888. * Gets the target of the compilation state
  21889. */
  21890. target: NodeMaterialBlockTargets;
  21891. /**
  21892. * Gets the list of emitted counters
  21893. */
  21894. counters: {
  21895. [key: string]: number;
  21896. };
  21897. /**
  21898. * Shared data between multiple NodeMaterialBuildState instances
  21899. */
  21900. sharedData: NodeMaterialBuildStateSharedData;
  21901. /** @hidden */
  21902. _vertexState: NodeMaterialBuildState;
  21903. /** @hidden */
  21904. _attributeDeclaration: string;
  21905. /** @hidden */
  21906. _uniformDeclaration: string;
  21907. /** @hidden */
  21908. _constantDeclaration: string;
  21909. /** @hidden */
  21910. _samplerDeclaration: string;
  21911. /** @hidden */
  21912. _varyingTransfer: string;
  21913. /** @hidden */
  21914. _injectAtEnd: string;
  21915. private _repeatableContentAnchorIndex;
  21916. /** @hidden */
  21917. _builtCompilationString: string;
  21918. /**
  21919. * Gets the emitted compilation strings
  21920. */
  21921. compilationString: string;
  21922. /**
  21923. * Finalize the compilation strings
  21924. * @param state defines the current compilation state
  21925. */
  21926. finalize(state: NodeMaterialBuildState): void;
  21927. /** @hidden */
  21928. get _repeatableContentAnchor(): string;
  21929. /** @hidden */
  21930. _getFreeVariableName(prefix: string): string;
  21931. /** @hidden */
  21932. _getFreeDefineName(prefix: string): string;
  21933. /** @hidden */
  21934. _excludeVariableName(name: string): void;
  21935. /** @hidden */
  21936. _emit2DSampler(name: string): void;
  21937. /** @hidden */
  21938. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21939. /** @hidden */
  21940. _emitExtension(name: string, extension: string, define?: string): void;
  21941. /** @hidden */
  21942. _emitFunction(name: string, code: string, comments: string): void;
  21943. /** @hidden */
  21944. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21945. replaceStrings?: {
  21946. search: RegExp;
  21947. replace: string;
  21948. }[];
  21949. repeatKey?: string;
  21950. }): string;
  21951. /** @hidden */
  21952. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21953. repeatKey?: string;
  21954. removeAttributes?: boolean;
  21955. removeUniforms?: boolean;
  21956. removeVaryings?: boolean;
  21957. removeIfDef?: boolean;
  21958. replaceStrings?: {
  21959. search: RegExp;
  21960. replace: string;
  21961. }[];
  21962. }, storeKey?: string): void;
  21963. /** @hidden */
  21964. _registerTempVariable(name: string): boolean;
  21965. /** @hidden */
  21966. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21967. /** @hidden */
  21968. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21969. /** @hidden */
  21970. _emitFloat(value: number): string;
  21971. }
  21972. }
  21973. declare module "babylonjs/Misc/uniqueIdGenerator" {
  21974. /**
  21975. * Helper class used to generate session unique ID
  21976. */
  21977. export class UniqueIdGenerator {
  21978. private static _UniqueIdCounter;
  21979. /**
  21980. * Gets an unique (relatively to the current scene) Id
  21981. */
  21982. static get UniqueId(): number;
  21983. }
  21984. }
  21985. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  21986. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21987. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21988. import { Nullable } from "babylonjs/types";
  21989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21990. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21991. import { Effect } from "babylonjs/Materials/effect";
  21992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21993. import { Mesh } from "babylonjs/Meshes/mesh";
  21994. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21995. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21996. import { Scene } from "babylonjs/scene";
  21997. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  21998. /**
  21999. * Defines a block that can be used inside a node based material
  22000. */
  22001. export class NodeMaterialBlock {
  22002. private _buildId;
  22003. private _buildTarget;
  22004. private _target;
  22005. private _isFinalMerger;
  22006. private _isInput;
  22007. protected _isUnique: boolean;
  22008. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22009. inputsAreExclusive: boolean;
  22010. /** @hidden */
  22011. _codeVariableName: string;
  22012. /** @hidden */
  22013. _inputs: NodeMaterialConnectionPoint[];
  22014. /** @hidden */
  22015. _outputs: NodeMaterialConnectionPoint[];
  22016. /** @hidden */
  22017. _preparationId: number;
  22018. /**
  22019. * Gets or sets the name of the block
  22020. */
  22021. name: string;
  22022. /**
  22023. * Gets or sets the unique id of the node
  22024. */
  22025. uniqueId: number;
  22026. /**
  22027. * Gets or sets the comments associated with this block
  22028. */
  22029. comments: string;
  22030. /**
  22031. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22032. */
  22033. get isUnique(): boolean;
  22034. /**
  22035. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22036. */
  22037. get isFinalMerger(): boolean;
  22038. /**
  22039. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22040. */
  22041. get isInput(): boolean;
  22042. /**
  22043. * Gets or sets the build Id
  22044. */
  22045. get buildId(): number;
  22046. set buildId(value: number);
  22047. /**
  22048. * Gets or sets the target of the block
  22049. */
  22050. get target(): NodeMaterialBlockTargets;
  22051. set target(value: NodeMaterialBlockTargets);
  22052. /**
  22053. * Gets the list of input points
  22054. */
  22055. get inputs(): NodeMaterialConnectionPoint[];
  22056. /** Gets the list of output points */
  22057. get outputs(): NodeMaterialConnectionPoint[];
  22058. /**
  22059. * Find an input by its name
  22060. * @param name defines the name of the input to look for
  22061. * @returns the input or null if not found
  22062. */
  22063. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22064. /**
  22065. * Find an output by its name
  22066. * @param name defines the name of the outputto look for
  22067. * @returns the output or null if not found
  22068. */
  22069. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22070. /**
  22071. * Creates a new NodeMaterialBlock
  22072. * @param name defines the block name
  22073. * @param target defines the target of that block (Vertex by default)
  22074. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22075. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22076. */
  22077. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22078. /**
  22079. * Initialize the block and prepare the context for build
  22080. * @param state defines the state that will be used for the build
  22081. */
  22082. initialize(state: NodeMaterialBuildState): void;
  22083. /**
  22084. * Bind data to effect. Will only be called for blocks with isBindable === true
  22085. * @param effect defines the effect to bind data to
  22086. * @param nodeMaterial defines the hosting NodeMaterial
  22087. * @param mesh defines the mesh that will be rendered
  22088. * @param subMesh defines the submesh that will be rendered
  22089. */
  22090. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22091. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22092. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22093. protected _writeFloat(value: number): string;
  22094. /**
  22095. * Gets the current class name e.g. "NodeMaterialBlock"
  22096. * @returns the class name
  22097. */
  22098. getClassName(): string;
  22099. /**
  22100. * Register a new input. Must be called inside a block constructor
  22101. * @param name defines the connection point name
  22102. * @param type defines the connection point type
  22103. * @param isOptional defines a boolean indicating that this input can be omitted
  22104. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22105. * @param point an already created connection point. If not provided, create a new one
  22106. * @returns the current block
  22107. */
  22108. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22109. /**
  22110. * Register a new output. Must be called inside a block constructor
  22111. * @param name defines the connection point name
  22112. * @param type defines the connection point type
  22113. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22114. * @param point an already created connection point. If not provided, create a new one
  22115. * @returns the current block
  22116. */
  22117. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22118. /**
  22119. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22120. * @param forOutput defines an optional connection point to check compatibility with
  22121. * @returns the first available input or null
  22122. */
  22123. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22124. /**
  22125. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22126. * @param forBlock defines an optional block to check compatibility with
  22127. * @returns the first available input or null
  22128. */
  22129. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22130. /**
  22131. * Gets the sibling of the given output
  22132. * @param current defines the current output
  22133. * @returns the next output in the list or null
  22134. */
  22135. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22136. /**
  22137. * Connect current block with another block
  22138. * @param other defines the block to connect with
  22139. * @param options define the various options to help pick the right connections
  22140. * @returns the current block
  22141. */
  22142. connectTo(other: NodeMaterialBlock, options?: {
  22143. input?: string;
  22144. output?: string;
  22145. outputSwizzle?: string;
  22146. }): this | undefined;
  22147. protected _buildBlock(state: NodeMaterialBuildState): void;
  22148. /**
  22149. * Add uniforms, samplers and uniform buffers at compilation time
  22150. * @param state defines the state to update
  22151. * @param nodeMaterial defines the node material requesting the update
  22152. * @param defines defines the material defines to update
  22153. * @param uniformBuffers defines the list of uniform buffer names
  22154. */
  22155. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22156. /**
  22157. * Add potential fallbacks if shader compilation fails
  22158. * @param mesh defines the mesh to be rendered
  22159. * @param fallbacks defines the current prioritized list of fallbacks
  22160. */
  22161. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22162. /**
  22163. * Initialize defines for shader compilation
  22164. * @param mesh defines the mesh to be rendered
  22165. * @param nodeMaterial defines the node material requesting the update
  22166. * @param defines defines the material defines to update
  22167. * @param useInstances specifies that instances should be used
  22168. */
  22169. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22170. /**
  22171. * Update defines for shader compilation
  22172. * @param mesh defines the mesh to be rendered
  22173. * @param nodeMaterial defines the node material requesting the update
  22174. * @param defines defines the material defines to update
  22175. * @param useInstances specifies that instances should be used
  22176. * @param subMesh defines which submesh to render
  22177. */
  22178. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22179. /**
  22180. * Lets the block try to connect some inputs automatically
  22181. * @param material defines the hosting NodeMaterial
  22182. */
  22183. autoConfigure(material: NodeMaterial): void;
  22184. /**
  22185. * Function called when a block is declared as repeatable content generator
  22186. * @param vertexShaderState defines the current compilation state for the vertex shader
  22187. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22188. * @param mesh defines the mesh to be rendered
  22189. * @param defines defines the material defines to update
  22190. */
  22191. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22192. /**
  22193. * Checks if the block is ready
  22194. * @param mesh defines the mesh to be rendered
  22195. * @param nodeMaterial defines the node material requesting the update
  22196. * @param defines defines the material defines to update
  22197. * @param useInstances specifies that instances should be used
  22198. * @returns true if the block is ready
  22199. */
  22200. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22201. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22202. private _processBuild;
  22203. /**
  22204. * Compile the current node and generate the shader code
  22205. * @param state defines the current compilation state (uniforms, samplers, current string)
  22206. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22207. * @returns true if already built
  22208. */
  22209. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22210. protected _inputRename(name: string): string;
  22211. protected _outputRename(name: string): string;
  22212. protected _dumpPropertiesCode(): string;
  22213. /** @hidden */
  22214. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22215. /** @hidden */
  22216. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22217. /**
  22218. * Clone the current block to a new identical block
  22219. * @param scene defines the hosting scene
  22220. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22221. * @returns a copy of the current block
  22222. */
  22223. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22224. /**
  22225. * Serializes this block in a JSON representation
  22226. * @returns the serialized block object
  22227. */
  22228. serialize(): any;
  22229. /** @hidden */
  22230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22231. private _deserializePortDisplayNamesAndExposedOnFrame;
  22232. /**
  22233. * Release resources
  22234. */
  22235. dispose(): void;
  22236. }
  22237. }
  22238. declare module "babylonjs/Materials/pushMaterial" {
  22239. import { Nullable } from "babylonjs/types";
  22240. import { Scene } from "babylonjs/scene";
  22241. import { Matrix } from "babylonjs/Maths/math.vector";
  22242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22243. import { Mesh } from "babylonjs/Meshes/mesh";
  22244. import { Material } from "babylonjs/Materials/material";
  22245. import { Effect } from "babylonjs/Materials/effect";
  22246. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22247. /**
  22248. * Base class of materials working in push mode in babylon JS
  22249. * @hidden
  22250. */
  22251. export class PushMaterial extends Material {
  22252. protected _activeEffect: Effect;
  22253. protected _normalMatrix: Matrix;
  22254. constructor(name: string, scene: Scene);
  22255. getEffect(): Effect;
  22256. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22257. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22258. /**
  22259. * Binds the given world matrix to the active effect
  22260. *
  22261. * @param world the matrix to bind
  22262. */
  22263. bindOnlyWorldMatrix(world: Matrix): void;
  22264. /**
  22265. * Binds the given normal matrix to the active effect
  22266. *
  22267. * @param normalMatrix the matrix to bind
  22268. */
  22269. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22270. bind(world: Matrix, mesh?: Mesh): void;
  22271. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22272. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22273. }
  22274. }
  22275. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22276. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22277. /**
  22278. * Root class for all node material optimizers
  22279. */
  22280. export class NodeMaterialOptimizer {
  22281. /**
  22282. * Function used to optimize a NodeMaterial graph
  22283. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22284. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22285. */
  22286. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22287. }
  22288. }
  22289. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22291. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22292. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22293. import { Scene } from "babylonjs/scene";
  22294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22295. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22296. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22297. /**
  22298. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22299. */
  22300. export class TransformBlock extends NodeMaterialBlock {
  22301. /**
  22302. * Defines the value to use to complement W value to transform it to a Vector4
  22303. */
  22304. complementW: number;
  22305. /**
  22306. * Defines the value to use to complement z value to transform it to a Vector4
  22307. */
  22308. complementZ: number;
  22309. /**
  22310. * Creates a new TransformBlock
  22311. * @param name defines the block name
  22312. */
  22313. constructor(name: string);
  22314. /**
  22315. * Gets the current class name
  22316. * @returns the class name
  22317. */
  22318. getClassName(): string;
  22319. /**
  22320. * Gets the vector input
  22321. */
  22322. get vector(): NodeMaterialConnectionPoint;
  22323. /**
  22324. * Gets the output component
  22325. */
  22326. get output(): NodeMaterialConnectionPoint;
  22327. /**
  22328. * Gets the xyz output component
  22329. */
  22330. get xyz(): NodeMaterialConnectionPoint;
  22331. /**
  22332. * Gets the matrix transform input
  22333. */
  22334. get transform(): NodeMaterialConnectionPoint;
  22335. protected _buildBlock(state: NodeMaterialBuildState): this;
  22336. /**
  22337. * Update defines for shader compilation
  22338. * @param mesh defines the mesh to be rendered
  22339. * @param nodeMaterial defines the node material requesting the update
  22340. * @param defines defines the material defines to update
  22341. * @param useInstances specifies that instances should be used
  22342. * @param subMesh defines which submesh to render
  22343. */
  22344. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22345. serialize(): any;
  22346. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22347. protected _dumpPropertiesCode(): string;
  22348. }
  22349. }
  22350. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22351. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22352. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22353. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22354. /**
  22355. * Block used to output the vertex position
  22356. */
  22357. export class VertexOutputBlock extends NodeMaterialBlock {
  22358. /**
  22359. * Creates a new VertexOutputBlock
  22360. * @param name defines the block name
  22361. */
  22362. constructor(name: string);
  22363. /**
  22364. * Gets the current class name
  22365. * @returns the class name
  22366. */
  22367. getClassName(): string;
  22368. /**
  22369. * Gets the vector input component
  22370. */
  22371. get vector(): NodeMaterialConnectionPoint;
  22372. protected _buildBlock(state: NodeMaterialBuildState): this;
  22373. }
  22374. }
  22375. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22376. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22377. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22378. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22379. /**
  22380. * Block used to output the final color
  22381. */
  22382. export class FragmentOutputBlock extends NodeMaterialBlock {
  22383. /**
  22384. * Create a new FragmentOutputBlock
  22385. * @param name defines the block name
  22386. */
  22387. constructor(name: string);
  22388. /**
  22389. * Gets the current class name
  22390. * @returns the class name
  22391. */
  22392. getClassName(): string;
  22393. /**
  22394. * Gets the rgba input component
  22395. */
  22396. get rgba(): NodeMaterialConnectionPoint;
  22397. /**
  22398. * Gets the rgb input component
  22399. */
  22400. get rgb(): NodeMaterialConnectionPoint;
  22401. /**
  22402. * Gets the a input component
  22403. */
  22404. get a(): NodeMaterialConnectionPoint;
  22405. protected _buildBlock(state: NodeMaterialBuildState): this;
  22406. }
  22407. }
  22408. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22412. /**
  22413. * Block used for the particle ramp gradient section
  22414. */
  22415. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22416. /**
  22417. * Create a new ParticleRampGradientBlock
  22418. * @param name defines the block name
  22419. */
  22420. constructor(name: string);
  22421. /**
  22422. * Gets the current class name
  22423. * @returns the class name
  22424. */
  22425. getClassName(): string;
  22426. /**
  22427. * Gets the color input component
  22428. */
  22429. get color(): NodeMaterialConnectionPoint;
  22430. /**
  22431. * Gets the rampColor output component
  22432. */
  22433. get rampColor(): NodeMaterialConnectionPoint;
  22434. /**
  22435. * Initialize the block and prepare the context for build
  22436. * @param state defines the state that will be used for the build
  22437. */
  22438. initialize(state: NodeMaterialBuildState): void;
  22439. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22440. }
  22441. }
  22442. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22443. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22444. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22445. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22446. /**
  22447. * Block used for the particle blend multiply section
  22448. */
  22449. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22450. /**
  22451. * Create a new ParticleBlendMultiplyBlock
  22452. * @param name defines the block name
  22453. */
  22454. constructor(name: string);
  22455. /**
  22456. * Gets the current class name
  22457. * @returns the class name
  22458. */
  22459. getClassName(): string;
  22460. /**
  22461. * Gets the color input component
  22462. */
  22463. get color(): NodeMaterialConnectionPoint;
  22464. /**
  22465. * Gets the alphaTexture input component
  22466. */
  22467. get alphaTexture(): NodeMaterialConnectionPoint;
  22468. /**
  22469. * Gets the alphaColor input component
  22470. */
  22471. get alphaColor(): NodeMaterialConnectionPoint;
  22472. /**
  22473. * Gets the blendColor output component
  22474. */
  22475. get blendColor(): NodeMaterialConnectionPoint;
  22476. /**
  22477. * Initialize the block and prepare the context for build
  22478. * @param state defines the state that will be used for the build
  22479. */
  22480. initialize(state: NodeMaterialBuildState): void;
  22481. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22482. }
  22483. }
  22484. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22485. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22486. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22487. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22488. /**
  22489. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22490. */
  22491. export class VectorMergerBlock extends NodeMaterialBlock {
  22492. /**
  22493. * Create a new VectorMergerBlock
  22494. * @param name defines the block name
  22495. */
  22496. constructor(name: string);
  22497. /**
  22498. * Gets the current class name
  22499. * @returns the class name
  22500. */
  22501. getClassName(): string;
  22502. /**
  22503. * Gets the xyz component (input)
  22504. */
  22505. get xyzIn(): NodeMaterialConnectionPoint;
  22506. /**
  22507. * Gets the xy component (input)
  22508. */
  22509. get xyIn(): NodeMaterialConnectionPoint;
  22510. /**
  22511. * Gets the x component (input)
  22512. */
  22513. get x(): NodeMaterialConnectionPoint;
  22514. /**
  22515. * Gets the y component (input)
  22516. */
  22517. get y(): NodeMaterialConnectionPoint;
  22518. /**
  22519. * Gets the z component (input)
  22520. */
  22521. get z(): NodeMaterialConnectionPoint;
  22522. /**
  22523. * Gets the w component (input)
  22524. */
  22525. get w(): NodeMaterialConnectionPoint;
  22526. /**
  22527. * Gets the xyzw component (output)
  22528. */
  22529. get xyzw(): NodeMaterialConnectionPoint;
  22530. /**
  22531. * Gets the xyz component (output)
  22532. */
  22533. get xyzOut(): NodeMaterialConnectionPoint;
  22534. /**
  22535. * Gets the xy component (output)
  22536. */
  22537. get xyOut(): NodeMaterialConnectionPoint;
  22538. /**
  22539. * Gets the xy component (output)
  22540. * @deprecated Please use xyOut instead.
  22541. */
  22542. get xy(): NodeMaterialConnectionPoint;
  22543. /**
  22544. * Gets the xyz component (output)
  22545. * @deprecated Please use xyzOut instead.
  22546. */
  22547. get xyz(): NodeMaterialConnectionPoint;
  22548. protected _buildBlock(state: NodeMaterialBuildState): this;
  22549. }
  22550. }
  22551. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22555. import { Vector2 } from "babylonjs/Maths/math.vector";
  22556. import { Scene } from "babylonjs/scene";
  22557. /**
  22558. * Block used to remap a float from a range to a new one
  22559. */
  22560. export class RemapBlock extends NodeMaterialBlock {
  22561. /**
  22562. * Gets or sets the source range
  22563. */
  22564. sourceRange: Vector2;
  22565. /**
  22566. * Gets or sets the target range
  22567. */
  22568. targetRange: Vector2;
  22569. /**
  22570. * Creates a new RemapBlock
  22571. * @param name defines the block name
  22572. */
  22573. constructor(name: string);
  22574. /**
  22575. * Gets the current class name
  22576. * @returns the class name
  22577. */
  22578. getClassName(): string;
  22579. /**
  22580. * Gets the input component
  22581. */
  22582. get input(): NodeMaterialConnectionPoint;
  22583. /**
  22584. * Gets the source min input component
  22585. */
  22586. get sourceMin(): NodeMaterialConnectionPoint;
  22587. /**
  22588. * Gets the source max input component
  22589. */
  22590. get sourceMax(): NodeMaterialConnectionPoint;
  22591. /**
  22592. * Gets the target min input component
  22593. */
  22594. get targetMin(): NodeMaterialConnectionPoint;
  22595. /**
  22596. * Gets the target max input component
  22597. */
  22598. get targetMax(): NodeMaterialConnectionPoint;
  22599. /**
  22600. * Gets the output component
  22601. */
  22602. get output(): NodeMaterialConnectionPoint;
  22603. protected _buildBlock(state: NodeMaterialBuildState): this;
  22604. protected _dumpPropertiesCode(): string;
  22605. serialize(): any;
  22606. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22607. }
  22608. }
  22609. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22610. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22611. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22612. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22613. /**
  22614. * Block used to multiply 2 values
  22615. */
  22616. export class MultiplyBlock extends NodeMaterialBlock {
  22617. /**
  22618. * Creates a new MultiplyBlock
  22619. * @param name defines the block name
  22620. */
  22621. constructor(name: string);
  22622. /**
  22623. * Gets the current class name
  22624. * @returns the class name
  22625. */
  22626. getClassName(): string;
  22627. /**
  22628. * Gets the left operand input component
  22629. */
  22630. get left(): NodeMaterialConnectionPoint;
  22631. /**
  22632. * Gets the right operand input component
  22633. */
  22634. get right(): NodeMaterialConnectionPoint;
  22635. /**
  22636. * Gets the output component
  22637. */
  22638. get output(): NodeMaterialConnectionPoint;
  22639. protected _buildBlock(state: NodeMaterialBuildState): this;
  22640. }
  22641. }
  22642. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22646. /**
  22647. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22648. */
  22649. export class ColorSplitterBlock extends NodeMaterialBlock {
  22650. /**
  22651. * Create a new ColorSplitterBlock
  22652. * @param name defines the block name
  22653. */
  22654. constructor(name: string);
  22655. /**
  22656. * Gets the current class name
  22657. * @returns the class name
  22658. */
  22659. getClassName(): string;
  22660. /**
  22661. * Gets the rgba component (input)
  22662. */
  22663. get rgba(): NodeMaterialConnectionPoint;
  22664. /**
  22665. * Gets the rgb component (input)
  22666. */
  22667. get rgbIn(): NodeMaterialConnectionPoint;
  22668. /**
  22669. * Gets the rgb component (output)
  22670. */
  22671. get rgbOut(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the r component (output)
  22674. */
  22675. get r(): NodeMaterialConnectionPoint;
  22676. /**
  22677. * Gets the g component (output)
  22678. */
  22679. get g(): NodeMaterialConnectionPoint;
  22680. /**
  22681. * Gets the b component (output)
  22682. */
  22683. get b(): NodeMaterialConnectionPoint;
  22684. /**
  22685. * Gets the a component (output)
  22686. */
  22687. get a(): NodeMaterialConnectionPoint;
  22688. protected _inputRename(name: string): string;
  22689. protected _outputRename(name: string): string;
  22690. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22691. }
  22692. }
  22693. declare module "babylonjs/Materials/Node/nodeMaterial" {
  22694. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22695. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  22696. import { Scene } from "babylonjs/scene";
  22697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22698. import { Matrix } from "babylonjs/Maths/math.vector";
  22699. import { Mesh } from "babylonjs/Meshes/mesh";
  22700. import { Engine } from "babylonjs/Engines/engine";
  22701. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22702. import { Observable } from "babylonjs/Misc/observable";
  22703. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22704. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22705. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  22706. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  22707. import { Nullable } from "babylonjs/types";
  22708. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22709. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22710. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22711. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22712. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22713. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22714. import { Effect } from "babylonjs/Materials/effect";
  22715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  22716. import { Camera } from "babylonjs/Cameras/camera";
  22717. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  22718. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  22719. /**
  22720. * Interface used to configure the node material editor
  22721. */
  22722. export interface INodeMaterialEditorOptions {
  22723. /** Define the URl to load node editor script */
  22724. editorURL?: string;
  22725. }
  22726. /** @hidden */
  22727. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22728. NORMAL: boolean;
  22729. TANGENT: boolean;
  22730. UV1: boolean;
  22731. /** BONES */
  22732. NUM_BONE_INFLUENCERS: number;
  22733. BonesPerMesh: number;
  22734. BONETEXTURE: boolean;
  22735. /** MORPH TARGETS */
  22736. MORPHTARGETS: boolean;
  22737. MORPHTARGETS_NORMAL: boolean;
  22738. MORPHTARGETS_TANGENT: boolean;
  22739. MORPHTARGETS_UV: boolean;
  22740. NUM_MORPH_INFLUENCERS: number;
  22741. /** IMAGE PROCESSING */
  22742. IMAGEPROCESSING: boolean;
  22743. VIGNETTE: boolean;
  22744. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22745. VIGNETTEBLENDMODEOPAQUE: boolean;
  22746. TONEMAPPING: boolean;
  22747. TONEMAPPING_ACES: boolean;
  22748. CONTRAST: boolean;
  22749. EXPOSURE: boolean;
  22750. COLORCURVES: boolean;
  22751. COLORGRADING: boolean;
  22752. COLORGRADING3D: boolean;
  22753. SAMPLER3DGREENDEPTH: boolean;
  22754. SAMPLER3DBGRMAP: boolean;
  22755. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22756. /** MISC. */
  22757. BUMPDIRECTUV: number;
  22758. constructor();
  22759. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22760. }
  22761. /**
  22762. * Class used to configure NodeMaterial
  22763. */
  22764. export interface INodeMaterialOptions {
  22765. /**
  22766. * Defines if blocks should emit comments
  22767. */
  22768. emitComments: boolean;
  22769. }
  22770. /**
  22771. * Class used to create a node based material built by assembling shader blocks
  22772. */
  22773. export class NodeMaterial extends PushMaterial {
  22774. private static _BuildIdGenerator;
  22775. private _options;
  22776. private _vertexCompilationState;
  22777. private _fragmentCompilationState;
  22778. private _sharedData;
  22779. private _buildId;
  22780. private _buildWasSuccessful;
  22781. private _cachedWorldViewMatrix;
  22782. private _cachedWorldViewProjectionMatrix;
  22783. private _optimizers;
  22784. private _animationFrame;
  22785. /** Define the Url to load node editor script */
  22786. static EditorURL: string;
  22787. /** Define the Url to load snippets */
  22788. static SnippetUrl: string;
  22789. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22790. static IgnoreTexturesAtLoadTime: boolean;
  22791. private BJSNODEMATERIALEDITOR;
  22792. /** Get the inspector from bundle or global */
  22793. private _getGlobalNodeMaterialEditor;
  22794. /**
  22795. * Snippet ID if the material was created from the snippet server
  22796. */
  22797. snippetId: string;
  22798. /**
  22799. * Gets or sets data used by visual editor
  22800. * @see https://nme.babylonjs.com
  22801. */
  22802. editorData: any;
  22803. /**
  22804. * 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)
  22805. */
  22806. ignoreAlpha: boolean;
  22807. /**
  22808. * Defines the maximum number of lights that can be used in the material
  22809. */
  22810. maxSimultaneousLights: number;
  22811. /**
  22812. * Observable raised when the material is built
  22813. */
  22814. onBuildObservable: Observable<NodeMaterial>;
  22815. /**
  22816. * Gets or sets the root nodes of the material vertex shader
  22817. */
  22818. _vertexOutputNodes: NodeMaterialBlock[];
  22819. /**
  22820. * Gets or sets the root nodes of the material fragment (pixel) shader
  22821. */
  22822. _fragmentOutputNodes: NodeMaterialBlock[];
  22823. /** Gets or sets options to control the node material overall behavior */
  22824. get options(): INodeMaterialOptions;
  22825. set options(options: INodeMaterialOptions);
  22826. /**
  22827. * Default configuration related to image processing available in the standard Material.
  22828. */
  22829. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22830. /**
  22831. * Gets the image processing configuration used either in this material.
  22832. */
  22833. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22834. /**
  22835. * Sets the Default image processing configuration used either in the this material.
  22836. *
  22837. * If sets to null, the scene one is in use.
  22838. */
  22839. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22840. /**
  22841. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22842. */
  22843. attachedBlocks: NodeMaterialBlock[];
  22844. /**
  22845. * Specifies the mode of the node material
  22846. * @hidden
  22847. */
  22848. _mode: NodeMaterialModes;
  22849. /**
  22850. * Gets the mode property
  22851. */
  22852. get mode(): NodeMaterialModes;
  22853. /**
  22854. * Create a new node based material
  22855. * @param name defines the material name
  22856. * @param scene defines the hosting scene
  22857. * @param options defines creation option
  22858. */
  22859. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22860. /**
  22861. * Gets the current class name of the material e.g. "NodeMaterial"
  22862. * @returns the class name
  22863. */
  22864. getClassName(): string;
  22865. /**
  22866. * Keep track of the image processing observer to allow dispose and replace.
  22867. */
  22868. private _imageProcessingObserver;
  22869. /**
  22870. * Attaches a new image processing configuration to the Standard Material.
  22871. * @param configuration
  22872. */
  22873. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22874. /**
  22875. * Get a block by its name
  22876. * @param name defines the name of the block to retrieve
  22877. * @returns the required block or null if not found
  22878. */
  22879. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22880. /**
  22881. * Get a block by its name
  22882. * @param predicate defines the predicate used to find the good candidate
  22883. * @returns the required block or null if not found
  22884. */
  22885. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22886. /**
  22887. * Get an input block by its name
  22888. * @param predicate defines the predicate used to find the good candidate
  22889. * @returns the required input block or null if not found
  22890. */
  22891. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22892. /**
  22893. * Gets the list of input blocks attached to this material
  22894. * @returns an array of InputBlocks
  22895. */
  22896. getInputBlocks(): InputBlock[];
  22897. /**
  22898. * Adds a new optimizer to the list of optimizers
  22899. * @param optimizer defines the optimizers to add
  22900. * @returns the current material
  22901. */
  22902. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22903. /**
  22904. * Remove an optimizer from the list of optimizers
  22905. * @param optimizer defines the optimizers to remove
  22906. * @returns the current material
  22907. */
  22908. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22909. /**
  22910. * Add a new block to the list of output nodes
  22911. * @param node defines the node to add
  22912. * @returns the current material
  22913. */
  22914. addOutputNode(node: NodeMaterialBlock): this;
  22915. /**
  22916. * Remove a block from the list of root nodes
  22917. * @param node defines the node to remove
  22918. * @returns the current material
  22919. */
  22920. removeOutputNode(node: NodeMaterialBlock): this;
  22921. private _addVertexOutputNode;
  22922. private _removeVertexOutputNode;
  22923. private _addFragmentOutputNode;
  22924. private _removeFragmentOutputNode;
  22925. /**
  22926. * Specifies if the material will require alpha blending
  22927. * @returns a boolean specifying if alpha blending is needed
  22928. */
  22929. needAlphaBlending(): boolean;
  22930. /**
  22931. * Specifies if this material should be rendered in alpha test mode
  22932. * @returns a boolean specifying if an alpha test is needed.
  22933. */
  22934. needAlphaTesting(): boolean;
  22935. private _initializeBlock;
  22936. private _resetDualBlocks;
  22937. /**
  22938. * Remove a block from the current node material
  22939. * @param block defines the block to remove
  22940. */
  22941. removeBlock(block: NodeMaterialBlock): void;
  22942. /**
  22943. * Build the material and generates the inner effect
  22944. * @param verbose defines if the build should log activity
  22945. */
  22946. build(verbose?: boolean): void;
  22947. /**
  22948. * Runs an otpimization phase to try to improve the shader code
  22949. */
  22950. optimize(): void;
  22951. private _prepareDefinesForAttributes;
  22952. /**
  22953. * Create a post process from the material
  22954. * @param camera The camera to apply the render pass to.
  22955. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22956. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22957. * @param engine The engine which the post process will be applied. (default: current engine)
  22958. * @param reusable If the post process can be reused on the same frame. (default: false)
  22959. * @param textureType Type of textures used when performing the post process. (default: 0)
  22960. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22961. * @returns the post process created
  22962. */
  22963. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  22964. /**
  22965. * Create the post process effect from the material
  22966. * @param postProcess The post process to create the effect for
  22967. */
  22968. createEffectForPostProcess(postProcess: PostProcess): void;
  22969. private _createEffectOrPostProcess;
  22970. private _createEffectForParticles;
  22971. /**
  22972. * Create the effect to be used as the custom effect for a particle system
  22973. * @param particleSystem Particle system to create the effect for
  22974. * @param onCompiled defines a function to call when the effect creation is successful
  22975. * @param onError defines a function to call when the effect creation has failed
  22976. */
  22977. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22978. private _processDefines;
  22979. /**
  22980. * Get if the submesh is ready to be used and all its information available.
  22981. * Child classes can use it to update shaders
  22982. * @param mesh defines the mesh to check
  22983. * @param subMesh defines which submesh to check
  22984. * @param useInstances specifies that instances should be used
  22985. * @returns a boolean indicating that the submesh is ready or not
  22986. */
  22987. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22988. /**
  22989. * Get a string representing the shaders built by the current node graph
  22990. */
  22991. get compiledShaders(): string;
  22992. /**
  22993. * Binds the world matrix to the material
  22994. * @param world defines the world transformation matrix
  22995. */
  22996. bindOnlyWorldMatrix(world: Matrix): void;
  22997. /**
  22998. * Binds the submesh to this material by preparing the effect and shader to draw
  22999. * @param world defines the world transformation matrix
  23000. * @param mesh defines the mesh containing the submesh
  23001. * @param subMesh defines the submesh to bind the material to
  23002. */
  23003. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23004. /**
  23005. * Gets the active textures from the material
  23006. * @returns an array of textures
  23007. */
  23008. getActiveTextures(): BaseTexture[];
  23009. /**
  23010. * Gets the list of texture blocks
  23011. * @returns an array of texture blocks
  23012. */
  23013. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23014. /**
  23015. * Specifies if the material uses a texture
  23016. * @param texture defines the texture to check against the material
  23017. * @returns a boolean specifying if the material uses the texture
  23018. */
  23019. hasTexture(texture: BaseTexture): boolean;
  23020. /**
  23021. * Disposes the material
  23022. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23023. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23024. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23025. */
  23026. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23027. /** Creates the node editor window. */
  23028. private _createNodeEditor;
  23029. /**
  23030. * Launch the node material editor
  23031. * @param config Define the configuration of the editor
  23032. * @return a promise fulfilled when the node editor is visible
  23033. */
  23034. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23035. /**
  23036. * Clear the current material
  23037. */
  23038. clear(): void;
  23039. /**
  23040. * Clear the current material and set it to a default state
  23041. */
  23042. setToDefault(): void;
  23043. /**
  23044. * Clear the current material and set it to a default state for post process
  23045. */
  23046. setToDefaultPostProcess(): void;
  23047. /**
  23048. * Clear the current material and set it to a default state for particle
  23049. */
  23050. setToDefaultParticle(): void;
  23051. /**
  23052. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23053. * @param url defines the url to load from
  23054. * @returns a promise that will fullfil when the material is fully loaded
  23055. */
  23056. loadAsync(url: string): Promise<void>;
  23057. private _gatherBlocks;
  23058. /**
  23059. * Generate a string containing the code declaration required to create an equivalent of this material
  23060. * @returns a string
  23061. */
  23062. generateCode(): string;
  23063. /**
  23064. * Serializes this material in a JSON representation
  23065. * @returns the serialized material object
  23066. */
  23067. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23068. private _restoreConnections;
  23069. /**
  23070. * Clear the current graph and load a new one from a serialization object
  23071. * @param source defines the JSON representation of the material
  23072. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23073. * @param merge defines whether or not the source must be merged or replace the current content
  23074. */
  23075. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23076. /**
  23077. * Makes a duplicate of the current material.
  23078. * @param name - name to use for the new material.
  23079. */
  23080. clone(name: string): NodeMaterial;
  23081. /**
  23082. * Creates a node material from parsed material data
  23083. * @param source defines the JSON representation of the material
  23084. * @param scene defines the hosting scene
  23085. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23086. * @returns a new node material
  23087. */
  23088. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23089. /**
  23090. * Creates a node material from a snippet saved in a remote file
  23091. * @param name defines the name of the material to create
  23092. * @param url defines the url to load from
  23093. * @param scene defines the hosting scene
  23094. * @returns a promise that will resolve to the new node material
  23095. */
  23096. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23097. /**
  23098. * Creates a node material from a snippet saved by the node material editor
  23099. * @param snippetId defines the snippet to load
  23100. * @param scene defines the hosting scene
  23101. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23102. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23103. * @returns a promise that will resolve to the new node material
  23104. */
  23105. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23106. /**
  23107. * Creates a new node material set to default basic configuration
  23108. * @param name defines the name of the material
  23109. * @param scene defines the hosting scene
  23110. * @returns a new NodeMaterial
  23111. */
  23112. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23113. }
  23114. }
  23115. declare module "babylonjs/PostProcesses/postProcess" {
  23116. import { Nullable } from "babylonjs/types";
  23117. import { SmartArray } from "babylonjs/Misc/smartArray";
  23118. import { Observable } from "babylonjs/Misc/observable";
  23119. import { Vector2 } from "babylonjs/Maths/math.vector";
  23120. import { Camera } from "babylonjs/Cameras/camera";
  23121. import { Effect } from "babylonjs/Materials/effect";
  23122. import "babylonjs/Shaders/postprocess.vertex";
  23123. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23124. import { Engine } from "babylonjs/Engines/engine";
  23125. import { Color4 } from "babylonjs/Maths/math.color";
  23126. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23127. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23128. import { Scene } from "babylonjs/scene";
  23129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23130. /**
  23131. * Size options for a post process
  23132. */
  23133. export type PostProcessOptions = {
  23134. width: number;
  23135. height: number;
  23136. };
  23137. /**
  23138. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23139. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23140. */
  23141. export class PostProcess {
  23142. /** Name of the PostProcess. */
  23143. name: string;
  23144. /**
  23145. * Gets or sets the unique id of the post process
  23146. */
  23147. uniqueId: number;
  23148. /**
  23149. * Width of the texture to apply the post process on
  23150. */
  23151. width: number;
  23152. /**
  23153. * Height of the texture to apply the post process on
  23154. */
  23155. height: number;
  23156. /**
  23157. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23158. */
  23159. nodeMaterialSource: Nullable<NodeMaterial>;
  23160. /**
  23161. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23162. * @hidden
  23163. */
  23164. _outputTexture: Nullable<InternalTexture>;
  23165. /**
  23166. * Sampling mode used by the shader
  23167. * See https://doc.babylonjs.com/classes/3.1/texture
  23168. */
  23169. renderTargetSamplingMode: number;
  23170. /**
  23171. * Clear color to use when screen clearing
  23172. */
  23173. clearColor: Color4;
  23174. /**
  23175. * If the buffer needs to be cleared before applying the post process. (default: true)
  23176. * Should be set to false if shader will overwrite all previous pixels.
  23177. */
  23178. autoClear: boolean;
  23179. /**
  23180. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23181. */
  23182. alphaMode: number;
  23183. /**
  23184. * Sets the setAlphaBlendConstants of the babylon engine
  23185. */
  23186. alphaConstants: Color4;
  23187. /**
  23188. * Animations to be used for the post processing
  23189. */
  23190. animations: import("babylonjs/Animations/animation").Animation[];
  23191. /**
  23192. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23193. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23194. */
  23195. enablePixelPerfectMode: boolean;
  23196. /**
  23197. * Force the postprocess to be applied without taking in account viewport
  23198. */
  23199. forceFullscreenViewport: boolean;
  23200. /**
  23201. * List of inspectable custom properties (used by the Inspector)
  23202. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23203. */
  23204. inspectableCustomProperties: IInspectable[];
  23205. /**
  23206. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23207. *
  23208. * | Value | Type | Description |
  23209. * | ----- | ----------------------------------- | ----------- |
  23210. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23211. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23212. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23213. *
  23214. */
  23215. scaleMode: number;
  23216. /**
  23217. * Force textures to be a power of two (default: false)
  23218. */
  23219. alwaysForcePOT: boolean;
  23220. private _samples;
  23221. /**
  23222. * Number of sample textures (default: 1)
  23223. */
  23224. get samples(): number;
  23225. set samples(n: number);
  23226. /**
  23227. * Modify the scale of the post process to be the same as the viewport (default: false)
  23228. */
  23229. adaptScaleToCurrentViewport: boolean;
  23230. private _camera;
  23231. protected _scene: Scene;
  23232. private _engine;
  23233. private _options;
  23234. private _reusable;
  23235. private _textureType;
  23236. private _textureFormat;
  23237. /**
  23238. * Smart array of input and output textures for the post process.
  23239. * @hidden
  23240. */
  23241. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23242. /**
  23243. * The index in _textures that corresponds to the output texture.
  23244. * @hidden
  23245. */
  23246. _currentRenderTextureInd: number;
  23247. private _effect;
  23248. private _samplers;
  23249. private _fragmentUrl;
  23250. private _vertexUrl;
  23251. private _parameters;
  23252. private _scaleRatio;
  23253. protected _indexParameters: any;
  23254. private _shareOutputWithPostProcess;
  23255. private _texelSize;
  23256. private _forcedOutputTexture;
  23257. /**
  23258. * Returns the fragment url or shader name used in the post process.
  23259. * @returns the fragment url or name in the shader store.
  23260. */
  23261. getEffectName(): string;
  23262. /**
  23263. * An event triggered when the postprocess is activated.
  23264. */
  23265. onActivateObservable: Observable<Camera>;
  23266. private _onActivateObserver;
  23267. /**
  23268. * A function that is added to the onActivateObservable
  23269. */
  23270. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23271. /**
  23272. * An event triggered when the postprocess changes its size.
  23273. */
  23274. onSizeChangedObservable: Observable<PostProcess>;
  23275. private _onSizeChangedObserver;
  23276. /**
  23277. * A function that is added to the onSizeChangedObservable
  23278. */
  23279. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23280. /**
  23281. * An event triggered when the postprocess applies its effect.
  23282. */
  23283. onApplyObservable: Observable<Effect>;
  23284. private _onApplyObserver;
  23285. /**
  23286. * A function that is added to the onApplyObservable
  23287. */
  23288. set onApply(callback: (effect: Effect) => void);
  23289. /**
  23290. * An event triggered before rendering the postprocess
  23291. */
  23292. onBeforeRenderObservable: Observable<Effect>;
  23293. private _onBeforeRenderObserver;
  23294. /**
  23295. * A function that is added to the onBeforeRenderObservable
  23296. */
  23297. set onBeforeRender(callback: (effect: Effect) => void);
  23298. /**
  23299. * An event triggered after rendering the postprocess
  23300. */
  23301. onAfterRenderObservable: Observable<Effect>;
  23302. private _onAfterRenderObserver;
  23303. /**
  23304. * A function that is added to the onAfterRenderObservable
  23305. */
  23306. set onAfterRender(callback: (efect: Effect) => void);
  23307. /**
  23308. * 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
  23309. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23310. */
  23311. get inputTexture(): InternalTexture;
  23312. set inputTexture(value: InternalTexture);
  23313. /**
  23314. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23315. * the only way to unset it is to use this function to restore its internal state
  23316. */
  23317. restoreDefaultInputTexture(): void;
  23318. /**
  23319. * Gets the camera which post process is applied to.
  23320. * @returns The camera the post process is applied to.
  23321. */
  23322. getCamera(): Camera;
  23323. /**
  23324. * Gets the texel size of the postprocess.
  23325. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23326. */
  23327. get texelSize(): Vector2;
  23328. /**
  23329. * Creates a new instance PostProcess
  23330. * @param name The name of the PostProcess.
  23331. * @param fragmentUrl The url of the fragment shader to be used.
  23332. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23333. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23334. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23335. * @param camera The camera to apply the render pass to.
  23336. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23337. * @param engine The engine which the post process will be applied. (default: current engine)
  23338. * @param reusable If the post process can be reused on the same frame. (default: false)
  23339. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23340. * @param textureType Type of textures used when performing the post process. (default: 0)
  23341. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23342. * @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
  23343. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  23344. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23345. */
  23346. constructor(
  23347. /** Name of the PostProcess. */
  23348. 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);
  23349. /**
  23350. * Gets a string idenfifying the name of the class
  23351. * @returns "PostProcess" string
  23352. */
  23353. getClassName(): string;
  23354. /**
  23355. * Gets the engine which this post process belongs to.
  23356. * @returns The engine the post process was enabled with.
  23357. */
  23358. getEngine(): Engine;
  23359. /**
  23360. * The effect that is created when initializing the post process.
  23361. * @returns The created effect corresponding the the postprocess.
  23362. */
  23363. getEffect(): Effect;
  23364. /**
  23365. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23366. * @param postProcess The post process to share the output with.
  23367. * @returns This post process.
  23368. */
  23369. shareOutputWith(postProcess: PostProcess): PostProcess;
  23370. /**
  23371. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23372. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23373. */
  23374. useOwnOutput(): void;
  23375. /**
  23376. * Updates the effect with the current post process compile time values and recompiles the shader.
  23377. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23378. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23379. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23380. * @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
  23381. * @param onCompiled Called when the shader has been compiled.
  23382. * @param onError Called if there is an error when compiling a shader.
  23383. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23384. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23385. */
  23386. 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;
  23387. /**
  23388. * The post process is reusable if it can be used multiple times within one frame.
  23389. * @returns If the post process is reusable
  23390. */
  23391. isReusable(): boolean;
  23392. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23393. markTextureDirty(): void;
  23394. /**
  23395. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23396. * 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.
  23397. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23398. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23399. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23400. * @returns The target texture that was bound to be written to.
  23401. */
  23402. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23403. /**
  23404. * If the post process is supported.
  23405. */
  23406. get isSupported(): boolean;
  23407. /**
  23408. * The aspect ratio of the output texture.
  23409. */
  23410. get aspectRatio(): number;
  23411. /**
  23412. * Get a value indicating if the post-process is ready to be used
  23413. * @returns true if the post-process is ready (shader is compiled)
  23414. */
  23415. isReady(): boolean;
  23416. /**
  23417. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23418. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23419. */
  23420. apply(): Nullable<Effect>;
  23421. private _disposeTextures;
  23422. /**
  23423. * Disposes the post process.
  23424. * @param camera The camera to dispose the post process on.
  23425. */
  23426. dispose(camera?: Camera): void;
  23427. }
  23428. }
  23429. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23430. /** @hidden */
  23431. export var kernelBlurVaryingDeclaration: {
  23432. name: string;
  23433. shader: string;
  23434. };
  23435. }
  23436. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23437. /** @hidden */
  23438. export var kernelBlurFragment: {
  23439. name: string;
  23440. shader: string;
  23441. };
  23442. }
  23443. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23444. /** @hidden */
  23445. export var kernelBlurFragment2: {
  23446. name: string;
  23447. shader: string;
  23448. };
  23449. }
  23450. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23451. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23452. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23453. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23454. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23455. /** @hidden */
  23456. export var kernelBlurPixelShader: {
  23457. name: string;
  23458. shader: string;
  23459. };
  23460. }
  23461. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23462. /** @hidden */
  23463. export var kernelBlurVertex: {
  23464. name: string;
  23465. shader: string;
  23466. };
  23467. }
  23468. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23469. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23470. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23471. /** @hidden */
  23472. export var kernelBlurVertexShader: {
  23473. name: string;
  23474. shader: string;
  23475. };
  23476. }
  23477. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23478. import { Vector2 } from "babylonjs/Maths/math.vector";
  23479. import { Nullable } from "babylonjs/types";
  23480. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23481. import { Camera } from "babylonjs/Cameras/camera";
  23482. import { Effect } from "babylonjs/Materials/effect";
  23483. import { Engine } from "babylonjs/Engines/engine";
  23484. import "babylonjs/Shaders/kernelBlur.fragment";
  23485. import "babylonjs/Shaders/kernelBlur.vertex";
  23486. /**
  23487. * The Blur Post Process which blurs an image based on a kernel and direction.
  23488. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23489. */
  23490. export class BlurPostProcess extends PostProcess {
  23491. /** The direction in which to blur the image. */
  23492. direction: Vector2;
  23493. private blockCompilation;
  23494. protected _kernel: number;
  23495. protected _idealKernel: number;
  23496. protected _packedFloat: boolean;
  23497. private _staticDefines;
  23498. /**
  23499. * Sets the length in pixels of the blur sample region
  23500. */
  23501. set kernel(v: number);
  23502. /**
  23503. * Gets the length in pixels of the blur sample region
  23504. */
  23505. get kernel(): number;
  23506. /**
  23507. * Sets wether or not the blur needs to unpack/repack floats
  23508. */
  23509. set packedFloat(v: boolean);
  23510. /**
  23511. * Gets wether or not the blur is unpacking/repacking floats
  23512. */
  23513. get packedFloat(): boolean;
  23514. /**
  23515. * Creates a new instance BlurPostProcess
  23516. * @param name The name of the effect.
  23517. * @param direction The direction in which to blur the image.
  23518. * @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.
  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 textureType Type of textures used when performing the post process. (default: 0)
  23525. * @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)
  23526. */
  23527. constructor(name: string,
  23528. /** The direction in which to blur the image. */
  23529. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23530. /**
  23531. * Updates the effect with the current post process compile time values and recompiles the shader.
  23532. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23533. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23534. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23535. * @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
  23536. * @param onCompiled Called when the shader has been compiled.
  23537. * @param onError Called if there is an error when compiling a shader.
  23538. */
  23539. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23540. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23541. /**
  23542. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  23543. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  23544. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  23545. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  23546. * The gaps between physical kernels are compensated for in the weighting of the samples
  23547. * @param idealKernel Ideal blur kernel.
  23548. * @return Nearest best kernel.
  23549. */
  23550. protected _nearestBestKernel(idealKernel: number): number;
  23551. /**
  23552. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  23553. * @param x The point on the Gaussian distribution to sample.
  23554. * @return the value of the Gaussian function at x.
  23555. */
  23556. protected _gaussianWeight(x: number): number;
  23557. /**
  23558. * Generates a string that can be used as a floating point number in GLSL.
  23559. * @param x Value to print.
  23560. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  23561. * @return GLSL float string.
  23562. */
  23563. protected _glslFloat(x: number, decimalFigures?: number): string;
  23564. }
  23565. }
  23566. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  23567. import { Scene } from "babylonjs/scene";
  23568. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23569. import { Plane } from "babylonjs/Maths/math.plane";
  23570. /**
  23571. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23572. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23573. * You can then easily use it as a reflectionTexture on a flat surface.
  23574. * In case the surface is not a plane, please consider relying on reflection probes.
  23575. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23576. */
  23577. export class MirrorTexture extends RenderTargetTexture {
  23578. private scene;
  23579. /**
  23580. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  23581. * 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.
  23582. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23583. */
  23584. mirrorPlane: Plane;
  23585. /**
  23586. * Define the blur ratio used to blur the reflection if needed.
  23587. */
  23588. set blurRatio(value: number);
  23589. get blurRatio(): number;
  23590. /**
  23591. * Define the adaptive blur kernel used to blur the reflection if needed.
  23592. * This will autocompute the closest best match for the `blurKernel`
  23593. */
  23594. set adaptiveBlurKernel(value: number);
  23595. /**
  23596. * Define the blur kernel used to blur the reflection if needed.
  23597. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23598. */
  23599. set blurKernel(value: number);
  23600. /**
  23601. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  23602. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23603. */
  23604. set blurKernelX(value: number);
  23605. get blurKernelX(): number;
  23606. /**
  23607. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  23608. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  23609. */
  23610. set blurKernelY(value: number);
  23611. get blurKernelY(): number;
  23612. private _autoComputeBlurKernel;
  23613. protected _onRatioRescale(): void;
  23614. private _updateGammaSpace;
  23615. private _imageProcessingConfigChangeObserver;
  23616. private _transformMatrix;
  23617. private _mirrorMatrix;
  23618. private _savedViewMatrix;
  23619. private _blurX;
  23620. private _blurY;
  23621. private _adaptiveBlurKernel;
  23622. private _blurKernelX;
  23623. private _blurKernelY;
  23624. private _blurRatio;
  23625. /**
  23626. * Instantiates a Mirror Texture.
  23627. * Mirror texture can be used to simulate the view from a mirror in a scene.
  23628. * It will dynamically be rendered every frame to adapt to the camera point of view.
  23629. * You can then easily use it as a reflectionTexture on a flat surface.
  23630. * In case the surface is not a plane, please consider relying on reflection probes.
  23631. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  23632. * @param name
  23633. * @param size
  23634. * @param scene
  23635. * @param generateMipMaps
  23636. * @param type
  23637. * @param samplingMode
  23638. * @param generateDepthBuffer
  23639. */
  23640. constructor(name: string, size: number | {
  23641. width: number;
  23642. height: number;
  23643. } | {
  23644. ratio: number;
  23645. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  23646. private _preparePostProcesses;
  23647. /**
  23648. * Clone the mirror texture.
  23649. * @returns the cloned texture
  23650. */
  23651. clone(): MirrorTexture;
  23652. /**
  23653. * Serialize the texture to a JSON representation you could use in Parse later on
  23654. * @returns the serialized JSON representation
  23655. */
  23656. serialize(): any;
  23657. /**
  23658. * Dispose the texture and release its associated resources.
  23659. */
  23660. dispose(): void;
  23661. }
  23662. }
  23663. declare module "babylonjs/Materials/Textures/texture" {
  23664. import { Observable } from "babylonjs/Misc/observable";
  23665. import { Nullable } from "babylonjs/types";
  23666. import { Matrix } from "babylonjs/Maths/math.vector";
  23667. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23668. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23669. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  23670. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  23671. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  23672. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23673. import { Scene } from "babylonjs/scene";
  23674. /**
  23675. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23676. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23677. */
  23678. export class Texture extends BaseTexture {
  23679. /**
  23680. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  23681. */
  23682. static SerializeBuffers: boolean;
  23683. /** @hidden */
  23684. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  23685. /** @hidden */
  23686. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  23687. /** @hidden */
  23688. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  23689. /** nearest is mag = nearest and min = nearest and mip = linear */
  23690. static readonly NEAREST_SAMPLINGMODE: number;
  23691. /** nearest is mag = nearest and min = nearest and mip = linear */
  23692. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  23693. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23694. static readonly BILINEAR_SAMPLINGMODE: number;
  23695. /** Bilinear is mag = linear and min = linear and mip = nearest */
  23696. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  23697. /** Trilinear is mag = linear and min = linear and mip = linear */
  23698. static readonly TRILINEAR_SAMPLINGMODE: number;
  23699. /** Trilinear is mag = linear and min = linear and mip = linear */
  23700. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  23701. /** mag = nearest and min = nearest and mip = nearest */
  23702. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  23703. /** mag = nearest and min = linear and mip = nearest */
  23704. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  23705. /** mag = nearest and min = linear and mip = linear */
  23706. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  23707. /** mag = nearest and min = linear and mip = none */
  23708. static readonly NEAREST_LINEAR: number;
  23709. /** mag = nearest and min = nearest and mip = none */
  23710. static readonly NEAREST_NEAREST: number;
  23711. /** mag = linear and min = nearest and mip = nearest */
  23712. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  23713. /** mag = linear and min = nearest and mip = linear */
  23714. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  23715. /** mag = linear and min = linear and mip = none */
  23716. static readonly LINEAR_LINEAR: number;
  23717. /** mag = linear and min = nearest and mip = none */
  23718. static readonly LINEAR_NEAREST: number;
  23719. /** Explicit coordinates mode */
  23720. static readonly EXPLICIT_MODE: number;
  23721. /** Spherical coordinates mode */
  23722. static readonly SPHERICAL_MODE: number;
  23723. /** Planar coordinates mode */
  23724. static readonly PLANAR_MODE: number;
  23725. /** Cubic coordinates mode */
  23726. static readonly CUBIC_MODE: number;
  23727. /** Projection coordinates mode */
  23728. static readonly PROJECTION_MODE: number;
  23729. /** Inverse Cubic coordinates mode */
  23730. static readonly SKYBOX_MODE: number;
  23731. /** Inverse Cubic coordinates mode */
  23732. static readonly INVCUBIC_MODE: number;
  23733. /** Equirectangular coordinates mode */
  23734. static readonly EQUIRECTANGULAR_MODE: number;
  23735. /** Equirectangular Fixed coordinates mode */
  23736. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  23737. /** Equirectangular Fixed Mirrored coordinates mode */
  23738. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  23739. /** Texture is not repeating outside of 0..1 UVs */
  23740. static readonly CLAMP_ADDRESSMODE: number;
  23741. /** Texture is repeating outside of 0..1 UVs */
  23742. static readonly WRAP_ADDRESSMODE: number;
  23743. /** Texture is repeating and mirrored */
  23744. static readonly MIRROR_ADDRESSMODE: number;
  23745. /**
  23746. * 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
  23747. */
  23748. static UseSerializedUrlIfAny: boolean;
  23749. /**
  23750. * Define the url of the texture.
  23751. */
  23752. url: Nullable<string>;
  23753. /**
  23754. * Define an offset on the texture to offset the u coordinates of the UVs
  23755. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23756. */
  23757. uOffset: number;
  23758. /**
  23759. * Define an offset on the texture to offset the v coordinates of the UVs
  23760. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  23761. */
  23762. vOffset: number;
  23763. /**
  23764. * Define an offset on the texture to scale the u coordinates of the UVs
  23765. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23766. */
  23767. uScale: number;
  23768. /**
  23769. * Define an offset on the texture to scale the v coordinates of the UVs
  23770. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  23771. */
  23772. vScale: number;
  23773. /**
  23774. * Define an offset on the texture to rotate around the u coordinates of the UVs
  23775. * @see https://doc.babylonjs.com/how_to/more_materials
  23776. */
  23777. uAng: number;
  23778. /**
  23779. * Define an offset on the texture to rotate around the v coordinates of the UVs
  23780. * @see https://doc.babylonjs.com/how_to/more_materials
  23781. */
  23782. vAng: number;
  23783. /**
  23784. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  23785. * @see https://doc.babylonjs.com/how_to/more_materials
  23786. */
  23787. wAng: number;
  23788. /**
  23789. * Defines the center of rotation (U)
  23790. */
  23791. uRotationCenter: number;
  23792. /**
  23793. * Defines the center of rotation (V)
  23794. */
  23795. vRotationCenter: number;
  23796. /**
  23797. * Defines the center of rotation (W)
  23798. */
  23799. wRotationCenter: number;
  23800. /**
  23801. * Are mip maps generated for this texture or not.
  23802. */
  23803. get noMipmap(): boolean;
  23804. /**
  23805. * List of inspectable custom properties (used by the Inspector)
  23806. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23807. */
  23808. inspectableCustomProperties: Nullable<IInspectable[]>;
  23809. private _noMipmap;
  23810. /** @hidden */
  23811. _invertY: boolean;
  23812. private _rowGenerationMatrix;
  23813. private _cachedTextureMatrix;
  23814. private _projectionModeMatrix;
  23815. private _t0;
  23816. private _t1;
  23817. private _t2;
  23818. private _cachedUOffset;
  23819. private _cachedVOffset;
  23820. private _cachedUScale;
  23821. private _cachedVScale;
  23822. private _cachedUAng;
  23823. private _cachedVAng;
  23824. private _cachedWAng;
  23825. private _cachedProjectionMatrixId;
  23826. private _cachedCoordinatesMode;
  23827. /** @hidden */
  23828. protected _initialSamplingMode: number;
  23829. /** @hidden */
  23830. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  23831. private _deleteBuffer;
  23832. protected _format: Nullable<number>;
  23833. private _delayedOnLoad;
  23834. private _delayedOnError;
  23835. private _mimeType?;
  23836. /**
  23837. * Observable triggered once the texture has been loaded.
  23838. */
  23839. onLoadObservable: Observable<Texture>;
  23840. protected _isBlocking: boolean;
  23841. /**
  23842. * Is the texture preventing material to render while loading.
  23843. * If false, a default texture will be used instead of the loading one during the preparation step.
  23844. */
  23845. set isBlocking(value: boolean);
  23846. get isBlocking(): boolean;
  23847. /**
  23848. * Get the current sampling mode associated with the texture.
  23849. */
  23850. get samplingMode(): number;
  23851. /**
  23852. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  23853. */
  23854. get invertY(): boolean;
  23855. /**
  23856. * Instantiates a new texture.
  23857. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  23858. * @see https://doc.babylonjs.com/babylon101/materials#texture
  23859. * @param url defines the url of the picture to load as a texture
  23860. * @param sceneOrEngine defines the scene or engine the texture will belong to
  23861. * @param noMipmap defines if the texture will require mip maps or not
  23862. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  23863. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23864. * @param onLoad defines a callback triggered when the texture has been loaded
  23865. * @param onError defines a callback triggered when an error occurred during the loading session
  23866. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  23867. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  23868. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23869. * @param mimeType defines an optional mime type information
  23870. */
  23871. 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);
  23872. /**
  23873. * Update the url (and optional buffer) of this texture if url was null during construction.
  23874. * @param url the url of the texture
  23875. * @param buffer the buffer of the texture (defaults to null)
  23876. * @param onLoad callback called when the texture is loaded (defaults to null)
  23877. */
  23878. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  23879. /**
  23880. * Finish the loading sequence of a texture flagged as delayed load.
  23881. * @hidden
  23882. */
  23883. delayLoad(): void;
  23884. private _prepareRowForTextureGeneration;
  23885. /**
  23886. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  23887. * @returns the transform matrix of the texture.
  23888. */
  23889. getTextureMatrix(uBase?: number): Matrix;
  23890. /**
  23891. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  23892. * @returns The reflection texture transform
  23893. */
  23894. getReflectionTextureMatrix(): Matrix;
  23895. /**
  23896. * Clones the texture.
  23897. * @returns the cloned texture
  23898. */
  23899. clone(): Texture;
  23900. /**
  23901. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  23902. * @returns The JSON representation of the texture
  23903. */
  23904. serialize(): any;
  23905. /**
  23906. * Get the current class name of the texture useful for serialization or dynamic coding.
  23907. * @returns "Texture"
  23908. */
  23909. getClassName(): string;
  23910. /**
  23911. * Dispose the texture and release its associated resources.
  23912. */
  23913. dispose(): void;
  23914. /**
  23915. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  23916. * @param parsedTexture Define the JSON representation of the texture
  23917. * @param scene Define the scene the parsed texture should be instantiated in
  23918. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  23919. * @returns The parsed texture if successful
  23920. */
  23921. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  23922. /**
  23923. * Creates a texture from its base 64 representation.
  23924. * @param data Define the base64 payload without the data: prefix
  23925. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23926. * @param scene Define the scene the texture should belong to
  23927. * @param noMipmap Forces the texture to not create mip map information if true
  23928. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23929. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23930. * @param onLoad define a callback triggered when the texture has been loaded
  23931. * @param onError define a callback triggered when an error occurred during the loading session
  23932. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23933. * @returns the created texture
  23934. */
  23935. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  23936. /**
  23937. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  23938. * @param data Define the base64 payload without the data: prefix
  23939. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  23940. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  23941. * @param scene Define the scene the texture should belong to
  23942. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  23943. * @param noMipmap Forces the texture to not create mip map information if true
  23944. * @param invertY define if the texture needs to be inverted on the y axis during loading
  23945. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  23946. * @param onLoad define a callback triggered when the texture has been loaded
  23947. * @param onError define a callback triggered when an error occurred during the loading session
  23948. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  23949. * @returns the created texture
  23950. */
  23951. 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;
  23952. }
  23953. }
  23954. declare module "babylonjs/PostProcesses/postProcessManager" {
  23955. import { Nullable } from "babylonjs/types";
  23956. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  23958. import { Scene } from "babylonjs/scene";
  23959. /**
  23960. * PostProcessManager is used to manage one or more post processes or post process pipelines
  23961. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23962. */
  23963. export class PostProcessManager {
  23964. private _scene;
  23965. private _indexBuffer;
  23966. private _vertexBuffers;
  23967. /**
  23968. * Creates a new instance PostProcess
  23969. * @param scene The scene that the post process is associated with.
  23970. */
  23971. constructor(scene: Scene);
  23972. private _prepareBuffers;
  23973. private _buildIndexBuffer;
  23974. /**
  23975. * Rebuilds the vertex buffers of the manager.
  23976. * @hidden
  23977. */
  23978. _rebuild(): void;
  23979. /**
  23980. * Prepares a frame to be run through a post process.
  23981. * @param sourceTexture The input texture to the post procesess. (default: null)
  23982. * @param postProcesses An array of post processes to be run. (default: null)
  23983. * @returns True if the post processes were able to be run.
  23984. * @hidden
  23985. */
  23986. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  23987. /**
  23988. * Manually render a set of post processes to a texture.
  23989. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  23990. * @param postProcesses An array of post processes to be run.
  23991. * @param targetTexture The target texture to render to.
  23992. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  23993. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  23994. * @param lodLevel defines which lod of the texture to render to
  23995. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  23996. */
  23997. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  23998. /**
  23999. * Finalize the result of the output of the postprocesses.
  24000. * @param doNotPresent If true the result will not be displayed to the screen.
  24001. * @param targetTexture The target texture to render to.
  24002. * @param faceIndex The index of the face to bind the target texture to.
  24003. * @param postProcesses The array of post processes to render.
  24004. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24005. * @hidden
  24006. */
  24007. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24008. /**
  24009. * Disposes of the post process manager.
  24010. */
  24011. dispose(): void;
  24012. }
  24013. }
  24014. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24015. import { Observable } from "babylonjs/Misc/observable";
  24016. import { SmartArray } from "babylonjs/Misc/smartArray";
  24017. import { Nullable, Immutable } from "babylonjs/types";
  24018. import { Camera } from "babylonjs/Cameras/camera";
  24019. import { Scene } from "babylonjs/scene";
  24020. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24021. import { Color4 } from "babylonjs/Maths/math.color";
  24022. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24023. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24024. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24025. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24026. import { Texture } from "babylonjs/Materials/Textures/texture";
  24027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24028. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24029. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24030. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24031. import { Engine } from "babylonjs/Engines/engine";
  24032. /**
  24033. * This Helps creating a texture that will be created from a camera in your scene.
  24034. * It is basically a dynamic texture that could be used to create special effects for instance.
  24035. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24036. */
  24037. export class RenderTargetTexture extends Texture {
  24038. isCube: boolean;
  24039. /**
  24040. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24041. */
  24042. static readonly REFRESHRATE_RENDER_ONCE: number;
  24043. /**
  24044. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24045. */
  24046. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24047. /**
  24048. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24049. * the central point of your effect and can save a lot of performances.
  24050. */
  24051. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24052. /**
  24053. * Use this predicate to dynamically define the list of mesh you want to render.
  24054. * If set, the renderList property will be overwritten.
  24055. */
  24056. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24057. private _renderList;
  24058. /**
  24059. * Use this list to define the list of mesh you want to render.
  24060. */
  24061. get renderList(): Nullable<Array<AbstractMesh>>;
  24062. set renderList(value: Nullable<Array<AbstractMesh>>);
  24063. /**
  24064. * Use this function to overload the renderList array at rendering time.
  24065. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24066. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24067. * the cube (if the RTT is a cube, else layerOrFace=0).
  24068. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24069. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24070. * hold dummy elements!
  24071. */
  24072. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24073. private _hookArray;
  24074. /**
  24075. * Define if particles should be rendered in your texture.
  24076. */
  24077. renderParticles: boolean;
  24078. /**
  24079. * Define if sprites should be rendered in your texture.
  24080. */
  24081. renderSprites: boolean;
  24082. /**
  24083. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  24084. */
  24085. coordinatesMode: number;
  24086. /**
  24087. * Define the camera used to render the texture.
  24088. */
  24089. activeCamera: Nullable<Camera>;
  24090. /**
  24091. * Override the mesh isReady function with your own one.
  24092. */
  24093. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24094. /**
  24095. * Override the render function of the texture with your own one.
  24096. */
  24097. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24098. /**
  24099. * Define if camera post processes should be use while rendering the texture.
  24100. */
  24101. useCameraPostProcesses: boolean;
  24102. /**
  24103. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24104. */
  24105. ignoreCameraViewport: boolean;
  24106. private _postProcessManager;
  24107. private _postProcesses;
  24108. private _resizeObserver;
  24109. /**
  24110. * An event triggered when the texture is unbind.
  24111. */
  24112. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24113. /**
  24114. * An event triggered when the texture is unbind.
  24115. */
  24116. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24117. private _onAfterUnbindObserver;
  24118. /**
  24119. * Set a after unbind callback in the texture.
  24120. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24121. */
  24122. set onAfterUnbind(callback: () => void);
  24123. /**
  24124. * An event triggered before rendering the texture
  24125. */
  24126. onBeforeRenderObservable: Observable<number>;
  24127. private _onBeforeRenderObserver;
  24128. /**
  24129. * Set a before render callback in the texture.
  24130. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24131. */
  24132. set onBeforeRender(callback: (faceIndex: number) => void);
  24133. /**
  24134. * An event triggered after rendering the texture
  24135. */
  24136. onAfterRenderObservable: Observable<number>;
  24137. private _onAfterRenderObserver;
  24138. /**
  24139. * Set a after render callback in the texture.
  24140. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24141. */
  24142. set onAfterRender(callback: (faceIndex: number) => void);
  24143. /**
  24144. * An event triggered after the texture clear
  24145. */
  24146. onClearObservable: Observable<Engine>;
  24147. private _onClearObserver;
  24148. /**
  24149. * Set a clear callback in the texture.
  24150. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24151. */
  24152. set onClear(callback: (Engine: Engine) => void);
  24153. /**
  24154. * An event triggered when the texture is resized.
  24155. */
  24156. onResizeObservable: Observable<RenderTargetTexture>;
  24157. /**
  24158. * Define the clear color of the Render Target if it should be different from the scene.
  24159. */
  24160. clearColor: Color4;
  24161. protected _size: number | {
  24162. width: number;
  24163. height: number;
  24164. layers?: number;
  24165. };
  24166. protected _initialSizeParameter: number | {
  24167. width: number;
  24168. height: number;
  24169. } | {
  24170. ratio: number;
  24171. };
  24172. protected _sizeRatio: Nullable<number>;
  24173. /** @hidden */
  24174. _generateMipMaps: boolean;
  24175. protected _renderingManager: RenderingManager;
  24176. /** @hidden */
  24177. _waitingRenderList: string[];
  24178. protected _doNotChangeAspectRatio: boolean;
  24179. protected _currentRefreshId: number;
  24180. protected _refreshRate: number;
  24181. protected _textureMatrix: Matrix;
  24182. protected _samples: number;
  24183. protected _renderTargetOptions: RenderTargetCreationOptions;
  24184. /**
  24185. * Gets render target creation options that were used.
  24186. */
  24187. get renderTargetOptions(): RenderTargetCreationOptions;
  24188. protected _onRatioRescale(): void;
  24189. /**
  24190. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24191. * It must define where the camera used to render the texture is set
  24192. */
  24193. boundingBoxPosition: Vector3;
  24194. private _boundingBoxSize;
  24195. /**
  24196. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24197. * When defined, the cubemap will switch to local mode
  24198. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24199. * @example https://www.babylonjs-playground.com/#RNASML
  24200. */
  24201. set boundingBoxSize(value: Vector3);
  24202. get boundingBoxSize(): Vector3;
  24203. /**
  24204. * In case the RTT has been created with a depth texture, get the associated
  24205. * depth texture.
  24206. * Otherwise, return null.
  24207. */
  24208. get depthStencilTexture(): Nullable<InternalTexture>;
  24209. /**
  24210. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24211. * or used a shadow, depth texture...
  24212. * @param name The friendly name of the texture
  24213. * @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)
  24214. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24215. * @param generateMipMaps True if mip maps need to be generated after render.
  24216. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24217. * @param type The type of the buffer in the RTT (int, half float, float...)
  24218. * @param isCube True if a cube texture needs to be created
  24219. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24220. * @param generateDepthBuffer True to generate a depth buffer
  24221. * @param generateStencilBuffer True to generate a stencil buffer
  24222. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24223. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24224. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24225. */
  24226. constructor(name: string, size: number | {
  24227. width: number;
  24228. height: number;
  24229. layers?: number;
  24230. } | {
  24231. ratio: number;
  24232. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24233. /**
  24234. * Creates a depth stencil texture.
  24235. * This is only available in WebGL 2 or with the depth texture extension available.
  24236. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24237. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24238. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24239. */
  24240. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24241. private _processSizeParameter;
  24242. /**
  24243. * Define the number of samples to use in case of MSAA.
  24244. * It defaults to one meaning no MSAA has been enabled.
  24245. */
  24246. get samples(): number;
  24247. set samples(value: number);
  24248. /**
  24249. * Resets the refresh counter of the texture and start bak from scratch.
  24250. * Could be useful to regenerate the texture if it is setup to render only once.
  24251. */
  24252. resetRefreshCounter(): void;
  24253. /**
  24254. * Define the refresh rate of the texture or the rendering frequency.
  24255. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24256. */
  24257. get refreshRate(): number;
  24258. set refreshRate(value: number);
  24259. /**
  24260. * Adds a post process to the render target rendering passes.
  24261. * @param postProcess define the post process to add
  24262. */
  24263. addPostProcess(postProcess: PostProcess): void;
  24264. /**
  24265. * Clear all the post processes attached to the render target
  24266. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24267. */
  24268. clearPostProcesses(dispose?: boolean): void;
  24269. /**
  24270. * Remove one of the post process from the list of attached post processes to the texture
  24271. * @param postProcess define the post process to remove from the list
  24272. */
  24273. removePostProcess(postProcess: PostProcess): void;
  24274. /** @hidden */
  24275. _shouldRender(): boolean;
  24276. /**
  24277. * Gets the actual render size of the texture.
  24278. * @returns the width of the render size
  24279. */
  24280. getRenderSize(): number;
  24281. /**
  24282. * Gets the actual render width of the texture.
  24283. * @returns the width of the render size
  24284. */
  24285. getRenderWidth(): number;
  24286. /**
  24287. * Gets the actual render height of the texture.
  24288. * @returns the height of the render size
  24289. */
  24290. getRenderHeight(): number;
  24291. /**
  24292. * Gets the actual number of layers of the texture.
  24293. * @returns the number of layers
  24294. */
  24295. getRenderLayers(): number;
  24296. /**
  24297. * Get if the texture can be rescaled or not.
  24298. */
  24299. get canRescale(): boolean;
  24300. /**
  24301. * Resize the texture using a ratio.
  24302. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24303. */
  24304. scale(ratio: number): void;
  24305. /**
  24306. * Get the texture reflection matrix used to rotate/transform the reflection.
  24307. * @returns the reflection matrix
  24308. */
  24309. getReflectionTextureMatrix(): Matrix;
  24310. /**
  24311. * Resize the texture to a new desired size.
  24312. * Be carrefull as it will recreate all the data in the new texture.
  24313. * @param size Define the new size. It can be:
  24314. * - a number for squared texture,
  24315. * - an object containing { width: number, height: number }
  24316. * - or an object containing a ratio { ratio: number }
  24317. */
  24318. resize(size: number | {
  24319. width: number;
  24320. height: number;
  24321. } | {
  24322. ratio: number;
  24323. }): void;
  24324. private _defaultRenderListPrepared;
  24325. /**
  24326. * Renders all the objects from the render list into the texture.
  24327. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24328. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24329. */
  24330. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24331. private _bestReflectionRenderTargetDimension;
  24332. private _prepareRenderingManager;
  24333. /**
  24334. * @hidden
  24335. * @param faceIndex face index to bind to if this is a cubetexture
  24336. * @param layer defines the index of the texture to bind in the array
  24337. */
  24338. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24339. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24340. private renderToTarget;
  24341. /**
  24342. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24343. * This allowed control for front to back rendering or reversly depending of the special needs.
  24344. *
  24345. * @param renderingGroupId The rendering group id corresponding to its index
  24346. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24347. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24348. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24349. */
  24350. 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;
  24351. /**
  24352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24353. *
  24354. * @param renderingGroupId The rendering group id corresponding to its index
  24355. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24356. */
  24357. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24358. /**
  24359. * Clones the texture.
  24360. * @returns the cloned texture
  24361. */
  24362. clone(): RenderTargetTexture;
  24363. /**
  24364. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24365. * @returns The JSON representation of the texture
  24366. */
  24367. serialize(): any;
  24368. /**
  24369. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24370. */
  24371. disposeFramebufferObjects(): void;
  24372. /**
  24373. * Dispose the texture and release its associated resources.
  24374. */
  24375. dispose(): void;
  24376. /** @hidden */
  24377. _rebuild(): void;
  24378. /**
  24379. * Clear the info related to rendering groups preventing retention point in material dispose.
  24380. */
  24381. freeRenderingGroups(): void;
  24382. /**
  24383. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24384. * @returns the view count
  24385. */
  24386. getViewCount(): number;
  24387. }
  24388. }
  24389. declare module "babylonjs/Misc/guid" {
  24390. /**
  24391. * Class used to manipulate GUIDs
  24392. */
  24393. export class GUID {
  24394. /**
  24395. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24396. * Be aware Math.random() could cause collisions, but:
  24397. * "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"
  24398. * @returns a pseudo random id
  24399. */
  24400. static RandomId(): string;
  24401. }
  24402. }
  24403. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24404. import { Nullable } from "babylonjs/types";
  24405. import { Scene } from "babylonjs/scene";
  24406. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24407. import { Material } from "babylonjs/Materials/material";
  24408. import { Effect } from "babylonjs/Materials/effect";
  24409. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24410. /**
  24411. * Options to be used when creating a shadow depth material
  24412. */
  24413. export interface IIOptionShadowDepthMaterial {
  24414. /** Variables in the vertex shader code that need to have their names remapped.
  24415. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24416. * "var_name" should be either: worldPos or vNormalW
  24417. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24418. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24419. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24420. */
  24421. remappedVariables?: string[];
  24422. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24423. standalone?: boolean;
  24424. }
  24425. /**
  24426. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24427. */
  24428. export class ShadowDepthWrapper {
  24429. private _scene;
  24430. private _options?;
  24431. private _baseMaterial;
  24432. private _onEffectCreatedObserver;
  24433. private _subMeshToEffect;
  24434. private _subMeshToDepthEffect;
  24435. private _meshes;
  24436. /** @hidden */
  24437. _matriceNames: any;
  24438. /** Gets the standalone status of the wrapper */
  24439. get standalone(): boolean;
  24440. /** Gets the base material the wrapper is built upon */
  24441. get baseMaterial(): Material;
  24442. /**
  24443. * Instantiate a new shadow depth wrapper.
  24444. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24445. * generate the shadow depth map. For more information, please refer to the documentation:
  24446. * https://doc.babylonjs.com/babylon101/shadows
  24447. * @param baseMaterial Material to wrap
  24448. * @param scene Define the scene the material belongs to
  24449. * @param options Options used to create the wrapper
  24450. */
  24451. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24452. /**
  24453. * Gets the effect to use to generate the depth map
  24454. * @param subMesh subMesh to get the effect for
  24455. * @param shadowGenerator shadow generator to get the effect for
  24456. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24457. */
  24458. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24459. /**
  24460. * Specifies that the submesh is ready to be used for depth rendering
  24461. * @param subMesh submesh to check
  24462. * @param defines the list of defines to take into account when checking the effect
  24463. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24464. * @param useInstances specifies that instances should be used
  24465. * @returns a boolean indicating that the submesh is ready or not
  24466. */
  24467. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24468. /**
  24469. * Disposes the resources
  24470. */
  24471. dispose(): void;
  24472. private _makeEffect;
  24473. }
  24474. }
  24475. declare module "babylonjs/Materials/material" {
  24476. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24477. import { SmartArray } from "babylonjs/Misc/smartArray";
  24478. import { Observable } from "babylonjs/Misc/observable";
  24479. import { Nullable } from "babylonjs/types";
  24480. import { Scene } from "babylonjs/scene";
  24481. import { Matrix } from "babylonjs/Maths/math.vector";
  24482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24484. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  24485. import { Effect } from "babylonjs/Materials/effect";
  24486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24488. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  24489. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24490. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  24491. import { Mesh } from "babylonjs/Meshes/mesh";
  24492. import { Animation } from "babylonjs/Animations/animation";
  24493. /**
  24494. * Options for compiling materials.
  24495. */
  24496. export interface IMaterialCompilationOptions {
  24497. /**
  24498. * Defines whether clip planes are enabled.
  24499. */
  24500. clipPlane: boolean;
  24501. /**
  24502. * Defines whether instances are enabled.
  24503. */
  24504. useInstances: boolean;
  24505. }
  24506. /**
  24507. * Options passed when calling customShaderNameResolve
  24508. */
  24509. export interface ICustomShaderNameResolveOptions {
  24510. /**
  24511. * 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
  24512. */
  24513. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  24514. }
  24515. /**
  24516. * Base class for the main features of a material in Babylon.js
  24517. */
  24518. export class Material implements IAnimatable {
  24519. /**
  24520. * Returns the triangle fill mode
  24521. */
  24522. static readonly TriangleFillMode: number;
  24523. /**
  24524. * Returns the wireframe mode
  24525. */
  24526. static readonly WireFrameFillMode: number;
  24527. /**
  24528. * Returns the point fill mode
  24529. */
  24530. static readonly PointFillMode: number;
  24531. /**
  24532. * Returns the point list draw mode
  24533. */
  24534. static readonly PointListDrawMode: number;
  24535. /**
  24536. * Returns the line list draw mode
  24537. */
  24538. static readonly LineListDrawMode: number;
  24539. /**
  24540. * Returns the line loop draw mode
  24541. */
  24542. static readonly LineLoopDrawMode: number;
  24543. /**
  24544. * Returns the line strip draw mode
  24545. */
  24546. static readonly LineStripDrawMode: number;
  24547. /**
  24548. * Returns the triangle strip draw mode
  24549. */
  24550. static readonly TriangleStripDrawMode: number;
  24551. /**
  24552. * Returns the triangle fan draw mode
  24553. */
  24554. static readonly TriangleFanDrawMode: number;
  24555. /**
  24556. * Stores the clock-wise side orientation
  24557. */
  24558. static readonly ClockWiseSideOrientation: number;
  24559. /**
  24560. * Stores the counter clock-wise side orientation
  24561. */
  24562. static readonly CounterClockWiseSideOrientation: number;
  24563. /**
  24564. * The dirty texture flag value
  24565. */
  24566. static readonly TextureDirtyFlag: number;
  24567. /**
  24568. * The dirty light flag value
  24569. */
  24570. static readonly LightDirtyFlag: number;
  24571. /**
  24572. * The dirty fresnel flag value
  24573. */
  24574. static readonly FresnelDirtyFlag: number;
  24575. /**
  24576. * The dirty attribute flag value
  24577. */
  24578. static readonly AttributesDirtyFlag: number;
  24579. /**
  24580. * The dirty misc flag value
  24581. */
  24582. static readonly MiscDirtyFlag: number;
  24583. /**
  24584. * The all dirty flag value
  24585. */
  24586. static readonly AllDirtyFlag: number;
  24587. /**
  24588. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  24589. */
  24590. static readonly MATERIAL_OPAQUE: number;
  24591. /**
  24592. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  24593. */
  24594. static readonly MATERIAL_ALPHATEST: number;
  24595. /**
  24596. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24597. */
  24598. static readonly MATERIAL_ALPHABLEND: number;
  24599. /**
  24600. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  24601. * They are also discarded below the alpha cutoff threshold to improve performances.
  24602. */
  24603. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  24604. /**
  24605. * The Whiteout method is used to blend normals.
  24606. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24607. */
  24608. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  24609. /**
  24610. * The Reoriented Normal Mapping method is used to blend normals.
  24611. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  24612. */
  24613. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  24614. /**
  24615. * Custom callback helping to override the default shader used in the material.
  24616. */
  24617. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  24618. /**
  24619. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  24620. */
  24621. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  24622. /**
  24623. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  24624. * This means that the material can keep using a previous shader while a new one is being compiled.
  24625. * This is mostly used when shader parallel compilation is supported (true by default)
  24626. */
  24627. allowShaderHotSwapping: boolean;
  24628. /**
  24629. * The ID of the material
  24630. */
  24631. id: string;
  24632. /**
  24633. * Gets or sets the unique id of the material
  24634. */
  24635. uniqueId: number;
  24636. /**
  24637. * The name of the material
  24638. */
  24639. name: string;
  24640. /**
  24641. * Gets or sets user defined metadata
  24642. */
  24643. metadata: any;
  24644. /**
  24645. * For internal use only. Please do not use.
  24646. */
  24647. reservedDataStore: any;
  24648. /**
  24649. * Specifies if the ready state should be checked on each call
  24650. */
  24651. checkReadyOnEveryCall: boolean;
  24652. /**
  24653. * Specifies if the ready state should be checked once
  24654. */
  24655. checkReadyOnlyOnce: boolean;
  24656. /**
  24657. * The state of the material
  24658. */
  24659. state: string;
  24660. /**
  24661. * If the material should be rendered to several textures with MRT extension
  24662. */
  24663. get shouldRenderToMRT(): boolean;
  24664. /**
  24665. * The alpha value of the material
  24666. */
  24667. protected _alpha: number;
  24668. /**
  24669. * List of inspectable custom properties (used by the Inspector)
  24670. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24671. */
  24672. inspectableCustomProperties: IInspectable[];
  24673. /**
  24674. * Sets the alpha value of the material
  24675. */
  24676. set alpha(value: number);
  24677. /**
  24678. * Gets the alpha value of the material
  24679. */
  24680. get alpha(): number;
  24681. /**
  24682. * Specifies if back face culling is enabled
  24683. */
  24684. protected _backFaceCulling: boolean;
  24685. /**
  24686. * Sets the back-face culling state
  24687. */
  24688. set backFaceCulling(value: boolean);
  24689. /**
  24690. * Gets the back-face culling state
  24691. */
  24692. get backFaceCulling(): boolean;
  24693. /**
  24694. * Stores the value for side orientation
  24695. */
  24696. sideOrientation: number;
  24697. /**
  24698. * Callback triggered when the material is compiled
  24699. */
  24700. onCompiled: Nullable<(effect: Effect) => void>;
  24701. /**
  24702. * Callback triggered when an error occurs
  24703. */
  24704. onError: Nullable<(effect: Effect, errors: string) => void>;
  24705. /**
  24706. * Callback triggered to get the render target textures
  24707. */
  24708. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  24709. /**
  24710. * Gets a boolean indicating that current material needs to register RTT
  24711. */
  24712. get hasRenderTargetTextures(): boolean;
  24713. /**
  24714. * Specifies if the material should be serialized
  24715. */
  24716. doNotSerialize: boolean;
  24717. /**
  24718. * @hidden
  24719. */
  24720. _storeEffectOnSubMeshes: boolean;
  24721. /**
  24722. * Stores the animations for the material
  24723. */
  24724. animations: Nullable<Array<Animation>>;
  24725. /**
  24726. * An event triggered when the material is disposed
  24727. */
  24728. onDisposeObservable: Observable<Material>;
  24729. /**
  24730. * An observer which watches for dispose events
  24731. */
  24732. private _onDisposeObserver;
  24733. private _onUnBindObservable;
  24734. /**
  24735. * Called during a dispose event
  24736. */
  24737. set onDispose(callback: () => void);
  24738. private _onBindObservable;
  24739. /**
  24740. * An event triggered when the material is bound
  24741. */
  24742. get onBindObservable(): Observable<AbstractMesh>;
  24743. /**
  24744. * An observer which watches for bind events
  24745. */
  24746. private _onBindObserver;
  24747. /**
  24748. * Called during a bind event
  24749. */
  24750. set onBind(callback: (Mesh: AbstractMesh) => void);
  24751. /**
  24752. * An event triggered when the material is unbound
  24753. */
  24754. get onUnBindObservable(): Observable<Material>;
  24755. protected _onEffectCreatedObservable: Nullable<Observable<{
  24756. effect: Effect;
  24757. subMesh: Nullable<SubMesh>;
  24758. }>>;
  24759. /**
  24760. * An event triggered when the effect is (re)created
  24761. */
  24762. get onEffectCreatedObservable(): Observable<{
  24763. effect: Effect;
  24764. subMesh: Nullable<SubMesh>;
  24765. }>;
  24766. /**
  24767. * Stores the value of the alpha mode
  24768. */
  24769. private _alphaMode;
  24770. /**
  24771. * Sets the value of the alpha mode.
  24772. *
  24773. * | Value | Type | Description |
  24774. * | --- | --- | --- |
  24775. * | 0 | ALPHA_DISABLE | |
  24776. * | 1 | ALPHA_ADD | |
  24777. * | 2 | ALPHA_COMBINE | |
  24778. * | 3 | ALPHA_SUBTRACT | |
  24779. * | 4 | ALPHA_MULTIPLY | |
  24780. * | 5 | ALPHA_MAXIMIZED | |
  24781. * | 6 | ALPHA_ONEONE | |
  24782. * | 7 | ALPHA_PREMULTIPLIED | |
  24783. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  24784. * | 9 | ALPHA_INTERPOLATE | |
  24785. * | 10 | ALPHA_SCREENMODE | |
  24786. *
  24787. */
  24788. set alphaMode(value: number);
  24789. /**
  24790. * Gets the value of the alpha mode
  24791. */
  24792. get alphaMode(): number;
  24793. /**
  24794. * Stores the state of the need depth pre-pass value
  24795. */
  24796. private _needDepthPrePass;
  24797. /**
  24798. * Sets the need depth pre-pass value
  24799. */
  24800. set needDepthPrePass(value: boolean);
  24801. /**
  24802. * Gets the depth pre-pass value
  24803. */
  24804. get needDepthPrePass(): boolean;
  24805. /**
  24806. * Specifies if depth writing should be disabled
  24807. */
  24808. disableDepthWrite: boolean;
  24809. /**
  24810. * Specifies if color writing should be disabled
  24811. */
  24812. disableColorWrite: boolean;
  24813. /**
  24814. * Specifies if depth writing should be forced
  24815. */
  24816. forceDepthWrite: boolean;
  24817. /**
  24818. * Specifies the depth function that should be used. 0 means the default engine function
  24819. */
  24820. depthFunction: number;
  24821. /**
  24822. * Specifies if there should be a separate pass for culling
  24823. */
  24824. separateCullingPass: boolean;
  24825. /**
  24826. * Stores the state specifing if fog should be enabled
  24827. */
  24828. private _fogEnabled;
  24829. /**
  24830. * Sets the state for enabling fog
  24831. */
  24832. set fogEnabled(value: boolean);
  24833. /**
  24834. * Gets the value of the fog enabled state
  24835. */
  24836. get fogEnabled(): boolean;
  24837. /**
  24838. * Stores the size of points
  24839. */
  24840. pointSize: number;
  24841. /**
  24842. * Stores the z offset value
  24843. */
  24844. zOffset: number;
  24845. get wireframe(): boolean;
  24846. /**
  24847. * Sets the state of wireframe mode
  24848. */
  24849. set wireframe(value: boolean);
  24850. /**
  24851. * Gets the value specifying if point clouds are enabled
  24852. */
  24853. get pointsCloud(): boolean;
  24854. /**
  24855. * Sets the state of point cloud mode
  24856. */
  24857. set pointsCloud(value: boolean);
  24858. /**
  24859. * Gets the material fill mode
  24860. */
  24861. get fillMode(): number;
  24862. /**
  24863. * Sets the material fill mode
  24864. */
  24865. set fillMode(value: number);
  24866. /**
  24867. * @hidden
  24868. * Stores the effects for the material
  24869. */
  24870. _effect: Nullable<Effect>;
  24871. /**
  24872. * Specifies if uniform buffers should be used
  24873. */
  24874. private _useUBO;
  24875. /**
  24876. * Stores a reference to the scene
  24877. */
  24878. private _scene;
  24879. /**
  24880. * Stores the fill mode state
  24881. */
  24882. private _fillMode;
  24883. /**
  24884. * Specifies if the depth write state should be cached
  24885. */
  24886. private _cachedDepthWriteState;
  24887. /**
  24888. * Specifies if the color write state should be cached
  24889. */
  24890. private _cachedColorWriteState;
  24891. /**
  24892. * Specifies if the depth function state should be cached
  24893. */
  24894. private _cachedDepthFunctionState;
  24895. /**
  24896. * Stores the uniform buffer
  24897. */
  24898. protected _uniformBuffer: UniformBuffer;
  24899. /** @hidden */
  24900. _indexInSceneMaterialArray: number;
  24901. /** @hidden */
  24902. meshMap: Nullable<{
  24903. [id: string]: AbstractMesh | undefined;
  24904. }>;
  24905. /**
  24906. * Creates a material instance
  24907. * @param name defines the name of the material
  24908. * @param scene defines the scene to reference
  24909. * @param doNotAdd specifies if the material should be added to the scene
  24910. */
  24911. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  24912. /**
  24913. * Returns a string representation of the current material
  24914. * @param fullDetails defines a boolean indicating which levels of logging is desired
  24915. * @returns a string with material information
  24916. */
  24917. toString(fullDetails?: boolean): string;
  24918. /**
  24919. * Gets the class name of the material
  24920. * @returns a string with the class name of the material
  24921. */
  24922. getClassName(): string;
  24923. /**
  24924. * Specifies if updates for the material been locked
  24925. */
  24926. get isFrozen(): boolean;
  24927. /**
  24928. * Locks updates for the material
  24929. */
  24930. freeze(): void;
  24931. /**
  24932. * Unlocks updates for the material
  24933. */
  24934. unfreeze(): void;
  24935. /**
  24936. * Specifies if the material is ready to be used
  24937. * @param mesh defines the mesh to check
  24938. * @param useInstances specifies if instances should be used
  24939. * @returns a boolean indicating if the material is ready to be used
  24940. */
  24941. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  24942. /**
  24943. * Specifies that the submesh is ready to be used
  24944. * @param mesh defines the mesh to check
  24945. * @param subMesh defines which submesh to check
  24946. * @param useInstances specifies that instances should be used
  24947. * @returns a boolean indicating that the submesh is ready or not
  24948. */
  24949. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24950. /**
  24951. * Returns the material effect
  24952. * @returns the effect associated with the material
  24953. */
  24954. getEffect(): Nullable<Effect>;
  24955. /**
  24956. * Returns the current scene
  24957. * @returns a Scene
  24958. */
  24959. getScene(): Scene;
  24960. /**
  24961. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  24962. */
  24963. protected _forceAlphaTest: boolean;
  24964. /**
  24965. * The transparency mode of the material.
  24966. */
  24967. protected _transparencyMode: Nullable<number>;
  24968. /**
  24969. * Gets the current transparency mode.
  24970. */
  24971. get transparencyMode(): Nullable<number>;
  24972. /**
  24973. * Sets the transparency mode of the material.
  24974. *
  24975. * | Value | Type | Description |
  24976. * | ----- | ----------------------------------- | ----------- |
  24977. * | 0 | OPAQUE | |
  24978. * | 1 | ALPHATEST | |
  24979. * | 2 | ALPHABLEND | |
  24980. * | 3 | ALPHATESTANDBLEND | |
  24981. *
  24982. */
  24983. set transparencyMode(value: Nullable<number>);
  24984. /**
  24985. * Returns true if alpha blending should be disabled.
  24986. */
  24987. protected get _disableAlphaBlending(): boolean;
  24988. /**
  24989. * Specifies whether or not this material should be rendered in alpha blend mode.
  24990. * @returns a boolean specifying if alpha blending is needed
  24991. */
  24992. needAlphaBlending(): boolean;
  24993. /**
  24994. * Specifies if the mesh will require alpha blending
  24995. * @param mesh defines the mesh to check
  24996. * @returns a boolean specifying if alpha blending is needed for the mesh
  24997. */
  24998. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  24999. /**
  25000. * Specifies whether or not this material should be rendered in alpha test mode.
  25001. * @returns a boolean specifying if an alpha test is needed.
  25002. */
  25003. needAlphaTesting(): boolean;
  25004. /**
  25005. * Specifies if material alpha testing should be turned on for the mesh
  25006. * @param mesh defines the mesh to check
  25007. */
  25008. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  25009. /**
  25010. * Gets the texture used for the alpha test
  25011. * @returns the texture to use for alpha testing
  25012. */
  25013. getAlphaTestTexture(): Nullable<BaseTexture>;
  25014. /**
  25015. * Marks the material to indicate that it needs to be re-calculated
  25016. */
  25017. markDirty(): void;
  25018. /** @hidden */
  25019. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  25020. /**
  25021. * Binds the material to the mesh
  25022. * @param world defines the world transformation matrix
  25023. * @param mesh defines the mesh to bind the material to
  25024. */
  25025. bind(world: Matrix, mesh?: Mesh): void;
  25026. /**
  25027. * Binds the submesh to the material
  25028. * @param world defines the world transformation matrix
  25029. * @param mesh defines the mesh containing the submesh
  25030. * @param subMesh defines the submesh to bind the material to
  25031. */
  25032. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  25033. /**
  25034. * Binds the world matrix to the material
  25035. * @param world defines the world transformation matrix
  25036. */
  25037. bindOnlyWorldMatrix(world: Matrix): void;
  25038. /**
  25039. * Binds the scene's uniform buffer to the effect.
  25040. * @param effect defines the effect to bind to the scene uniform buffer
  25041. * @param sceneUbo defines the uniform buffer storing scene data
  25042. */
  25043. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  25044. /**
  25045. * Binds the view matrix to the effect
  25046. * @param effect defines the effect to bind the view matrix to
  25047. */
  25048. bindView(effect: Effect): void;
  25049. /**
  25050. * Binds the view projection matrix to the effect
  25051. * @param effect defines the effect to bind the view projection matrix to
  25052. */
  25053. bindViewProjection(effect: Effect): void;
  25054. /**
  25055. * Processes to execute after binding the material to a mesh
  25056. * @param mesh defines the rendered mesh
  25057. */
  25058. protected _afterBind(mesh?: Mesh): void;
  25059. /**
  25060. * Unbinds the material from the mesh
  25061. */
  25062. unbind(): void;
  25063. /**
  25064. * Gets the active textures from the material
  25065. * @returns an array of textures
  25066. */
  25067. getActiveTextures(): BaseTexture[];
  25068. /**
  25069. * Specifies if the material uses a texture
  25070. * @param texture defines the texture to check against the material
  25071. * @returns a boolean specifying if the material uses the texture
  25072. */
  25073. hasTexture(texture: BaseTexture): boolean;
  25074. /**
  25075. * Makes a duplicate of the material, and gives it a new name
  25076. * @param name defines the new name for the duplicated material
  25077. * @returns the cloned material
  25078. */
  25079. clone(name: string): Nullable<Material>;
  25080. /**
  25081. * Gets the meshes bound to the material
  25082. * @returns an array of meshes bound to the material
  25083. */
  25084. getBindedMeshes(): AbstractMesh[];
  25085. /**
  25086. * Force shader compilation
  25087. * @param mesh defines the mesh associated with this material
  25088. * @param onCompiled defines a function to execute once the material is compiled
  25089. * @param options defines the options to configure the compilation
  25090. * @param onError defines a function to execute if the material fails compiling
  25091. */
  25092. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  25093. /**
  25094. * Force shader compilation
  25095. * @param mesh defines the mesh that will use this material
  25096. * @param options defines additional options for compiling the shaders
  25097. * @returns a promise that resolves when the compilation completes
  25098. */
  25099. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  25100. private static readonly _AllDirtyCallBack;
  25101. private static readonly _ImageProcessingDirtyCallBack;
  25102. private static readonly _TextureDirtyCallBack;
  25103. private static readonly _FresnelDirtyCallBack;
  25104. private static readonly _MiscDirtyCallBack;
  25105. private static readonly _LightsDirtyCallBack;
  25106. private static readonly _AttributeDirtyCallBack;
  25107. private static _FresnelAndMiscDirtyCallBack;
  25108. private static _TextureAndMiscDirtyCallBack;
  25109. private static readonly _DirtyCallbackArray;
  25110. private static readonly _RunDirtyCallBacks;
  25111. /**
  25112. * Marks a define in the material to indicate that it needs to be re-computed
  25113. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  25114. */
  25115. markAsDirty(flag: number): void;
  25116. /**
  25117. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  25118. * @param func defines a function which checks material defines against the submeshes
  25119. */
  25120. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  25121. /**
  25122. * Indicates that the scene should check if the rendering now needs a prepass
  25123. */
  25124. protected _markScenePrePassDirty(): void;
  25125. /**
  25126. * Indicates that we need to re-calculated for all submeshes
  25127. */
  25128. protected _markAllSubMeshesAsAllDirty(): void;
  25129. /**
  25130. * Indicates that image processing needs to be re-calculated for all submeshes
  25131. */
  25132. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  25133. /**
  25134. * Indicates that textures need to be re-calculated for all submeshes
  25135. */
  25136. protected _markAllSubMeshesAsTexturesDirty(): void;
  25137. /**
  25138. * Indicates that fresnel needs to be re-calculated for all submeshes
  25139. */
  25140. protected _markAllSubMeshesAsFresnelDirty(): void;
  25141. /**
  25142. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  25143. */
  25144. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  25145. /**
  25146. * Indicates that lights need to be re-calculated for all submeshes
  25147. */
  25148. protected _markAllSubMeshesAsLightsDirty(): void;
  25149. /**
  25150. * Indicates that attributes need to be re-calculated for all submeshes
  25151. */
  25152. protected _markAllSubMeshesAsAttributesDirty(): void;
  25153. /**
  25154. * Indicates that misc needs to be re-calculated for all submeshes
  25155. */
  25156. protected _markAllSubMeshesAsMiscDirty(): void;
  25157. /**
  25158. * Indicates that textures and misc need to be re-calculated for all submeshes
  25159. */
  25160. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  25161. /**
  25162. * Disposes the material
  25163. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  25164. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  25165. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  25166. */
  25167. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  25168. /** @hidden */
  25169. private releaseVertexArrayObject;
  25170. /**
  25171. * Serializes this material
  25172. * @returns the serialized material object
  25173. */
  25174. serialize(): any;
  25175. /**
  25176. * Creates a material from parsed material data
  25177. * @param parsedMaterial defines parsed material data
  25178. * @param scene defines the hosting scene
  25179. * @param rootUrl defines the root URL to use to load textures
  25180. * @returns a new material
  25181. */
  25182. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  25183. }
  25184. }
  25185. declare module "babylonjs/Materials/multiMaterial" {
  25186. import { Nullable } from "babylonjs/types";
  25187. import { Scene } from "babylonjs/scene";
  25188. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25189. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25190. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25191. import { Material } from "babylonjs/Materials/material";
  25192. /**
  25193. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25194. * separate meshes. This can be use to improve performances.
  25195. * @see https://doc.babylonjs.com/how_to/multi_materials
  25196. */
  25197. export class MultiMaterial extends Material {
  25198. private _subMaterials;
  25199. /**
  25200. * Gets or Sets the list of Materials used within the multi material.
  25201. * They need to be ordered according to the submeshes order in the associated mesh
  25202. */
  25203. get subMaterials(): Nullable<Material>[];
  25204. set subMaterials(value: Nullable<Material>[]);
  25205. /**
  25206. * Function used to align with Node.getChildren()
  25207. * @returns the list of Materials used within the multi material
  25208. */
  25209. getChildren(): Nullable<Material>[];
  25210. /**
  25211. * Instantiates a new Multi Material
  25212. * A multi-material is used to apply different materials to different parts of the same object without the need of
  25213. * separate meshes. This can be use to improve performances.
  25214. * @see https://doc.babylonjs.com/how_to/multi_materials
  25215. * @param name Define the name in the scene
  25216. * @param scene Define the scene the material belongs to
  25217. */
  25218. constructor(name: string, scene: Scene);
  25219. private _hookArray;
  25220. /**
  25221. * Get one of the submaterial by its index in the submaterials array
  25222. * @param index The index to look the sub material at
  25223. * @returns The Material if the index has been defined
  25224. */
  25225. getSubMaterial(index: number): Nullable<Material>;
  25226. /**
  25227. * Get the list of active textures for the whole sub materials list.
  25228. * @returns All the textures that will be used during the rendering
  25229. */
  25230. getActiveTextures(): BaseTexture[];
  25231. /**
  25232. * Gets the current class name of the material e.g. "MultiMaterial"
  25233. * Mainly use in serialization.
  25234. * @returns the class name
  25235. */
  25236. getClassName(): string;
  25237. /**
  25238. * Checks if the material is ready to render the requested sub mesh
  25239. * @param mesh Define the mesh the submesh belongs to
  25240. * @param subMesh Define the sub mesh to look readyness for
  25241. * @param useInstances Define whether or not the material is used with instances
  25242. * @returns true if ready, otherwise false
  25243. */
  25244. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25245. /**
  25246. * Clones the current material and its related sub materials
  25247. * @param name Define the name of the newly cloned material
  25248. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  25249. * @returns the cloned material
  25250. */
  25251. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  25252. /**
  25253. * Serializes the materials into a JSON representation.
  25254. * @returns the JSON representation
  25255. */
  25256. serialize(): any;
  25257. /**
  25258. * Dispose the material and release its associated resources
  25259. * @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)
  25260. * @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)
  25261. * @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)
  25262. */
  25263. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  25264. /**
  25265. * Creates a MultiMaterial from parsed MultiMaterial data.
  25266. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  25267. * @param scene defines the hosting scene
  25268. * @returns a new MultiMaterial
  25269. */
  25270. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  25271. }
  25272. }
  25273. declare module "babylonjs/Meshes/subMesh" {
  25274. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  25275. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25276. import { Engine } from "babylonjs/Engines/engine";
  25277. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  25278. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25279. import { Effect } from "babylonjs/Materials/effect";
  25280. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25281. import { Plane } from "babylonjs/Maths/math.plane";
  25282. import { Collider } from "babylonjs/Collisions/collider";
  25283. import { Material } from "babylonjs/Materials/material";
  25284. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25286. import { Mesh } from "babylonjs/Meshes/mesh";
  25287. import { Ray } from "babylonjs/Culling/ray";
  25288. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  25289. /**
  25290. * Defines a subdivision inside a mesh
  25291. */
  25292. export class SubMesh implements ICullable {
  25293. /** the material index to use */
  25294. materialIndex: number;
  25295. /** vertex index start */
  25296. verticesStart: number;
  25297. /** vertices count */
  25298. verticesCount: number;
  25299. /** index start */
  25300. indexStart: number;
  25301. /** indices count */
  25302. indexCount: number;
  25303. /** @hidden */
  25304. _materialDefines: Nullable<MaterialDefines>;
  25305. /** @hidden */
  25306. _materialEffect: Nullable<Effect>;
  25307. /** @hidden */
  25308. _effectOverride: Nullable<Effect>;
  25309. /**
  25310. * Gets material defines used by the effect associated to the sub mesh
  25311. */
  25312. get materialDefines(): Nullable<MaterialDefines>;
  25313. /**
  25314. * Sets material defines used by the effect associated to the sub mesh
  25315. */
  25316. set materialDefines(defines: Nullable<MaterialDefines>);
  25317. /**
  25318. * Gets associated effect
  25319. */
  25320. get effect(): Nullable<Effect>;
  25321. /**
  25322. * Sets associated effect (effect used to render this submesh)
  25323. * @param effect defines the effect to associate with
  25324. * @param defines defines the set of defines used to compile this effect
  25325. */
  25326. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  25327. /** @hidden */
  25328. _linesIndexCount: number;
  25329. private _mesh;
  25330. private _renderingMesh;
  25331. private _boundingInfo;
  25332. private _linesIndexBuffer;
  25333. /** @hidden */
  25334. _lastColliderWorldVertices: Nullable<Vector3[]>;
  25335. /** @hidden */
  25336. _trianglePlanes: Plane[];
  25337. /** @hidden */
  25338. _lastColliderTransformMatrix: Nullable<Matrix>;
  25339. /** @hidden */
  25340. _renderId: number;
  25341. /** @hidden */
  25342. _alphaIndex: number;
  25343. /** @hidden */
  25344. _distanceToCamera: number;
  25345. /** @hidden */
  25346. _id: number;
  25347. private _currentMaterial;
  25348. /**
  25349. * Add a new submesh to a mesh
  25350. * @param materialIndex defines the material index to use
  25351. * @param verticesStart defines vertex index start
  25352. * @param verticesCount defines vertices count
  25353. * @param indexStart defines index start
  25354. * @param indexCount defines indices count
  25355. * @param mesh defines the parent mesh
  25356. * @param renderingMesh defines an optional rendering mesh
  25357. * @param createBoundingBox defines if bounding box should be created for this submesh
  25358. * @returns the new submesh
  25359. */
  25360. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  25361. /**
  25362. * Creates a new submesh
  25363. * @param materialIndex defines the material index to use
  25364. * @param verticesStart defines vertex index start
  25365. * @param verticesCount defines vertices count
  25366. * @param indexStart defines index start
  25367. * @param indexCount defines indices count
  25368. * @param mesh defines the parent mesh
  25369. * @param renderingMesh defines an optional rendering mesh
  25370. * @param createBoundingBox defines if bounding box should be created for this submesh
  25371. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  25372. */
  25373. constructor(
  25374. /** the material index to use */
  25375. materialIndex: number,
  25376. /** vertex index start */
  25377. verticesStart: number,
  25378. /** vertices count */
  25379. verticesCount: number,
  25380. /** index start */
  25381. indexStart: number,
  25382. /** indices count */
  25383. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  25384. /**
  25385. * Returns true if this submesh covers the entire parent mesh
  25386. * @ignorenaming
  25387. */
  25388. get IsGlobal(): boolean;
  25389. /**
  25390. * Returns the submesh BoudingInfo object
  25391. * @returns current bounding info (or mesh's one if the submesh is global)
  25392. */
  25393. getBoundingInfo(): BoundingInfo;
  25394. /**
  25395. * Sets the submesh BoundingInfo
  25396. * @param boundingInfo defines the new bounding info to use
  25397. * @returns the SubMesh
  25398. */
  25399. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  25400. /**
  25401. * Returns the mesh of the current submesh
  25402. * @return the parent mesh
  25403. */
  25404. getMesh(): AbstractMesh;
  25405. /**
  25406. * Returns the rendering mesh of the submesh
  25407. * @returns the rendering mesh (could be different from parent mesh)
  25408. */
  25409. getRenderingMesh(): Mesh;
  25410. /**
  25411. * Returns the replacement mesh of the submesh
  25412. * @returns the replacement mesh (could be different from parent mesh)
  25413. */
  25414. getReplacementMesh(): Nullable<AbstractMesh>;
  25415. /**
  25416. * Returns the effective mesh of the submesh
  25417. * @returns the effective mesh (could be different from parent mesh)
  25418. */
  25419. getEffectiveMesh(): AbstractMesh;
  25420. /**
  25421. * Returns the submesh material
  25422. * @returns null or the current material
  25423. */
  25424. getMaterial(): Nullable<Material>;
  25425. private _IsMultiMaterial;
  25426. /**
  25427. * Sets a new updated BoundingInfo object to the submesh
  25428. * @param data defines an optional position array to use to determine the bounding info
  25429. * @returns the SubMesh
  25430. */
  25431. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  25432. /** @hidden */
  25433. _checkCollision(collider: Collider): boolean;
  25434. /**
  25435. * Updates the submesh BoundingInfo
  25436. * @param world defines the world matrix to use to update the bounding info
  25437. * @returns the submesh
  25438. */
  25439. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  25440. /**
  25441. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  25442. * @param frustumPlanes defines the frustum planes
  25443. * @returns true if the submesh is intersecting with the frustum
  25444. */
  25445. isInFrustum(frustumPlanes: Plane[]): boolean;
  25446. /**
  25447. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  25448. * @param frustumPlanes defines the frustum planes
  25449. * @returns true if the submesh is inside the frustum
  25450. */
  25451. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25452. /**
  25453. * Renders the submesh
  25454. * @param enableAlphaMode defines if alpha needs to be used
  25455. * @returns the submesh
  25456. */
  25457. render(enableAlphaMode: boolean): SubMesh;
  25458. /**
  25459. * @hidden
  25460. */
  25461. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  25462. /**
  25463. * Checks if the submesh intersects with a ray
  25464. * @param ray defines the ray to test
  25465. * @returns true is the passed ray intersects the submesh bounding box
  25466. */
  25467. canIntersects(ray: Ray): boolean;
  25468. /**
  25469. * Intersects current submesh with a ray
  25470. * @param ray defines the ray to test
  25471. * @param positions defines mesh's positions array
  25472. * @param indices defines mesh's indices array
  25473. * @param fastCheck defines if the first intersection will be used (and not the closest)
  25474. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25475. * @returns intersection info or null if no intersection
  25476. */
  25477. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  25478. /** @hidden */
  25479. private _intersectLines;
  25480. /** @hidden */
  25481. private _intersectUnIndexedLines;
  25482. /** @hidden */
  25483. private _intersectTriangles;
  25484. /** @hidden */
  25485. private _intersectUnIndexedTriangles;
  25486. /** @hidden */
  25487. _rebuild(): void;
  25488. /**
  25489. * Creates a new submesh from the passed mesh
  25490. * @param newMesh defines the new hosting mesh
  25491. * @param newRenderingMesh defines an optional rendering mesh
  25492. * @returns the new submesh
  25493. */
  25494. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  25495. /**
  25496. * Release associated resources
  25497. */
  25498. dispose(): void;
  25499. /**
  25500. * Gets the class name
  25501. * @returns the string "SubMesh".
  25502. */
  25503. getClassName(): string;
  25504. /**
  25505. * Creates a new submesh from indices data
  25506. * @param materialIndex the index of the main mesh material
  25507. * @param startIndex the index where to start the copy in the mesh indices array
  25508. * @param indexCount the number of indices to copy then from the startIndex
  25509. * @param mesh the main mesh to create the submesh from
  25510. * @param renderingMesh the optional rendering mesh
  25511. * @returns a new submesh
  25512. */
  25513. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  25514. }
  25515. }
  25516. declare module "babylonjs/Loading/sceneLoaderFlags" {
  25517. /**
  25518. * Class used to represent data loading progression
  25519. */
  25520. export class SceneLoaderFlags {
  25521. private static _ForceFullSceneLoadingForIncremental;
  25522. private static _ShowLoadingScreen;
  25523. private static _CleanBoneMatrixWeights;
  25524. private static _loggingLevel;
  25525. /**
  25526. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  25527. */
  25528. static get ForceFullSceneLoadingForIncremental(): boolean;
  25529. static set ForceFullSceneLoadingForIncremental(value: boolean);
  25530. /**
  25531. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  25532. */
  25533. static get ShowLoadingScreen(): boolean;
  25534. static set ShowLoadingScreen(value: boolean);
  25535. /**
  25536. * Defines the current logging level (while loading the scene)
  25537. * @ignorenaming
  25538. */
  25539. static get loggingLevel(): number;
  25540. static set loggingLevel(value: number);
  25541. /**
  25542. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  25543. */
  25544. static get CleanBoneMatrixWeights(): boolean;
  25545. static set CleanBoneMatrixWeights(value: boolean);
  25546. }
  25547. }
  25548. declare module "babylonjs/Meshes/geometry" {
  25549. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  25550. import { Scene } from "babylonjs/scene";
  25551. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  25552. import { Engine } from "babylonjs/Engines/engine";
  25553. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  25554. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  25555. import { Effect } from "babylonjs/Materials/effect";
  25556. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  25557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  25558. import { Mesh } from "babylonjs/Meshes/mesh";
  25559. /**
  25560. * Class used to store geometry data (vertex buffers + index buffer)
  25561. */
  25562. export class Geometry implements IGetSetVerticesData {
  25563. /**
  25564. * Gets or sets the ID of the geometry
  25565. */
  25566. id: string;
  25567. /**
  25568. * Gets or sets the unique ID of the geometry
  25569. */
  25570. uniqueId: number;
  25571. /**
  25572. * Gets the delay loading state of the geometry (none by default which means not delayed)
  25573. */
  25574. delayLoadState: number;
  25575. /**
  25576. * Gets the file containing the data to load when running in delay load state
  25577. */
  25578. delayLoadingFile: Nullable<string>;
  25579. /**
  25580. * Callback called when the geometry is updated
  25581. */
  25582. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  25583. private _scene;
  25584. private _engine;
  25585. private _meshes;
  25586. private _totalVertices;
  25587. /** @hidden */
  25588. _indices: IndicesArray;
  25589. /** @hidden */
  25590. _vertexBuffers: {
  25591. [key: string]: VertexBuffer;
  25592. };
  25593. private _isDisposed;
  25594. private _extend;
  25595. private _boundingBias;
  25596. /** @hidden */
  25597. _delayInfo: Array<string>;
  25598. private _indexBuffer;
  25599. private _indexBufferIsUpdatable;
  25600. /** @hidden */
  25601. _boundingInfo: Nullable<BoundingInfo>;
  25602. /** @hidden */
  25603. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  25604. /** @hidden */
  25605. _softwareSkinningFrameId: number;
  25606. private _vertexArrayObjects;
  25607. private _updatable;
  25608. /** @hidden */
  25609. _positions: Nullable<Vector3[]>;
  25610. /**
  25611. * 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
  25612. */
  25613. get boundingBias(): Vector2;
  25614. /**
  25615. * 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
  25616. */
  25617. set boundingBias(value: Vector2);
  25618. /**
  25619. * Static function used to attach a new empty geometry to a mesh
  25620. * @param mesh defines the mesh to attach the geometry to
  25621. * @returns the new Geometry
  25622. */
  25623. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  25624. /** Get the list of meshes using this geometry */
  25625. get meshes(): Mesh[];
  25626. /**
  25627. * 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
  25628. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  25629. */
  25630. useBoundingInfoFromGeometry: boolean;
  25631. /**
  25632. * Creates a new geometry
  25633. * @param id defines the unique ID
  25634. * @param scene defines the hosting scene
  25635. * @param vertexData defines the VertexData used to get geometry data
  25636. * @param updatable defines if geometry must be updatable (false by default)
  25637. * @param mesh defines the mesh that will be associated with the geometry
  25638. */
  25639. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  25640. /**
  25641. * Gets the current extend of the geometry
  25642. */
  25643. get extend(): {
  25644. minimum: Vector3;
  25645. maximum: Vector3;
  25646. };
  25647. /**
  25648. * Gets the hosting scene
  25649. * @returns the hosting Scene
  25650. */
  25651. getScene(): Scene;
  25652. /**
  25653. * Gets the hosting engine
  25654. * @returns the hosting Engine
  25655. */
  25656. getEngine(): Engine;
  25657. /**
  25658. * Defines if the geometry is ready to use
  25659. * @returns true if the geometry is ready to be used
  25660. */
  25661. isReady(): boolean;
  25662. /**
  25663. * Gets a value indicating that the geometry should not be serialized
  25664. */
  25665. get doNotSerialize(): boolean;
  25666. /** @hidden */
  25667. _rebuild(): void;
  25668. /**
  25669. * Affects all geometry data in one call
  25670. * @param vertexData defines the geometry data
  25671. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  25672. */
  25673. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  25674. /**
  25675. * Set specific vertex data
  25676. * @param kind defines the data kind (Position, normal, etc...)
  25677. * @param data defines the vertex data to use
  25678. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25679. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25680. */
  25681. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  25682. /**
  25683. * Removes a specific vertex data
  25684. * @param kind defines the data kind (Position, normal, etc...)
  25685. */
  25686. removeVerticesData(kind: string): void;
  25687. /**
  25688. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  25689. * @param buffer defines the vertex buffer to use
  25690. * @param totalVertices defines the total number of vertices for position kind (could be null)
  25691. */
  25692. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  25693. /**
  25694. * Update a specific vertex buffer
  25695. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  25696. * It will do nothing if the buffer is not updatable
  25697. * @param kind defines the data kind (Position, normal, etc...)
  25698. * @param data defines the data to use
  25699. * @param offset defines the offset in the target buffer where to store the data
  25700. * @param useBytes set to true if the offset is in bytes
  25701. */
  25702. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  25703. /**
  25704. * Update a specific vertex buffer
  25705. * This function will create a new buffer if the current one is not updatable
  25706. * @param kind defines the data kind (Position, normal, etc...)
  25707. * @param data defines the data to use
  25708. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  25709. */
  25710. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  25711. private _updateBoundingInfo;
  25712. /** @hidden */
  25713. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  25714. /**
  25715. * Gets total number of vertices
  25716. * @returns the total number of vertices
  25717. */
  25718. getTotalVertices(): number;
  25719. /**
  25720. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25721. * @param kind defines the data kind (Position, normal, etc...)
  25722. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25723. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25724. * @returns a float array containing vertex data
  25725. */
  25726. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25727. /**
  25728. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  25729. * @param kind defines the data kind (Position, normal, etc...)
  25730. * @returns true if the vertex buffer with the specified kind is updatable
  25731. */
  25732. isVertexBufferUpdatable(kind: string): boolean;
  25733. /**
  25734. * Gets a specific vertex buffer
  25735. * @param kind defines the data kind (Position, normal, etc...)
  25736. * @returns a VertexBuffer
  25737. */
  25738. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25739. /**
  25740. * Returns all vertex buffers
  25741. * @return an object holding all vertex buffers indexed by kind
  25742. */
  25743. getVertexBuffers(): Nullable<{
  25744. [key: string]: VertexBuffer;
  25745. }>;
  25746. /**
  25747. * Gets a boolean indicating if specific vertex buffer is present
  25748. * @param kind defines the data kind (Position, normal, etc...)
  25749. * @returns true if data is present
  25750. */
  25751. isVerticesDataPresent(kind: string): boolean;
  25752. /**
  25753. * Gets a list of all attached data kinds (Position, normal, etc...)
  25754. * @returns a list of string containing all kinds
  25755. */
  25756. getVerticesDataKinds(): string[];
  25757. /**
  25758. * Update index buffer
  25759. * @param indices defines the indices to store in the index buffer
  25760. * @param offset defines the offset in the target buffer where to store the data
  25761. * @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)
  25762. */
  25763. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  25764. /**
  25765. * Creates a new index buffer
  25766. * @param indices defines the indices to store in the index buffer
  25767. * @param totalVertices defines the total number of vertices (could be null)
  25768. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25769. */
  25770. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  25771. /**
  25772. * Return the total number of indices
  25773. * @returns the total number of indices
  25774. */
  25775. getTotalIndices(): number;
  25776. /**
  25777. * Gets the index buffer array
  25778. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25779. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25780. * @returns the index buffer array
  25781. */
  25782. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25783. /**
  25784. * Gets the index buffer
  25785. * @return the index buffer
  25786. */
  25787. getIndexBuffer(): Nullable<DataBuffer>;
  25788. /** @hidden */
  25789. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  25790. /**
  25791. * Release the associated resources for a specific mesh
  25792. * @param mesh defines the source mesh
  25793. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  25794. */
  25795. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  25796. /**
  25797. * Apply current geometry to a given mesh
  25798. * @param mesh defines the mesh to apply geometry to
  25799. */
  25800. applyToMesh(mesh: Mesh): void;
  25801. private _updateExtend;
  25802. private _applyToMesh;
  25803. private notifyUpdate;
  25804. /**
  25805. * Load the geometry if it was flagged as delay loaded
  25806. * @param scene defines the hosting scene
  25807. * @param onLoaded defines a callback called when the geometry is loaded
  25808. */
  25809. load(scene: Scene, onLoaded?: () => void): void;
  25810. private _queueLoad;
  25811. /**
  25812. * Invert the geometry to move from a right handed system to a left handed one.
  25813. */
  25814. toLeftHanded(): void;
  25815. /** @hidden */
  25816. _resetPointsArrayCache(): void;
  25817. /** @hidden */
  25818. _generatePointsArray(): boolean;
  25819. /**
  25820. * Gets a value indicating if the geometry is disposed
  25821. * @returns true if the geometry was disposed
  25822. */
  25823. isDisposed(): boolean;
  25824. private _disposeVertexArrayObjects;
  25825. /**
  25826. * Free all associated resources
  25827. */
  25828. dispose(): void;
  25829. /**
  25830. * Clone the current geometry into a new geometry
  25831. * @param id defines the unique ID of the new geometry
  25832. * @returns a new geometry object
  25833. */
  25834. copy(id: string): Geometry;
  25835. /**
  25836. * Serialize the current geometry info (and not the vertices data) into a JSON object
  25837. * @return a JSON representation of the current geometry data (without the vertices data)
  25838. */
  25839. serialize(): any;
  25840. private toNumberArray;
  25841. /**
  25842. * Serialize all vertices data into a JSON oject
  25843. * @returns a JSON representation of the current geometry data
  25844. */
  25845. serializeVerticeData(): any;
  25846. /**
  25847. * Extracts a clone of a mesh geometry
  25848. * @param mesh defines the source mesh
  25849. * @param id defines the unique ID of the new geometry object
  25850. * @returns the new geometry object
  25851. */
  25852. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  25853. /**
  25854. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  25855. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25856. * Be aware Math.random() could cause collisions, but:
  25857. * "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"
  25858. * @returns a string containing a new GUID
  25859. */
  25860. static RandomId(): string;
  25861. /** @hidden */
  25862. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  25863. private static _CleanMatricesWeights;
  25864. /**
  25865. * Create a new geometry from persisted data (Using .babylon file format)
  25866. * @param parsedVertexData defines the persisted data
  25867. * @param scene defines the hosting scene
  25868. * @param rootUrl defines the root url to use to load assets (like delayed data)
  25869. * @returns the new geometry object
  25870. */
  25871. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  25872. }
  25873. }
  25874. declare module "babylonjs/Meshes/mesh.vertexData" {
  25875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  25876. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  25877. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  25878. import { Geometry } from "babylonjs/Meshes/geometry";
  25879. import { Mesh } from "babylonjs/Meshes/mesh";
  25880. /**
  25881. * Define an interface for all classes that will get and set the data on vertices
  25882. */
  25883. export interface IGetSetVerticesData {
  25884. /**
  25885. * Gets a boolean indicating if specific vertex data is present
  25886. * @param kind defines the vertex data kind to use
  25887. * @returns true is data kind is present
  25888. */
  25889. isVerticesDataPresent(kind: string): boolean;
  25890. /**
  25891. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  25892. * @param kind defines the data kind (Position, normal, etc...)
  25893. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  25894. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25895. * @returns a float array containing vertex data
  25896. */
  25897. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25898. /**
  25899. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25900. * @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.
  25901. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25902. * @returns the indices array or an empty array if the mesh has no geometry
  25903. */
  25904. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25905. /**
  25906. * Set specific vertex data
  25907. * @param kind defines the data kind (Position, normal, etc...)
  25908. * @param data defines the vertex data to use
  25909. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  25910. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  25911. */
  25912. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  25913. /**
  25914. * Update a specific associated vertex buffer
  25915. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25916. * - VertexBuffer.PositionKind
  25917. * - VertexBuffer.UVKind
  25918. * - VertexBuffer.UV2Kind
  25919. * - VertexBuffer.UV3Kind
  25920. * - VertexBuffer.UV4Kind
  25921. * - VertexBuffer.UV5Kind
  25922. * - VertexBuffer.UV6Kind
  25923. * - VertexBuffer.ColorKind
  25924. * - VertexBuffer.MatricesIndicesKind
  25925. * - VertexBuffer.MatricesIndicesExtraKind
  25926. * - VertexBuffer.MatricesWeightsKind
  25927. * - VertexBuffer.MatricesWeightsExtraKind
  25928. * @param data defines the data source
  25929. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25930. * @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)
  25931. */
  25932. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  25933. /**
  25934. * Creates a new index buffer
  25935. * @param indices defines the indices to store in the index buffer
  25936. * @param totalVertices defines the total number of vertices (could be null)
  25937. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  25938. */
  25939. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  25940. }
  25941. /**
  25942. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  25943. */
  25944. export class VertexData {
  25945. /**
  25946. * Mesh side orientation : usually the external or front surface
  25947. */
  25948. static readonly FRONTSIDE: number;
  25949. /**
  25950. * Mesh side orientation : usually the internal or back surface
  25951. */
  25952. static readonly BACKSIDE: number;
  25953. /**
  25954. * Mesh side orientation : both internal and external or front and back surfaces
  25955. */
  25956. static readonly DOUBLESIDE: number;
  25957. /**
  25958. * Mesh side orientation : by default, `FRONTSIDE`
  25959. */
  25960. static readonly DEFAULTSIDE: number;
  25961. /**
  25962. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  25963. */
  25964. positions: Nullable<FloatArray>;
  25965. /**
  25966. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  25967. */
  25968. normals: Nullable<FloatArray>;
  25969. /**
  25970. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  25971. */
  25972. tangents: Nullable<FloatArray>;
  25973. /**
  25974. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25975. */
  25976. uvs: Nullable<FloatArray>;
  25977. /**
  25978. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25979. */
  25980. uvs2: Nullable<FloatArray>;
  25981. /**
  25982. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25983. */
  25984. uvs3: Nullable<FloatArray>;
  25985. /**
  25986. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25987. */
  25988. uvs4: Nullable<FloatArray>;
  25989. /**
  25990. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25991. */
  25992. uvs5: Nullable<FloatArray>;
  25993. /**
  25994. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  25995. */
  25996. uvs6: Nullable<FloatArray>;
  25997. /**
  25998. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  25999. */
  26000. colors: Nullable<FloatArray>;
  26001. /**
  26002. * 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).
  26003. */
  26004. matricesIndices: Nullable<FloatArray>;
  26005. /**
  26006. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  26007. */
  26008. matricesWeights: Nullable<FloatArray>;
  26009. /**
  26010. * An array extending the number of possible indices
  26011. */
  26012. matricesIndicesExtra: Nullable<FloatArray>;
  26013. /**
  26014. * An array extending the number of possible weights when the number of indices is extended
  26015. */
  26016. matricesWeightsExtra: Nullable<FloatArray>;
  26017. /**
  26018. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  26019. */
  26020. indices: Nullable<IndicesArray>;
  26021. /**
  26022. * Uses the passed data array to set the set the values for the specified kind of data
  26023. * @param data a linear array of floating numbers
  26024. * @param kind the type of data that is being set, eg positions, colors etc
  26025. */
  26026. set(data: FloatArray, kind: string): void;
  26027. /**
  26028. * Associates the vertexData to the passed Mesh.
  26029. * Sets it as updatable or not (default `false`)
  26030. * @param mesh the mesh the vertexData is applied to
  26031. * @param updatable when used and having the value true allows new data to update the vertexData
  26032. * @returns the VertexData
  26033. */
  26034. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  26035. /**
  26036. * Associates the vertexData to the passed Geometry.
  26037. * Sets it as updatable or not (default `false`)
  26038. * @param geometry the geometry the vertexData is applied to
  26039. * @param updatable when used and having the value true allows new data to update the vertexData
  26040. * @returns VertexData
  26041. */
  26042. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  26043. /**
  26044. * Updates the associated mesh
  26045. * @param mesh the mesh to be updated
  26046. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26047. * @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
  26048. * @returns VertexData
  26049. */
  26050. updateMesh(mesh: Mesh): VertexData;
  26051. /**
  26052. * Updates the associated geometry
  26053. * @param geometry the geometry to be updated
  26054. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  26055. * @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
  26056. * @returns VertexData.
  26057. */
  26058. updateGeometry(geometry: Geometry): VertexData;
  26059. private _applyTo;
  26060. private _update;
  26061. /**
  26062. * Transforms each position and each normal of the vertexData according to the passed Matrix
  26063. * @param matrix the transforming matrix
  26064. * @returns the VertexData
  26065. */
  26066. transform(matrix: Matrix): VertexData;
  26067. /**
  26068. * Merges the passed VertexData into the current one
  26069. * @param other the VertexData to be merged into the current one
  26070. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  26071. * @returns the modified VertexData
  26072. */
  26073. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  26074. private _mergeElement;
  26075. private _validate;
  26076. /**
  26077. * Serializes the VertexData
  26078. * @returns a serialized object
  26079. */
  26080. serialize(): any;
  26081. /**
  26082. * Extracts the vertexData from a mesh
  26083. * @param mesh the mesh from which to extract the VertexData
  26084. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  26085. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26086. * @returns the object VertexData associated to the passed mesh
  26087. */
  26088. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26089. /**
  26090. * Extracts the vertexData from the geometry
  26091. * @param geometry the geometry from which to extract the VertexData
  26092. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  26093. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  26094. * @returns the object VertexData associated to the passed mesh
  26095. */
  26096. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  26097. private static _ExtractFrom;
  26098. /**
  26099. * Creates the VertexData for a Ribbon
  26100. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  26101. * * pathArray array of paths, each of which an array of successive Vector3
  26102. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  26103. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  26104. * * 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
  26105. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26106. * * 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)
  26107. * * 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)
  26108. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  26109. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  26110. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  26111. * @returns the VertexData of the ribbon
  26112. */
  26113. static CreateRibbon(options: {
  26114. pathArray: Vector3[][];
  26115. closeArray?: boolean;
  26116. closePath?: boolean;
  26117. offset?: number;
  26118. sideOrientation?: number;
  26119. frontUVs?: Vector4;
  26120. backUVs?: Vector4;
  26121. invertUV?: boolean;
  26122. uvs?: Vector2[];
  26123. colors?: Color4[];
  26124. }): VertexData;
  26125. /**
  26126. * Creates the VertexData for a box
  26127. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26128. * * size sets the width, height and depth of the box to the value of size, optional default 1
  26129. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  26130. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  26131. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  26132. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26133. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26134. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26135. * * 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)
  26136. * * 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)
  26137. * @returns the VertexData of the box
  26138. */
  26139. static CreateBox(options: {
  26140. size?: number;
  26141. width?: number;
  26142. height?: number;
  26143. depth?: number;
  26144. faceUV?: Vector4[];
  26145. faceColors?: Color4[];
  26146. sideOrientation?: number;
  26147. frontUVs?: Vector4;
  26148. backUVs?: Vector4;
  26149. }): VertexData;
  26150. /**
  26151. * Creates the VertexData for a tiled box
  26152. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26153. * * faceTiles sets the pattern, tile size and number of tiles for a face
  26154. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  26155. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  26156. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26157. * @returns the VertexData of the box
  26158. */
  26159. static CreateTiledBox(options: {
  26160. pattern?: number;
  26161. width?: number;
  26162. height?: number;
  26163. depth?: number;
  26164. tileSize?: number;
  26165. tileWidth?: number;
  26166. tileHeight?: number;
  26167. alignHorizontal?: number;
  26168. alignVertical?: number;
  26169. faceUV?: Vector4[];
  26170. faceColors?: Color4[];
  26171. sideOrientation?: number;
  26172. }): VertexData;
  26173. /**
  26174. * Creates the VertexData for a tiled plane
  26175. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26176. * * pattern a limited pattern arrangement depending on the number
  26177. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  26178. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  26179. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  26180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26181. * * 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)
  26182. * * 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)
  26183. * @returns the VertexData of the tiled plane
  26184. */
  26185. static CreateTiledPlane(options: {
  26186. pattern?: number;
  26187. tileSize?: number;
  26188. tileWidth?: number;
  26189. tileHeight?: number;
  26190. size?: number;
  26191. width?: number;
  26192. height?: number;
  26193. alignHorizontal?: number;
  26194. alignVertical?: number;
  26195. sideOrientation?: number;
  26196. frontUVs?: Vector4;
  26197. backUVs?: Vector4;
  26198. }): VertexData;
  26199. /**
  26200. * Creates the VertexData for an ellipsoid, defaults to a sphere
  26201. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26202. * * segments sets the number of horizontal strips optional, default 32
  26203. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  26204. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  26205. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  26206. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  26207. * * 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
  26208. * * 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
  26209. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26210. * * 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)
  26211. * * 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)
  26212. * @returns the VertexData of the ellipsoid
  26213. */
  26214. static CreateSphere(options: {
  26215. segments?: number;
  26216. diameter?: number;
  26217. diameterX?: number;
  26218. diameterY?: number;
  26219. diameterZ?: number;
  26220. arc?: number;
  26221. slice?: number;
  26222. sideOrientation?: number;
  26223. frontUVs?: Vector4;
  26224. backUVs?: Vector4;
  26225. }): VertexData;
  26226. /**
  26227. * Creates the VertexData for a cylinder, cone or prism
  26228. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26229. * * height sets the height (y direction) of the cylinder, optional, default 2
  26230. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  26231. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  26232. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  26233. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26234. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  26235. * * 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
  26236. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26237. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26238. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  26239. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  26240. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26241. * * 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)
  26242. * * 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)
  26243. * @returns the VertexData of the cylinder, cone or prism
  26244. */
  26245. static CreateCylinder(options: {
  26246. height?: number;
  26247. diameterTop?: number;
  26248. diameterBottom?: number;
  26249. diameter?: number;
  26250. tessellation?: number;
  26251. subdivisions?: number;
  26252. arc?: number;
  26253. faceColors?: Color4[];
  26254. faceUV?: Vector4[];
  26255. hasRings?: boolean;
  26256. enclose?: boolean;
  26257. sideOrientation?: number;
  26258. frontUVs?: Vector4;
  26259. backUVs?: Vector4;
  26260. }): VertexData;
  26261. /**
  26262. * Creates the VertexData for a torus
  26263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  26264. * * diameter the diameter of the torus, optional default 1
  26265. * * thickness the diameter of the tube forming the torus, optional default 0.5
  26266. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  26267. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26268. * * 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)
  26269. * * 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)
  26270. * @returns the VertexData of the torus
  26271. */
  26272. static CreateTorus(options: {
  26273. diameter?: number;
  26274. thickness?: number;
  26275. tessellation?: number;
  26276. sideOrientation?: number;
  26277. frontUVs?: Vector4;
  26278. backUVs?: Vector4;
  26279. }): VertexData;
  26280. /**
  26281. * Creates the VertexData of the LineSystem
  26282. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  26283. * - lines an array of lines, each line being an array of successive Vector3
  26284. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  26285. * @returns the VertexData of the LineSystem
  26286. */
  26287. static CreateLineSystem(options: {
  26288. lines: Vector3[][];
  26289. colors?: Nullable<Color4[][]>;
  26290. }): VertexData;
  26291. /**
  26292. * Create the VertexData for a DashedLines
  26293. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  26294. * - points an array successive Vector3
  26295. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  26296. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  26297. * - dashNb the intended total number of dashes, optional, default 200
  26298. * @returns the VertexData for the DashedLines
  26299. */
  26300. static CreateDashedLines(options: {
  26301. points: Vector3[];
  26302. dashSize?: number;
  26303. gapSize?: number;
  26304. dashNb?: number;
  26305. }): VertexData;
  26306. /**
  26307. * Creates the VertexData for a Ground
  26308. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26309. * - width the width (x direction) of the ground, optional, default 1
  26310. * - height the height (z direction) of the ground, optional, default 1
  26311. * - subdivisions the number of subdivisions per side, optional, default 1
  26312. * @returns the VertexData of the Ground
  26313. */
  26314. static CreateGround(options: {
  26315. width?: number;
  26316. height?: number;
  26317. subdivisions?: number;
  26318. subdivisionsX?: number;
  26319. subdivisionsY?: number;
  26320. }): VertexData;
  26321. /**
  26322. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  26323. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  26324. * * xmin the ground minimum X coordinate, optional, default -1
  26325. * * zmin the ground minimum Z coordinate, optional, default -1
  26326. * * xmax the ground maximum X coordinate, optional, default 1
  26327. * * zmax the ground maximum Z coordinate, optional, default 1
  26328. * * 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}
  26329. * * 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}
  26330. * @returns the VertexData of the TiledGround
  26331. */
  26332. static CreateTiledGround(options: {
  26333. xmin: number;
  26334. zmin: number;
  26335. xmax: number;
  26336. zmax: number;
  26337. subdivisions?: {
  26338. w: number;
  26339. h: number;
  26340. };
  26341. precision?: {
  26342. w: number;
  26343. h: number;
  26344. };
  26345. }): VertexData;
  26346. /**
  26347. * Creates the VertexData of the Ground designed from a heightmap
  26348. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  26349. * * width the width (x direction) of the ground
  26350. * * height the height (z direction) of the ground
  26351. * * subdivisions the number of subdivisions per side
  26352. * * minHeight the minimum altitude on the ground, optional, default 0
  26353. * * maxHeight the maximum altitude on the ground, optional default 1
  26354. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  26355. * * buffer the array holding the image color data
  26356. * * bufferWidth the width of image
  26357. * * bufferHeight the height of image
  26358. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  26359. * @returns the VertexData of the Ground designed from a heightmap
  26360. */
  26361. static CreateGroundFromHeightMap(options: {
  26362. width: number;
  26363. height: number;
  26364. subdivisions: number;
  26365. minHeight: number;
  26366. maxHeight: number;
  26367. colorFilter: Color3;
  26368. buffer: Uint8Array;
  26369. bufferWidth: number;
  26370. bufferHeight: number;
  26371. alphaFilter: number;
  26372. }): VertexData;
  26373. /**
  26374. * Creates the VertexData for a Plane
  26375. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  26376. * * size sets the width and height of the plane to the value of size, optional default 1
  26377. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  26378. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  26379. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26380. * * 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)
  26381. * * 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)
  26382. * @returns the VertexData of the box
  26383. */
  26384. static CreatePlane(options: {
  26385. size?: number;
  26386. width?: number;
  26387. height?: number;
  26388. sideOrientation?: number;
  26389. frontUVs?: Vector4;
  26390. backUVs?: Vector4;
  26391. }): VertexData;
  26392. /**
  26393. * Creates the VertexData of the Disc or regular Polygon
  26394. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  26395. * * radius the radius of the disc, optional default 0.5
  26396. * * tessellation the number of polygon sides, optional, default 64
  26397. * * 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
  26398. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26399. * * 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)
  26400. * * 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)
  26401. * @returns the VertexData of the box
  26402. */
  26403. static CreateDisc(options: {
  26404. radius?: number;
  26405. tessellation?: number;
  26406. arc?: number;
  26407. sideOrientation?: number;
  26408. frontUVs?: Vector4;
  26409. backUVs?: Vector4;
  26410. }): VertexData;
  26411. /**
  26412. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  26413. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  26414. * @param polygon a mesh built from polygonTriangulation.build()
  26415. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26416. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26417. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26418. * @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)
  26419. * @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)
  26420. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  26421. * @returns the VertexData of the Polygon
  26422. */
  26423. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  26424. /**
  26425. * Creates the VertexData of the IcoSphere
  26426. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  26427. * * radius the radius of the IcoSphere, optional default 1
  26428. * * radiusX allows stretching in the x direction, optional, default radius
  26429. * * radiusY allows stretching in the y direction, optional, default radius
  26430. * * radiusZ allows stretching in the z direction, optional, default radius
  26431. * * flat when true creates a flat shaded mesh, optional, default true
  26432. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26433. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26434. * * 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)
  26435. * * 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)
  26436. * @returns the VertexData of the IcoSphere
  26437. */
  26438. static CreateIcoSphere(options: {
  26439. radius?: number;
  26440. radiusX?: number;
  26441. radiusY?: number;
  26442. radiusZ?: number;
  26443. flat?: boolean;
  26444. subdivisions?: number;
  26445. sideOrientation?: number;
  26446. frontUVs?: Vector4;
  26447. backUVs?: Vector4;
  26448. }): VertexData;
  26449. /**
  26450. * Creates the VertexData for a Polyhedron
  26451. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  26452. * * type provided types are:
  26453. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  26454. * * 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)
  26455. * * size the size of the IcoSphere, optional default 1
  26456. * * sizeX allows stretching in the x direction, optional, default size
  26457. * * sizeY allows stretching in the y direction, optional, default size
  26458. * * sizeZ allows stretching in the z direction, optional, default size
  26459. * * 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
  26460. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  26461. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  26462. * * flat when true creates a flat shaded mesh, optional, default true
  26463. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  26464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26465. * * 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)
  26466. * * 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)
  26467. * @returns the VertexData of the Polyhedron
  26468. */
  26469. static CreatePolyhedron(options: {
  26470. type?: number;
  26471. size?: number;
  26472. sizeX?: number;
  26473. sizeY?: number;
  26474. sizeZ?: number;
  26475. custom?: any;
  26476. faceUV?: Vector4[];
  26477. faceColors?: Color4[];
  26478. flat?: boolean;
  26479. sideOrientation?: number;
  26480. frontUVs?: Vector4;
  26481. backUVs?: Vector4;
  26482. }): VertexData;
  26483. /**
  26484. * Creates the VertexData for a TorusKnot
  26485. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  26486. * * radius the radius of the torus knot, optional, default 2
  26487. * * tube the thickness of the tube, optional, default 0.5
  26488. * * radialSegments the number of sides on each tube segments, optional, default 32
  26489. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  26490. * * p the number of windings around the z axis, optional, default 2
  26491. * * q the number of windings around the x axis, optional, default 3
  26492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26493. * * 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)
  26494. * * 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)
  26495. * @returns the VertexData of the Torus Knot
  26496. */
  26497. static CreateTorusKnot(options: {
  26498. radius?: number;
  26499. tube?: number;
  26500. radialSegments?: number;
  26501. tubularSegments?: number;
  26502. p?: number;
  26503. q?: number;
  26504. sideOrientation?: number;
  26505. frontUVs?: Vector4;
  26506. backUVs?: Vector4;
  26507. }): VertexData;
  26508. /**
  26509. * Compute normals for given positions and indices
  26510. * @param positions an array of vertex positions, [...., x, y, z, ......]
  26511. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  26512. * @param normals an array of vertex normals, [...., x, y, z, ......]
  26513. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  26514. * * facetNormals : optional array of facet normals (vector3)
  26515. * * facetPositions : optional array of facet positions (vector3)
  26516. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  26517. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  26518. * * bInfo : optional bounding info, required for facetPartitioning computation
  26519. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  26520. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  26521. * * useRightHandedSystem: optional boolean to for right handed system computation
  26522. * * depthSort : optional boolean to enable the facet depth sort computation
  26523. * * distanceTo : optional Vector3 to compute the facet depth from this location
  26524. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  26525. */
  26526. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  26527. facetNormals?: any;
  26528. facetPositions?: any;
  26529. facetPartitioning?: any;
  26530. ratio?: number;
  26531. bInfo?: any;
  26532. bbSize?: Vector3;
  26533. subDiv?: any;
  26534. useRightHandedSystem?: boolean;
  26535. depthSort?: boolean;
  26536. distanceTo?: Vector3;
  26537. depthSortedFacets?: any;
  26538. }): void;
  26539. /** @hidden */
  26540. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  26541. /**
  26542. * Applies VertexData created from the imported parameters to the geometry
  26543. * @param parsedVertexData the parsed data from an imported file
  26544. * @param geometry the geometry to apply the VertexData to
  26545. */
  26546. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  26547. }
  26548. }
  26549. declare module "babylonjs/Morph/morphTarget" {
  26550. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  26551. import { Observable } from "babylonjs/Misc/observable";
  26552. import { Nullable, FloatArray } from "babylonjs/types";
  26553. import { Scene } from "babylonjs/scene";
  26554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26555. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  26556. /**
  26557. * Defines a target to use with MorphTargetManager
  26558. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26559. */
  26560. export class MorphTarget implements IAnimatable {
  26561. /** defines the name of the target */
  26562. name: string;
  26563. /**
  26564. * Gets or sets the list of animations
  26565. */
  26566. animations: import("babylonjs/Animations/animation").Animation[];
  26567. private _scene;
  26568. private _positions;
  26569. private _normals;
  26570. private _tangents;
  26571. private _uvs;
  26572. private _influence;
  26573. private _uniqueId;
  26574. /**
  26575. * Observable raised when the influence changes
  26576. */
  26577. onInfluenceChanged: Observable<boolean>;
  26578. /** @hidden */
  26579. _onDataLayoutChanged: Observable<void>;
  26580. /**
  26581. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  26582. */
  26583. get influence(): number;
  26584. set influence(influence: number);
  26585. /**
  26586. * Gets or sets the id of the morph Target
  26587. */
  26588. id: string;
  26589. private _animationPropertiesOverride;
  26590. /**
  26591. * Gets or sets the animation properties override
  26592. */
  26593. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  26594. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  26595. /**
  26596. * Creates a new MorphTarget
  26597. * @param name defines the name of the target
  26598. * @param influence defines the influence to use
  26599. * @param scene defines the scene the morphtarget belongs to
  26600. */
  26601. constructor(
  26602. /** defines the name of the target */
  26603. name: string, influence?: number, scene?: Nullable<Scene>);
  26604. /**
  26605. * Gets the unique ID of this manager
  26606. */
  26607. get uniqueId(): number;
  26608. /**
  26609. * Gets a boolean defining if the target contains position data
  26610. */
  26611. get hasPositions(): boolean;
  26612. /**
  26613. * Gets a boolean defining if the target contains normal data
  26614. */
  26615. get hasNormals(): boolean;
  26616. /**
  26617. * Gets a boolean defining if the target contains tangent data
  26618. */
  26619. get hasTangents(): boolean;
  26620. /**
  26621. * Gets a boolean defining if the target contains texture coordinates data
  26622. */
  26623. get hasUVs(): boolean;
  26624. /**
  26625. * Affects position data to this target
  26626. * @param data defines the position data to use
  26627. */
  26628. setPositions(data: Nullable<FloatArray>): void;
  26629. /**
  26630. * Gets the position data stored in this target
  26631. * @returns a FloatArray containing the position data (or null if not present)
  26632. */
  26633. getPositions(): Nullable<FloatArray>;
  26634. /**
  26635. * Affects normal data to this target
  26636. * @param data defines the normal data to use
  26637. */
  26638. setNormals(data: Nullable<FloatArray>): void;
  26639. /**
  26640. * Gets the normal data stored in this target
  26641. * @returns a FloatArray containing the normal data (or null if not present)
  26642. */
  26643. getNormals(): Nullable<FloatArray>;
  26644. /**
  26645. * Affects tangent data to this target
  26646. * @param data defines the tangent data to use
  26647. */
  26648. setTangents(data: Nullable<FloatArray>): void;
  26649. /**
  26650. * Gets the tangent data stored in this target
  26651. * @returns a FloatArray containing the tangent data (or null if not present)
  26652. */
  26653. getTangents(): Nullable<FloatArray>;
  26654. /**
  26655. * Affects texture coordinates data to this target
  26656. * @param data defines the texture coordinates data to use
  26657. */
  26658. setUVs(data: Nullable<FloatArray>): void;
  26659. /**
  26660. * Gets the texture coordinates data stored in this target
  26661. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  26662. */
  26663. getUVs(): Nullable<FloatArray>;
  26664. /**
  26665. * Clone the current target
  26666. * @returns a new MorphTarget
  26667. */
  26668. clone(): MorphTarget;
  26669. /**
  26670. * Serializes the current target into a Serialization object
  26671. * @returns the serialized object
  26672. */
  26673. serialize(): any;
  26674. /**
  26675. * Returns the string "MorphTarget"
  26676. * @returns "MorphTarget"
  26677. */
  26678. getClassName(): string;
  26679. /**
  26680. * Creates a new target from serialized data
  26681. * @param serializationObject defines the serialized data to use
  26682. * @returns a new MorphTarget
  26683. */
  26684. static Parse(serializationObject: any): MorphTarget;
  26685. /**
  26686. * Creates a MorphTarget from mesh data
  26687. * @param mesh defines the source mesh
  26688. * @param name defines the name to use for the new target
  26689. * @param influence defines the influence to attach to the target
  26690. * @returns a new MorphTarget
  26691. */
  26692. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  26693. }
  26694. }
  26695. declare module "babylonjs/Morph/morphTargetManager" {
  26696. import { Nullable } from "babylonjs/types";
  26697. import { Scene } from "babylonjs/scene";
  26698. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  26699. /**
  26700. * This class is used to deform meshes using morphing between different targets
  26701. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  26702. */
  26703. export class MorphTargetManager {
  26704. private _targets;
  26705. private _targetInfluenceChangedObservers;
  26706. private _targetDataLayoutChangedObservers;
  26707. private _activeTargets;
  26708. private _scene;
  26709. private _influences;
  26710. private _supportsNormals;
  26711. private _supportsTangents;
  26712. private _supportsUVs;
  26713. private _vertexCount;
  26714. private _uniqueId;
  26715. private _tempInfluences;
  26716. /**
  26717. * Gets or sets a boolean indicating if normals must be morphed
  26718. */
  26719. enableNormalMorphing: boolean;
  26720. /**
  26721. * Gets or sets a boolean indicating if tangents must be morphed
  26722. */
  26723. enableTangentMorphing: boolean;
  26724. /**
  26725. * Gets or sets a boolean indicating if UV must be morphed
  26726. */
  26727. enableUVMorphing: boolean;
  26728. /**
  26729. * Creates a new MorphTargetManager
  26730. * @param scene defines the current scene
  26731. */
  26732. constructor(scene?: Nullable<Scene>);
  26733. /**
  26734. * Gets the unique ID of this manager
  26735. */
  26736. get uniqueId(): number;
  26737. /**
  26738. * Gets the number of vertices handled by this manager
  26739. */
  26740. get vertexCount(): number;
  26741. /**
  26742. * Gets a boolean indicating if this manager supports morphing of normals
  26743. */
  26744. get supportsNormals(): boolean;
  26745. /**
  26746. * Gets a boolean indicating if this manager supports morphing of tangents
  26747. */
  26748. get supportsTangents(): boolean;
  26749. /**
  26750. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  26751. */
  26752. get supportsUVs(): boolean;
  26753. /**
  26754. * Gets the number of targets stored in this manager
  26755. */
  26756. get numTargets(): number;
  26757. /**
  26758. * Gets the number of influencers (ie. the number of targets with influences > 0)
  26759. */
  26760. get numInfluencers(): number;
  26761. /**
  26762. * Gets the list of influences (one per target)
  26763. */
  26764. get influences(): Float32Array;
  26765. /**
  26766. * Gets the active target at specified index. An active target is a target with an influence > 0
  26767. * @param index defines the index to check
  26768. * @returns the requested target
  26769. */
  26770. getActiveTarget(index: number): MorphTarget;
  26771. /**
  26772. * Gets the target at specified index
  26773. * @param index defines the index to check
  26774. * @returns the requested target
  26775. */
  26776. getTarget(index: number): MorphTarget;
  26777. /**
  26778. * Add a new target to this manager
  26779. * @param target defines the target to add
  26780. */
  26781. addTarget(target: MorphTarget): void;
  26782. /**
  26783. * Removes a target from the manager
  26784. * @param target defines the target to remove
  26785. */
  26786. removeTarget(target: MorphTarget): void;
  26787. /**
  26788. * Clone the current manager
  26789. * @returns a new MorphTargetManager
  26790. */
  26791. clone(): MorphTargetManager;
  26792. /**
  26793. * Serializes the current manager into a Serialization object
  26794. * @returns the serialized object
  26795. */
  26796. serialize(): any;
  26797. private _syncActiveTargets;
  26798. /**
  26799. * Syncrhonize the targets with all the meshes using this morph target manager
  26800. */
  26801. synchronize(): void;
  26802. /**
  26803. * Creates a new MorphTargetManager from serialized data
  26804. * @param serializationObject defines the serialized data
  26805. * @param scene defines the hosting scene
  26806. * @returns the new MorphTargetManager
  26807. */
  26808. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  26809. }
  26810. }
  26811. declare module "babylonjs/Meshes/meshLODLevel" {
  26812. import { Mesh } from "babylonjs/Meshes/mesh";
  26813. import { Nullable } from "babylonjs/types";
  26814. /**
  26815. * Class used to represent a specific level of detail of a mesh
  26816. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  26817. */
  26818. export class MeshLODLevel {
  26819. /** Defines the distance where this level should start being displayed */
  26820. distance: number;
  26821. /** Defines the mesh to use to render this level */
  26822. mesh: Nullable<Mesh>;
  26823. /**
  26824. * Creates a new LOD level
  26825. * @param distance defines the distance where this level should star being displayed
  26826. * @param mesh defines the mesh to use to render this level
  26827. */
  26828. constructor(
  26829. /** Defines the distance where this level should start being displayed */
  26830. distance: number,
  26831. /** Defines the mesh to use to render this level */
  26832. mesh: Nullable<Mesh>);
  26833. }
  26834. }
  26835. declare module "babylonjs/Misc/canvasGenerator" {
  26836. /**
  26837. * Helper class used to generate a canvas to manipulate images
  26838. */
  26839. export class CanvasGenerator {
  26840. /**
  26841. * Create a new canvas (or offscreen canvas depending on the context)
  26842. * @param width defines the expected width
  26843. * @param height defines the expected height
  26844. * @return a new canvas or offscreen canvas
  26845. */
  26846. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  26847. }
  26848. }
  26849. declare module "babylonjs/Meshes/groundMesh" {
  26850. import { Scene } from "babylonjs/scene";
  26851. import { Vector3 } from "babylonjs/Maths/math.vector";
  26852. import { Mesh } from "babylonjs/Meshes/mesh";
  26853. /**
  26854. * Mesh representing the gorund
  26855. */
  26856. export class GroundMesh extends Mesh {
  26857. /** If octree should be generated */
  26858. generateOctree: boolean;
  26859. private _heightQuads;
  26860. /** @hidden */
  26861. _subdivisionsX: number;
  26862. /** @hidden */
  26863. _subdivisionsY: number;
  26864. /** @hidden */
  26865. _width: number;
  26866. /** @hidden */
  26867. _height: number;
  26868. /** @hidden */
  26869. _minX: number;
  26870. /** @hidden */
  26871. _maxX: number;
  26872. /** @hidden */
  26873. _minZ: number;
  26874. /** @hidden */
  26875. _maxZ: number;
  26876. constructor(name: string, scene: Scene);
  26877. /**
  26878. * "GroundMesh"
  26879. * @returns "GroundMesh"
  26880. */
  26881. getClassName(): string;
  26882. /**
  26883. * The minimum of x and y subdivisions
  26884. */
  26885. get subdivisions(): number;
  26886. /**
  26887. * X subdivisions
  26888. */
  26889. get subdivisionsX(): number;
  26890. /**
  26891. * Y subdivisions
  26892. */
  26893. get subdivisionsY(): number;
  26894. /**
  26895. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  26896. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  26897. * @param chunksCount the number of subdivisions for x and y
  26898. * @param octreeBlocksSize (Default: 32)
  26899. */
  26900. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  26901. /**
  26902. * Returns a height (y) value in the Worl system :
  26903. * the ground altitude at the coordinates (x, z) expressed in the World system.
  26904. * @param x x coordinate
  26905. * @param z z coordinate
  26906. * @returns the ground y position if (x, z) are outside the ground surface.
  26907. */
  26908. getHeightAtCoordinates(x: number, z: number): number;
  26909. /**
  26910. * Returns a normalized vector (Vector3) orthogonal to the ground
  26911. * at the ground coordinates (x, z) expressed in the World system.
  26912. * @param x x coordinate
  26913. * @param z z coordinate
  26914. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  26915. */
  26916. getNormalAtCoordinates(x: number, z: number): Vector3;
  26917. /**
  26918. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  26919. * at the ground coordinates (x, z) expressed in the World system.
  26920. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  26921. * @param x x coordinate
  26922. * @param z z coordinate
  26923. * @param ref vector to store the result
  26924. * @returns the GroundMesh.
  26925. */
  26926. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  26927. /**
  26928. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  26929. * if the ground has been updated.
  26930. * This can be used in the render loop.
  26931. * @returns the GroundMesh.
  26932. */
  26933. updateCoordinateHeights(): GroundMesh;
  26934. private _getFacetAt;
  26935. private _initHeightQuads;
  26936. private _computeHeightQuads;
  26937. /**
  26938. * Serializes this ground mesh
  26939. * @param serializationObject object to write serialization to
  26940. */
  26941. serialize(serializationObject: any): void;
  26942. /**
  26943. * Parses a serialized ground mesh
  26944. * @param parsedMesh the serialized mesh
  26945. * @param scene the scene to create the ground mesh in
  26946. * @returns the created ground mesh
  26947. */
  26948. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  26949. }
  26950. }
  26951. declare module "babylonjs/Physics/physicsJoint" {
  26952. import { Vector3 } from "babylonjs/Maths/math.vector";
  26953. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  26954. /**
  26955. * Interface for Physics-Joint data
  26956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26957. */
  26958. export interface PhysicsJointData {
  26959. /**
  26960. * The main pivot of the joint
  26961. */
  26962. mainPivot?: Vector3;
  26963. /**
  26964. * The connected pivot of the joint
  26965. */
  26966. connectedPivot?: Vector3;
  26967. /**
  26968. * The main axis of the joint
  26969. */
  26970. mainAxis?: Vector3;
  26971. /**
  26972. * The connected axis of the joint
  26973. */
  26974. connectedAxis?: Vector3;
  26975. /**
  26976. * The collision of the joint
  26977. */
  26978. collision?: boolean;
  26979. /**
  26980. * Native Oimo/Cannon/Energy data
  26981. */
  26982. nativeParams?: any;
  26983. }
  26984. /**
  26985. * This is a holder class for the physics joint created by the physics plugin
  26986. * It holds a set of functions to control the underlying joint
  26987. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  26988. */
  26989. export class PhysicsJoint {
  26990. /**
  26991. * The type of the physics joint
  26992. */
  26993. type: number;
  26994. /**
  26995. * The data for the physics joint
  26996. */
  26997. jointData: PhysicsJointData;
  26998. private _physicsJoint;
  26999. protected _physicsPlugin: IPhysicsEnginePlugin;
  27000. /**
  27001. * Initializes the physics joint
  27002. * @param type The type of the physics joint
  27003. * @param jointData The data for the physics joint
  27004. */
  27005. constructor(
  27006. /**
  27007. * The type of the physics joint
  27008. */
  27009. type: number,
  27010. /**
  27011. * The data for the physics joint
  27012. */
  27013. jointData: PhysicsJointData);
  27014. /**
  27015. * Gets the physics joint
  27016. */
  27017. get physicsJoint(): any;
  27018. /**
  27019. * Sets the physics joint
  27020. */
  27021. set physicsJoint(newJoint: any);
  27022. /**
  27023. * Sets the physics plugin
  27024. */
  27025. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  27026. /**
  27027. * Execute a function that is physics-plugin specific.
  27028. * @param {Function} func the function that will be executed.
  27029. * It accepts two parameters: the physics world and the physics joint
  27030. */
  27031. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  27032. /**
  27033. * Distance-Joint type
  27034. */
  27035. static DistanceJoint: number;
  27036. /**
  27037. * Hinge-Joint type
  27038. */
  27039. static HingeJoint: number;
  27040. /**
  27041. * Ball-and-Socket joint type
  27042. */
  27043. static BallAndSocketJoint: number;
  27044. /**
  27045. * Wheel-Joint type
  27046. */
  27047. static WheelJoint: number;
  27048. /**
  27049. * Slider-Joint type
  27050. */
  27051. static SliderJoint: number;
  27052. /**
  27053. * Prismatic-Joint type
  27054. */
  27055. static PrismaticJoint: number;
  27056. /**
  27057. * Universal-Joint type
  27058. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  27059. */
  27060. static UniversalJoint: number;
  27061. /**
  27062. * Hinge-Joint 2 type
  27063. */
  27064. static Hinge2Joint: number;
  27065. /**
  27066. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  27067. */
  27068. static PointToPointJoint: number;
  27069. /**
  27070. * Spring-Joint type
  27071. */
  27072. static SpringJoint: number;
  27073. /**
  27074. * Lock-Joint type
  27075. */
  27076. static LockJoint: number;
  27077. }
  27078. /**
  27079. * A class representing a physics distance joint
  27080. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27081. */
  27082. export class DistanceJoint extends PhysicsJoint {
  27083. /**
  27084. *
  27085. * @param jointData The data for the Distance-Joint
  27086. */
  27087. constructor(jointData: DistanceJointData);
  27088. /**
  27089. * Update the predefined distance.
  27090. * @param maxDistance The maximum preferred distance
  27091. * @param minDistance The minimum preferred distance
  27092. */
  27093. updateDistance(maxDistance: number, minDistance?: number): void;
  27094. }
  27095. /**
  27096. * Represents a Motor-Enabled Joint
  27097. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27098. */
  27099. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  27100. /**
  27101. * Initializes the Motor-Enabled Joint
  27102. * @param type The type of the joint
  27103. * @param jointData The physica joint data for the joint
  27104. */
  27105. constructor(type: number, jointData: PhysicsJointData);
  27106. /**
  27107. * Set the motor values.
  27108. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27109. * @param force the force to apply
  27110. * @param maxForce max force for this motor.
  27111. */
  27112. setMotor(force?: number, maxForce?: number): void;
  27113. /**
  27114. * Set the motor's limits.
  27115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27116. * @param upperLimit The upper limit of the motor
  27117. * @param lowerLimit The lower limit of the motor
  27118. */
  27119. setLimit(upperLimit: number, lowerLimit?: number): void;
  27120. }
  27121. /**
  27122. * This class represents a single physics Hinge-Joint
  27123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27124. */
  27125. export class HingeJoint extends MotorEnabledJoint {
  27126. /**
  27127. * Initializes the Hinge-Joint
  27128. * @param jointData The joint data for the Hinge-Joint
  27129. */
  27130. constructor(jointData: PhysicsJointData);
  27131. /**
  27132. * Set the motor values.
  27133. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27134. * @param {number} force the force to apply
  27135. * @param {number} maxForce max force for this motor.
  27136. */
  27137. setMotor(force?: number, maxForce?: number): void;
  27138. /**
  27139. * Set the motor's limits.
  27140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27141. * @param upperLimit The upper limit of the motor
  27142. * @param lowerLimit The lower limit of the motor
  27143. */
  27144. setLimit(upperLimit: number, lowerLimit?: number): void;
  27145. }
  27146. /**
  27147. * This class represents a dual hinge physics joint (same as wheel joint)
  27148. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27149. */
  27150. export class Hinge2Joint extends MotorEnabledJoint {
  27151. /**
  27152. * Initializes the Hinge2-Joint
  27153. * @param jointData The joint data for the Hinge2-Joint
  27154. */
  27155. constructor(jointData: PhysicsJointData);
  27156. /**
  27157. * Set the motor values.
  27158. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27159. * @param {number} targetSpeed the speed the motor is to reach
  27160. * @param {number} maxForce max force for this motor.
  27161. * @param {motorIndex} the motor's index, 0 or 1.
  27162. */
  27163. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  27164. /**
  27165. * Set the motor limits.
  27166. * Attention, this function is plugin specific. Engines won't react 100% the same.
  27167. * @param {number} upperLimit the upper limit
  27168. * @param {number} lowerLimit lower limit
  27169. * @param {motorIndex} the motor's index, 0 or 1.
  27170. */
  27171. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27172. }
  27173. /**
  27174. * Interface for a motor enabled joint
  27175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27176. */
  27177. export interface IMotorEnabledJoint {
  27178. /**
  27179. * Physics joint
  27180. */
  27181. physicsJoint: any;
  27182. /**
  27183. * Sets the motor of the motor-enabled joint
  27184. * @param force The force of the motor
  27185. * @param maxForce The maximum force of the motor
  27186. * @param motorIndex The index of the motor
  27187. */
  27188. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  27189. /**
  27190. * Sets the limit of the motor
  27191. * @param upperLimit The upper limit of the motor
  27192. * @param lowerLimit The lower limit of the motor
  27193. * @param motorIndex The index of the motor
  27194. */
  27195. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27196. }
  27197. /**
  27198. * Joint data for a Distance-Joint
  27199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27200. */
  27201. export interface DistanceJointData extends PhysicsJointData {
  27202. /**
  27203. * Max distance the 2 joint objects can be apart
  27204. */
  27205. maxDistance: number;
  27206. }
  27207. /**
  27208. * Joint data from a spring joint
  27209. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27210. */
  27211. export interface SpringJointData extends PhysicsJointData {
  27212. /**
  27213. * Length of the spring
  27214. */
  27215. length: number;
  27216. /**
  27217. * Stiffness of the spring
  27218. */
  27219. stiffness: number;
  27220. /**
  27221. * Damping of the spring
  27222. */
  27223. damping: number;
  27224. /** this callback will be called when applying the force to the impostors. */
  27225. forceApplicationCallback: () => void;
  27226. }
  27227. }
  27228. declare module "babylonjs/Physics/physicsRaycastResult" {
  27229. import { Vector3 } from "babylonjs/Maths/math.vector";
  27230. /**
  27231. * Holds the data for the raycast result
  27232. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27233. */
  27234. export class PhysicsRaycastResult {
  27235. private _hasHit;
  27236. private _hitDistance;
  27237. private _hitNormalWorld;
  27238. private _hitPointWorld;
  27239. private _rayFromWorld;
  27240. private _rayToWorld;
  27241. /**
  27242. * Gets if there was a hit
  27243. */
  27244. get hasHit(): boolean;
  27245. /**
  27246. * Gets the distance from the hit
  27247. */
  27248. get hitDistance(): number;
  27249. /**
  27250. * Gets the hit normal/direction in the world
  27251. */
  27252. get hitNormalWorld(): Vector3;
  27253. /**
  27254. * Gets the hit point in the world
  27255. */
  27256. get hitPointWorld(): Vector3;
  27257. /**
  27258. * Gets the ray "start point" of the ray in the world
  27259. */
  27260. get rayFromWorld(): Vector3;
  27261. /**
  27262. * Gets the ray "end point" of the ray in the world
  27263. */
  27264. get rayToWorld(): Vector3;
  27265. /**
  27266. * Sets the hit data (normal & point in world space)
  27267. * @param hitNormalWorld defines the normal in world space
  27268. * @param hitPointWorld defines the point in world space
  27269. */
  27270. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  27271. /**
  27272. * Sets the distance from the start point to the hit point
  27273. * @param distance
  27274. */
  27275. setHitDistance(distance: number): void;
  27276. /**
  27277. * Calculates the distance manually
  27278. */
  27279. calculateHitDistance(): void;
  27280. /**
  27281. * Resets all the values to default
  27282. * @param from The from point on world space
  27283. * @param to The to point on world space
  27284. */
  27285. reset(from?: Vector3, to?: Vector3): void;
  27286. }
  27287. /**
  27288. * Interface for the size containing width and height
  27289. */
  27290. interface IXYZ {
  27291. /**
  27292. * X
  27293. */
  27294. x: number;
  27295. /**
  27296. * Y
  27297. */
  27298. y: number;
  27299. /**
  27300. * Z
  27301. */
  27302. z: number;
  27303. }
  27304. }
  27305. declare module "babylonjs/Physics/IPhysicsEngine" {
  27306. import { Nullable } from "babylonjs/types";
  27307. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  27308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27309. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  27310. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  27311. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  27312. /**
  27313. * Interface used to describe a physics joint
  27314. */
  27315. export interface PhysicsImpostorJoint {
  27316. /** Defines the main impostor to which the joint is linked */
  27317. mainImpostor: PhysicsImpostor;
  27318. /** Defines the impostor that is connected to the main impostor using this joint */
  27319. connectedImpostor: PhysicsImpostor;
  27320. /** Defines the joint itself */
  27321. joint: PhysicsJoint;
  27322. }
  27323. /** @hidden */
  27324. export interface IPhysicsEnginePlugin {
  27325. world: any;
  27326. name: string;
  27327. setGravity(gravity: Vector3): void;
  27328. setTimeStep(timeStep: number): void;
  27329. getTimeStep(): number;
  27330. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  27331. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27332. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  27333. generatePhysicsBody(impostor: PhysicsImpostor): void;
  27334. removePhysicsBody(impostor: PhysicsImpostor): void;
  27335. generateJoint(joint: PhysicsImpostorJoint): void;
  27336. removeJoint(joint: PhysicsImpostorJoint): void;
  27337. isSupported(): boolean;
  27338. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  27339. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  27340. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27341. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  27342. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27343. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  27344. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  27345. getBodyMass(impostor: PhysicsImpostor): number;
  27346. getBodyFriction(impostor: PhysicsImpostor): number;
  27347. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  27348. getBodyRestitution(impostor: PhysicsImpostor): number;
  27349. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  27350. getBodyPressure?(impostor: PhysicsImpostor): number;
  27351. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  27352. getBodyStiffness?(impostor: PhysicsImpostor): number;
  27353. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  27354. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  27355. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  27356. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  27357. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  27358. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27359. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  27360. sleepBody(impostor: PhysicsImpostor): void;
  27361. wakeUpBody(impostor: PhysicsImpostor): void;
  27362. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27363. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  27364. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  27365. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  27366. getRadius(impostor: PhysicsImpostor): number;
  27367. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  27368. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  27369. dispose(): void;
  27370. }
  27371. /**
  27372. * Interface used to define a physics engine
  27373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27374. */
  27375. export interface IPhysicsEngine {
  27376. /**
  27377. * Gets the gravity vector used by the simulation
  27378. */
  27379. gravity: Vector3;
  27380. /**
  27381. * Sets the gravity vector used by the simulation
  27382. * @param gravity defines the gravity vector to use
  27383. */
  27384. setGravity(gravity: Vector3): void;
  27385. /**
  27386. * Set the time step of the physics engine.
  27387. * Default is 1/60.
  27388. * To slow it down, enter 1/600 for example.
  27389. * To speed it up, 1/30
  27390. * @param newTimeStep the new timestep to apply to this world.
  27391. */
  27392. setTimeStep(newTimeStep: number): void;
  27393. /**
  27394. * Get the time step of the physics engine.
  27395. * @returns the current time step
  27396. */
  27397. getTimeStep(): number;
  27398. /**
  27399. * Set the sub time step of the physics engine.
  27400. * Default is 0 meaning there is no sub steps
  27401. * To increase physics resolution precision, set a small value (like 1 ms)
  27402. * @param subTimeStep defines the new sub timestep used for physics resolution.
  27403. */
  27404. setSubTimeStep(subTimeStep: number): void;
  27405. /**
  27406. * Get the sub time step of the physics engine.
  27407. * @returns the current sub time step
  27408. */
  27409. getSubTimeStep(): number;
  27410. /**
  27411. * Release all resources
  27412. */
  27413. dispose(): void;
  27414. /**
  27415. * Gets the name of the current physics plugin
  27416. * @returns the name of the plugin
  27417. */
  27418. getPhysicsPluginName(): string;
  27419. /**
  27420. * Adding a new impostor for the impostor tracking.
  27421. * This will be done by the impostor itself.
  27422. * @param impostor the impostor to add
  27423. */
  27424. addImpostor(impostor: PhysicsImpostor): void;
  27425. /**
  27426. * Remove an impostor from the engine.
  27427. * This impostor and its mesh will not longer be updated by the physics engine.
  27428. * @param impostor the impostor to remove
  27429. */
  27430. removeImpostor(impostor: PhysicsImpostor): void;
  27431. /**
  27432. * Add a joint to the physics engine
  27433. * @param mainImpostor defines the main impostor to which the joint is added.
  27434. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  27435. * @param joint defines the joint that will connect both impostors.
  27436. */
  27437. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27438. /**
  27439. * Removes a joint from the simulation
  27440. * @param mainImpostor defines the impostor used with the joint
  27441. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  27442. * @param joint defines the joint to remove
  27443. */
  27444. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  27445. /**
  27446. * Gets the current plugin used to run the simulation
  27447. * @returns current plugin
  27448. */
  27449. getPhysicsPlugin(): IPhysicsEnginePlugin;
  27450. /**
  27451. * Gets the list of physic impostors
  27452. * @returns an array of PhysicsImpostor
  27453. */
  27454. getImpostors(): Array<PhysicsImpostor>;
  27455. /**
  27456. * Gets the impostor for a physics enabled object
  27457. * @param object defines the object impersonated by the impostor
  27458. * @returns the PhysicsImpostor or null if not found
  27459. */
  27460. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  27461. /**
  27462. * Gets the impostor for a physics body object
  27463. * @param body defines physics body used by the impostor
  27464. * @returns the PhysicsImpostor or null if not found
  27465. */
  27466. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  27467. /**
  27468. * Does a raycast in the physics world
  27469. * @param from when should the ray start?
  27470. * @param to when should the ray end?
  27471. * @returns PhysicsRaycastResult
  27472. */
  27473. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  27474. /**
  27475. * Called by the scene. No need to call it.
  27476. * @param delta defines the timespam between frames
  27477. */
  27478. _step(delta: number): void;
  27479. }
  27480. }
  27481. declare module "babylonjs/Physics/physicsImpostor" {
  27482. import { Nullable, IndicesArray } from "babylonjs/types";
  27483. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  27484. import { TransformNode } from "babylonjs/Meshes/transformNode";
  27485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27486. import { Scene } from "babylonjs/scene";
  27487. import { Bone } from "babylonjs/Bones/bone";
  27488. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  27489. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  27490. import { Space } from "babylonjs/Maths/math.axis";
  27491. /**
  27492. * The interface for the physics imposter parameters
  27493. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27494. */
  27495. export interface PhysicsImpostorParameters {
  27496. /**
  27497. * The mass of the physics imposter
  27498. */
  27499. mass: number;
  27500. /**
  27501. * The friction of the physics imposter
  27502. */
  27503. friction?: number;
  27504. /**
  27505. * The coefficient of restitution of the physics imposter
  27506. */
  27507. restitution?: number;
  27508. /**
  27509. * The native options of the physics imposter
  27510. */
  27511. nativeOptions?: any;
  27512. /**
  27513. * Specifies if the parent should be ignored
  27514. */
  27515. ignoreParent?: boolean;
  27516. /**
  27517. * Specifies if bi-directional transformations should be disabled
  27518. */
  27519. disableBidirectionalTransformation?: boolean;
  27520. /**
  27521. * The pressure inside the physics imposter, soft object only
  27522. */
  27523. pressure?: number;
  27524. /**
  27525. * The stiffness the physics imposter, soft object only
  27526. */
  27527. stiffness?: number;
  27528. /**
  27529. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  27530. */
  27531. velocityIterations?: number;
  27532. /**
  27533. * The number of iterations used in maintaining consistent vertex positions, soft object only
  27534. */
  27535. positionIterations?: number;
  27536. /**
  27537. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  27538. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  27539. * Add to fix multiple points
  27540. */
  27541. fixedPoints?: number;
  27542. /**
  27543. * The collision margin around a soft object
  27544. */
  27545. margin?: number;
  27546. /**
  27547. * The collision margin around a soft object
  27548. */
  27549. damping?: number;
  27550. /**
  27551. * The path for a rope based on an extrusion
  27552. */
  27553. path?: any;
  27554. /**
  27555. * The shape of an extrusion used for a rope based on an extrusion
  27556. */
  27557. shape?: any;
  27558. }
  27559. /**
  27560. * Interface for a physics-enabled object
  27561. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27562. */
  27563. export interface IPhysicsEnabledObject {
  27564. /**
  27565. * The position of the physics-enabled object
  27566. */
  27567. position: Vector3;
  27568. /**
  27569. * The rotation of the physics-enabled object
  27570. */
  27571. rotationQuaternion: Nullable<Quaternion>;
  27572. /**
  27573. * The scale of the physics-enabled object
  27574. */
  27575. scaling: Vector3;
  27576. /**
  27577. * The rotation of the physics-enabled object
  27578. */
  27579. rotation?: Vector3;
  27580. /**
  27581. * The parent of the physics-enabled object
  27582. */
  27583. parent?: any;
  27584. /**
  27585. * The bounding info of the physics-enabled object
  27586. * @returns The bounding info of the physics-enabled object
  27587. */
  27588. getBoundingInfo(): BoundingInfo;
  27589. /**
  27590. * Computes the world matrix
  27591. * @param force Specifies if the world matrix should be computed by force
  27592. * @returns A world matrix
  27593. */
  27594. computeWorldMatrix(force: boolean): Matrix;
  27595. /**
  27596. * Gets the world matrix
  27597. * @returns A world matrix
  27598. */
  27599. getWorldMatrix?(): Matrix;
  27600. /**
  27601. * Gets the child meshes
  27602. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  27603. * @returns An array of abstract meshes
  27604. */
  27605. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  27606. /**
  27607. * Gets the vertex data
  27608. * @param kind The type of vertex data
  27609. * @returns A nullable array of numbers, or a float32 array
  27610. */
  27611. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  27612. /**
  27613. * Gets the indices from the mesh
  27614. * @returns A nullable array of index arrays
  27615. */
  27616. getIndices?(): Nullable<IndicesArray>;
  27617. /**
  27618. * Gets the scene from the mesh
  27619. * @returns the indices array or null
  27620. */
  27621. getScene?(): Scene;
  27622. /**
  27623. * Gets the absolute position from the mesh
  27624. * @returns the absolute position
  27625. */
  27626. getAbsolutePosition(): Vector3;
  27627. /**
  27628. * Gets the absolute pivot point from the mesh
  27629. * @returns the absolute pivot point
  27630. */
  27631. getAbsolutePivotPoint(): Vector3;
  27632. /**
  27633. * Rotates the mesh
  27634. * @param axis The axis of rotation
  27635. * @param amount The amount of rotation
  27636. * @param space The space of the rotation
  27637. * @returns The rotation transform node
  27638. */
  27639. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  27640. /**
  27641. * Translates the mesh
  27642. * @param axis The axis of translation
  27643. * @param distance The distance of translation
  27644. * @param space The space of the translation
  27645. * @returns The transform node
  27646. */
  27647. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  27648. /**
  27649. * Sets the absolute position of the mesh
  27650. * @param absolutePosition The absolute position of the mesh
  27651. * @returns The transform node
  27652. */
  27653. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  27654. /**
  27655. * Gets the class name of the mesh
  27656. * @returns The class name
  27657. */
  27658. getClassName(): string;
  27659. }
  27660. /**
  27661. * Represents a physics imposter
  27662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27663. */
  27664. export class PhysicsImpostor {
  27665. /**
  27666. * The physics-enabled object used as the physics imposter
  27667. */
  27668. object: IPhysicsEnabledObject;
  27669. /**
  27670. * The type of the physics imposter
  27671. */
  27672. type: number;
  27673. private _options;
  27674. private _scene?;
  27675. /**
  27676. * The default object size of the imposter
  27677. */
  27678. static DEFAULT_OBJECT_SIZE: Vector3;
  27679. /**
  27680. * The identity quaternion of the imposter
  27681. */
  27682. static IDENTITY_QUATERNION: Quaternion;
  27683. /** @hidden */
  27684. _pluginData: any;
  27685. private _physicsEngine;
  27686. private _physicsBody;
  27687. private _bodyUpdateRequired;
  27688. private _onBeforePhysicsStepCallbacks;
  27689. private _onAfterPhysicsStepCallbacks;
  27690. /** @hidden */
  27691. _onPhysicsCollideCallbacks: Array<{
  27692. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  27693. otherImpostors: Array<PhysicsImpostor>;
  27694. }>;
  27695. private _deltaPosition;
  27696. private _deltaRotation;
  27697. private _deltaRotationConjugated;
  27698. /** @hidden */
  27699. _isFromLine: boolean;
  27700. private _parent;
  27701. private _isDisposed;
  27702. private static _tmpVecs;
  27703. private static _tmpQuat;
  27704. /**
  27705. * Specifies if the physics imposter is disposed
  27706. */
  27707. get isDisposed(): boolean;
  27708. /**
  27709. * Gets the mass of the physics imposter
  27710. */
  27711. get mass(): number;
  27712. set mass(value: number);
  27713. /**
  27714. * Gets the coefficient of friction
  27715. */
  27716. get friction(): number;
  27717. /**
  27718. * Sets the coefficient of friction
  27719. */
  27720. set friction(value: number);
  27721. /**
  27722. * Gets the coefficient of restitution
  27723. */
  27724. get restitution(): number;
  27725. /**
  27726. * Sets the coefficient of restitution
  27727. */
  27728. set restitution(value: number);
  27729. /**
  27730. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  27731. */
  27732. get pressure(): number;
  27733. /**
  27734. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  27735. */
  27736. set pressure(value: number);
  27737. /**
  27738. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27739. */
  27740. get stiffness(): number;
  27741. /**
  27742. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  27743. */
  27744. set stiffness(value: number);
  27745. /**
  27746. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27747. */
  27748. get velocityIterations(): number;
  27749. /**
  27750. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  27751. */
  27752. set velocityIterations(value: number);
  27753. /**
  27754. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27755. */
  27756. get positionIterations(): number;
  27757. /**
  27758. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  27759. */
  27760. set positionIterations(value: number);
  27761. /**
  27762. * The unique id of the physics imposter
  27763. * set by the physics engine when adding this impostor to the array
  27764. */
  27765. uniqueId: number;
  27766. /**
  27767. * @hidden
  27768. */
  27769. soft: boolean;
  27770. /**
  27771. * @hidden
  27772. */
  27773. segments: number;
  27774. private _joints;
  27775. /**
  27776. * Initializes the physics imposter
  27777. * @param object The physics-enabled object used as the physics imposter
  27778. * @param type The type of the physics imposter
  27779. * @param _options The options for the physics imposter
  27780. * @param _scene The Babylon scene
  27781. */
  27782. constructor(
  27783. /**
  27784. * The physics-enabled object used as the physics imposter
  27785. */
  27786. object: IPhysicsEnabledObject,
  27787. /**
  27788. * The type of the physics imposter
  27789. */
  27790. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  27791. /**
  27792. * This function will completly initialize this impostor.
  27793. * It will create a new body - but only if this mesh has no parent.
  27794. * If it has, this impostor will not be used other than to define the impostor
  27795. * of the child mesh.
  27796. * @hidden
  27797. */
  27798. _init(): void;
  27799. private _getPhysicsParent;
  27800. /**
  27801. * Should a new body be generated.
  27802. * @returns boolean specifying if body initialization is required
  27803. */
  27804. isBodyInitRequired(): boolean;
  27805. /**
  27806. * Sets the updated scaling
  27807. * @param updated Specifies if the scaling is updated
  27808. */
  27809. setScalingUpdated(): void;
  27810. /**
  27811. * Force a regeneration of this or the parent's impostor's body.
  27812. * Use under cautious - This will remove all joints already implemented.
  27813. */
  27814. forceUpdate(): void;
  27815. /**
  27816. * Gets the body that holds this impostor. Either its own, or its parent.
  27817. */
  27818. get physicsBody(): any;
  27819. /**
  27820. * Get the parent of the physics imposter
  27821. * @returns Physics imposter or null
  27822. */
  27823. get parent(): Nullable<PhysicsImpostor>;
  27824. /**
  27825. * Sets the parent of the physics imposter
  27826. */
  27827. set parent(value: Nullable<PhysicsImpostor>);
  27828. /**
  27829. * Set the physics body. Used mainly by the physics engine/plugin
  27830. */
  27831. set physicsBody(physicsBody: any);
  27832. /**
  27833. * Resets the update flags
  27834. */
  27835. resetUpdateFlags(): void;
  27836. /**
  27837. * Gets the object extend size
  27838. * @returns the object extend size
  27839. */
  27840. getObjectExtendSize(): Vector3;
  27841. /**
  27842. * Gets the object center
  27843. * @returns The object center
  27844. */
  27845. getObjectCenter(): Vector3;
  27846. /**
  27847. * Get a specific parameter from the options parameters
  27848. * @param paramName The object parameter name
  27849. * @returns The object parameter
  27850. */
  27851. getParam(paramName: string): any;
  27852. /**
  27853. * Sets a specific parameter in the options given to the physics plugin
  27854. * @param paramName The parameter name
  27855. * @param value The value of the parameter
  27856. */
  27857. setParam(paramName: string, value: number): void;
  27858. /**
  27859. * Specifically change the body's mass option. Won't recreate the physics body object
  27860. * @param mass The mass of the physics imposter
  27861. */
  27862. setMass(mass: number): void;
  27863. /**
  27864. * Gets the linear velocity
  27865. * @returns linear velocity or null
  27866. */
  27867. getLinearVelocity(): Nullable<Vector3>;
  27868. /**
  27869. * Sets the linear velocity
  27870. * @param velocity linear velocity or null
  27871. */
  27872. setLinearVelocity(velocity: Nullable<Vector3>): void;
  27873. /**
  27874. * Gets the angular velocity
  27875. * @returns angular velocity or null
  27876. */
  27877. getAngularVelocity(): Nullable<Vector3>;
  27878. /**
  27879. * Sets the angular velocity
  27880. * @param velocity The velocity or null
  27881. */
  27882. setAngularVelocity(velocity: Nullable<Vector3>): void;
  27883. /**
  27884. * Execute a function with the physics plugin native code
  27885. * Provide a function the will have two variables - the world object and the physics body object
  27886. * @param func The function to execute with the physics plugin native code
  27887. */
  27888. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  27889. /**
  27890. * Register a function that will be executed before the physics world is stepping forward
  27891. * @param func The function to execute before the physics world is stepped forward
  27892. */
  27893. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27894. /**
  27895. * Unregister a function that will be executed before the physics world is stepping forward
  27896. * @param func The function to execute before the physics world is stepped forward
  27897. */
  27898. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27899. /**
  27900. * Register a function that will be executed after the physics step
  27901. * @param func The function to execute after physics step
  27902. */
  27903. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27904. /**
  27905. * Unregisters a function that will be executed after the physics step
  27906. * @param func The function to execute after physics step
  27907. */
  27908. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  27909. /**
  27910. * register a function that will be executed when this impostor collides against a different body
  27911. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  27912. * @param func Callback that is executed on collision
  27913. */
  27914. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  27915. /**
  27916. * Unregisters the physics imposter on contact
  27917. * @param collideAgainst The physics object to collide against
  27918. * @param func Callback to execute on collision
  27919. */
  27920. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  27921. private _tmpQuat;
  27922. private _tmpQuat2;
  27923. /**
  27924. * Get the parent rotation
  27925. * @returns The parent rotation
  27926. */
  27927. getParentsRotation(): Quaternion;
  27928. /**
  27929. * this function is executed by the physics engine.
  27930. */
  27931. beforeStep: () => void;
  27932. /**
  27933. * this function is executed by the physics engine
  27934. */
  27935. afterStep: () => void;
  27936. /**
  27937. * Legacy collision detection event support
  27938. */
  27939. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  27940. /**
  27941. * event and body object due to cannon's event-based architecture.
  27942. */
  27943. onCollide: (e: {
  27944. body: any;
  27945. }) => void;
  27946. /**
  27947. * Apply a force
  27948. * @param force The force to apply
  27949. * @param contactPoint The contact point for the force
  27950. * @returns The physics imposter
  27951. */
  27952. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27953. /**
  27954. * Apply an impulse
  27955. * @param force The impulse force
  27956. * @param contactPoint The contact point for the impulse force
  27957. * @returns The physics imposter
  27958. */
  27959. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  27960. /**
  27961. * A help function to create a joint
  27962. * @param otherImpostor A physics imposter used to create a joint
  27963. * @param jointType The type of joint
  27964. * @param jointData The data for the joint
  27965. * @returns The physics imposter
  27966. */
  27967. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  27968. /**
  27969. * Add a joint to this impostor with a different impostor
  27970. * @param otherImpostor A physics imposter used to add a joint
  27971. * @param joint The joint to add
  27972. * @returns The physics imposter
  27973. */
  27974. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  27975. /**
  27976. * Add an anchor to a cloth impostor
  27977. * @param otherImpostor rigid impostor to anchor to
  27978. * @param width ratio across width from 0 to 1
  27979. * @param height ratio up height from 0 to 1
  27980. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  27981. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  27982. * @returns impostor the soft imposter
  27983. */
  27984. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27985. /**
  27986. * Add a hook to a rope impostor
  27987. * @param otherImpostor rigid impostor to anchor to
  27988. * @param length ratio across rope from 0 to 1
  27989. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  27990. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  27991. * @returns impostor the rope imposter
  27992. */
  27993. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  27994. /**
  27995. * Will keep this body still, in a sleep mode.
  27996. * @returns the physics imposter
  27997. */
  27998. sleep(): PhysicsImpostor;
  27999. /**
  28000. * Wake the body up.
  28001. * @returns The physics imposter
  28002. */
  28003. wakeUp(): PhysicsImpostor;
  28004. /**
  28005. * Clones the physics imposter
  28006. * @param newObject The physics imposter clones to this physics-enabled object
  28007. * @returns A nullable physics imposter
  28008. */
  28009. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28010. /**
  28011. * Disposes the physics imposter
  28012. */
  28013. dispose(): void;
  28014. /**
  28015. * Sets the delta position
  28016. * @param position The delta position amount
  28017. */
  28018. setDeltaPosition(position: Vector3): void;
  28019. /**
  28020. * Sets the delta rotation
  28021. * @param rotation The delta rotation amount
  28022. */
  28023. setDeltaRotation(rotation: Quaternion): void;
  28024. /**
  28025. * Gets the box size of the physics imposter and stores the result in the input parameter
  28026. * @param result Stores the box size
  28027. * @returns The physics imposter
  28028. */
  28029. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  28030. /**
  28031. * Gets the radius of the physics imposter
  28032. * @returns Radius of the physics imposter
  28033. */
  28034. getRadius(): number;
  28035. /**
  28036. * Sync a bone with this impostor
  28037. * @param bone The bone to sync to the impostor.
  28038. * @param boneMesh The mesh that the bone is influencing.
  28039. * @param jointPivot The pivot of the joint / bone in local space.
  28040. * @param distToJoint Optional distance from the impostor to the joint.
  28041. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28042. */
  28043. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  28044. /**
  28045. * Sync impostor to a bone
  28046. * @param bone The bone that the impostor will be synced to.
  28047. * @param boneMesh The mesh that the bone is influencing.
  28048. * @param jointPivot The pivot of the joint / bone in local space.
  28049. * @param distToJoint Optional distance from the impostor to the joint.
  28050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  28051. * @param boneAxis Optional vector3 axis the bone is aligned with
  28052. */
  28053. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  28054. /**
  28055. * No-Imposter type
  28056. */
  28057. static NoImpostor: number;
  28058. /**
  28059. * Sphere-Imposter type
  28060. */
  28061. static SphereImpostor: number;
  28062. /**
  28063. * Box-Imposter type
  28064. */
  28065. static BoxImpostor: number;
  28066. /**
  28067. * Plane-Imposter type
  28068. */
  28069. static PlaneImpostor: number;
  28070. /**
  28071. * Mesh-imposter type
  28072. */
  28073. static MeshImpostor: number;
  28074. /**
  28075. * Capsule-Impostor type (Ammo.js plugin only)
  28076. */
  28077. static CapsuleImpostor: number;
  28078. /**
  28079. * Cylinder-Imposter type
  28080. */
  28081. static CylinderImpostor: number;
  28082. /**
  28083. * Particle-Imposter type
  28084. */
  28085. static ParticleImpostor: number;
  28086. /**
  28087. * Heightmap-Imposter type
  28088. */
  28089. static HeightmapImpostor: number;
  28090. /**
  28091. * ConvexHull-Impostor type (Ammo.js plugin only)
  28092. */
  28093. static ConvexHullImpostor: number;
  28094. /**
  28095. * Custom-Imposter type (Ammo.js plugin only)
  28096. */
  28097. static CustomImpostor: number;
  28098. /**
  28099. * Rope-Imposter type
  28100. */
  28101. static RopeImpostor: number;
  28102. /**
  28103. * Cloth-Imposter type
  28104. */
  28105. static ClothImpostor: number;
  28106. /**
  28107. * Softbody-Imposter type
  28108. */
  28109. static SoftbodyImpostor: number;
  28110. }
  28111. }
  28112. declare module "babylonjs/Meshes/mesh" {
  28113. import { Observable } from "babylonjs/Misc/observable";
  28114. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28115. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  28116. import { Camera } from "babylonjs/Cameras/camera";
  28117. import { Scene } from "babylonjs/scene";
  28118. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  28119. import { Color4 } from "babylonjs/Maths/math.color";
  28120. import { Engine } from "babylonjs/Engines/engine";
  28121. import { Node } from "babylonjs/node";
  28122. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  28123. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28124. import { Buffer } from "babylonjs/Meshes/buffer";
  28125. import { Geometry } from "babylonjs/Meshes/geometry";
  28126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28127. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28128. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  28129. import { Effect } from "babylonjs/Materials/effect";
  28130. import { Material } from "babylonjs/Materials/material";
  28131. import { Skeleton } from "babylonjs/Bones/skeleton";
  28132. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  28133. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  28134. import { Path3D } from "babylonjs/Maths/math.path";
  28135. import { Plane } from "babylonjs/Maths/math.plane";
  28136. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28137. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  28138. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  28139. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  28140. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28141. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  28142. /**
  28143. * @hidden
  28144. **/
  28145. export class _CreationDataStorage {
  28146. closePath?: boolean;
  28147. closeArray?: boolean;
  28148. idx: number[];
  28149. dashSize: number;
  28150. gapSize: number;
  28151. path3D: Path3D;
  28152. pathArray: Vector3[][];
  28153. arc: number;
  28154. radius: number;
  28155. cap: number;
  28156. tessellation: number;
  28157. }
  28158. /**
  28159. * @hidden
  28160. **/
  28161. class _InstanceDataStorage {
  28162. visibleInstances: any;
  28163. batchCache: _InstancesBatch;
  28164. instancesBufferSize: number;
  28165. instancesBuffer: Nullable<Buffer>;
  28166. instancesData: Float32Array;
  28167. overridenInstanceCount: number;
  28168. isFrozen: boolean;
  28169. previousBatch: Nullable<_InstancesBatch>;
  28170. hardwareInstancedRendering: boolean;
  28171. sideOrientation: number;
  28172. manualUpdate: boolean;
  28173. }
  28174. /**
  28175. * @hidden
  28176. **/
  28177. export class _InstancesBatch {
  28178. mustReturn: boolean;
  28179. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  28180. renderSelf: boolean[];
  28181. hardwareInstancedRendering: boolean[];
  28182. }
  28183. /**
  28184. * @hidden
  28185. **/
  28186. class _ThinInstanceDataStorage {
  28187. instancesCount: number;
  28188. matrixBuffer: Nullable<Buffer>;
  28189. matrixBufferSize: number;
  28190. matrixData: Nullable<Float32Array>;
  28191. boundingVectors: Array<Vector3>;
  28192. }
  28193. /**
  28194. * Class used to represent renderable models
  28195. */
  28196. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  28197. /**
  28198. * Mesh side orientation : usually the external or front surface
  28199. */
  28200. static readonly FRONTSIDE: number;
  28201. /**
  28202. * Mesh side orientation : usually the internal or back surface
  28203. */
  28204. static readonly BACKSIDE: number;
  28205. /**
  28206. * Mesh side orientation : both internal and external or front and back surfaces
  28207. */
  28208. static readonly DOUBLESIDE: number;
  28209. /**
  28210. * Mesh side orientation : by default, `FRONTSIDE`
  28211. */
  28212. static readonly DEFAULTSIDE: number;
  28213. /**
  28214. * Mesh cap setting : no cap
  28215. */
  28216. static readonly NO_CAP: number;
  28217. /**
  28218. * Mesh cap setting : one cap at the beginning of the mesh
  28219. */
  28220. static readonly CAP_START: number;
  28221. /**
  28222. * Mesh cap setting : one cap at the end of the mesh
  28223. */
  28224. static readonly CAP_END: number;
  28225. /**
  28226. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  28227. */
  28228. static readonly CAP_ALL: number;
  28229. /**
  28230. * Mesh pattern setting : no flip or rotate
  28231. */
  28232. static readonly NO_FLIP: number;
  28233. /**
  28234. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  28235. */
  28236. static readonly FLIP_TILE: number;
  28237. /**
  28238. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  28239. */
  28240. static readonly ROTATE_TILE: number;
  28241. /**
  28242. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  28243. */
  28244. static readonly FLIP_ROW: number;
  28245. /**
  28246. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  28247. */
  28248. static readonly ROTATE_ROW: number;
  28249. /**
  28250. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  28251. */
  28252. static readonly FLIP_N_ROTATE_TILE: number;
  28253. /**
  28254. * Mesh pattern setting : rotate pattern and rotate
  28255. */
  28256. static readonly FLIP_N_ROTATE_ROW: number;
  28257. /**
  28258. * Mesh tile positioning : part tiles same on left/right or top/bottom
  28259. */
  28260. static readonly CENTER: number;
  28261. /**
  28262. * Mesh tile positioning : part tiles on left
  28263. */
  28264. static readonly LEFT: number;
  28265. /**
  28266. * Mesh tile positioning : part tiles on right
  28267. */
  28268. static readonly RIGHT: number;
  28269. /**
  28270. * Mesh tile positioning : part tiles on top
  28271. */
  28272. static readonly TOP: number;
  28273. /**
  28274. * Mesh tile positioning : part tiles on bottom
  28275. */
  28276. static readonly BOTTOM: number;
  28277. /**
  28278. * Gets the default side orientation.
  28279. * @param orientation the orientation to value to attempt to get
  28280. * @returns the default orientation
  28281. * @hidden
  28282. */
  28283. static _GetDefaultSideOrientation(orientation?: number): number;
  28284. private _internalMeshDataInfo;
  28285. /**
  28286. * An event triggered before rendering the mesh
  28287. */
  28288. get onBeforeRenderObservable(): Observable<Mesh>;
  28289. /**
  28290. * An event triggered before binding the mesh
  28291. */
  28292. get onBeforeBindObservable(): Observable<Mesh>;
  28293. /**
  28294. * An event triggered after rendering the mesh
  28295. */
  28296. get onAfterRenderObservable(): Observable<Mesh>;
  28297. /**
  28298. * An event triggered before drawing the mesh
  28299. */
  28300. get onBeforeDrawObservable(): Observable<Mesh>;
  28301. private _onBeforeDrawObserver;
  28302. /**
  28303. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  28304. */
  28305. set onBeforeDraw(callback: () => void);
  28306. get hasInstances(): boolean;
  28307. get hasThinInstances(): boolean;
  28308. /**
  28309. * Gets the delay loading state of the mesh (when delay loading is turned on)
  28310. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  28311. */
  28312. delayLoadState: number;
  28313. /**
  28314. * Gets the list of instances created from this mesh
  28315. * it is not supposed to be modified manually.
  28316. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  28317. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28318. */
  28319. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  28320. /**
  28321. * Gets the file containing delay loading data for this mesh
  28322. */
  28323. delayLoadingFile: string;
  28324. /** @hidden */
  28325. _binaryInfo: any;
  28326. /**
  28327. * User defined function used to change how LOD level selection is done
  28328. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28329. */
  28330. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  28331. /**
  28332. * Gets or sets the morph target manager
  28333. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  28334. */
  28335. get morphTargetManager(): Nullable<MorphTargetManager>;
  28336. set morphTargetManager(value: Nullable<MorphTargetManager>);
  28337. /** @hidden */
  28338. _creationDataStorage: Nullable<_CreationDataStorage>;
  28339. /** @hidden */
  28340. _geometry: Nullable<Geometry>;
  28341. /** @hidden */
  28342. _delayInfo: Array<string>;
  28343. /** @hidden */
  28344. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  28345. /** @hidden */
  28346. _instanceDataStorage: _InstanceDataStorage;
  28347. /** @hidden */
  28348. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  28349. private _effectiveMaterial;
  28350. /** @hidden */
  28351. _shouldGenerateFlatShading: boolean;
  28352. /** @hidden */
  28353. _originalBuilderSideOrientation: number;
  28354. /**
  28355. * Use this property to change the original side orientation defined at construction time
  28356. */
  28357. overrideMaterialSideOrientation: Nullable<number>;
  28358. /**
  28359. * Gets the source mesh (the one used to clone this one from)
  28360. */
  28361. get source(): Nullable<Mesh>;
  28362. /**
  28363. * Gets or sets a boolean indicating that this mesh does not use index buffer
  28364. */
  28365. get isUnIndexed(): boolean;
  28366. set isUnIndexed(value: boolean);
  28367. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  28368. get worldMatrixInstancedBuffer(): Float32Array;
  28369. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  28370. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  28371. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  28372. /**
  28373. * @constructor
  28374. * @param name The value used by scene.getMeshByName() to do a lookup.
  28375. * @param scene The scene to add this mesh to.
  28376. * @param parent The parent of this mesh, if it has one
  28377. * @param source An optional Mesh from which geometry is shared, cloned.
  28378. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  28379. * When false, achieved by calling a clone(), also passing False.
  28380. * This will make creation of children, recursive.
  28381. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  28382. */
  28383. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  28384. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  28385. doNotInstantiate: boolean;
  28386. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  28387. /**
  28388. * Gets the class name
  28389. * @returns the string "Mesh".
  28390. */
  28391. getClassName(): string;
  28392. /** @hidden */
  28393. get _isMesh(): boolean;
  28394. /**
  28395. * Returns a description of this mesh
  28396. * @param fullDetails define if full details about this mesh must be used
  28397. * @returns a descriptive string representing this mesh
  28398. */
  28399. toString(fullDetails?: boolean): string;
  28400. /** @hidden */
  28401. _unBindEffect(): void;
  28402. /**
  28403. * Gets a boolean indicating if this mesh has LOD
  28404. */
  28405. get hasLODLevels(): boolean;
  28406. /**
  28407. * Gets the list of MeshLODLevel associated with the current mesh
  28408. * @returns an array of MeshLODLevel
  28409. */
  28410. getLODLevels(): MeshLODLevel[];
  28411. private _sortLODLevels;
  28412. /**
  28413. * Add a mesh as LOD level triggered at the given distance.
  28414. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28415. * @param distance The distance from the center of the object to show this level
  28416. * @param mesh The mesh to be added as LOD level (can be null)
  28417. * @return This mesh (for chaining)
  28418. */
  28419. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  28420. /**
  28421. * Returns the LOD level mesh at the passed distance or null if not found.
  28422. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28423. * @param distance The distance from the center of the object to show this level
  28424. * @returns a Mesh or `null`
  28425. */
  28426. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  28427. /**
  28428. * Remove a mesh from the LOD array
  28429. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28430. * @param mesh defines the mesh to be removed
  28431. * @return This mesh (for chaining)
  28432. */
  28433. removeLODLevel(mesh: Mesh): Mesh;
  28434. /**
  28435. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  28436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  28437. * @param camera defines the camera to use to compute distance
  28438. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  28439. * @return This mesh (for chaining)
  28440. */
  28441. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  28442. /**
  28443. * Gets the mesh internal Geometry object
  28444. */
  28445. get geometry(): Nullable<Geometry>;
  28446. /**
  28447. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  28448. * @returns the total number of vertices
  28449. */
  28450. getTotalVertices(): number;
  28451. /**
  28452. * Returns the content of an associated vertex buffer
  28453. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28454. * - VertexBuffer.PositionKind
  28455. * - VertexBuffer.UVKind
  28456. * - VertexBuffer.UV2Kind
  28457. * - VertexBuffer.UV3Kind
  28458. * - VertexBuffer.UV4Kind
  28459. * - VertexBuffer.UV5Kind
  28460. * - VertexBuffer.UV6Kind
  28461. * - VertexBuffer.ColorKind
  28462. * - VertexBuffer.MatricesIndicesKind
  28463. * - VertexBuffer.MatricesIndicesExtraKind
  28464. * - VertexBuffer.MatricesWeightsKind
  28465. * - VertexBuffer.MatricesWeightsExtraKind
  28466. * @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
  28467. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  28468. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  28469. */
  28470. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  28471. /**
  28472. * Returns the mesh VertexBuffer object from the requested `kind`
  28473. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28474. * - VertexBuffer.PositionKind
  28475. * - VertexBuffer.NormalKind
  28476. * - VertexBuffer.UVKind
  28477. * - VertexBuffer.UV2Kind
  28478. * - VertexBuffer.UV3Kind
  28479. * - VertexBuffer.UV4Kind
  28480. * - VertexBuffer.UV5Kind
  28481. * - VertexBuffer.UV6Kind
  28482. * - VertexBuffer.ColorKind
  28483. * - VertexBuffer.MatricesIndicesKind
  28484. * - VertexBuffer.MatricesIndicesExtraKind
  28485. * - VertexBuffer.MatricesWeightsKind
  28486. * - VertexBuffer.MatricesWeightsExtraKind
  28487. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  28488. */
  28489. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  28490. /**
  28491. * Tests if a specific vertex buffer is associated with this mesh
  28492. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28493. * - VertexBuffer.PositionKind
  28494. * - VertexBuffer.NormalKind
  28495. * - VertexBuffer.UVKind
  28496. * - VertexBuffer.UV2Kind
  28497. * - VertexBuffer.UV3Kind
  28498. * - VertexBuffer.UV4Kind
  28499. * - VertexBuffer.UV5Kind
  28500. * - VertexBuffer.UV6Kind
  28501. * - VertexBuffer.ColorKind
  28502. * - VertexBuffer.MatricesIndicesKind
  28503. * - VertexBuffer.MatricesIndicesExtraKind
  28504. * - VertexBuffer.MatricesWeightsKind
  28505. * - VertexBuffer.MatricesWeightsExtraKind
  28506. * @returns a boolean
  28507. */
  28508. isVerticesDataPresent(kind: string): boolean;
  28509. /**
  28510. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  28511. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  28512. * - VertexBuffer.PositionKind
  28513. * - VertexBuffer.UVKind
  28514. * - VertexBuffer.UV2Kind
  28515. * - VertexBuffer.UV3Kind
  28516. * - VertexBuffer.UV4Kind
  28517. * - VertexBuffer.UV5Kind
  28518. * - VertexBuffer.UV6Kind
  28519. * - VertexBuffer.ColorKind
  28520. * - VertexBuffer.MatricesIndicesKind
  28521. * - VertexBuffer.MatricesIndicesExtraKind
  28522. * - VertexBuffer.MatricesWeightsKind
  28523. * - VertexBuffer.MatricesWeightsExtraKind
  28524. * @returns a boolean
  28525. */
  28526. isVertexBufferUpdatable(kind: string): boolean;
  28527. /**
  28528. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  28529. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  28530. * - VertexBuffer.PositionKind
  28531. * - VertexBuffer.NormalKind
  28532. * - VertexBuffer.UVKind
  28533. * - VertexBuffer.UV2Kind
  28534. * - VertexBuffer.UV3Kind
  28535. * - VertexBuffer.UV4Kind
  28536. * - VertexBuffer.UV5Kind
  28537. * - VertexBuffer.UV6Kind
  28538. * - VertexBuffer.ColorKind
  28539. * - VertexBuffer.MatricesIndicesKind
  28540. * - VertexBuffer.MatricesIndicesExtraKind
  28541. * - VertexBuffer.MatricesWeightsKind
  28542. * - VertexBuffer.MatricesWeightsExtraKind
  28543. * @returns an array of strings
  28544. */
  28545. getVerticesDataKinds(): string[];
  28546. /**
  28547. * Returns a positive integer : the total number of indices in this mesh geometry.
  28548. * @returns the numner of indices or zero if the mesh has no geometry.
  28549. */
  28550. getTotalIndices(): number;
  28551. /**
  28552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  28553. * @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.
  28554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  28555. * @returns the indices array or an empty array if the mesh has no geometry
  28556. */
  28557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  28558. get isBlocked(): boolean;
  28559. /**
  28560. * Determine if the current mesh is ready to be rendered
  28561. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  28562. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  28563. * @returns true if all associated assets are ready (material, textures, shaders)
  28564. */
  28565. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  28566. /**
  28567. * 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.
  28568. */
  28569. get areNormalsFrozen(): boolean;
  28570. /**
  28571. * 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.
  28572. * @returns the current mesh
  28573. */
  28574. freezeNormals(): Mesh;
  28575. /**
  28576. * 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
  28577. * @returns the current mesh
  28578. */
  28579. unfreezeNormals(): Mesh;
  28580. /**
  28581. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  28582. */
  28583. set overridenInstanceCount(count: number);
  28584. /** @hidden */
  28585. _preActivate(): Mesh;
  28586. /** @hidden */
  28587. _preActivateForIntermediateRendering(renderId: number): Mesh;
  28588. /** @hidden */
  28589. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  28590. protected _afterComputeWorldMatrix(): void;
  28591. /** @hidden */
  28592. _postActivate(): void;
  28593. /**
  28594. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  28595. * This means the mesh underlying bounding box and sphere are recomputed.
  28596. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  28597. * @returns the current mesh
  28598. */
  28599. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  28600. /** @hidden */
  28601. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  28602. /**
  28603. * This function will subdivide the mesh into multiple submeshes
  28604. * @param count defines the expected number of submeshes
  28605. */
  28606. subdivide(count: number): void;
  28607. /**
  28608. * Copy a FloatArray into a specific associated vertex buffer
  28609. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28610. * - VertexBuffer.PositionKind
  28611. * - VertexBuffer.UVKind
  28612. * - VertexBuffer.UV2Kind
  28613. * - VertexBuffer.UV3Kind
  28614. * - VertexBuffer.UV4Kind
  28615. * - VertexBuffer.UV5Kind
  28616. * - VertexBuffer.UV6Kind
  28617. * - VertexBuffer.ColorKind
  28618. * - VertexBuffer.MatricesIndicesKind
  28619. * - VertexBuffer.MatricesIndicesExtraKind
  28620. * - VertexBuffer.MatricesWeightsKind
  28621. * - VertexBuffer.MatricesWeightsExtraKind
  28622. * @param data defines the data source
  28623. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28624. * @param stride defines the data stride size (can be null)
  28625. * @returns the current mesh
  28626. */
  28627. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  28628. /**
  28629. * Delete a vertex buffer associated with this mesh
  28630. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  28631. * - VertexBuffer.PositionKind
  28632. * - VertexBuffer.UVKind
  28633. * - VertexBuffer.UV2Kind
  28634. * - VertexBuffer.UV3Kind
  28635. * - VertexBuffer.UV4Kind
  28636. * - VertexBuffer.UV5Kind
  28637. * - VertexBuffer.UV6Kind
  28638. * - VertexBuffer.ColorKind
  28639. * - VertexBuffer.MatricesIndicesKind
  28640. * - VertexBuffer.MatricesIndicesExtraKind
  28641. * - VertexBuffer.MatricesWeightsKind
  28642. * - VertexBuffer.MatricesWeightsExtraKind
  28643. */
  28644. removeVerticesData(kind: string): void;
  28645. /**
  28646. * Flags an associated vertex buffer as updatable
  28647. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  28648. * - VertexBuffer.PositionKind
  28649. * - VertexBuffer.UVKind
  28650. * - VertexBuffer.UV2Kind
  28651. * - VertexBuffer.UV3Kind
  28652. * - VertexBuffer.UV4Kind
  28653. * - VertexBuffer.UV5Kind
  28654. * - VertexBuffer.UV6Kind
  28655. * - VertexBuffer.ColorKind
  28656. * - VertexBuffer.MatricesIndicesKind
  28657. * - VertexBuffer.MatricesIndicesExtraKind
  28658. * - VertexBuffer.MatricesWeightsKind
  28659. * - VertexBuffer.MatricesWeightsExtraKind
  28660. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  28661. */
  28662. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  28663. /**
  28664. * Sets the mesh global Vertex Buffer
  28665. * @param buffer defines the buffer to use
  28666. * @returns the current mesh
  28667. */
  28668. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  28669. /**
  28670. * Update a specific associated vertex buffer
  28671. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  28672. * - VertexBuffer.PositionKind
  28673. * - VertexBuffer.UVKind
  28674. * - VertexBuffer.UV2Kind
  28675. * - VertexBuffer.UV3Kind
  28676. * - VertexBuffer.UV4Kind
  28677. * - VertexBuffer.UV5Kind
  28678. * - VertexBuffer.UV6Kind
  28679. * - VertexBuffer.ColorKind
  28680. * - VertexBuffer.MatricesIndicesKind
  28681. * - VertexBuffer.MatricesIndicesExtraKind
  28682. * - VertexBuffer.MatricesWeightsKind
  28683. * - VertexBuffer.MatricesWeightsExtraKind
  28684. * @param data defines the data source
  28685. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  28686. * @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)
  28687. * @returns the current mesh
  28688. */
  28689. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  28690. /**
  28691. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  28692. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  28693. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  28694. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  28695. * @returns the current mesh
  28696. */
  28697. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  28698. /**
  28699. * Creates a un-shared specific occurence of the geometry for the mesh.
  28700. * @returns the current mesh
  28701. */
  28702. makeGeometryUnique(): Mesh;
  28703. /**
  28704. * Set the index buffer of this mesh
  28705. * @param indices defines the source data
  28706. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  28707. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  28708. * @returns the current mesh
  28709. */
  28710. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  28711. /**
  28712. * Update the current index buffer
  28713. * @param indices defines the source data
  28714. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  28715. * @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)
  28716. * @returns the current mesh
  28717. */
  28718. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  28719. /**
  28720. * Invert the geometry to move from a right handed system to a left handed one.
  28721. * @returns the current mesh
  28722. */
  28723. toLeftHanded(): Mesh;
  28724. /** @hidden */
  28725. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  28726. /** @hidden */
  28727. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  28728. /**
  28729. * Registers for this mesh a javascript function called just before the rendering process
  28730. * @param func defines the function to call before rendering this mesh
  28731. * @returns the current mesh
  28732. */
  28733. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28734. /**
  28735. * Disposes a previously registered javascript function called before the rendering
  28736. * @param func defines the function to remove
  28737. * @returns the current mesh
  28738. */
  28739. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  28740. /**
  28741. * Registers for this mesh a javascript function called just after the rendering is complete
  28742. * @param func defines the function to call after rendering this mesh
  28743. * @returns the current mesh
  28744. */
  28745. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28746. /**
  28747. * Disposes a previously registered javascript function called after the rendering.
  28748. * @param func defines the function to remove
  28749. * @returns the current mesh
  28750. */
  28751. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  28752. /** @hidden */
  28753. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  28754. /** @hidden */
  28755. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  28756. /** @hidden */
  28757. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  28758. /** @hidden */
  28759. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  28760. /** @hidden */
  28761. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  28762. /** @hidden */
  28763. _rebuild(): void;
  28764. /** @hidden */
  28765. _freeze(): void;
  28766. /** @hidden */
  28767. _unFreeze(): void;
  28768. /**
  28769. * 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
  28770. * @param subMesh defines the subMesh to render
  28771. * @param enableAlphaMode defines if alpha mode can be changed
  28772. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  28773. * @returns the current mesh
  28774. */
  28775. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  28776. private _onBeforeDraw;
  28777. /**
  28778. * Renormalize the mesh and patch it up if there are no weights
  28779. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  28780. * However in the case of zero weights then we set just a single influence to 1.
  28781. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  28782. */
  28783. cleanMatrixWeights(): void;
  28784. private normalizeSkinFourWeights;
  28785. private normalizeSkinWeightsAndExtra;
  28786. /**
  28787. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  28788. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  28789. * the user know there was an issue with importing the mesh
  28790. * @returns a validation object with skinned, valid and report string
  28791. */
  28792. validateSkinning(): {
  28793. skinned: boolean;
  28794. valid: boolean;
  28795. report: string;
  28796. };
  28797. /** @hidden */
  28798. _checkDelayState(): Mesh;
  28799. private _queueLoad;
  28800. /**
  28801. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  28802. * A mesh is in the frustum if its bounding box intersects the frustum
  28803. * @param frustumPlanes defines the frustum to test
  28804. * @returns true if the mesh is in the frustum planes
  28805. */
  28806. isInFrustum(frustumPlanes: Plane[]): boolean;
  28807. /**
  28808. * Sets the mesh material by the material or multiMaterial `id` property
  28809. * @param id is a string identifying the material or the multiMaterial
  28810. * @returns the current mesh
  28811. */
  28812. setMaterialByID(id: string): Mesh;
  28813. /**
  28814. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  28815. * @returns an array of IAnimatable
  28816. */
  28817. getAnimatables(): IAnimatable[];
  28818. /**
  28819. * Modifies the mesh geometry according to the passed transformation matrix.
  28820. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  28821. * The mesh normals are modified using the same transformation.
  28822. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28823. * @param transform defines the transform matrix to use
  28824. * @see https://doc.babylonjs.com/resources/baking_transformations
  28825. * @returns the current mesh
  28826. */
  28827. bakeTransformIntoVertices(transform: Matrix): Mesh;
  28828. /**
  28829. * Modifies the mesh geometry according to its own current World Matrix.
  28830. * The mesh World Matrix is then reset.
  28831. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  28832. * Note that, under the hood, this method sets a new VertexBuffer each call.
  28833. * @see https://doc.babylonjs.com/resources/baking_transformations
  28834. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  28835. * @returns the current mesh
  28836. */
  28837. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  28838. /** @hidden */
  28839. get _positions(): Nullable<Vector3[]>;
  28840. /** @hidden */
  28841. _resetPointsArrayCache(): Mesh;
  28842. /** @hidden */
  28843. _generatePointsArray(): boolean;
  28844. /**
  28845. * Returns a new Mesh object generated from the current mesh properties.
  28846. * This method must not get confused with createInstance()
  28847. * @param name is a string, the name given to the new mesh
  28848. * @param newParent can be any Node object (default `null`)
  28849. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  28850. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  28851. * @returns a new mesh
  28852. */
  28853. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  28854. /**
  28855. * Releases resources associated with this mesh.
  28856. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  28857. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  28858. */
  28859. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  28860. /** @hidden */
  28861. _disposeInstanceSpecificData(): void;
  28862. /** @hidden */
  28863. _disposeThinInstanceSpecificData(): void;
  28864. /**
  28865. * Modifies the mesh geometry according to a displacement map.
  28866. * 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.
  28867. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28868. * @param url is a string, the URL from the image file is to be downloaded.
  28869. * @param minHeight is the lower limit of the displacement.
  28870. * @param maxHeight is the upper limit of the displacement.
  28871. * @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.
  28872. * @param uvOffset is an optional vector2 used to offset UV.
  28873. * @param uvScale is an optional vector2 used to scale UV.
  28874. * @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.
  28875. * @returns the Mesh.
  28876. */
  28877. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28878. /**
  28879. * Modifies the mesh geometry according to a displacementMap buffer.
  28880. * 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.
  28881. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  28882. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  28883. * @param heightMapWidth is the width of the buffer image.
  28884. * @param heightMapHeight is the height of the buffer image.
  28885. * @param minHeight is the lower limit of the displacement.
  28886. * @param maxHeight is the upper limit of the displacement.
  28887. * @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.
  28888. * @param uvOffset is an optional vector2 used to offset UV.
  28889. * @param uvScale is an optional vector2 used to scale UV.
  28890. * @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.
  28891. * @returns the Mesh.
  28892. */
  28893. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  28894. /**
  28895. * Modify the mesh to get a flat shading rendering.
  28896. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  28897. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  28898. * @returns current mesh
  28899. */
  28900. convertToFlatShadedMesh(): Mesh;
  28901. /**
  28902. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  28903. * In other words, more vertices, no more indices and a single bigger VBO.
  28904. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  28905. * @returns current mesh
  28906. */
  28907. convertToUnIndexedMesh(): Mesh;
  28908. /**
  28909. * Inverses facet orientations.
  28910. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28911. * @param flipNormals will also inverts the normals
  28912. * @returns current mesh
  28913. */
  28914. flipFaces(flipNormals?: boolean): Mesh;
  28915. /**
  28916. * Increase the number of facets and hence vertices in a mesh
  28917. * Vertex normals are interpolated from existing vertex normals
  28918. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28919. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  28920. */
  28921. increaseVertices(numberPerEdge: number): void;
  28922. /**
  28923. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  28924. * This will undo any application of covertToFlatShadedMesh
  28925. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  28926. */
  28927. forceSharedVertices(): void;
  28928. /** @hidden */
  28929. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  28930. /** @hidden */
  28931. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  28932. /**
  28933. * Creates a new InstancedMesh object from the mesh model.
  28934. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  28935. * @param name defines the name of the new instance
  28936. * @returns a new InstancedMesh
  28937. */
  28938. createInstance(name: string): InstancedMesh;
  28939. /**
  28940. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  28941. * After this call, all the mesh instances have the same submeshes than the current mesh.
  28942. * @returns the current mesh
  28943. */
  28944. synchronizeInstances(): Mesh;
  28945. /**
  28946. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  28947. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  28948. * This should be used together with the simplification to avoid disappearing triangles.
  28949. * @param successCallback an optional success callback to be called after the optimization finished.
  28950. * @returns the current mesh
  28951. */
  28952. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  28953. /**
  28954. * Serialize current mesh
  28955. * @param serializationObject defines the object which will receive the serialization data
  28956. */
  28957. serialize(serializationObject: any): void;
  28958. /** @hidden */
  28959. _syncGeometryWithMorphTargetManager(): void;
  28960. /** @hidden */
  28961. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  28962. /**
  28963. * Returns a new Mesh object parsed from the source provided.
  28964. * @param parsedMesh is the source
  28965. * @param scene defines the hosting scene
  28966. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  28967. * @returns a new Mesh
  28968. */
  28969. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  28970. /**
  28971. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  28972. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  28973. * @param name defines the name of the mesh to create
  28974. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  28975. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  28976. * @param closePath creates a seam between the first and the last points of each path of the path array
  28977. * @param offset is taken in account only if the `pathArray` is containing a single path
  28978. * @param scene defines the hosting scene
  28979. * @param updatable defines if the mesh must be flagged as updatable
  28980. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28981. * @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)
  28982. * @returns a new Mesh
  28983. */
  28984. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  28985. /**
  28986. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  28987. * @param name defines the name of the mesh to create
  28988. * @param radius sets the radius size (float) of the polygon (default 0.5)
  28989. * @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
  28990. * @param scene defines the hosting scene
  28991. * @param updatable defines if the mesh must be flagged as updatable
  28992. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  28993. * @returns a new Mesh
  28994. */
  28995. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  28996. /**
  28997. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  28998. * @param name defines the name of the mesh to create
  28999. * @param size sets the size (float) of each box side (default 1)
  29000. * @param scene defines the hosting scene
  29001. * @param updatable defines if the mesh must be flagged as updatable
  29002. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29003. * @returns a new Mesh
  29004. */
  29005. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  29006. /**
  29007. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  29008. * @param name defines the name of the mesh to create
  29009. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29010. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29011. * @param scene defines the hosting scene
  29012. * @param updatable defines if the mesh must be flagged as updatable
  29013. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29014. * @returns a new Mesh
  29015. */
  29016. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29017. /**
  29018. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  29019. * @param name defines the name of the mesh to create
  29020. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  29021. * @param diameter sets the diameter size (float) of the sphere (default 1)
  29022. * @param scene defines the hosting scene
  29023. * @returns a new Mesh
  29024. */
  29025. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  29026. /**
  29027. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  29028. * @param name defines the name of the mesh to create
  29029. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  29030. * @param diameterTop set the top cap diameter (floats, default 1)
  29031. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  29032. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  29033. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  29034. * @param scene defines the hosting scene
  29035. * @param updatable defines if the mesh must be flagged as updatable
  29036. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29037. * @returns a new Mesh
  29038. */
  29039. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  29040. /**
  29041. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  29042. * @param name defines the name of the mesh to create
  29043. * @param diameter sets the diameter size (float) of the torus (default 1)
  29044. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  29045. * @param tessellation sets the number of torus sides (postive integer, default 16)
  29046. * @param scene defines the hosting scene
  29047. * @param updatable defines if the mesh must be flagged as updatable
  29048. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29049. * @returns a new Mesh
  29050. */
  29051. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29052. /**
  29053. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  29054. * @param name defines the name of the mesh to create
  29055. * @param radius sets the global radius size (float) of the torus knot (default 2)
  29056. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  29057. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  29058. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  29059. * @param p the number of windings on X axis (positive integers, default 2)
  29060. * @param q the number of windings on Y axis (positive integers, default 3)
  29061. * @param scene defines the hosting scene
  29062. * @param updatable defines if the mesh must be flagged as updatable
  29063. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29064. * @returns a new Mesh
  29065. */
  29066. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29067. /**
  29068. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  29069. * @param name defines the name of the mesh to create
  29070. * @param points is an array successive Vector3
  29071. * @param scene defines the hosting scene
  29072. * @param updatable defines if the mesh must be flagged as updatable
  29073. * @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).
  29074. * @returns a new Mesh
  29075. */
  29076. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  29077. /**
  29078. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  29079. * @param name defines the name of the mesh to create
  29080. * @param points is an array successive Vector3
  29081. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  29082. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  29083. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  29084. * @param scene defines the hosting scene
  29085. * @param updatable defines if the mesh must be flagged as updatable
  29086. * @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)
  29087. * @returns a new Mesh
  29088. */
  29089. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  29090. /**
  29091. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  29092. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  29093. * 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.
  29094. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29095. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  29096. * Remember you can only change the shape positions, not their number when updating a polygon.
  29097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  29098. * @param name defines the name of the mesh to create
  29099. * @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
  29100. * @param scene defines the hosting scene
  29101. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29102. * @param updatable defines if the mesh must be flagged as updatable
  29103. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29104. * @param earcutInjection can be used to inject your own earcut reference
  29105. * @returns a new Mesh
  29106. */
  29107. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29108. /**
  29109. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  29110. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  29111. * @param name defines the name of the mesh to create
  29112. * @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
  29113. * @param depth defines the height of extrusion
  29114. * @param scene defines the hosting scene
  29115. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  29116. * @param updatable defines if the mesh must be flagged as updatable
  29117. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29118. * @param earcutInjection can be used to inject your own earcut reference
  29119. * @returns a new Mesh
  29120. */
  29121. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  29122. /**
  29123. * Creates an extruded shape mesh.
  29124. * 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
  29125. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29126. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29127. * @param name defines the name of the mesh to create
  29128. * @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
  29129. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29130. * @param scale is the value to scale the shape
  29131. * @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
  29132. * @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
  29133. * @param scene defines the hosting scene
  29134. * @param updatable defines if the mesh must be flagged as updatable
  29135. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29136. * @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)
  29137. * @returns a new Mesh
  29138. */
  29139. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29140. /**
  29141. * Creates an custom extruded shape mesh.
  29142. * The custom extrusion is a parametric shape.
  29143. * It has no predefined shape. Its final shape will depend on the input parameters.
  29144. * Please consider using the same method from the MeshBuilder class instead
  29145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  29146. * @param name defines the name of the mesh to create
  29147. * @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
  29148. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  29149. * @param scaleFunction is a custom Javascript function called on each path point
  29150. * @param rotationFunction is a custom Javascript function called on each path point
  29151. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  29152. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  29153. * @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
  29154. * @param scene defines the hosting scene
  29155. * @param updatable defines if the mesh must be flagged as updatable
  29156. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29157. * @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)
  29158. * @returns a new Mesh
  29159. */
  29160. 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;
  29161. /**
  29162. * Creates lathe mesh.
  29163. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  29164. * Please consider using the same method from the MeshBuilder class instead
  29165. * @param name defines the name of the mesh to create
  29166. * @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
  29167. * @param radius is the radius value of the lathe
  29168. * @param tessellation is the side number of the lathe.
  29169. * @param scene defines the hosting scene
  29170. * @param updatable defines if the mesh must be flagged as updatable
  29171. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29172. * @returns a new Mesh
  29173. */
  29174. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29175. /**
  29176. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  29177. * @param name defines the name of the mesh to create
  29178. * @param size sets the size (float) of both sides of the plane at once (default 1)
  29179. * @param scene defines the hosting scene
  29180. * @param updatable defines if the mesh must be flagged as updatable
  29181. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29182. * @returns a new Mesh
  29183. */
  29184. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  29185. /**
  29186. * Creates a ground mesh.
  29187. * Please consider using the same method from the MeshBuilder class instead
  29188. * @param name defines the name of the mesh to create
  29189. * @param width set the width of the ground
  29190. * @param height set the height of the ground
  29191. * @param subdivisions sets the number of subdivisions per side
  29192. * @param scene defines the hosting scene
  29193. * @param updatable defines if the mesh must be flagged as updatable
  29194. * @returns a new Mesh
  29195. */
  29196. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  29197. /**
  29198. * Creates a tiled ground mesh.
  29199. * Please consider using the same method from the MeshBuilder class instead
  29200. * @param name defines the name of the mesh to create
  29201. * @param xmin set the ground minimum X coordinate
  29202. * @param zmin set the ground minimum Y coordinate
  29203. * @param xmax set the ground maximum X coordinate
  29204. * @param zmax set the ground maximum Z coordinate
  29205. * @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
  29206. * @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
  29207. * @param scene defines the hosting scene
  29208. * @param updatable defines if the mesh must be flagged as updatable
  29209. * @returns a new Mesh
  29210. */
  29211. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  29212. w: number;
  29213. h: number;
  29214. }, precision: {
  29215. w: number;
  29216. h: number;
  29217. }, scene: Scene, updatable?: boolean): Mesh;
  29218. /**
  29219. * Creates a ground mesh from a height map.
  29220. * Please consider using the same method from the MeshBuilder class instead
  29221. * @see https://doc.babylonjs.com/babylon101/height_map
  29222. * @param name defines the name of the mesh to create
  29223. * @param url sets the URL of the height map image resource
  29224. * @param width set the ground width size
  29225. * @param height set the ground height size
  29226. * @param subdivisions sets the number of subdivision per side
  29227. * @param minHeight is the minimum altitude on the ground
  29228. * @param maxHeight is the maximum altitude on the ground
  29229. * @param scene defines the hosting scene
  29230. * @param updatable defines if the mesh must be flagged as updatable
  29231. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  29232. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  29233. * @returns a new Mesh
  29234. */
  29235. 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;
  29236. /**
  29237. * Creates a tube mesh.
  29238. * The tube is a parametric shape.
  29239. * It has no predefined shape. Its final shape will depend on the input parameters.
  29240. * Please consider using the same method from the MeshBuilder class instead
  29241. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29242. * @param name defines the name of the mesh to create
  29243. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  29244. * @param radius sets the tube radius size
  29245. * @param tessellation is the number of sides on the tubular surface
  29246. * @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
  29247. * @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
  29248. * @param scene defines the hosting scene
  29249. * @param updatable defines if the mesh must be flagged as updatable
  29250. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  29251. * @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)
  29252. * @returns a new Mesh
  29253. */
  29254. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  29255. (i: number, distance: number): number;
  29256. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  29257. /**
  29258. * Creates a polyhedron mesh.
  29259. * Please consider using the same method from the MeshBuilder class instead.
  29260. * * 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
  29261. * * The parameter `size` (positive float, default 1) sets the polygon size
  29262. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  29263. * * 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`
  29264. * * 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
  29265. * * 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)`)
  29266. * * 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
  29267. * * 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
  29268. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29269. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29271. * @param name defines the name of the mesh to create
  29272. * @param options defines the options used to create the mesh
  29273. * @param scene defines the hosting scene
  29274. * @returns a new Mesh
  29275. */
  29276. static CreatePolyhedron(name: string, options: {
  29277. type?: number;
  29278. size?: number;
  29279. sizeX?: number;
  29280. sizeY?: number;
  29281. sizeZ?: number;
  29282. custom?: any;
  29283. faceUV?: Vector4[];
  29284. faceColors?: Color4[];
  29285. updatable?: boolean;
  29286. sideOrientation?: number;
  29287. }, scene: Scene): Mesh;
  29288. /**
  29289. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  29290. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  29291. * * 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`)
  29292. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  29293. * * 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
  29294. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  29295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29296. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29297. * @param name defines the name of the mesh
  29298. * @param options defines the options used to create the mesh
  29299. * @param scene defines the hosting scene
  29300. * @returns a new Mesh
  29301. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  29302. */
  29303. static CreateIcoSphere(name: string, options: {
  29304. radius?: number;
  29305. flat?: boolean;
  29306. subdivisions?: number;
  29307. sideOrientation?: number;
  29308. updatable?: boolean;
  29309. }, scene: Scene): Mesh;
  29310. /**
  29311. * Creates a decal mesh.
  29312. * Please consider using the same method from the MeshBuilder class instead.
  29313. * A decal is a mesh usually applied as a model onto the surface of another mesh
  29314. * @param name defines the name of the mesh
  29315. * @param sourceMesh defines the mesh receiving the decal
  29316. * @param position sets the position of the decal in world coordinates
  29317. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  29318. * @param size sets the decal scaling
  29319. * @param angle sets the angle to rotate the decal
  29320. * @returns a new Mesh
  29321. */
  29322. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  29323. /**
  29324. * Prepare internal position array for software CPU skinning
  29325. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  29326. */
  29327. setPositionsForCPUSkinning(): Float32Array;
  29328. /**
  29329. * Prepare internal normal array for software CPU skinning
  29330. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  29331. */
  29332. setNormalsForCPUSkinning(): Float32Array;
  29333. /**
  29334. * Updates the vertex buffer by applying transformation from the bones
  29335. * @param skeleton defines the skeleton to apply to current mesh
  29336. * @returns the current mesh
  29337. */
  29338. applySkeleton(skeleton: Skeleton): Mesh;
  29339. /**
  29340. * 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
  29341. * @param meshes defines the list of meshes to scan
  29342. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  29343. */
  29344. static MinMax(meshes: AbstractMesh[]): {
  29345. min: Vector3;
  29346. max: Vector3;
  29347. };
  29348. /**
  29349. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  29350. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  29351. * @returns a vector3
  29352. */
  29353. static Center(meshesOrMinMaxVector: {
  29354. min: Vector3;
  29355. max: Vector3;
  29356. } | AbstractMesh[]): Vector3;
  29357. /**
  29358. * Merge the array of meshes into a single mesh for performance reasons.
  29359. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  29360. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  29361. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  29362. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  29363. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  29364. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  29365. * @returns a new mesh
  29366. */
  29367. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  29368. /** @hidden */
  29369. addInstance(instance: InstancedMesh): void;
  29370. /** @hidden */
  29371. removeInstance(instance: InstancedMesh): void;
  29372. }
  29373. }
  29374. declare module "babylonjs/Cameras/camera" {
  29375. import { SmartArray } from "babylonjs/Misc/smartArray";
  29376. import { Observable } from "babylonjs/Misc/observable";
  29377. import { Nullable } from "babylonjs/types";
  29378. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  29379. import { Scene } from "babylonjs/scene";
  29380. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  29381. import { Node } from "babylonjs/node";
  29382. import { Mesh } from "babylonjs/Meshes/mesh";
  29383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29384. import { ICullable } from "babylonjs/Culling/boundingInfo";
  29385. import { Viewport } from "babylonjs/Maths/math.viewport";
  29386. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29387. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29388. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  29389. import { Ray } from "babylonjs/Culling/ray";
  29390. /**
  29391. * This is the base class of all the camera used in the application.
  29392. * @see https://doc.babylonjs.com/features/cameras
  29393. */
  29394. export class Camera extends Node {
  29395. /** @hidden */
  29396. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  29397. /**
  29398. * This is the default projection mode used by the cameras.
  29399. * It helps recreating a feeling of perspective and better appreciate depth.
  29400. * This is the best way to simulate real life cameras.
  29401. */
  29402. static readonly PERSPECTIVE_CAMERA: number;
  29403. /**
  29404. * This helps creating camera with an orthographic mode.
  29405. * 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.
  29406. */
  29407. static readonly ORTHOGRAPHIC_CAMERA: number;
  29408. /**
  29409. * This is the default FOV mode for perspective cameras.
  29410. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  29411. */
  29412. static readonly FOVMODE_VERTICAL_FIXED: number;
  29413. /**
  29414. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  29415. */
  29416. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  29417. /**
  29418. * This specifies ther is no need for a camera rig.
  29419. * Basically only one eye is rendered corresponding to the camera.
  29420. */
  29421. static readonly RIG_MODE_NONE: number;
  29422. /**
  29423. * Simulates a camera Rig with one blue eye and one red eye.
  29424. * This can be use with 3d blue and red glasses.
  29425. */
  29426. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  29427. /**
  29428. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  29429. */
  29430. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  29431. /**
  29432. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  29433. */
  29434. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  29435. /**
  29436. * Defines that both eyes of the camera will be rendered over under each other.
  29437. */
  29438. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  29439. /**
  29440. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  29441. */
  29442. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  29443. /**
  29444. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  29445. */
  29446. static readonly RIG_MODE_VR: number;
  29447. /**
  29448. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  29449. */
  29450. static readonly RIG_MODE_WEBVR: number;
  29451. /**
  29452. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  29453. */
  29454. static readonly RIG_MODE_CUSTOM: number;
  29455. /**
  29456. * Defines if by default attaching controls should prevent the default javascript event to continue.
  29457. */
  29458. static ForceAttachControlToAlwaysPreventDefault: boolean;
  29459. /**
  29460. * Define the input manager associated with the camera.
  29461. */
  29462. inputs: CameraInputsManager<Camera>;
  29463. /** @hidden */
  29464. _position: Vector3;
  29465. /**
  29466. * Define the current local position of the camera in the scene
  29467. */
  29468. get position(): Vector3;
  29469. set position(newPosition: Vector3);
  29470. /**
  29471. * The vector the camera should consider as up.
  29472. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  29473. */
  29474. upVector: Vector3;
  29475. /**
  29476. * Define the current limit on the left side for an orthographic camera
  29477. * In scene unit
  29478. */
  29479. orthoLeft: Nullable<number>;
  29480. /**
  29481. * Define the current limit on the right side for an orthographic camera
  29482. * In scene unit
  29483. */
  29484. orthoRight: Nullable<number>;
  29485. /**
  29486. * Define the current limit on the bottom side for an orthographic camera
  29487. * In scene unit
  29488. */
  29489. orthoBottom: Nullable<number>;
  29490. /**
  29491. * Define the current limit on the top side for an orthographic camera
  29492. * In scene unit
  29493. */
  29494. orthoTop: Nullable<number>;
  29495. /**
  29496. * Field Of View is set in Radians. (default is 0.8)
  29497. */
  29498. fov: number;
  29499. /**
  29500. * Define the minimum distance the camera can see from.
  29501. * This is important to note that the depth buffer are not infinite and the closer it starts
  29502. * the more your scene might encounter depth fighting issue.
  29503. */
  29504. minZ: number;
  29505. /**
  29506. * Define the maximum distance the camera can see to.
  29507. * This is important to note that the depth buffer are not infinite and the further it end
  29508. * the more your scene might encounter depth fighting issue.
  29509. */
  29510. maxZ: number;
  29511. /**
  29512. * Define the default inertia of the camera.
  29513. * This helps giving a smooth feeling to the camera movement.
  29514. */
  29515. inertia: number;
  29516. /**
  29517. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  29518. */
  29519. mode: number;
  29520. /**
  29521. * Define whether the camera is intermediate.
  29522. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  29523. */
  29524. isIntermediate: boolean;
  29525. /**
  29526. * Define the viewport of the camera.
  29527. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  29528. */
  29529. viewport: Viewport;
  29530. /**
  29531. * Restricts the camera to viewing objects with the same layerMask.
  29532. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  29533. */
  29534. layerMask: number;
  29535. /**
  29536. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  29537. */
  29538. fovMode: number;
  29539. /**
  29540. * Rig mode of the camera.
  29541. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  29542. * This is normally controlled byt the camera themselves as internal use.
  29543. */
  29544. cameraRigMode: number;
  29545. /**
  29546. * Defines the distance between both "eyes" in case of a RIG
  29547. */
  29548. interaxialDistance: number;
  29549. /**
  29550. * Defines if stereoscopic rendering is done side by side or over under.
  29551. */
  29552. isStereoscopicSideBySide: boolean;
  29553. /**
  29554. * 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
  29555. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  29556. * else in the scene. (Eg. security camera)
  29557. *
  29558. * 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)
  29559. */
  29560. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  29561. /**
  29562. * When set, the camera will render to this render target instead of the default canvas
  29563. *
  29564. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  29565. */
  29566. outputRenderTarget: Nullable<RenderTargetTexture>;
  29567. /**
  29568. * Observable triggered when the camera view matrix has changed.
  29569. */
  29570. onViewMatrixChangedObservable: Observable<Camera>;
  29571. /**
  29572. * Observable triggered when the camera Projection matrix has changed.
  29573. */
  29574. onProjectionMatrixChangedObservable: Observable<Camera>;
  29575. /**
  29576. * Observable triggered when the inputs have been processed.
  29577. */
  29578. onAfterCheckInputsObservable: Observable<Camera>;
  29579. /**
  29580. * Observable triggered when reset has been called and applied to the camera.
  29581. */
  29582. onRestoreStateObservable: Observable<Camera>;
  29583. /**
  29584. * Is this camera a part of a rig system?
  29585. */
  29586. isRigCamera: boolean;
  29587. /**
  29588. * If isRigCamera set to true this will be set with the parent camera.
  29589. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  29590. */
  29591. rigParent?: Camera;
  29592. /** @hidden */
  29593. _cameraRigParams: any;
  29594. /** @hidden */
  29595. _rigCameras: Camera[];
  29596. /** @hidden */
  29597. _rigPostProcess: Nullable<PostProcess>;
  29598. protected _webvrViewMatrix: Matrix;
  29599. /** @hidden */
  29600. _skipRendering: boolean;
  29601. /** @hidden */
  29602. _projectionMatrix: Matrix;
  29603. /** @hidden */
  29604. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  29605. /** @hidden */
  29606. _activeMeshes: SmartArray<AbstractMesh>;
  29607. protected _globalPosition: Vector3;
  29608. /** @hidden */
  29609. _computedViewMatrix: Matrix;
  29610. private _doNotComputeProjectionMatrix;
  29611. private _transformMatrix;
  29612. private _frustumPlanes;
  29613. private _refreshFrustumPlanes;
  29614. private _storedFov;
  29615. private _stateStored;
  29616. /**
  29617. * Instantiates a new camera object.
  29618. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  29619. * @see https://doc.babylonjs.com/features/cameras
  29620. * @param name Defines the name of the camera in the scene
  29621. * @param position Defines the position of the camera
  29622. * @param scene Defines the scene the camera belongs too
  29623. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  29624. */
  29625. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  29626. /**
  29627. * Store current camera state (fov, position, etc..)
  29628. * @returns the camera
  29629. */
  29630. storeState(): Camera;
  29631. /**
  29632. * Restores the camera state values if it has been stored. You must call storeState() first
  29633. */
  29634. protected _restoreStateValues(): boolean;
  29635. /**
  29636. * Restored camera state. You must call storeState() first.
  29637. * @returns true if restored and false otherwise
  29638. */
  29639. restoreState(): boolean;
  29640. /**
  29641. * Gets the class name of the camera.
  29642. * @returns the class name
  29643. */
  29644. getClassName(): string;
  29645. /** @hidden */
  29646. readonly _isCamera: boolean;
  29647. /**
  29648. * Gets a string representation of the camera useful for debug purpose.
  29649. * @param fullDetails Defines that a more verboe level of logging is required
  29650. * @returns the string representation
  29651. */
  29652. toString(fullDetails?: boolean): string;
  29653. /**
  29654. * Gets the current world space position of the camera.
  29655. */
  29656. get globalPosition(): Vector3;
  29657. /**
  29658. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  29659. * @returns the active meshe list
  29660. */
  29661. getActiveMeshes(): SmartArray<AbstractMesh>;
  29662. /**
  29663. * Check whether a mesh is part of the current active mesh list of the camera
  29664. * @param mesh Defines the mesh to check
  29665. * @returns true if active, false otherwise
  29666. */
  29667. isActiveMesh(mesh: Mesh): boolean;
  29668. /**
  29669. * Is this camera ready to be used/rendered
  29670. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  29671. * @return true if the camera is ready
  29672. */
  29673. isReady(completeCheck?: boolean): boolean;
  29674. /** @hidden */
  29675. _initCache(): void;
  29676. /** @hidden */
  29677. _updateCache(ignoreParentClass?: boolean): void;
  29678. /** @hidden */
  29679. _isSynchronized(): boolean;
  29680. /** @hidden */
  29681. _isSynchronizedViewMatrix(): boolean;
  29682. /** @hidden */
  29683. _isSynchronizedProjectionMatrix(): boolean;
  29684. /**
  29685. * Attach the input controls to a specific dom element to get the input from.
  29686. * @param element Defines the element the controls should be listened from
  29687. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  29688. */
  29689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  29690. /**
  29691. * Detach the current controls from the specified dom element.
  29692. * @param element Defines the element to stop listening the inputs from
  29693. */
  29694. detachControl(element: HTMLElement): void;
  29695. /**
  29696. * Update the camera state according to the different inputs gathered during the frame.
  29697. */
  29698. update(): void;
  29699. /** @hidden */
  29700. _checkInputs(): void;
  29701. /** @hidden */
  29702. get rigCameras(): Camera[];
  29703. /**
  29704. * Gets the post process used by the rig cameras
  29705. */
  29706. get rigPostProcess(): Nullable<PostProcess>;
  29707. /**
  29708. * Internal, gets the first post proces.
  29709. * @returns the first post process to be run on this camera.
  29710. */
  29711. _getFirstPostProcess(): Nullable<PostProcess>;
  29712. private _cascadePostProcessesToRigCams;
  29713. /**
  29714. * Attach a post process to the camera.
  29715. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29716. * @param postProcess The post process to attach to the camera
  29717. * @param insertAt The position of the post process in case several of them are in use in the scene
  29718. * @returns the position the post process has been inserted at
  29719. */
  29720. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  29721. /**
  29722. * Detach a post process to the camera.
  29723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  29724. * @param postProcess The post process to detach from the camera
  29725. */
  29726. detachPostProcess(postProcess: PostProcess): void;
  29727. /**
  29728. * Gets the current world matrix of the camera
  29729. */
  29730. getWorldMatrix(): Matrix;
  29731. /** @hidden */
  29732. _getViewMatrix(): Matrix;
  29733. /**
  29734. * Gets the current view matrix of the camera.
  29735. * @param force forces the camera to recompute the matrix without looking at the cached state
  29736. * @returns the view matrix
  29737. */
  29738. getViewMatrix(force?: boolean): Matrix;
  29739. /**
  29740. * Freeze the projection matrix.
  29741. * It will prevent the cache check of the camera projection compute and can speed up perf
  29742. * if no parameter of the camera are meant to change
  29743. * @param projection Defines manually a projection if necessary
  29744. */
  29745. freezeProjectionMatrix(projection?: Matrix): void;
  29746. /**
  29747. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  29748. */
  29749. unfreezeProjectionMatrix(): void;
  29750. /**
  29751. * Gets the current projection matrix of the camera.
  29752. * @param force forces the camera to recompute the matrix without looking at the cached state
  29753. * @returns the projection matrix
  29754. */
  29755. getProjectionMatrix(force?: boolean): Matrix;
  29756. /**
  29757. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  29758. * @returns a Matrix
  29759. */
  29760. getTransformationMatrix(): Matrix;
  29761. private _updateFrustumPlanes;
  29762. /**
  29763. * Checks if a cullable object (mesh...) is in the camera frustum
  29764. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  29765. * @param target The object to check
  29766. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  29767. * @returns true if the object is in frustum otherwise false
  29768. */
  29769. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  29770. /**
  29771. * Checks if a cullable object (mesh...) is in the camera frustum
  29772. * Unlike isInFrustum this cheks the full bounding box
  29773. * @param target The object to check
  29774. * @returns true if the object is in frustum otherwise false
  29775. */
  29776. isCompletelyInFrustum(target: ICullable): boolean;
  29777. /**
  29778. * Gets a ray in the forward direction from the camera.
  29779. * @param length Defines the length of the ray to create
  29780. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  29781. * @param origin Defines the start point of the ray which defaults to the camera position
  29782. * @returns the forward ray
  29783. */
  29784. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  29785. /**
  29786. * Releases resources associated with this node.
  29787. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29788. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29789. */
  29790. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29791. /** @hidden */
  29792. _isLeftCamera: boolean;
  29793. /**
  29794. * Gets the left camera of a rig setup in case of Rigged Camera
  29795. */
  29796. get isLeftCamera(): boolean;
  29797. /** @hidden */
  29798. _isRightCamera: boolean;
  29799. /**
  29800. * Gets the right camera of a rig setup in case of Rigged Camera
  29801. */
  29802. get isRightCamera(): boolean;
  29803. /**
  29804. * Gets the left camera of a rig setup in case of Rigged Camera
  29805. */
  29806. get leftCamera(): Nullable<FreeCamera>;
  29807. /**
  29808. * Gets the right camera of a rig setup in case of Rigged Camera
  29809. */
  29810. get rightCamera(): Nullable<FreeCamera>;
  29811. /**
  29812. * Gets the left camera target of a rig setup in case of Rigged Camera
  29813. * @returns the target position
  29814. */
  29815. getLeftTarget(): Nullable<Vector3>;
  29816. /**
  29817. * Gets the right camera target of a rig setup in case of Rigged Camera
  29818. * @returns the target position
  29819. */
  29820. getRightTarget(): Nullable<Vector3>;
  29821. /**
  29822. * @hidden
  29823. */
  29824. setCameraRigMode(mode: number, rigParams: any): void;
  29825. /** @hidden */
  29826. static _setStereoscopicRigMode(camera: Camera): void;
  29827. /** @hidden */
  29828. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  29829. /** @hidden */
  29830. static _setVRRigMode(camera: Camera, rigParams: any): void;
  29831. /** @hidden */
  29832. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  29833. /** @hidden */
  29834. _getVRProjectionMatrix(): Matrix;
  29835. protected _updateCameraRotationMatrix(): void;
  29836. protected _updateWebVRCameraRotationMatrix(): void;
  29837. /**
  29838. * This function MUST be overwritten by the different WebVR cameras available.
  29839. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29840. * @hidden
  29841. */
  29842. _getWebVRProjectionMatrix(): Matrix;
  29843. /**
  29844. * This function MUST be overwritten by the different WebVR cameras available.
  29845. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  29846. * @hidden
  29847. */
  29848. _getWebVRViewMatrix(): Matrix;
  29849. /** @hidden */
  29850. setCameraRigParameter(name: string, value: any): void;
  29851. /**
  29852. * needs to be overridden by children so sub has required properties to be copied
  29853. * @hidden
  29854. */
  29855. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  29856. /**
  29857. * May need to be overridden by children
  29858. * @hidden
  29859. */
  29860. _updateRigCameras(): void;
  29861. /** @hidden */
  29862. _setupInputs(): void;
  29863. /**
  29864. * Serialiaze the camera setup to a json represention
  29865. * @returns the JSON representation
  29866. */
  29867. serialize(): any;
  29868. /**
  29869. * Clones the current camera.
  29870. * @param name The cloned camera name
  29871. * @returns the cloned camera
  29872. */
  29873. clone(name: string): Camera;
  29874. /**
  29875. * Gets the direction of the camera relative to a given local axis.
  29876. * @param localAxis Defines the reference axis to provide a relative direction.
  29877. * @return the direction
  29878. */
  29879. getDirection(localAxis: Vector3): Vector3;
  29880. /**
  29881. * Returns the current camera absolute rotation
  29882. */
  29883. get absoluteRotation(): Quaternion;
  29884. /**
  29885. * Gets the direction of the camera relative to a given local axis into a passed vector.
  29886. * @param localAxis Defines the reference axis to provide a relative direction.
  29887. * @param result Defines the vector to store the result in
  29888. */
  29889. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  29890. /**
  29891. * Gets a camera constructor for a given camera type
  29892. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  29893. * @param name The name of the camera the result will be able to instantiate
  29894. * @param scene The scene the result will construct the camera in
  29895. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  29896. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  29897. * @returns a factory method to construc the camera
  29898. */
  29899. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  29900. /**
  29901. * Compute the world matrix of the camera.
  29902. * @returns the camera world matrix
  29903. */
  29904. computeWorldMatrix(): Matrix;
  29905. /**
  29906. * Parse a JSON and creates the camera from the parsed information
  29907. * @param parsedCamera The JSON to parse
  29908. * @param scene The scene to instantiate the camera in
  29909. * @returns the newly constructed camera
  29910. */
  29911. static Parse(parsedCamera: any, scene: Scene): Camera;
  29912. }
  29913. }
  29914. declare module "babylonjs/Meshes/Builders/discBuilder" {
  29915. import { Nullable } from "babylonjs/types";
  29916. import { Scene } from "babylonjs/scene";
  29917. import { Vector4 } from "babylonjs/Maths/math.vector";
  29918. import { Mesh } from "babylonjs/Meshes/mesh";
  29919. /**
  29920. * Class containing static functions to help procedurally build meshes
  29921. */
  29922. export class DiscBuilder {
  29923. /**
  29924. * Creates a plane polygonal mesh. By default, this is a disc
  29925. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  29926. * * 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
  29927. * * 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
  29928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  29929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  29930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  29931. * @param name defines the name of the mesh
  29932. * @param options defines the options used to create the mesh
  29933. * @param scene defines the hosting scene
  29934. * @returns the plane polygonal mesh
  29935. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  29936. */
  29937. static CreateDisc(name: string, options: {
  29938. radius?: number;
  29939. tessellation?: number;
  29940. arc?: number;
  29941. updatable?: boolean;
  29942. sideOrientation?: number;
  29943. frontUVs?: Vector4;
  29944. backUVs?: Vector4;
  29945. }, scene?: Nullable<Scene>): Mesh;
  29946. }
  29947. }
  29948. declare module "babylonjs/Materials/fresnelParameters" {
  29949. import { DeepImmutable } from "babylonjs/types";
  29950. import { Color3 } from "babylonjs/Maths/math.color";
  29951. /**
  29952. * Options to be used when creating a FresnelParameters.
  29953. */
  29954. export type IFresnelParametersCreationOptions = {
  29955. /**
  29956. * Define the color used on edges (grazing angle)
  29957. */
  29958. leftColor?: Color3;
  29959. /**
  29960. * Define the color used on center
  29961. */
  29962. rightColor?: Color3;
  29963. /**
  29964. * Define bias applied to computed fresnel term
  29965. */
  29966. bias?: number;
  29967. /**
  29968. * Defined the power exponent applied to fresnel term
  29969. */
  29970. power?: number;
  29971. /**
  29972. * Define if the fresnel effect is enable or not.
  29973. */
  29974. isEnabled?: boolean;
  29975. };
  29976. /**
  29977. * Serialized format for FresnelParameters.
  29978. */
  29979. export type IFresnelParametersSerialized = {
  29980. /**
  29981. * Define the color used on edges (grazing angle) [as an array]
  29982. */
  29983. leftColor: number[];
  29984. /**
  29985. * Define the color used on center [as an array]
  29986. */
  29987. rightColor: number[];
  29988. /**
  29989. * Define bias applied to computed fresnel term
  29990. */
  29991. bias: number;
  29992. /**
  29993. * Defined the power exponent applied to fresnel term
  29994. */
  29995. power?: number;
  29996. /**
  29997. * Define if the fresnel effect is enable or not.
  29998. */
  29999. isEnabled: boolean;
  30000. };
  30001. /**
  30002. * This represents all the required information to add a fresnel effect on a material:
  30003. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30004. */
  30005. export class FresnelParameters {
  30006. private _isEnabled;
  30007. /**
  30008. * Define if the fresnel effect is enable or not.
  30009. */
  30010. get isEnabled(): boolean;
  30011. set isEnabled(value: boolean);
  30012. /**
  30013. * Define the color used on edges (grazing angle)
  30014. */
  30015. leftColor: Color3;
  30016. /**
  30017. * Define the color used on center
  30018. */
  30019. rightColor: Color3;
  30020. /**
  30021. * Define bias applied to computed fresnel term
  30022. */
  30023. bias: number;
  30024. /**
  30025. * Defined the power exponent applied to fresnel term
  30026. */
  30027. power: number;
  30028. /**
  30029. * Creates a new FresnelParameters object.
  30030. *
  30031. * @param options provide your own settings to optionally to override defaults
  30032. */
  30033. constructor(options?: IFresnelParametersCreationOptions);
  30034. /**
  30035. * Clones the current fresnel and its valuues
  30036. * @returns a clone fresnel configuration
  30037. */
  30038. clone(): FresnelParameters;
  30039. /**
  30040. * Determines equality between FresnelParameters objects
  30041. * @param otherFresnelParameters defines the second operand
  30042. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  30043. */
  30044. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  30045. /**
  30046. * Serializes the current fresnel parameters to a JSON representation.
  30047. * @return the JSON serialization
  30048. */
  30049. serialize(): IFresnelParametersSerialized;
  30050. /**
  30051. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30052. * @param parsedFresnelParameters Define the JSON representation
  30053. * @returns the parsed parameters
  30054. */
  30055. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  30056. }
  30057. }
  30058. declare module "babylonjs/Materials/materialFlags" {
  30059. /**
  30060. * This groups all the flags used to control the materials channel.
  30061. */
  30062. export class MaterialFlags {
  30063. private static _DiffuseTextureEnabled;
  30064. /**
  30065. * Are diffuse textures enabled in the application.
  30066. */
  30067. static get DiffuseTextureEnabled(): boolean;
  30068. static set DiffuseTextureEnabled(value: boolean);
  30069. private static _DetailTextureEnabled;
  30070. /**
  30071. * Are detail textures enabled in the application.
  30072. */
  30073. static get DetailTextureEnabled(): boolean;
  30074. static set DetailTextureEnabled(value: boolean);
  30075. private static _AmbientTextureEnabled;
  30076. /**
  30077. * Are ambient textures enabled in the application.
  30078. */
  30079. static get AmbientTextureEnabled(): boolean;
  30080. static set AmbientTextureEnabled(value: boolean);
  30081. private static _OpacityTextureEnabled;
  30082. /**
  30083. * Are opacity textures enabled in the application.
  30084. */
  30085. static get OpacityTextureEnabled(): boolean;
  30086. static set OpacityTextureEnabled(value: boolean);
  30087. private static _ReflectionTextureEnabled;
  30088. /**
  30089. * Are reflection textures enabled in the application.
  30090. */
  30091. static get ReflectionTextureEnabled(): boolean;
  30092. static set ReflectionTextureEnabled(value: boolean);
  30093. private static _EmissiveTextureEnabled;
  30094. /**
  30095. * Are emissive textures enabled in the application.
  30096. */
  30097. static get EmissiveTextureEnabled(): boolean;
  30098. static set EmissiveTextureEnabled(value: boolean);
  30099. private static _SpecularTextureEnabled;
  30100. /**
  30101. * Are specular textures enabled in the application.
  30102. */
  30103. static get SpecularTextureEnabled(): boolean;
  30104. static set SpecularTextureEnabled(value: boolean);
  30105. private static _BumpTextureEnabled;
  30106. /**
  30107. * Are bump textures enabled in the application.
  30108. */
  30109. static get BumpTextureEnabled(): boolean;
  30110. static set BumpTextureEnabled(value: boolean);
  30111. private static _LightmapTextureEnabled;
  30112. /**
  30113. * Are lightmap textures enabled in the application.
  30114. */
  30115. static get LightmapTextureEnabled(): boolean;
  30116. static set LightmapTextureEnabled(value: boolean);
  30117. private static _RefractionTextureEnabled;
  30118. /**
  30119. * Are refraction textures enabled in the application.
  30120. */
  30121. static get RefractionTextureEnabled(): boolean;
  30122. static set RefractionTextureEnabled(value: boolean);
  30123. private static _ColorGradingTextureEnabled;
  30124. /**
  30125. * Are color grading textures enabled in the application.
  30126. */
  30127. static get ColorGradingTextureEnabled(): boolean;
  30128. static set ColorGradingTextureEnabled(value: boolean);
  30129. private static _FresnelEnabled;
  30130. /**
  30131. * Are fresnels enabled in the application.
  30132. */
  30133. static get FresnelEnabled(): boolean;
  30134. static set FresnelEnabled(value: boolean);
  30135. private static _ClearCoatTextureEnabled;
  30136. /**
  30137. * Are clear coat textures enabled in the application.
  30138. */
  30139. static get ClearCoatTextureEnabled(): boolean;
  30140. static set ClearCoatTextureEnabled(value: boolean);
  30141. private static _ClearCoatBumpTextureEnabled;
  30142. /**
  30143. * Are clear coat bump textures enabled in the application.
  30144. */
  30145. static get ClearCoatBumpTextureEnabled(): boolean;
  30146. static set ClearCoatBumpTextureEnabled(value: boolean);
  30147. private static _ClearCoatTintTextureEnabled;
  30148. /**
  30149. * Are clear coat tint textures enabled in the application.
  30150. */
  30151. static get ClearCoatTintTextureEnabled(): boolean;
  30152. static set ClearCoatTintTextureEnabled(value: boolean);
  30153. private static _SheenTextureEnabled;
  30154. /**
  30155. * Are sheen textures enabled in the application.
  30156. */
  30157. static get SheenTextureEnabled(): boolean;
  30158. static set SheenTextureEnabled(value: boolean);
  30159. private static _AnisotropicTextureEnabled;
  30160. /**
  30161. * Are anisotropic textures enabled in the application.
  30162. */
  30163. static get AnisotropicTextureEnabled(): boolean;
  30164. static set AnisotropicTextureEnabled(value: boolean);
  30165. private static _ThicknessTextureEnabled;
  30166. /**
  30167. * Are thickness textures enabled in the application.
  30168. */
  30169. static get ThicknessTextureEnabled(): boolean;
  30170. static set ThicknessTextureEnabled(value: boolean);
  30171. }
  30172. }
  30173. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  30174. /** @hidden */
  30175. export var defaultFragmentDeclaration: {
  30176. name: string;
  30177. shader: string;
  30178. };
  30179. }
  30180. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  30181. /** @hidden */
  30182. export var defaultUboDeclaration: {
  30183. name: string;
  30184. shader: string;
  30185. };
  30186. }
  30187. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  30188. /** @hidden */
  30189. export var prePassDeclaration: {
  30190. name: string;
  30191. shader: string;
  30192. };
  30193. }
  30194. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  30195. /** @hidden */
  30196. export var lightFragmentDeclaration: {
  30197. name: string;
  30198. shader: string;
  30199. };
  30200. }
  30201. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  30202. /** @hidden */
  30203. export var lightUboDeclaration: {
  30204. name: string;
  30205. shader: string;
  30206. };
  30207. }
  30208. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  30209. /** @hidden */
  30210. export var lightsFragmentFunctions: {
  30211. name: string;
  30212. shader: string;
  30213. };
  30214. }
  30215. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  30216. /** @hidden */
  30217. export var shadowsFragmentFunctions: {
  30218. name: string;
  30219. shader: string;
  30220. };
  30221. }
  30222. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  30223. /** @hidden */
  30224. export var fresnelFunction: {
  30225. name: string;
  30226. shader: string;
  30227. };
  30228. }
  30229. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  30230. /** @hidden */
  30231. export var bumpFragmentMainFunctions: {
  30232. name: string;
  30233. shader: string;
  30234. };
  30235. }
  30236. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  30237. /** @hidden */
  30238. export var bumpFragmentFunctions: {
  30239. name: string;
  30240. shader: string;
  30241. };
  30242. }
  30243. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  30244. /** @hidden */
  30245. export var logDepthDeclaration: {
  30246. name: string;
  30247. shader: string;
  30248. };
  30249. }
  30250. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  30251. /** @hidden */
  30252. export var bumpFragment: {
  30253. name: string;
  30254. shader: string;
  30255. };
  30256. }
  30257. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  30258. /** @hidden */
  30259. export var depthPrePass: {
  30260. name: string;
  30261. shader: string;
  30262. };
  30263. }
  30264. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  30265. /** @hidden */
  30266. export var lightFragment: {
  30267. name: string;
  30268. shader: string;
  30269. };
  30270. }
  30271. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  30272. /** @hidden */
  30273. export var logDepthFragment: {
  30274. name: string;
  30275. shader: string;
  30276. };
  30277. }
  30278. declare module "babylonjs/Shaders/default.fragment" {
  30279. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  30280. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30281. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  30282. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30283. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30284. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30285. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  30286. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  30287. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  30288. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  30289. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  30290. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  30291. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  30292. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  30293. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  30294. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30295. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  30296. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  30297. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  30298. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  30299. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  30300. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  30301. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  30302. /** @hidden */
  30303. export var defaultPixelShader: {
  30304. name: string;
  30305. shader: string;
  30306. };
  30307. }
  30308. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  30309. /** @hidden */
  30310. export var defaultVertexDeclaration: {
  30311. name: string;
  30312. shader: string;
  30313. };
  30314. }
  30315. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  30316. /** @hidden */
  30317. export var bumpVertexDeclaration: {
  30318. name: string;
  30319. shader: string;
  30320. };
  30321. }
  30322. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  30323. /** @hidden */
  30324. export var bumpVertex: {
  30325. name: string;
  30326. shader: string;
  30327. };
  30328. }
  30329. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  30330. /** @hidden */
  30331. export var fogVertex: {
  30332. name: string;
  30333. shader: string;
  30334. };
  30335. }
  30336. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  30337. /** @hidden */
  30338. export var shadowsVertex: {
  30339. name: string;
  30340. shader: string;
  30341. };
  30342. }
  30343. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  30344. /** @hidden */
  30345. export var pointCloudVertex: {
  30346. name: string;
  30347. shader: string;
  30348. };
  30349. }
  30350. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  30351. /** @hidden */
  30352. export var logDepthVertex: {
  30353. name: string;
  30354. shader: string;
  30355. };
  30356. }
  30357. declare module "babylonjs/Shaders/default.vertex" {
  30358. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  30359. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  30360. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  30361. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  30362. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  30363. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  30364. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  30365. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  30366. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  30367. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  30368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  30369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  30370. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  30371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  30372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  30373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  30374. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  30375. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  30376. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  30377. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  30378. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  30379. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  30380. /** @hidden */
  30381. export var defaultVertexShader: {
  30382. name: string;
  30383. shader: string;
  30384. };
  30385. }
  30386. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  30387. import { Nullable } from "babylonjs/types";
  30388. import { Scene } from "babylonjs/scene";
  30389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30390. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  30391. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30392. /**
  30393. * @hidden
  30394. */
  30395. export interface IMaterialDetailMapDefines {
  30396. DETAIL: boolean;
  30397. DETAILDIRECTUV: number;
  30398. DETAIL_NORMALBLENDMETHOD: number;
  30399. /** @hidden */
  30400. _areTexturesDirty: boolean;
  30401. }
  30402. /**
  30403. * Define the code related to the detail map parameters of a material
  30404. *
  30405. * Inspired from:
  30406. * 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
  30407. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  30408. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  30409. */
  30410. export class DetailMapConfiguration {
  30411. private _texture;
  30412. /**
  30413. * The detail texture of the material.
  30414. */
  30415. texture: Nullable<BaseTexture>;
  30416. /**
  30417. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  30418. * Bigger values mean stronger blending
  30419. */
  30420. diffuseBlendLevel: number;
  30421. /**
  30422. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  30423. * Bigger values mean stronger blending. Only used with PBR materials
  30424. */
  30425. roughnessBlendLevel: number;
  30426. /**
  30427. * Defines how strong the bump effect from the detail map is
  30428. * Bigger values mean stronger effect
  30429. */
  30430. bumpLevel: number;
  30431. private _normalBlendMethod;
  30432. /**
  30433. * The method used to blend the bump and detail normals together
  30434. */
  30435. normalBlendMethod: number;
  30436. private _isEnabled;
  30437. /**
  30438. * Enable or disable the detail map on this material
  30439. */
  30440. isEnabled: boolean;
  30441. /** @hidden */
  30442. private _internalMarkAllSubMeshesAsTexturesDirty;
  30443. /** @hidden */
  30444. _markAllSubMeshesAsTexturesDirty(): void;
  30445. /**
  30446. * Instantiate a new detail map
  30447. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  30448. */
  30449. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  30450. /**
  30451. * Gets whether the submesh is ready to be used or not.
  30452. * @param defines the list of "defines" to update.
  30453. * @param scene defines the scene the material belongs to.
  30454. * @returns - boolean indicating that the submesh is ready or not.
  30455. */
  30456. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  30457. /**
  30458. * Update the defines for detail map usage
  30459. * @param defines the list of "defines" to update.
  30460. * @param scene defines the scene the material belongs to.
  30461. */
  30462. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  30463. /**
  30464. * Binds the material data.
  30465. * @param uniformBuffer defines the Uniform buffer to fill in.
  30466. * @param scene defines the scene the material belongs to.
  30467. * @param isFrozen defines whether the material is frozen or not.
  30468. */
  30469. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  30470. /**
  30471. * Checks to see if a texture is used in the material.
  30472. * @param texture - Base texture to use.
  30473. * @returns - Boolean specifying if a texture is used in the material.
  30474. */
  30475. hasTexture(texture: BaseTexture): boolean;
  30476. /**
  30477. * Returns an array of the actively used textures.
  30478. * @param activeTextures Array of BaseTextures
  30479. */
  30480. getActiveTextures(activeTextures: BaseTexture[]): void;
  30481. /**
  30482. * Returns the animatable textures.
  30483. * @param animatables Array of animatable textures.
  30484. */
  30485. getAnimatables(animatables: IAnimatable[]): void;
  30486. /**
  30487. * Disposes the resources of the material.
  30488. * @param forceDisposeTextures - Forces the disposal of all textures.
  30489. */
  30490. dispose(forceDisposeTextures?: boolean): void;
  30491. /**
  30492. * Get the current class name useful for serialization or dynamic coding.
  30493. * @returns "DetailMap"
  30494. */
  30495. getClassName(): string;
  30496. /**
  30497. * Add the required uniforms to the current list.
  30498. * @param uniforms defines the current uniform list.
  30499. */
  30500. static AddUniforms(uniforms: string[]): void;
  30501. /**
  30502. * Add the required samplers to the current list.
  30503. * @param samplers defines the current sampler list.
  30504. */
  30505. static AddSamplers(samplers: string[]): void;
  30506. /**
  30507. * Add the required uniforms to the current buffer.
  30508. * @param uniformBuffer defines the current uniform buffer.
  30509. */
  30510. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  30511. /**
  30512. * Makes a duplicate of the current instance into another one.
  30513. * @param detailMap define the instance where to copy the info
  30514. */
  30515. copyTo(detailMap: DetailMapConfiguration): void;
  30516. /**
  30517. * Serializes this detail map instance
  30518. * @returns - An object with the serialized instance.
  30519. */
  30520. serialize(): any;
  30521. /**
  30522. * Parses a detail map setting from a serialized object.
  30523. * @param source - Serialized object.
  30524. * @param scene Defines the scene we are parsing for
  30525. * @param rootUrl Defines the rootUrl to load from
  30526. */
  30527. parse(source: any, scene: Scene, rootUrl: string): void;
  30528. }
  30529. }
  30530. declare module "babylonjs/Materials/standardMaterial" {
  30531. import { SmartArray } from "babylonjs/Misc/smartArray";
  30532. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30533. import { Nullable } from "babylonjs/types";
  30534. import { Scene } from "babylonjs/scene";
  30535. import { Matrix } from "babylonjs/Maths/math.vector";
  30536. import { Color3 } from "babylonjs/Maths/math.color";
  30537. import { SubMesh } from "babylonjs/Meshes/subMesh";
  30538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30539. import { Mesh } from "babylonjs/Meshes/mesh";
  30540. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  30541. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30542. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  30543. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30544. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  30545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30547. import "babylonjs/Shaders/default.fragment";
  30548. import "babylonjs/Shaders/default.vertex";
  30549. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  30550. /** @hidden */
  30551. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  30552. MAINUV1: boolean;
  30553. MAINUV2: boolean;
  30554. DIFFUSE: boolean;
  30555. DIFFUSEDIRECTUV: number;
  30556. DETAIL: boolean;
  30557. DETAILDIRECTUV: number;
  30558. DETAIL_NORMALBLENDMETHOD: number;
  30559. AMBIENT: boolean;
  30560. AMBIENTDIRECTUV: number;
  30561. OPACITY: boolean;
  30562. OPACITYDIRECTUV: number;
  30563. OPACITYRGB: boolean;
  30564. REFLECTION: boolean;
  30565. EMISSIVE: boolean;
  30566. EMISSIVEDIRECTUV: number;
  30567. SPECULAR: boolean;
  30568. SPECULARDIRECTUV: number;
  30569. BUMP: boolean;
  30570. BUMPDIRECTUV: number;
  30571. PARALLAX: boolean;
  30572. PARALLAXOCCLUSION: boolean;
  30573. SPECULAROVERALPHA: boolean;
  30574. CLIPPLANE: boolean;
  30575. CLIPPLANE2: boolean;
  30576. CLIPPLANE3: boolean;
  30577. CLIPPLANE4: boolean;
  30578. CLIPPLANE5: boolean;
  30579. CLIPPLANE6: boolean;
  30580. ALPHATEST: boolean;
  30581. DEPTHPREPASS: boolean;
  30582. ALPHAFROMDIFFUSE: boolean;
  30583. POINTSIZE: boolean;
  30584. FOG: boolean;
  30585. SPECULARTERM: boolean;
  30586. DIFFUSEFRESNEL: boolean;
  30587. OPACITYFRESNEL: boolean;
  30588. REFLECTIONFRESNEL: boolean;
  30589. REFRACTIONFRESNEL: boolean;
  30590. EMISSIVEFRESNEL: boolean;
  30591. FRESNEL: boolean;
  30592. NORMAL: boolean;
  30593. UV1: boolean;
  30594. UV2: boolean;
  30595. VERTEXCOLOR: boolean;
  30596. VERTEXALPHA: boolean;
  30597. NUM_BONE_INFLUENCERS: number;
  30598. BonesPerMesh: number;
  30599. BONETEXTURE: boolean;
  30600. INSTANCES: boolean;
  30601. THIN_INSTANCES: boolean;
  30602. GLOSSINESS: boolean;
  30603. ROUGHNESS: boolean;
  30604. EMISSIVEASILLUMINATION: boolean;
  30605. LINKEMISSIVEWITHDIFFUSE: boolean;
  30606. REFLECTIONFRESNELFROMSPECULAR: boolean;
  30607. LIGHTMAP: boolean;
  30608. LIGHTMAPDIRECTUV: number;
  30609. OBJECTSPACE_NORMALMAP: boolean;
  30610. USELIGHTMAPASSHADOWMAP: boolean;
  30611. REFLECTIONMAP_3D: boolean;
  30612. REFLECTIONMAP_SPHERICAL: boolean;
  30613. REFLECTIONMAP_PLANAR: boolean;
  30614. REFLECTIONMAP_CUBIC: boolean;
  30615. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  30616. REFLECTIONMAP_PROJECTION: boolean;
  30617. REFLECTIONMAP_SKYBOX: boolean;
  30618. REFLECTIONMAP_EXPLICIT: boolean;
  30619. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  30620. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  30621. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  30622. INVERTCUBICMAP: boolean;
  30623. LOGARITHMICDEPTH: boolean;
  30624. REFRACTION: boolean;
  30625. REFRACTIONMAP_3D: boolean;
  30626. REFLECTIONOVERALPHA: boolean;
  30627. TWOSIDEDLIGHTING: boolean;
  30628. SHADOWFLOAT: boolean;
  30629. MORPHTARGETS: boolean;
  30630. MORPHTARGETS_NORMAL: boolean;
  30631. MORPHTARGETS_TANGENT: boolean;
  30632. MORPHTARGETS_UV: boolean;
  30633. NUM_MORPH_INFLUENCERS: number;
  30634. NONUNIFORMSCALING: boolean;
  30635. PREMULTIPLYALPHA: boolean;
  30636. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  30637. ALPHABLEND: boolean;
  30638. PREPASS: boolean;
  30639. SCENE_MRT_COUNT: number;
  30640. RGBDLIGHTMAP: boolean;
  30641. RGBDREFLECTION: boolean;
  30642. RGBDREFRACTION: boolean;
  30643. IMAGEPROCESSING: boolean;
  30644. VIGNETTE: boolean;
  30645. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30646. VIGNETTEBLENDMODEOPAQUE: boolean;
  30647. TONEMAPPING: boolean;
  30648. TONEMAPPING_ACES: boolean;
  30649. CONTRAST: boolean;
  30650. COLORCURVES: boolean;
  30651. COLORGRADING: boolean;
  30652. COLORGRADING3D: boolean;
  30653. SAMPLER3DGREENDEPTH: boolean;
  30654. SAMPLER3DBGRMAP: boolean;
  30655. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30656. MULTIVIEW: boolean;
  30657. /**
  30658. * If the reflection texture on this material is in linear color space
  30659. * @hidden
  30660. */
  30661. IS_REFLECTION_LINEAR: boolean;
  30662. /**
  30663. * If the refraction texture on this material is in linear color space
  30664. * @hidden
  30665. */
  30666. IS_REFRACTION_LINEAR: boolean;
  30667. EXPOSURE: boolean;
  30668. constructor();
  30669. setReflectionMode(modeToEnable: string): void;
  30670. }
  30671. /**
  30672. * This is the default material used in Babylon. It is the best trade off between quality
  30673. * and performances.
  30674. * @see https://doc.babylonjs.com/babylon101/materials
  30675. */
  30676. export class StandardMaterial extends PushMaterial {
  30677. private _diffuseTexture;
  30678. /**
  30679. * The basic texture of the material as viewed under a light.
  30680. */
  30681. diffuseTexture: Nullable<BaseTexture>;
  30682. private _ambientTexture;
  30683. /**
  30684. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  30685. */
  30686. ambientTexture: Nullable<BaseTexture>;
  30687. private _opacityTexture;
  30688. /**
  30689. * Define the transparency of the material from a texture.
  30690. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  30691. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  30692. */
  30693. opacityTexture: Nullable<BaseTexture>;
  30694. private _reflectionTexture;
  30695. /**
  30696. * Define the texture used to display the reflection.
  30697. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30698. */
  30699. reflectionTexture: Nullable<BaseTexture>;
  30700. private _emissiveTexture;
  30701. /**
  30702. * Define texture of the material as if self lit.
  30703. * This will be mixed in the final result even in the absence of light.
  30704. */
  30705. emissiveTexture: Nullable<BaseTexture>;
  30706. private _specularTexture;
  30707. /**
  30708. * Define how the color and intensity of the highlight given by the light in the material.
  30709. */
  30710. specularTexture: Nullable<BaseTexture>;
  30711. private _bumpTexture;
  30712. /**
  30713. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  30714. * 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.
  30715. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  30716. */
  30717. bumpTexture: Nullable<BaseTexture>;
  30718. private _lightmapTexture;
  30719. /**
  30720. * Complex lighting can be computationally expensive to compute at runtime.
  30721. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  30722. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  30723. */
  30724. lightmapTexture: Nullable<BaseTexture>;
  30725. private _refractionTexture;
  30726. /**
  30727. * Define the texture used to display the refraction.
  30728. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30729. */
  30730. refractionTexture: Nullable<BaseTexture>;
  30731. /**
  30732. * The color of the material lit by the environmental background lighting.
  30733. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  30734. */
  30735. ambientColor: Color3;
  30736. /**
  30737. * The basic color of the material as viewed under a light.
  30738. */
  30739. diffuseColor: Color3;
  30740. /**
  30741. * Define how the color and intensity of the highlight given by the light in the material.
  30742. */
  30743. specularColor: Color3;
  30744. /**
  30745. * Define the color of the material as if self lit.
  30746. * This will be mixed in the final result even in the absence of light.
  30747. */
  30748. emissiveColor: Color3;
  30749. /**
  30750. * Defines how sharp are the highlights in the material.
  30751. * The bigger the value the sharper giving a more glossy feeling to the result.
  30752. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  30753. */
  30754. specularPower: number;
  30755. private _useAlphaFromDiffuseTexture;
  30756. /**
  30757. * Does the transparency come from the diffuse texture alpha channel.
  30758. */
  30759. useAlphaFromDiffuseTexture: boolean;
  30760. private _useEmissiveAsIllumination;
  30761. /**
  30762. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  30763. */
  30764. useEmissiveAsIllumination: boolean;
  30765. private _linkEmissiveWithDiffuse;
  30766. /**
  30767. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  30768. * the emissive level when the final color is close to one.
  30769. */
  30770. linkEmissiveWithDiffuse: boolean;
  30771. private _useSpecularOverAlpha;
  30772. /**
  30773. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  30774. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  30775. */
  30776. useSpecularOverAlpha: boolean;
  30777. private _useReflectionOverAlpha;
  30778. /**
  30779. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  30780. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  30781. */
  30782. useReflectionOverAlpha: boolean;
  30783. private _disableLighting;
  30784. /**
  30785. * Does lights from the scene impacts this material.
  30786. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  30787. */
  30788. disableLighting: boolean;
  30789. private _useObjectSpaceNormalMap;
  30790. /**
  30791. * Allows using an object space normal map (instead of tangent space).
  30792. */
  30793. useObjectSpaceNormalMap: boolean;
  30794. private _useParallax;
  30795. /**
  30796. * Is parallax enabled or not.
  30797. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30798. */
  30799. useParallax: boolean;
  30800. private _useParallaxOcclusion;
  30801. /**
  30802. * Is parallax occlusion enabled or not.
  30803. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  30804. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  30805. */
  30806. useParallaxOcclusion: boolean;
  30807. /**
  30808. * 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.
  30809. */
  30810. parallaxScaleBias: number;
  30811. private _roughness;
  30812. /**
  30813. * Helps to define how blurry the reflections should appears in the material.
  30814. */
  30815. roughness: number;
  30816. /**
  30817. * In case of refraction, define the value of the index of refraction.
  30818. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30819. */
  30820. indexOfRefraction: number;
  30821. /**
  30822. * Invert the refraction texture alongside the y axis.
  30823. * It can be useful with procedural textures or probe for instance.
  30824. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  30825. */
  30826. invertRefractionY: boolean;
  30827. /**
  30828. * Defines the alpha limits in alpha test mode.
  30829. */
  30830. alphaCutOff: number;
  30831. private _useLightmapAsShadowmap;
  30832. /**
  30833. * In case of light mapping, define whether the map contains light or shadow informations.
  30834. */
  30835. useLightmapAsShadowmap: boolean;
  30836. private _diffuseFresnelParameters;
  30837. /**
  30838. * Define the diffuse fresnel parameters of the material.
  30839. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30840. */
  30841. diffuseFresnelParameters: FresnelParameters;
  30842. private _opacityFresnelParameters;
  30843. /**
  30844. * Define the opacity fresnel parameters of the material.
  30845. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30846. */
  30847. opacityFresnelParameters: FresnelParameters;
  30848. private _reflectionFresnelParameters;
  30849. /**
  30850. * Define the reflection fresnel parameters of the material.
  30851. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30852. */
  30853. reflectionFresnelParameters: FresnelParameters;
  30854. private _refractionFresnelParameters;
  30855. /**
  30856. * Define the refraction fresnel parameters of the material.
  30857. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30858. */
  30859. refractionFresnelParameters: FresnelParameters;
  30860. private _emissiveFresnelParameters;
  30861. /**
  30862. * Define the emissive fresnel parameters of the material.
  30863. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30864. */
  30865. emissiveFresnelParameters: FresnelParameters;
  30866. private _useReflectionFresnelFromSpecular;
  30867. /**
  30868. * If true automatically deducts the fresnels values from the material specularity.
  30869. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30870. */
  30871. useReflectionFresnelFromSpecular: boolean;
  30872. private _useGlossinessFromSpecularMapAlpha;
  30873. /**
  30874. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  30875. */
  30876. useGlossinessFromSpecularMapAlpha: boolean;
  30877. private _maxSimultaneousLights;
  30878. /**
  30879. * Defines the maximum number of lights that can be used in the material
  30880. */
  30881. maxSimultaneousLights: number;
  30882. private _invertNormalMapX;
  30883. /**
  30884. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  30885. */
  30886. invertNormalMapX: boolean;
  30887. private _invertNormalMapY;
  30888. /**
  30889. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  30890. */
  30891. invertNormalMapY: boolean;
  30892. private _twoSidedLighting;
  30893. /**
  30894. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  30895. */
  30896. twoSidedLighting: boolean;
  30897. /**
  30898. * Default configuration related to image processing available in the standard Material.
  30899. */
  30900. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  30901. /**
  30902. * Gets the image processing configuration used either in this material.
  30903. */
  30904. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  30905. /**
  30906. * Sets the Default image processing configuration used either in the this material.
  30907. *
  30908. * If sets to null, the scene one is in use.
  30909. */
  30910. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  30911. /**
  30912. * Keep track of the image processing observer to allow dispose and replace.
  30913. */
  30914. private _imageProcessingObserver;
  30915. /**
  30916. * Attaches a new image processing configuration to the Standard Material.
  30917. * @param configuration
  30918. */
  30919. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  30920. /**
  30921. * Gets wether the color curves effect is enabled.
  30922. */
  30923. get cameraColorCurvesEnabled(): boolean;
  30924. /**
  30925. * Sets wether the color curves effect is enabled.
  30926. */
  30927. set cameraColorCurvesEnabled(value: boolean);
  30928. /**
  30929. * Gets wether the color grading effect is enabled.
  30930. */
  30931. get cameraColorGradingEnabled(): boolean;
  30932. /**
  30933. * Gets wether the color grading effect is enabled.
  30934. */
  30935. set cameraColorGradingEnabled(value: boolean);
  30936. /**
  30937. * Gets wether tonemapping is enabled or not.
  30938. */
  30939. get cameraToneMappingEnabled(): boolean;
  30940. /**
  30941. * Sets wether tonemapping is enabled or not
  30942. */
  30943. set cameraToneMappingEnabled(value: boolean);
  30944. /**
  30945. * The camera exposure used on this material.
  30946. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30947. * This corresponds to a photographic exposure.
  30948. */
  30949. get cameraExposure(): number;
  30950. /**
  30951. * The camera exposure used on this material.
  30952. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  30953. * This corresponds to a photographic exposure.
  30954. */
  30955. set cameraExposure(value: number);
  30956. /**
  30957. * Gets The camera contrast used on this material.
  30958. */
  30959. get cameraContrast(): number;
  30960. /**
  30961. * Sets The camera contrast used on this material.
  30962. */
  30963. set cameraContrast(value: number);
  30964. /**
  30965. * Gets the Color Grading 2D Lookup Texture.
  30966. */
  30967. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  30968. /**
  30969. * Sets the Color Grading 2D Lookup Texture.
  30970. */
  30971. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  30972. /**
  30973. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30974. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30975. * 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;
  30976. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30977. */
  30978. get cameraColorCurves(): Nullable<ColorCurves>;
  30979. /**
  30980. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30981. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30982. * 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;
  30983. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30984. */
  30985. set cameraColorCurves(value: Nullable<ColorCurves>);
  30986. /**
  30987. * Should this material render to several textures at once
  30988. */
  30989. get shouldRenderToMRT(): boolean;
  30990. /**
  30991. * Defines the detail map parameters for the material.
  30992. */
  30993. readonly detailMap: DetailMapConfiguration;
  30994. protected _renderTargets: SmartArray<RenderTargetTexture>;
  30995. protected _worldViewProjectionMatrix: Matrix;
  30996. protected _globalAmbientColor: Color3;
  30997. protected _useLogarithmicDepth: boolean;
  30998. protected _rebuildInParallel: boolean;
  30999. /**
  31000. * Instantiates a new standard material.
  31001. * This is the default material used in Babylon. It is the best trade off between quality
  31002. * and performances.
  31003. * @see https://doc.babylonjs.com/babylon101/materials
  31004. * @param name Define the name of the material in the scene
  31005. * @param scene Define the scene the material belong to
  31006. */
  31007. constructor(name: string, scene: Scene);
  31008. /**
  31009. * Gets a boolean indicating that current material needs to register RTT
  31010. */
  31011. get hasRenderTargetTextures(): boolean;
  31012. /**
  31013. * Gets the current class name of the material e.g. "StandardMaterial"
  31014. * Mainly use in serialization.
  31015. * @returns the class name
  31016. */
  31017. getClassName(): string;
  31018. /**
  31019. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  31020. * You can try switching to logarithmic depth.
  31021. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  31022. */
  31023. get useLogarithmicDepth(): boolean;
  31024. set useLogarithmicDepth(value: boolean);
  31025. /**
  31026. * Specifies if the material will require alpha blending
  31027. * @returns a boolean specifying if alpha blending is needed
  31028. */
  31029. needAlphaBlending(): boolean;
  31030. /**
  31031. * Specifies if this material should be rendered in alpha test mode
  31032. * @returns a boolean specifying if an alpha test is needed.
  31033. */
  31034. needAlphaTesting(): boolean;
  31035. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  31036. /**
  31037. * Get the texture used for alpha test purpose.
  31038. * @returns the diffuse texture in case of the standard material.
  31039. */
  31040. getAlphaTestTexture(): Nullable<BaseTexture>;
  31041. /**
  31042. * Get if the submesh is ready to be used and all its information available.
  31043. * Child classes can use it to update shaders
  31044. * @param mesh defines the mesh to check
  31045. * @param subMesh defines which submesh to check
  31046. * @param useInstances specifies that instances should be used
  31047. * @returns a boolean indicating that the submesh is ready or not
  31048. */
  31049. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  31050. /**
  31051. * Builds the material UBO layouts.
  31052. * Used internally during the effect preparation.
  31053. */
  31054. buildUniformLayout(): void;
  31055. /**
  31056. * Unbinds the material from the mesh
  31057. */
  31058. unbind(): void;
  31059. /**
  31060. * Binds the submesh to this material by preparing the effect and shader to draw
  31061. * @param world defines the world transformation matrix
  31062. * @param mesh defines the mesh containing the submesh
  31063. * @param subMesh defines the submesh to bind the material to
  31064. */
  31065. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  31066. /**
  31067. * Get the list of animatables in the material.
  31068. * @returns the list of animatables object used in the material
  31069. */
  31070. getAnimatables(): IAnimatable[];
  31071. /**
  31072. * Gets the active textures from the material
  31073. * @returns an array of textures
  31074. */
  31075. getActiveTextures(): BaseTexture[];
  31076. /**
  31077. * Specifies if the material uses a texture
  31078. * @param texture defines the texture to check against the material
  31079. * @returns a boolean specifying if the material uses the texture
  31080. */
  31081. hasTexture(texture: BaseTexture): boolean;
  31082. /**
  31083. * Disposes the material
  31084. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  31085. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  31086. */
  31087. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  31088. /**
  31089. * Makes a duplicate of the material, and gives it a new name
  31090. * @param name defines the new name for the duplicated material
  31091. * @returns the cloned material
  31092. */
  31093. clone(name: string): StandardMaterial;
  31094. /**
  31095. * Serializes this material in a JSON representation
  31096. * @returns the serialized material object
  31097. */
  31098. serialize(): any;
  31099. /**
  31100. * Creates a standard material from parsed material data
  31101. * @param source defines the JSON representation of the material
  31102. * @param scene defines the hosting scene
  31103. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  31104. * @returns a new standard material
  31105. */
  31106. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  31107. /**
  31108. * Are diffuse textures enabled in the application.
  31109. */
  31110. static get DiffuseTextureEnabled(): boolean;
  31111. static set DiffuseTextureEnabled(value: boolean);
  31112. /**
  31113. * Are detail textures enabled in the application.
  31114. */
  31115. static get DetailTextureEnabled(): boolean;
  31116. static set DetailTextureEnabled(value: boolean);
  31117. /**
  31118. * Are ambient textures enabled in the application.
  31119. */
  31120. static get AmbientTextureEnabled(): boolean;
  31121. static set AmbientTextureEnabled(value: boolean);
  31122. /**
  31123. * Are opacity textures enabled in the application.
  31124. */
  31125. static get OpacityTextureEnabled(): boolean;
  31126. static set OpacityTextureEnabled(value: boolean);
  31127. /**
  31128. * Are reflection textures enabled in the application.
  31129. */
  31130. static get ReflectionTextureEnabled(): boolean;
  31131. static set ReflectionTextureEnabled(value: boolean);
  31132. /**
  31133. * Are emissive textures enabled in the application.
  31134. */
  31135. static get EmissiveTextureEnabled(): boolean;
  31136. static set EmissiveTextureEnabled(value: boolean);
  31137. /**
  31138. * Are specular textures enabled in the application.
  31139. */
  31140. static get SpecularTextureEnabled(): boolean;
  31141. static set SpecularTextureEnabled(value: boolean);
  31142. /**
  31143. * Are bump textures enabled in the application.
  31144. */
  31145. static get BumpTextureEnabled(): boolean;
  31146. static set BumpTextureEnabled(value: boolean);
  31147. /**
  31148. * Are lightmap textures enabled in the application.
  31149. */
  31150. static get LightmapTextureEnabled(): boolean;
  31151. static set LightmapTextureEnabled(value: boolean);
  31152. /**
  31153. * Are refraction textures enabled in the application.
  31154. */
  31155. static get RefractionTextureEnabled(): boolean;
  31156. static set RefractionTextureEnabled(value: boolean);
  31157. /**
  31158. * Are color grading textures enabled in the application.
  31159. */
  31160. static get ColorGradingTextureEnabled(): boolean;
  31161. static set ColorGradingTextureEnabled(value: boolean);
  31162. /**
  31163. * Are fresnels enabled in the application.
  31164. */
  31165. static get FresnelEnabled(): boolean;
  31166. static set FresnelEnabled(value: boolean);
  31167. }
  31168. }
  31169. declare module "babylonjs/Particles/solidParticleSystem" {
  31170. import { Nullable } from "babylonjs/types";
  31171. import { Mesh } from "babylonjs/Meshes/mesh";
  31172. import { Scene, IDisposable } from "babylonjs/scene";
  31173. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  31174. import { Material } from "babylonjs/Materials/material";
  31175. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  31176. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  31177. /**
  31178. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  31179. *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.
  31180. * The SPS is also a particle system. It provides some methods to manage the particles.
  31181. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  31182. *
  31183. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  31184. */
  31185. export class SolidParticleSystem implements IDisposable {
  31186. /**
  31187. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  31188. * Example : var p = SPS.particles[i];
  31189. */
  31190. particles: SolidParticle[];
  31191. /**
  31192. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  31193. */
  31194. nbParticles: number;
  31195. /**
  31196. * If the particles must ever face the camera (default false). Useful for planar particles.
  31197. */
  31198. billboard: boolean;
  31199. /**
  31200. * Recompute normals when adding a shape
  31201. */
  31202. recomputeNormals: boolean;
  31203. /**
  31204. * This a counter ofr your own usage. It's not set by any SPS functions.
  31205. */
  31206. counter: number;
  31207. /**
  31208. * The SPS name. This name is also given to the underlying mesh.
  31209. */
  31210. name: string;
  31211. /**
  31212. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  31213. */
  31214. mesh: Mesh;
  31215. /**
  31216. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  31217. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  31218. */
  31219. vars: any;
  31220. /**
  31221. * This array is populated when the SPS is set as 'pickable'.
  31222. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  31223. * Each element of this array is an object `{idx: int, faceId: int}`.
  31224. * `idx` is the picked particle index in the `SPS.particles` array
  31225. * `faceId` is the picked face index counted within this particle.
  31226. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  31227. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  31228. * Use the method SPS.pickedParticle(pickingInfo) instead.
  31229. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31230. */
  31231. pickedParticles: {
  31232. idx: number;
  31233. faceId: number;
  31234. }[];
  31235. /**
  31236. * This array is populated when the SPS is set as 'pickable'
  31237. * Each key of this array is a submesh index.
  31238. * Each element of this array is a second array defined like this :
  31239. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  31240. * Each element of this second array is an object `{idx: int, faceId: int}`.
  31241. * `idx` is the picked particle index in the `SPS.particles` array
  31242. * `faceId` is the picked face index counted within this particle.
  31243. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  31244. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  31245. */
  31246. pickedBySubMesh: {
  31247. idx: number;
  31248. faceId: number;
  31249. }[][];
  31250. /**
  31251. * This array is populated when `enableDepthSort` is set to true.
  31252. * Each element of this array is an instance of the class DepthSortedParticle.
  31253. */
  31254. depthSortedParticles: DepthSortedParticle[];
  31255. /**
  31256. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  31257. * @hidden
  31258. */
  31259. _bSphereOnly: boolean;
  31260. /**
  31261. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  31262. * @hidden
  31263. */
  31264. _bSphereRadiusFactor: number;
  31265. private _scene;
  31266. private _positions;
  31267. private _indices;
  31268. private _normals;
  31269. private _colors;
  31270. private _uvs;
  31271. private _indices32;
  31272. private _positions32;
  31273. private _normals32;
  31274. private _fixedNormal32;
  31275. private _colors32;
  31276. private _uvs32;
  31277. private _index;
  31278. private _updatable;
  31279. private _pickable;
  31280. private _isVisibilityBoxLocked;
  31281. private _alwaysVisible;
  31282. private _depthSort;
  31283. private _expandable;
  31284. private _shapeCounter;
  31285. private _copy;
  31286. private _color;
  31287. private _computeParticleColor;
  31288. private _computeParticleTexture;
  31289. private _computeParticleRotation;
  31290. private _computeParticleVertex;
  31291. private _computeBoundingBox;
  31292. private _depthSortParticles;
  31293. private _camera;
  31294. private _mustUnrotateFixedNormals;
  31295. private _particlesIntersect;
  31296. private _needs32Bits;
  31297. private _isNotBuilt;
  31298. private _lastParticleId;
  31299. private _idxOfId;
  31300. private _multimaterialEnabled;
  31301. private _useModelMaterial;
  31302. private _indicesByMaterial;
  31303. private _materialIndexes;
  31304. private _depthSortFunction;
  31305. private _materialSortFunction;
  31306. private _materials;
  31307. private _multimaterial;
  31308. private _materialIndexesById;
  31309. private _defaultMaterial;
  31310. private _autoUpdateSubMeshes;
  31311. private _tmpVertex;
  31312. /**
  31313. * Creates a SPS (Solid Particle System) object.
  31314. * @param name (String) is the SPS name, this will be the underlying mesh name.
  31315. * @param scene (Scene) is the scene in which the SPS is added.
  31316. * @param options defines the options of the sps e.g.
  31317. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  31318. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  31319. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  31320. * * 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.
  31321. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  31322. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  31323. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  31324. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  31325. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  31326. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  31327. */
  31328. constructor(name: string, scene: Scene, options?: {
  31329. updatable?: boolean;
  31330. isPickable?: boolean;
  31331. enableDepthSort?: boolean;
  31332. particleIntersection?: boolean;
  31333. boundingSphereOnly?: boolean;
  31334. bSphereRadiusFactor?: number;
  31335. expandable?: boolean;
  31336. useModelMaterial?: boolean;
  31337. enableMultiMaterial?: boolean;
  31338. });
  31339. /**
  31340. * Builds the SPS underlying mesh. Returns a standard Mesh.
  31341. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  31342. * @returns the created mesh
  31343. */
  31344. buildMesh(): Mesh;
  31345. /**
  31346. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  31347. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  31348. * Thus the particles generated from `digest()` have their property `position` set yet.
  31349. * @param mesh ( Mesh ) is the mesh to be digested
  31350. * @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
  31351. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  31352. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  31353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31354. * @returns the current SPS
  31355. */
  31356. digest(mesh: Mesh, options?: {
  31357. facetNb?: number;
  31358. number?: number;
  31359. delta?: number;
  31360. storage?: [];
  31361. }): SolidParticleSystem;
  31362. /**
  31363. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  31364. * @hidden
  31365. */
  31366. private _unrotateFixedNormals;
  31367. /**
  31368. * Resets the temporary working copy particle
  31369. * @hidden
  31370. */
  31371. private _resetCopy;
  31372. /**
  31373. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  31374. * @param p the current index in the positions array to be updated
  31375. * @param ind the current index in the indices array
  31376. * @param shape a Vector3 array, the shape geometry
  31377. * @param positions the positions array to be updated
  31378. * @param meshInd the shape indices array
  31379. * @param indices the indices array to be updated
  31380. * @param meshUV the shape uv array
  31381. * @param uvs the uv array to be updated
  31382. * @param meshCol the shape color array
  31383. * @param colors the color array to be updated
  31384. * @param meshNor the shape normals array
  31385. * @param normals the normals array to be updated
  31386. * @param idx the particle index
  31387. * @param idxInShape the particle index in its shape
  31388. * @param options the addShape() method passed options
  31389. * @model the particle model
  31390. * @hidden
  31391. */
  31392. private _meshBuilder;
  31393. /**
  31394. * Returns a shape Vector3 array from positions float array
  31395. * @param positions float array
  31396. * @returns a vector3 array
  31397. * @hidden
  31398. */
  31399. private _posToShape;
  31400. /**
  31401. * Returns a shapeUV array from a float uvs (array deep copy)
  31402. * @param uvs as a float array
  31403. * @returns a shapeUV array
  31404. * @hidden
  31405. */
  31406. private _uvsToShapeUV;
  31407. /**
  31408. * Adds a new particle object in the particles array
  31409. * @param idx particle index in particles array
  31410. * @param id particle id
  31411. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  31412. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  31413. * @param model particle ModelShape object
  31414. * @param shapeId model shape identifier
  31415. * @param idxInShape index of the particle in the current model
  31416. * @param bInfo model bounding info object
  31417. * @param storage target storage array, if any
  31418. * @hidden
  31419. */
  31420. private _addParticle;
  31421. /**
  31422. * Adds some particles to the SPS from the model shape. Returns the shape id.
  31423. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  31424. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  31425. * @param nb (positive integer) the number of particles to be created from this model
  31426. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  31427. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  31428. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  31429. * @returns the number of shapes in the system
  31430. */
  31431. addShape(mesh: Mesh, nb: number, options?: {
  31432. positionFunction?: any;
  31433. vertexFunction?: any;
  31434. storage?: [];
  31435. }): number;
  31436. /**
  31437. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  31438. * @hidden
  31439. */
  31440. private _rebuildParticle;
  31441. /**
  31442. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  31443. * @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.
  31444. * @returns the SPS.
  31445. */
  31446. rebuildMesh(reset?: boolean): SolidParticleSystem;
  31447. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  31448. * Returns an array with the removed particles.
  31449. * 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.
  31450. * The SPS can't be empty so at least one particle needs to remain in place.
  31451. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  31452. * @param start index of the first particle to remove
  31453. * @param end index of the last particle to remove (included)
  31454. * @returns an array populated with the removed particles
  31455. */
  31456. removeParticles(start: number, end: number): SolidParticle[];
  31457. /**
  31458. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  31459. * @param solidParticleArray an array populated with Solid Particles objects
  31460. * @returns the SPS
  31461. */
  31462. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  31463. /**
  31464. * Creates a new particle and modifies the SPS mesh geometry :
  31465. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  31466. * - calls _addParticle() to populate the particle array
  31467. * factorized code from addShape() and insertParticlesFromArray()
  31468. * @param idx particle index in the particles array
  31469. * @param i particle index in its shape
  31470. * @param modelShape particle ModelShape object
  31471. * @param shape shape vertex array
  31472. * @param meshInd shape indices array
  31473. * @param meshUV shape uv array
  31474. * @param meshCol shape color array
  31475. * @param meshNor shape normals array
  31476. * @param bbInfo shape bounding info
  31477. * @param storage target particle storage
  31478. * @options addShape() passed options
  31479. * @hidden
  31480. */
  31481. private _insertNewParticle;
  31482. /**
  31483. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  31484. * This method calls `updateParticle()` for each particle of the SPS.
  31485. * For an animated SPS, it is usually called within the render loop.
  31486. * 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.
  31487. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  31488. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  31489. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  31490. * @returns the SPS.
  31491. */
  31492. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  31493. /**
  31494. * Disposes the SPS.
  31495. */
  31496. dispose(): void;
  31497. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  31498. * idx is the particle index in the SPS
  31499. * faceId is the picked face index counted within this particle.
  31500. * Returns null if the pickInfo can't identify a picked particle.
  31501. * @param pickingInfo (PickingInfo object)
  31502. * @returns {idx: number, faceId: number} or null
  31503. */
  31504. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  31505. idx: number;
  31506. faceId: number;
  31507. }>;
  31508. /**
  31509. * Returns a SolidParticle object from its identifier : particle.id
  31510. * @param id (integer) the particle Id
  31511. * @returns the searched particle or null if not found in the SPS.
  31512. */
  31513. getParticleById(id: number): Nullable<SolidParticle>;
  31514. /**
  31515. * Returns a new array populated with the particles having the passed shapeId.
  31516. * @param shapeId (integer) the shape identifier
  31517. * @returns a new solid particle array
  31518. */
  31519. getParticlesByShapeId(shapeId: number): SolidParticle[];
  31520. /**
  31521. * Populates the passed array "ref" with the particles having the passed shapeId.
  31522. * @param shapeId the shape identifier
  31523. * @returns the SPS
  31524. * @param ref
  31525. */
  31526. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  31527. /**
  31528. * Computes the required SubMeshes according the materials assigned to the particles.
  31529. * @returns the solid particle system.
  31530. * Does nothing if called before the SPS mesh is built.
  31531. */
  31532. computeSubMeshes(): SolidParticleSystem;
  31533. /**
  31534. * Sorts the solid particles by material when MultiMaterial is enabled.
  31535. * Updates the indices32 array.
  31536. * Updates the indicesByMaterial array.
  31537. * Updates the mesh indices array.
  31538. * @returns the SPS
  31539. * @hidden
  31540. */
  31541. private _sortParticlesByMaterial;
  31542. /**
  31543. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  31544. * @hidden
  31545. */
  31546. private _setMaterialIndexesById;
  31547. /**
  31548. * Returns an array with unique values of Materials from the passed array
  31549. * @param array the material array to be checked and filtered
  31550. * @hidden
  31551. */
  31552. private _filterUniqueMaterialId;
  31553. /**
  31554. * Sets a new Standard Material as _defaultMaterial if not already set.
  31555. * @hidden
  31556. */
  31557. private _setDefaultMaterial;
  31558. /**
  31559. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  31560. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31561. * @returns the SPS.
  31562. */
  31563. refreshVisibleSize(): SolidParticleSystem;
  31564. /**
  31565. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  31566. * @param size the size (float) of the visibility box
  31567. * note : this doesn't lock the SPS mesh bounding box.
  31568. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31569. */
  31570. setVisibilityBox(size: number): void;
  31571. /**
  31572. * Gets whether the SPS as always visible or not
  31573. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31574. */
  31575. get isAlwaysVisible(): boolean;
  31576. /**
  31577. * Sets the SPS as always visible or not
  31578. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31579. */
  31580. set isAlwaysVisible(val: boolean);
  31581. /**
  31582. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31583. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31584. */
  31585. set isVisibilityBoxLocked(val: boolean);
  31586. /**
  31587. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  31588. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  31589. */
  31590. get isVisibilityBoxLocked(): boolean;
  31591. /**
  31592. * Tells to `setParticles()` to compute the particle rotations or not.
  31593. * Default value : true. The SPS is faster when it's set to false.
  31594. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31595. */
  31596. set computeParticleRotation(val: boolean);
  31597. /**
  31598. * Tells to `setParticles()` to compute the particle colors or not.
  31599. * Default value : true. The SPS is faster when it's set to false.
  31600. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31601. */
  31602. set computeParticleColor(val: boolean);
  31603. set computeParticleTexture(val: boolean);
  31604. /**
  31605. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  31606. * Default value : false. The SPS is faster when it's set to false.
  31607. * Note : the particle custom vertex positions aren't stored values.
  31608. */
  31609. set computeParticleVertex(val: boolean);
  31610. /**
  31611. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  31612. */
  31613. set computeBoundingBox(val: boolean);
  31614. /**
  31615. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  31616. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31617. * Default : `true`
  31618. */
  31619. set depthSortParticles(val: boolean);
  31620. /**
  31621. * Gets if `setParticles()` computes the particle rotations or not.
  31622. * Default value : true. The SPS is faster when it's set to false.
  31623. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  31624. */
  31625. get computeParticleRotation(): boolean;
  31626. /**
  31627. * Gets if `setParticles()` computes the particle colors or not.
  31628. * Default value : true. The SPS is faster when it's set to false.
  31629. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  31630. */
  31631. get computeParticleColor(): boolean;
  31632. /**
  31633. * Gets if `setParticles()` computes the particle textures or not.
  31634. * Default value : true. The SPS is faster when it's set to false.
  31635. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  31636. */
  31637. get computeParticleTexture(): boolean;
  31638. /**
  31639. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  31640. * Default value : false. The SPS is faster when it's set to false.
  31641. * Note : the particle custom vertex positions aren't stored values.
  31642. */
  31643. get computeParticleVertex(): boolean;
  31644. /**
  31645. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  31646. */
  31647. get computeBoundingBox(): boolean;
  31648. /**
  31649. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  31650. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  31651. * Default : `true`
  31652. */
  31653. get depthSortParticles(): boolean;
  31654. /**
  31655. * Gets if the SPS is created as expandable at construction time.
  31656. * Default : `false`
  31657. */
  31658. get expandable(): boolean;
  31659. /**
  31660. * Gets if the SPS supports the Multi Materials
  31661. */
  31662. get multimaterialEnabled(): boolean;
  31663. /**
  31664. * Gets if the SPS uses the model materials for its own multimaterial.
  31665. */
  31666. get useModelMaterial(): boolean;
  31667. /**
  31668. * The SPS used material array.
  31669. */
  31670. get materials(): Material[];
  31671. /**
  31672. * Sets the SPS MultiMaterial from the passed materials.
  31673. * Note : the passed array is internally copied and not used then by reference.
  31674. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  31675. */
  31676. setMultiMaterial(materials: Material[]): void;
  31677. /**
  31678. * The SPS computed multimaterial object
  31679. */
  31680. get multimaterial(): MultiMaterial;
  31681. set multimaterial(mm: MultiMaterial);
  31682. /**
  31683. * If the subMeshes must be updated on the next call to setParticles()
  31684. */
  31685. get autoUpdateSubMeshes(): boolean;
  31686. set autoUpdateSubMeshes(val: boolean);
  31687. /**
  31688. * This function does nothing. It may be overwritten to set all the particle first values.
  31689. * The SPS doesn't call this function, you may have to call it by your own.
  31690. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31691. */
  31692. initParticles(): void;
  31693. /**
  31694. * This function does nothing. It may be overwritten to recycle a particle.
  31695. * The SPS doesn't call this function, you may have to call it by your own.
  31696. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31697. * @param particle The particle to recycle
  31698. * @returns the recycled particle
  31699. */
  31700. recycleParticle(particle: SolidParticle): SolidParticle;
  31701. /**
  31702. * Updates a particle : this function should be overwritten by the user.
  31703. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  31704. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  31705. * @example : just set a particle position or velocity and recycle conditions
  31706. * @param particle The particle to update
  31707. * @returns the updated particle
  31708. */
  31709. updateParticle(particle: SolidParticle): SolidParticle;
  31710. /**
  31711. * Updates a vertex of a particle : it can be overwritten by the user.
  31712. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  31713. * @param particle the current particle
  31714. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  31715. * @param pt the index of the current vertex in the particle shape
  31716. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  31717. * @example : just set a vertex particle position or color
  31718. * @returns the sps
  31719. */
  31720. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  31721. /**
  31722. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  31723. * This does nothing and may be overwritten by the user.
  31724. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31725. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31726. * @param update the boolean update value actually passed to setParticles()
  31727. */
  31728. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31729. /**
  31730. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  31731. * This will be passed three parameters.
  31732. * This does nothing and may be overwritten by the user.
  31733. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31734. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  31735. * @param update the boolean update value actually passed to setParticles()
  31736. */
  31737. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  31738. }
  31739. }
  31740. declare module "babylonjs/Particles/solidParticle" {
  31741. import { Nullable } from "babylonjs/types";
  31742. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  31743. import { Color4 } from "babylonjs/Maths/math.color";
  31744. import { Mesh } from "babylonjs/Meshes/mesh";
  31745. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  31746. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  31747. import { Plane } from "babylonjs/Maths/math.plane";
  31748. import { Material } from "babylonjs/Materials/material";
  31749. /**
  31750. * Represents one particle of a solid particle system.
  31751. */
  31752. export class SolidParticle {
  31753. /**
  31754. * particle global index
  31755. */
  31756. idx: number;
  31757. /**
  31758. * particle identifier
  31759. */
  31760. id: number;
  31761. /**
  31762. * The color of the particle
  31763. */
  31764. color: Nullable<Color4>;
  31765. /**
  31766. * The world space position of the particle.
  31767. */
  31768. position: Vector3;
  31769. /**
  31770. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  31771. */
  31772. rotation: Vector3;
  31773. /**
  31774. * The world space rotation quaternion of the particle.
  31775. */
  31776. rotationQuaternion: Nullable<Quaternion>;
  31777. /**
  31778. * The scaling of the particle.
  31779. */
  31780. scaling: Vector3;
  31781. /**
  31782. * The uvs of the particle.
  31783. */
  31784. uvs: Vector4;
  31785. /**
  31786. * The current speed of the particle.
  31787. */
  31788. velocity: Vector3;
  31789. /**
  31790. * The pivot point in the particle local space.
  31791. */
  31792. pivot: Vector3;
  31793. /**
  31794. * Must the particle be translated from its pivot point in its local space ?
  31795. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  31796. * Default : false
  31797. */
  31798. translateFromPivot: boolean;
  31799. /**
  31800. * Is the particle active or not ?
  31801. */
  31802. alive: boolean;
  31803. /**
  31804. * Is the particle visible or not ?
  31805. */
  31806. isVisible: boolean;
  31807. /**
  31808. * Index of this particle in the global "positions" array (Internal use)
  31809. * @hidden
  31810. */
  31811. _pos: number;
  31812. /**
  31813. * @hidden Index of this particle in the global "indices" array (Internal use)
  31814. */
  31815. _ind: number;
  31816. /**
  31817. * @hidden ModelShape of this particle (Internal use)
  31818. */
  31819. _model: ModelShape;
  31820. /**
  31821. * ModelShape id of this particle
  31822. */
  31823. shapeId: number;
  31824. /**
  31825. * Index of the particle in its shape id
  31826. */
  31827. idxInShape: number;
  31828. /**
  31829. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  31830. */
  31831. _modelBoundingInfo: BoundingInfo;
  31832. /**
  31833. * @hidden Particle BoundingInfo object (Internal use)
  31834. */
  31835. _boundingInfo: BoundingInfo;
  31836. /**
  31837. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  31838. */
  31839. _sps: SolidParticleSystem;
  31840. /**
  31841. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  31842. */
  31843. _stillInvisible: boolean;
  31844. /**
  31845. * @hidden Last computed particle rotation matrix
  31846. */
  31847. _rotationMatrix: number[];
  31848. /**
  31849. * Parent particle Id, if any.
  31850. * Default null.
  31851. */
  31852. parentId: Nullable<number>;
  31853. /**
  31854. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  31855. */
  31856. materialIndex: Nullable<number>;
  31857. /**
  31858. * Custom object or properties.
  31859. */
  31860. props: Nullable<any>;
  31861. /**
  31862. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  31863. * The possible values are :
  31864. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  31865. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31866. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  31867. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  31868. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  31869. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  31870. * */
  31871. cullingStrategy: number;
  31872. /**
  31873. * @hidden Internal global position in the SPS.
  31874. */
  31875. _globalPosition: Vector3;
  31876. /**
  31877. * Creates a Solid Particle object.
  31878. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  31879. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  31880. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  31881. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  31882. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  31883. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  31884. * @param shapeId (integer) is the model shape identifier in the SPS.
  31885. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  31886. * @param sps defines the sps it is associated to
  31887. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  31888. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  31889. */
  31890. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  31891. /**
  31892. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  31893. * @param target the particle target
  31894. * @returns the current particle
  31895. */
  31896. copyToRef(target: SolidParticle): SolidParticle;
  31897. /**
  31898. * Legacy support, changed scale to scaling
  31899. */
  31900. get scale(): Vector3;
  31901. /**
  31902. * Legacy support, changed scale to scaling
  31903. */
  31904. set scale(scale: Vector3);
  31905. /**
  31906. * Legacy support, changed quaternion to rotationQuaternion
  31907. */
  31908. get quaternion(): Nullable<Quaternion>;
  31909. /**
  31910. * Legacy support, changed quaternion to rotationQuaternion
  31911. */
  31912. set quaternion(q: Nullable<Quaternion>);
  31913. /**
  31914. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  31915. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  31916. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  31917. * @returns true if it intersects
  31918. */
  31919. intersectsMesh(target: Mesh | SolidParticle): boolean;
  31920. /**
  31921. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  31922. * A particle is in the frustum if its bounding box intersects the frustum
  31923. * @param frustumPlanes defines the frustum to test
  31924. * @returns true if the particle is in the frustum planes
  31925. */
  31926. isInFrustum(frustumPlanes: Plane[]): boolean;
  31927. /**
  31928. * get the rotation matrix of the particle
  31929. * @hidden
  31930. */
  31931. getRotationMatrix(m: Matrix): void;
  31932. }
  31933. /**
  31934. * Represents the shape of the model used by one particle of a solid particle system.
  31935. * SPS internal tool, don't use it manually.
  31936. */
  31937. export class ModelShape {
  31938. /**
  31939. * The shape id
  31940. * @hidden
  31941. */
  31942. shapeID: number;
  31943. /**
  31944. * flat array of model positions (internal use)
  31945. * @hidden
  31946. */
  31947. _shape: Vector3[];
  31948. /**
  31949. * flat array of model UVs (internal use)
  31950. * @hidden
  31951. */
  31952. _shapeUV: number[];
  31953. /**
  31954. * color array of the model
  31955. * @hidden
  31956. */
  31957. _shapeColors: number[];
  31958. /**
  31959. * indices array of the model
  31960. * @hidden
  31961. */
  31962. _indices: number[];
  31963. /**
  31964. * normals array of the model
  31965. * @hidden
  31966. */
  31967. _normals: number[];
  31968. /**
  31969. * length of the shape in the model indices array (internal use)
  31970. * @hidden
  31971. */
  31972. _indicesLength: number;
  31973. /**
  31974. * Custom position function (internal use)
  31975. * @hidden
  31976. */
  31977. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  31978. /**
  31979. * Custom vertex function (internal use)
  31980. * @hidden
  31981. */
  31982. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  31983. /**
  31984. * Model material (internal use)
  31985. * @hidden
  31986. */
  31987. _material: Nullable<Material>;
  31988. /**
  31989. * 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.
  31990. * SPS internal tool, don't use it manually.
  31991. * @hidden
  31992. */
  31993. 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>);
  31994. }
  31995. /**
  31996. * Represents a Depth Sorted Particle in the solid particle system.
  31997. * @hidden
  31998. */
  31999. export class DepthSortedParticle {
  32000. /**
  32001. * Particle index
  32002. */
  32003. idx: number;
  32004. /**
  32005. * Index of the particle in the "indices" array
  32006. */
  32007. ind: number;
  32008. /**
  32009. * Length of the particle shape in the "indices" array
  32010. */
  32011. indicesLength: number;
  32012. /**
  32013. * Squared distance from the particle to the camera
  32014. */
  32015. sqDistance: number;
  32016. /**
  32017. * Material index when used with MultiMaterials
  32018. */
  32019. materialIndex: number;
  32020. /**
  32021. * Creates a new sorted particle
  32022. * @param materialIndex
  32023. */
  32024. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  32025. }
  32026. /**
  32027. * Represents a solid particle vertex
  32028. */
  32029. export class SolidParticleVertex {
  32030. /**
  32031. * Vertex position
  32032. */
  32033. position: Vector3;
  32034. /**
  32035. * Vertex color
  32036. */
  32037. color: Color4;
  32038. /**
  32039. * Vertex UV
  32040. */
  32041. uv: Vector2;
  32042. /**
  32043. * Creates a new solid particle vertex
  32044. */
  32045. constructor();
  32046. /** Vertex x coordinate */
  32047. get x(): number;
  32048. set x(val: number);
  32049. /** Vertex y coordinate */
  32050. get y(): number;
  32051. set y(val: number);
  32052. /** Vertex z coordinate */
  32053. get z(): number;
  32054. set z(val: number);
  32055. }
  32056. }
  32057. declare module "babylonjs/Collisions/meshCollisionData" {
  32058. import { Collider } from "babylonjs/Collisions/collider";
  32059. import { Vector3 } from "babylonjs/Maths/math.vector";
  32060. import { Nullable } from "babylonjs/types";
  32061. import { Observer } from "babylonjs/Misc/observable";
  32062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32063. /**
  32064. * @hidden
  32065. */
  32066. export class _MeshCollisionData {
  32067. _checkCollisions: boolean;
  32068. _collisionMask: number;
  32069. _collisionGroup: number;
  32070. _surroundingMeshes: Nullable<AbstractMesh[]>;
  32071. _collider: Nullable<Collider>;
  32072. _oldPositionForCollisions: Vector3;
  32073. _diffPositionForCollisions: Vector3;
  32074. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  32075. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  32076. }
  32077. }
  32078. declare module "babylonjs/Meshes/abstractMesh" {
  32079. import { Observable } from "babylonjs/Misc/observable";
  32080. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  32081. import { Camera } from "babylonjs/Cameras/camera";
  32082. import { Scene, IDisposable } from "babylonjs/scene";
  32083. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  32084. import { Node } from "babylonjs/node";
  32085. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  32086. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32087. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32088. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32089. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32090. import { Material } from "babylonjs/Materials/material";
  32091. import { Light } from "babylonjs/Lights/light";
  32092. import { Skeleton } from "babylonjs/Bones/skeleton";
  32093. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  32094. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  32095. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32096. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  32097. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  32098. import { Plane } from "babylonjs/Maths/math.plane";
  32099. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32100. import { Ray } from "babylonjs/Culling/ray";
  32101. import { Collider } from "babylonjs/Collisions/collider";
  32102. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32103. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  32104. /** @hidden */
  32105. class _FacetDataStorage {
  32106. facetPositions: Vector3[];
  32107. facetNormals: Vector3[];
  32108. facetPartitioning: number[][];
  32109. facetNb: number;
  32110. partitioningSubdivisions: number;
  32111. partitioningBBoxRatio: number;
  32112. facetDataEnabled: boolean;
  32113. facetParameters: any;
  32114. bbSize: Vector3;
  32115. subDiv: {
  32116. max: number;
  32117. X: number;
  32118. Y: number;
  32119. Z: number;
  32120. };
  32121. facetDepthSort: boolean;
  32122. facetDepthSortEnabled: boolean;
  32123. depthSortedIndices: IndicesArray;
  32124. depthSortedFacets: {
  32125. ind: number;
  32126. sqDistance: number;
  32127. }[];
  32128. facetDepthSortFunction: (f1: {
  32129. ind: number;
  32130. sqDistance: number;
  32131. }, f2: {
  32132. ind: number;
  32133. sqDistance: number;
  32134. }) => number;
  32135. facetDepthSortFrom: Vector3;
  32136. facetDepthSortOrigin: Vector3;
  32137. invertedMatrix: Matrix;
  32138. }
  32139. /**
  32140. * @hidden
  32141. **/
  32142. class _InternalAbstractMeshDataInfo {
  32143. _hasVertexAlpha: boolean;
  32144. _useVertexColors: boolean;
  32145. _numBoneInfluencers: number;
  32146. _applyFog: boolean;
  32147. _receiveShadows: boolean;
  32148. _facetData: _FacetDataStorage;
  32149. _visibility: number;
  32150. _skeleton: Nullable<Skeleton>;
  32151. _layerMask: number;
  32152. _computeBonesUsingShaders: boolean;
  32153. _isActive: boolean;
  32154. _onlyForInstances: boolean;
  32155. _isActiveIntermediate: boolean;
  32156. _onlyForInstancesIntermediate: boolean;
  32157. _actAsRegularMesh: boolean;
  32158. }
  32159. /**
  32160. * Class used to store all common mesh properties
  32161. */
  32162. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  32163. /** No occlusion */
  32164. static OCCLUSION_TYPE_NONE: number;
  32165. /** Occlusion set to optimisitic */
  32166. static OCCLUSION_TYPE_OPTIMISTIC: number;
  32167. /** Occlusion set to strict */
  32168. static OCCLUSION_TYPE_STRICT: number;
  32169. /** Use an accurante occlusion algorithm */
  32170. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  32171. /** Use a conservative occlusion algorithm */
  32172. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  32173. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  32174. * Test order :
  32175. * Is the bounding sphere outside the frustum ?
  32176. * If not, are the bounding box vertices outside the frustum ?
  32177. * It not, then the cullable object is in the frustum.
  32178. */
  32179. static readonly CULLINGSTRATEGY_STANDARD: number;
  32180. /** Culling strategy : Bounding Sphere Only.
  32181. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  32182. * It's also less accurate than the standard because some not visible objects can still be selected.
  32183. * Test : is the bounding sphere outside the frustum ?
  32184. * If not, then the cullable object is in the frustum.
  32185. */
  32186. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  32187. /** Culling strategy : Optimistic Inclusion.
  32188. * This in an inclusion test first, then the standard exclusion test.
  32189. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  32190. * 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.
  32191. * Anyway, it's as accurate as the standard strategy.
  32192. * Test :
  32193. * Is the cullable object bounding sphere center in the frustum ?
  32194. * If not, apply the default culling strategy.
  32195. */
  32196. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  32197. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  32198. * This in an inclusion test first, then the bounding sphere only exclusion test.
  32199. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  32200. * 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.
  32201. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  32202. * Test :
  32203. * Is the cullable object bounding sphere center in the frustum ?
  32204. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  32205. */
  32206. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  32207. /**
  32208. * No billboard
  32209. */
  32210. static get BILLBOARDMODE_NONE(): number;
  32211. /** Billboard on X axis */
  32212. static get BILLBOARDMODE_X(): number;
  32213. /** Billboard on Y axis */
  32214. static get BILLBOARDMODE_Y(): number;
  32215. /** Billboard on Z axis */
  32216. static get BILLBOARDMODE_Z(): number;
  32217. /** Billboard on all axes */
  32218. static get BILLBOARDMODE_ALL(): number;
  32219. /** Billboard on using position instead of orientation */
  32220. static get BILLBOARDMODE_USE_POSITION(): number;
  32221. /** @hidden */
  32222. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  32223. /**
  32224. * The culling strategy to use to check whether the mesh must be rendered or not.
  32225. * This value can be changed at any time and will be used on the next render mesh selection.
  32226. * The possible values are :
  32227. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32228. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32229. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32230. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32231. * Please read each static variable documentation to get details about the culling process.
  32232. * */
  32233. cullingStrategy: number;
  32234. /**
  32235. * Gets the number of facets in the mesh
  32236. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32237. */
  32238. get facetNb(): number;
  32239. /**
  32240. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  32241. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32242. */
  32243. get partitioningSubdivisions(): number;
  32244. set partitioningSubdivisions(nb: number);
  32245. /**
  32246. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  32247. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  32248. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  32249. */
  32250. get partitioningBBoxRatio(): number;
  32251. set partitioningBBoxRatio(ratio: number);
  32252. /**
  32253. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  32254. * Works only for updatable meshes.
  32255. * Doesn't work with multi-materials
  32256. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32257. */
  32258. get mustDepthSortFacets(): boolean;
  32259. set mustDepthSortFacets(sort: boolean);
  32260. /**
  32261. * The location (Vector3) where the facet depth sort must be computed from.
  32262. * By default, the active camera position.
  32263. * Used only when facet depth sort is enabled
  32264. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  32265. */
  32266. get facetDepthSortFrom(): Vector3;
  32267. set facetDepthSortFrom(location: Vector3);
  32268. /**
  32269. * gets a boolean indicating if facetData is enabled
  32270. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  32271. */
  32272. get isFacetDataEnabled(): boolean;
  32273. /** @hidden */
  32274. _updateNonUniformScalingState(value: boolean): boolean;
  32275. /**
  32276. * An event triggered when this mesh collides with another one
  32277. */
  32278. onCollideObservable: Observable<AbstractMesh>;
  32279. /** Set a function to call when this mesh collides with another one */
  32280. set onCollide(callback: () => void);
  32281. /**
  32282. * An event triggered when the collision's position changes
  32283. */
  32284. onCollisionPositionChangeObservable: Observable<Vector3>;
  32285. /** Set a function to call when the collision's position changes */
  32286. set onCollisionPositionChange(callback: () => void);
  32287. /**
  32288. * An event triggered when material is changed
  32289. */
  32290. onMaterialChangedObservable: Observable<AbstractMesh>;
  32291. /**
  32292. * Gets or sets the orientation for POV movement & rotation
  32293. */
  32294. definedFacingForward: boolean;
  32295. /** @hidden */
  32296. _occlusionQuery: Nullable<WebGLQuery>;
  32297. /** @hidden */
  32298. _renderingGroup: Nullable<RenderingGroup>;
  32299. /**
  32300. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32301. */
  32302. get visibility(): number;
  32303. /**
  32304. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  32305. */
  32306. set visibility(value: number);
  32307. /** Gets or sets the alpha index used to sort transparent meshes
  32308. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  32309. */
  32310. alphaIndex: number;
  32311. /**
  32312. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  32313. */
  32314. isVisible: boolean;
  32315. /**
  32316. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  32317. */
  32318. isPickable: boolean;
  32319. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  32320. showSubMeshesBoundingBox: boolean;
  32321. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  32322. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  32323. */
  32324. isBlocker: boolean;
  32325. /**
  32326. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  32327. */
  32328. enablePointerMoveEvents: boolean;
  32329. /**
  32330. * Specifies the rendering group id for this mesh (0 by default)
  32331. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  32332. */
  32333. renderingGroupId: number;
  32334. private _material;
  32335. /** Gets or sets current material */
  32336. get material(): Nullable<Material>;
  32337. set material(value: Nullable<Material>);
  32338. /**
  32339. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  32340. * @see https://doc.babylonjs.com/babylon101/shadows
  32341. */
  32342. get receiveShadows(): boolean;
  32343. set receiveShadows(value: boolean);
  32344. /** Defines color to use when rendering outline */
  32345. outlineColor: Color3;
  32346. /** Define width to use when rendering outline */
  32347. outlineWidth: number;
  32348. /** Defines color to use when rendering overlay */
  32349. overlayColor: Color3;
  32350. /** Defines alpha to use when rendering overlay */
  32351. overlayAlpha: number;
  32352. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  32353. get hasVertexAlpha(): boolean;
  32354. set hasVertexAlpha(value: boolean);
  32355. /** 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) */
  32356. get useVertexColors(): boolean;
  32357. set useVertexColors(value: boolean);
  32358. /**
  32359. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  32360. */
  32361. get computeBonesUsingShaders(): boolean;
  32362. set computeBonesUsingShaders(value: boolean);
  32363. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  32364. get numBoneInfluencers(): number;
  32365. set numBoneInfluencers(value: number);
  32366. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  32367. get applyFog(): boolean;
  32368. set applyFog(value: boolean);
  32369. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  32370. useOctreeForRenderingSelection: boolean;
  32371. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  32372. useOctreeForPicking: boolean;
  32373. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  32374. useOctreeForCollisions: boolean;
  32375. /**
  32376. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  32377. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  32378. */
  32379. get layerMask(): number;
  32380. set layerMask(value: number);
  32381. /**
  32382. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  32383. */
  32384. alwaysSelectAsActiveMesh: boolean;
  32385. /**
  32386. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  32387. */
  32388. doNotSyncBoundingInfo: boolean;
  32389. /**
  32390. * Gets or sets the current action manager
  32391. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  32392. */
  32393. actionManager: Nullable<AbstractActionManager>;
  32394. private _meshCollisionData;
  32395. /**
  32396. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  32397. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32398. */
  32399. ellipsoid: Vector3;
  32400. /**
  32401. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  32402. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32403. */
  32404. ellipsoidOffset: Vector3;
  32405. /**
  32406. * Gets or sets a collision mask used to mask collisions (default is -1).
  32407. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32408. */
  32409. get collisionMask(): number;
  32410. set collisionMask(mask: number);
  32411. /**
  32412. * Gets or sets the current collision group mask (-1 by default).
  32413. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  32414. */
  32415. get collisionGroup(): number;
  32416. set collisionGroup(mask: number);
  32417. /**
  32418. * Gets or sets current surrounding meshes (null by default).
  32419. *
  32420. * By default collision detection is tested against every mesh in the scene.
  32421. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  32422. * meshes will be tested for the collision.
  32423. *
  32424. * Note: if set to an empty array no collision will happen when this mesh is moved.
  32425. */
  32426. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  32427. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  32428. /**
  32429. * Defines edge width used when edgesRenderer is enabled
  32430. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32431. */
  32432. edgesWidth: number;
  32433. /**
  32434. * Defines edge color used when edgesRenderer is enabled
  32435. * @see https://www.babylonjs-playground.com/#10OJSG#13
  32436. */
  32437. edgesColor: Color4;
  32438. /** @hidden */
  32439. _edgesRenderer: Nullable<IEdgesRenderer>;
  32440. /** @hidden */
  32441. _masterMesh: Nullable<AbstractMesh>;
  32442. /** @hidden */
  32443. _boundingInfo: Nullable<BoundingInfo>;
  32444. /** @hidden */
  32445. _renderId: number;
  32446. /**
  32447. * Gets or sets the list of subMeshes
  32448. * @see https://doc.babylonjs.com/how_to/multi_materials
  32449. */
  32450. subMeshes: SubMesh[];
  32451. /** @hidden */
  32452. _intersectionsInProgress: AbstractMesh[];
  32453. /** @hidden */
  32454. _unIndexed: boolean;
  32455. /** @hidden */
  32456. _lightSources: Light[];
  32457. /** Gets the list of lights affecting that mesh */
  32458. get lightSources(): Light[];
  32459. /** @hidden */
  32460. get _positions(): Nullable<Vector3[]>;
  32461. /** @hidden */
  32462. _waitingData: {
  32463. lods: Nullable<any>;
  32464. actions: Nullable<any>;
  32465. freezeWorldMatrix: Nullable<boolean>;
  32466. };
  32467. /** @hidden */
  32468. _bonesTransformMatrices: Nullable<Float32Array>;
  32469. /** @hidden */
  32470. _transformMatrixTexture: Nullable<RawTexture>;
  32471. /**
  32472. * Gets or sets a skeleton to apply skining transformations
  32473. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  32474. */
  32475. set skeleton(value: Nullable<Skeleton>);
  32476. get skeleton(): Nullable<Skeleton>;
  32477. /**
  32478. * An event triggered when the mesh is rebuilt.
  32479. */
  32480. onRebuildObservable: Observable<AbstractMesh>;
  32481. /**
  32482. * Creates a new AbstractMesh
  32483. * @param name defines the name of the mesh
  32484. * @param scene defines the hosting scene
  32485. */
  32486. constructor(name: string, scene?: Nullable<Scene>);
  32487. /**
  32488. * Returns the string "AbstractMesh"
  32489. * @returns "AbstractMesh"
  32490. */
  32491. getClassName(): string;
  32492. /**
  32493. * Gets a string representation of the current mesh
  32494. * @param fullDetails defines a boolean indicating if full details must be included
  32495. * @returns a string representation of the current mesh
  32496. */
  32497. toString(fullDetails?: boolean): string;
  32498. /**
  32499. * @hidden
  32500. */
  32501. protected _getEffectiveParent(): Nullable<Node>;
  32502. /** @hidden */
  32503. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  32504. /** @hidden */
  32505. _rebuild(): void;
  32506. /** @hidden */
  32507. _resyncLightSources(): void;
  32508. /** @hidden */
  32509. _resyncLightSource(light: Light): void;
  32510. /** @hidden */
  32511. _unBindEffect(): void;
  32512. /** @hidden */
  32513. _removeLightSource(light: Light, dispose: boolean): void;
  32514. private _markSubMeshesAsDirty;
  32515. /** @hidden */
  32516. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  32517. /** @hidden */
  32518. _markSubMeshesAsAttributesDirty(): void;
  32519. /** @hidden */
  32520. _markSubMeshesAsMiscDirty(): void;
  32521. /**
  32522. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  32523. */
  32524. get scaling(): Vector3;
  32525. set scaling(newScaling: Vector3);
  32526. /**
  32527. * Returns true if the mesh is blocked. Implemented by child classes
  32528. */
  32529. get isBlocked(): boolean;
  32530. /**
  32531. * Returns the mesh itself by default. Implemented by child classes
  32532. * @param camera defines the camera to use to pick the right LOD level
  32533. * @returns the currentAbstractMesh
  32534. */
  32535. getLOD(camera: Camera): Nullable<AbstractMesh>;
  32536. /**
  32537. * Returns 0 by default. Implemented by child classes
  32538. * @returns an integer
  32539. */
  32540. getTotalVertices(): number;
  32541. /**
  32542. * Returns a positive integer : the total number of indices in this mesh geometry.
  32543. * @returns the numner of indices or zero if the mesh has no geometry.
  32544. */
  32545. getTotalIndices(): number;
  32546. /**
  32547. * Returns null by default. Implemented by child classes
  32548. * @returns null
  32549. */
  32550. getIndices(): Nullable<IndicesArray>;
  32551. /**
  32552. * Returns the array of the requested vertex data kind. Implemented by child classes
  32553. * @param kind defines the vertex data kind to use
  32554. * @returns null
  32555. */
  32556. getVerticesData(kind: string): Nullable<FloatArray>;
  32557. /**
  32558. * Sets the vertex data of the mesh geometry for the requested `kind`.
  32559. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  32560. * Note that a new underlying VertexBuffer object is created each call.
  32561. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  32562. * @param kind defines vertex data kind:
  32563. * * VertexBuffer.PositionKind
  32564. * * VertexBuffer.UVKind
  32565. * * VertexBuffer.UV2Kind
  32566. * * VertexBuffer.UV3Kind
  32567. * * VertexBuffer.UV4Kind
  32568. * * VertexBuffer.UV5Kind
  32569. * * VertexBuffer.UV6Kind
  32570. * * VertexBuffer.ColorKind
  32571. * * VertexBuffer.MatricesIndicesKind
  32572. * * VertexBuffer.MatricesIndicesExtraKind
  32573. * * VertexBuffer.MatricesWeightsKind
  32574. * * VertexBuffer.MatricesWeightsExtraKind
  32575. * @param data defines the data source
  32576. * @param updatable defines if the data must be flagged as updatable (or static)
  32577. * @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
  32578. * @returns the current mesh
  32579. */
  32580. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32581. /**
  32582. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  32583. * If the mesh has no geometry, it is simply returned as it is.
  32584. * @param kind defines vertex data kind:
  32585. * * VertexBuffer.PositionKind
  32586. * * VertexBuffer.UVKind
  32587. * * VertexBuffer.UV2Kind
  32588. * * VertexBuffer.UV3Kind
  32589. * * VertexBuffer.UV4Kind
  32590. * * VertexBuffer.UV5Kind
  32591. * * VertexBuffer.UV6Kind
  32592. * * VertexBuffer.ColorKind
  32593. * * VertexBuffer.MatricesIndicesKind
  32594. * * VertexBuffer.MatricesIndicesExtraKind
  32595. * * VertexBuffer.MatricesWeightsKind
  32596. * * VertexBuffer.MatricesWeightsExtraKind
  32597. * @param data defines the data source
  32598. * @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
  32599. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  32600. * @returns the current mesh
  32601. */
  32602. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32603. /**
  32604. * Sets the mesh indices,
  32605. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  32606. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  32607. * @param totalVertices Defines the total number of vertices
  32608. * @returns the current mesh
  32609. */
  32610. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  32611. /**
  32612. * Gets a boolean indicating if specific vertex data is present
  32613. * @param kind defines the vertex data kind to use
  32614. * @returns true is data kind is present
  32615. */
  32616. isVerticesDataPresent(kind: string): boolean;
  32617. /**
  32618. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  32619. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  32620. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  32621. * @returns a BoundingInfo
  32622. */
  32623. getBoundingInfo(): BoundingInfo;
  32624. /**
  32625. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  32626. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  32627. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  32628. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  32629. * @returns the current mesh
  32630. */
  32631. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  32632. /**
  32633. * Overwrite the current bounding info
  32634. * @param boundingInfo defines the new bounding info
  32635. * @returns the current mesh
  32636. */
  32637. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  32638. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  32639. get useBones(): boolean;
  32640. /** @hidden */
  32641. _preActivate(): void;
  32642. /** @hidden */
  32643. _preActivateForIntermediateRendering(renderId: number): void;
  32644. /** @hidden */
  32645. _activate(renderId: number, intermediateRendering: boolean): boolean;
  32646. /** @hidden */
  32647. _postActivate(): void;
  32648. /** @hidden */
  32649. _freeze(): void;
  32650. /** @hidden */
  32651. _unFreeze(): void;
  32652. /**
  32653. * Gets the current world matrix
  32654. * @returns a Matrix
  32655. */
  32656. getWorldMatrix(): Matrix;
  32657. /** @hidden */
  32658. _getWorldMatrixDeterminant(): number;
  32659. /**
  32660. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  32661. */
  32662. get isAnInstance(): boolean;
  32663. /**
  32664. * Gets a boolean indicating if this mesh has instances
  32665. */
  32666. get hasInstances(): boolean;
  32667. /**
  32668. * Gets a boolean indicating if this mesh has thin instances
  32669. */
  32670. get hasThinInstances(): boolean;
  32671. /**
  32672. * Perform relative position change from the point of view of behind the front of the mesh.
  32673. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32674. * Supports definition of mesh facing forward or backward
  32675. * @param amountRight defines the distance on the right axis
  32676. * @param amountUp defines the distance on the up axis
  32677. * @param amountForward defines the distance on the forward axis
  32678. * @returns the current mesh
  32679. */
  32680. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  32681. /**
  32682. * Calculate relative position change from the point of view of behind the front of the mesh.
  32683. * This is performed taking into account the meshes current rotation, so you do not have to care.
  32684. * Supports definition of mesh facing forward or backward
  32685. * @param amountRight defines the distance on the right axis
  32686. * @param amountUp defines the distance on the up axis
  32687. * @param amountForward defines the distance on the forward axis
  32688. * @returns the new displacement vector
  32689. */
  32690. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  32691. /**
  32692. * Perform relative rotation change from the point of view of behind the front of the mesh.
  32693. * Supports definition of mesh facing forward or backward
  32694. * @param flipBack defines the flip
  32695. * @param twirlClockwise defines the twirl
  32696. * @param tiltRight defines the tilt
  32697. * @returns the current mesh
  32698. */
  32699. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  32700. /**
  32701. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  32702. * Supports definition of mesh facing forward or backward.
  32703. * @param flipBack defines the flip
  32704. * @param twirlClockwise defines the twirl
  32705. * @param tiltRight defines the tilt
  32706. * @returns the new rotation vector
  32707. */
  32708. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  32709. /**
  32710. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32711. * This means the mesh underlying bounding box and sphere are recomputed.
  32712. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32713. * @returns the current mesh
  32714. */
  32715. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  32716. /** @hidden */
  32717. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  32718. /** @hidden */
  32719. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  32720. /** @hidden */
  32721. _updateBoundingInfo(): AbstractMesh;
  32722. /** @hidden */
  32723. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  32724. /** @hidden */
  32725. protected _afterComputeWorldMatrix(): void;
  32726. /** @hidden */
  32727. get _effectiveMesh(): AbstractMesh;
  32728. /**
  32729. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32730. * A mesh is in the frustum if its bounding box intersects the frustum
  32731. * @param frustumPlanes defines the frustum to test
  32732. * @returns true if the mesh is in the frustum planes
  32733. */
  32734. isInFrustum(frustumPlanes: Plane[]): boolean;
  32735. /**
  32736. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  32737. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  32738. * @param frustumPlanes defines the frustum to test
  32739. * @returns true if the mesh is completely in the frustum planes
  32740. */
  32741. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  32742. /**
  32743. * True if the mesh intersects another mesh or a SolidParticle object
  32744. * @param mesh defines a target mesh or SolidParticle to test
  32745. * @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)
  32746. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  32747. * @returns true if there is an intersection
  32748. */
  32749. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  32750. /**
  32751. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  32752. * @param point defines the point to test
  32753. * @returns true if there is an intersection
  32754. */
  32755. intersectsPoint(point: Vector3): boolean;
  32756. /**
  32757. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  32758. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32759. */
  32760. get checkCollisions(): boolean;
  32761. set checkCollisions(collisionEnabled: boolean);
  32762. /**
  32763. * Gets Collider object used to compute collisions (not physics)
  32764. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32765. */
  32766. get collider(): Nullable<Collider>;
  32767. /**
  32768. * Move the mesh using collision engine
  32769. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32770. * @param displacement defines the requested displacement vector
  32771. * @returns the current mesh
  32772. */
  32773. moveWithCollisions(displacement: Vector3): AbstractMesh;
  32774. private _onCollisionPositionChange;
  32775. /** @hidden */
  32776. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  32777. /** @hidden */
  32778. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  32779. /** @hidden */
  32780. _checkCollision(collider: Collider): AbstractMesh;
  32781. /** @hidden */
  32782. _generatePointsArray(): boolean;
  32783. /**
  32784. * Checks if the passed Ray intersects with the mesh
  32785. * @param ray defines the ray to use
  32786. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  32787. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  32788. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  32789. * @returns the picking info
  32790. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  32791. */
  32792. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  32793. /**
  32794. * Clones the current mesh
  32795. * @param name defines the mesh name
  32796. * @param newParent defines the new mesh parent
  32797. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  32798. * @returns the new mesh
  32799. */
  32800. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  32801. /**
  32802. * Disposes all the submeshes of the current meshnp
  32803. * @returns the current mesh
  32804. */
  32805. releaseSubMeshes(): AbstractMesh;
  32806. /**
  32807. * Releases resources associated with this abstract mesh.
  32808. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  32809. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  32810. */
  32811. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  32812. /**
  32813. * Adds the passed mesh as a child to the current mesh
  32814. * @param mesh defines the child mesh
  32815. * @returns the current mesh
  32816. */
  32817. addChild(mesh: AbstractMesh): AbstractMesh;
  32818. /**
  32819. * Removes the passed mesh from the current mesh children list
  32820. * @param mesh defines the child mesh
  32821. * @returns the current mesh
  32822. */
  32823. removeChild(mesh: AbstractMesh): AbstractMesh;
  32824. /** @hidden */
  32825. private _initFacetData;
  32826. /**
  32827. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  32828. * This method can be called within the render loop.
  32829. * 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
  32830. * @returns the current mesh
  32831. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32832. */
  32833. updateFacetData(): AbstractMesh;
  32834. /**
  32835. * Returns the facetLocalNormals array.
  32836. * The normals are expressed in the mesh local spac
  32837. * @returns an array of Vector3
  32838. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32839. */
  32840. getFacetLocalNormals(): Vector3[];
  32841. /**
  32842. * Returns the facetLocalPositions array.
  32843. * The facet positions are expressed in the mesh local space
  32844. * @returns an array of Vector3
  32845. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32846. */
  32847. getFacetLocalPositions(): Vector3[];
  32848. /**
  32849. * Returns the facetLocalPartioning array
  32850. * @returns an array of array of numbers
  32851. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32852. */
  32853. getFacetLocalPartitioning(): number[][];
  32854. /**
  32855. * Returns the i-th facet position in the world system.
  32856. * This method allocates a new Vector3 per call
  32857. * @param i defines the facet index
  32858. * @returns a new Vector3
  32859. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32860. */
  32861. getFacetPosition(i: number): Vector3;
  32862. /**
  32863. * Sets the reference Vector3 with the i-th facet position in the world system
  32864. * @param i defines the facet index
  32865. * @param ref defines the target vector
  32866. * @returns the current mesh
  32867. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32868. */
  32869. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  32870. /**
  32871. * Returns the i-th facet normal in the world system.
  32872. * This method allocates a new Vector3 per call
  32873. * @param i defines the facet index
  32874. * @returns a new Vector3
  32875. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32876. */
  32877. getFacetNormal(i: number): Vector3;
  32878. /**
  32879. * Sets the reference Vector3 with the i-th facet normal in the world system
  32880. * @param i defines the facet index
  32881. * @param ref defines the target vector
  32882. * @returns the current mesh
  32883. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32884. */
  32885. getFacetNormalToRef(i: number, ref: Vector3): this;
  32886. /**
  32887. * 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)
  32888. * @param x defines x coordinate
  32889. * @param y defines y coordinate
  32890. * @param z defines z coordinate
  32891. * @returns the array of facet indexes
  32892. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32893. */
  32894. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  32895. /**
  32896. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  32897. * @param projected sets as the (x,y,z) world projection on the facet
  32898. * @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
  32899. * @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
  32900. * @param x defines x coordinate
  32901. * @param y defines y coordinate
  32902. * @param z defines z coordinate
  32903. * @returns the face index if found (or null instead)
  32904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32905. */
  32906. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32907. /**
  32908. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  32909. * @param projected sets as the (x,y,z) local projection on the facet
  32910. * @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
  32911. * @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
  32912. * @param x defines x coordinate
  32913. * @param y defines y coordinate
  32914. * @param z defines z coordinate
  32915. * @returns the face index if found (or null instead)
  32916. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32917. */
  32918. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  32919. /**
  32920. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  32921. * @returns the parameters
  32922. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32923. */
  32924. getFacetDataParameters(): any;
  32925. /**
  32926. * Disables the feature FacetData and frees the related memory
  32927. * @returns the current mesh
  32928. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  32929. */
  32930. disableFacetData(): AbstractMesh;
  32931. /**
  32932. * Updates the AbstractMesh indices array
  32933. * @param indices defines the data source
  32934. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32935. * @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)
  32936. * @returns the current mesh
  32937. */
  32938. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32939. /**
  32940. * Creates new normals data for the mesh
  32941. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  32942. * @returns the current mesh
  32943. */
  32944. createNormals(updatable: boolean): AbstractMesh;
  32945. /**
  32946. * Align the mesh with a normal
  32947. * @param normal defines the normal to use
  32948. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  32949. * @returns the current mesh
  32950. */
  32951. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  32952. /** @hidden */
  32953. _checkOcclusionQuery(): boolean;
  32954. /**
  32955. * Disables the mesh edge rendering mode
  32956. * @returns the currentAbstractMesh
  32957. */
  32958. disableEdgesRendering(): AbstractMesh;
  32959. /**
  32960. * Enables the edge rendering mode on the mesh.
  32961. * This mode makes the mesh edges visible
  32962. * @param epsilon defines the maximal distance between two angles to detect a face
  32963. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  32964. * @returns the currentAbstractMesh
  32965. * @see https://www.babylonjs-playground.com/#19O9TU#0
  32966. */
  32967. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  32968. /**
  32969. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  32970. * @returns an array of particle systems in the scene that use the mesh as an emitter
  32971. */
  32972. getConnectedParticleSystems(): IParticleSystem[];
  32973. }
  32974. }
  32975. declare module "babylonjs/Actions/actionEvent" {
  32976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32977. import { Nullable } from "babylonjs/types";
  32978. import { Sprite } from "babylonjs/Sprites/sprite";
  32979. import { Scene } from "babylonjs/scene";
  32980. import { Vector2 } from "babylonjs/Maths/math.vector";
  32981. /**
  32982. * Interface used to define ActionEvent
  32983. */
  32984. export interface IActionEvent {
  32985. /** The mesh or sprite that triggered the action */
  32986. source: any;
  32987. /** The X mouse cursor position at the time of the event */
  32988. pointerX: number;
  32989. /** The Y mouse cursor position at the time of the event */
  32990. pointerY: number;
  32991. /** The mesh that is currently pointed at (can be null) */
  32992. meshUnderPointer: Nullable<AbstractMesh>;
  32993. /** the original (browser) event that triggered the ActionEvent */
  32994. sourceEvent?: any;
  32995. /** additional data for the event */
  32996. additionalData?: any;
  32997. }
  32998. /**
  32999. * ActionEvent is the event being sent when an action is triggered.
  33000. */
  33001. export class ActionEvent implements IActionEvent {
  33002. /** The mesh or sprite that triggered the action */
  33003. source: any;
  33004. /** The X mouse cursor position at the time of the event */
  33005. pointerX: number;
  33006. /** The Y mouse cursor position at the time of the event */
  33007. pointerY: number;
  33008. /** The mesh that is currently pointed at (can be null) */
  33009. meshUnderPointer: Nullable<AbstractMesh>;
  33010. /** the original (browser) event that triggered the ActionEvent */
  33011. sourceEvent?: any;
  33012. /** additional data for the event */
  33013. additionalData?: any;
  33014. /**
  33015. * Creates a new ActionEvent
  33016. * @param source The mesh or sprite that triggered the action
  33017. * @param pointerX The X mouse cursor position at the time of the event
  33018. * @param pointerY The Y mouse cursor position at the time of the event
  33019. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  33020. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  33021. * @param additionalData additional data for the event
  33022. */
  33023. constructor(
  33024. /** The mesh or sprite that triggered the action */
  33025. source: any,
  33026. /** The X mouse cursor position at the time of the event */
  33027. pointerX: number,
  33028. /** The Y mouse cursor position at the time of the event */
  33029. pointerY: number,
  33030. /** The mesh that is currently pointed at (can be null) */
  33031. meshUnderPointer: Nullable<AbstractMesh>,
  33032. /** the original (browser) event that triggered the ActionEvent */
  33033. sourceEvent?: any,
  33034. /** additional data for the event */
  33035. additionalData?: any);
  33036. /**
  33037. * Helper function to auto-create an ActionEvent from a source mesh.
  33038. * @param source The source mesh that triggered the event
  33039. * @param evt The original (browser) event
  33040. * @param additionalData additional data for the event
  33041. * @returns the new ActionEvent
  33042. */
  33043. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  33044. /**
  33045. * Helper function to auto-create an ActionEvent from a source sprite
  33046. * @param source The source sprite that triggered the event
  33047. * @param scene Scene associated with the sprite
  33048. * @param evt The original (browser) event
  33049. * @param additionalData additional data for the event
  33050. * @returns the new ActionEvent
  33051. */
  33052. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  33053. /**
  33054. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  33055. * @param scene the scene where the event occurred
  33056. * @param evt The original (browser) event
  33057. * @returns the new ActionEvent
  33058. */
  33059. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  33060. /**
  33061. * Helper function to auto-create an ActionEvent from a primitive
  33062. * @param prim defines the target primitive
  33063. * @param pointerPos defines the pointer position
  33064. * @param evt The original (browser) event
  33065. * @param additionalData additional data for the event
  33066. * @returns the new ActionEvent
  33067. */
  33068. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  33069. }
  33070. }
  33071. declare module "babylonjs/Actions/abstractActionManager" {
  33072. import { IDisposable } from "babylonjs/scene";
  33073. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  33074. import { IAction } from "babylonjs/Actions/action";
  33075. import { Nullable } from "babylonjs/types";
  33076. /**
  33077. * Abstract class used to decouple action Manager from scene and meshes.
  33078. * Do not instantiate.
  33079. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33080. */
  33081. export abstract class AbstractActionManager implements IDisposable {
  33082. /** Gets the list of active triggers */
  33083. static Triggers: {
  33084. [key: string]: number;
  33085. };
  33086. /** Gets the cursor to use when hovering items */
  33087. hoverCursor: string;
  33088. /** Gets the list of actions */
  33089. actions: IAction[];
  33090. /**
  33091. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  33092. */
  33093. isRecursive: boolean;
  33094. /**
  33095. * Releases all associated resources
  33096. */
  33097. abstract dispose(): void;
  33098. /**
  33099. * Does this action manager has pointer triggers
  33100. */
  33101. abstract get hasPointerTriggers(): boolean;
  33102. /**
  33103. * Does this action manager has pick triggers
  33104. */
  33105. abstract get hasPickTriggers(): boolean;
  33106. /**
  33107. * Process a specific trigger
  33108. * @param trigger defines the trigger to process
  33109. * @param evt defines the event details to be processed
  33110. */
  33111. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  33112. /**
  33113. * Does this action manager handles actions of any of the given triggers
  33114. * @param triggers defines the triggers to be tested
  33115. * @return a boolean indicating whether one (or more) of the triggers is handled
  33116. */
  33117. abstract hasSpecificTriggers(triggers: number[]): boolean;
  33118. /**
  33119. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  33120. * speed.
  33121. * @param triggerA defines the trigger to be tested
  33122. * @param triggerB defines the trigger to be tested
  33123. * @return a boolean indicating whether one (or more) of the triggers is handled
  33124. */
  33125. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  33126. /**
  33127. * Does this action manager handles actions of a given trigger
  33128. * @param trigger defines the trigger to be tested
  33129. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  33130. * @return whether the trigger is handled
  33131. */
  33132. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  33133. /**
  33134. * Serialize this manager to a JSON object
  33135. * @param name defines the property name to store this manager
  33136. * @returns a JSON representation of this manager
  33137. */
  33138. abstract serialize(name: string): any;
  33139. /**
  33140. * Registers an action to this action manager
  33141. * @param action defines the action to be registered
  33142. * @return the action amended (prepared) after registration
  33143. */
  33144. abstract registerAction(action: IAction): Nullable<IAction>;
  33145. /**
  33146. * Unregisters an action to this action manager
  33147. * @param action defines the action to be unregistered
  33148. * @return a boolean indicating whether the action has been unregistered
  33149. */
  33150. abstract unregisterAction(action: IAction): Boolean;
  33151. /**
  33152. * Does exist one action manager with at least one trigger
  33153. **/
  33154. static get HasTriggers(): boolean;
  33155. /**
  33156. * Does exist one action manager with at least one pick trigger
  33157. **/
  33158. static get HasPickTriggers(): boolean;
  33159. /**
  33160. * Does exist one action manager that handles actions of a given trigger
  33161. * @param trigger defines the trigger to be tested
  33162. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  33163. **/
  33164. static HasSpecificTrigger(trigger: number): boolean;
  33165. }
  33166. }
  33167. declare module "babylonjs/node" {
  33168. import { Scene } from "babylonjs/scene";
  33169. import { Nullable } from "babylonjs/types";
  33170. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  33171. import { Engine } from "babylonjs/Engines/engine";
  33172. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  33173. import { Observable } from "babylonjs/Misc/observable";
  33174. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33175. import { IInspectable } from "babylonjs/Misc/iInspectable";
  33176. import { Animatable } from "babylonjs/Animations/animatable";
  33177. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33178. import { Animation } from "babylonjs/Animations/animation";
  33179. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33181. /**
  33182. * Defines how a node can be built from a string name.
  33183. */
  33184. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  33185. /**
  33186. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  33187. */
  33188. export class Node implements IBehaviorAware<Node> {
  33189. /** @hidden */
  33190. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  33191. private static _NodeConstructors;
  33192. /**
  33193. * Add a new node constructor
  33194. * @param type defines the type name of the node to construct
  33195. * @param constructorFunc defines the constructor function
  33196. */
  33197. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  33198. /**
  33199. * Returns a node constructor based on type name
  33200. * @param type defines the type name
  33201. * @param name defines the new node name
  33202. * @param scene defines the hosting scene
  33203. * @param options defines optional options to transmit to constructors
  33204. * @returns the new constructor or null
  33205. */
  33206. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  33207. /**
  33208. * Gets or sets the name of the node
  33209. */
  33210. name: string;
  33211. /**
  33212. * Gets or sets the id of the node
  33213. */
  33214. id: string;
  33215. /**
  33216. * Gets or sets the unique id of the node
  33217. */
  33218. uniqueId: number;
  33219. /**
  33220. * Gets or sets a string used to store user defined state for the node
  33221. */
  33222. state: string;
  33223. /**
  33224. * Gets or sets an object used to store user defined information for the node
  33225. */
  33226. metadata: any;
  33227. /**
  33228. * For internal use only. Please do not use.
  33229. */
  33230. reservedDataStore: any;
  33231. /**
  33232. * List of inspectable custom properties (used by the Inspector)
  33233. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  33234. */
  33235. inspectableCustomProperties: IInspectable[];
  33236. private _doNotSerialize;
  33237. /**
  33238. * Gets or sets a boolean used to define if the node must be serialized
  33239. */
  33240. get doNotSerialize(): boolean;
  33241. set doNotSerialize(value: boolean);
  33242. /** @hidden */
  33243. _isDisposed: boolean;
  33244. /**
  33245. * Gets a list of Animations associated with the node
  33246. */
  33247. animations: import("babylonjs/Animations/animation").Animation[];
  33248. protected _ranges: {
  33249. [name: string]: Nullable<AnimationRange>;
  33250. };
  33251. /**
  33252. * Callback raised when the node is ready to be used
  33253. */
  33254. onReady: Nullable<(node: Node) => void>;
  33255. private _isEnabled;
  33256. private _isParentEnabled;
  33257. private _isReady;
  33258. /** @hidden */
  33259. _currentRenderId: number;
  33260. private _parentUpdateId;
  33261. /** @hidden */
  33262. _childUpdateId: number;
  33263. /** @hidden */
  33264. _waitingParentId: Nullable<string>;
  33265. /** @hidden */
  33266. _scene: Scene;
  33267. /** @hidden */
  33268. _cache: any;
  33269. private _parentNode;
  33270. private _children;
  33271. /** @hidden */
  33272. _worldMatrix: Matrix;
  33273. /** @hidden */
  33274. _worldMatrixDeterminant: number;
  33275. /** @hidden */
  33276. _worldMatrixDeterminantIsDirty: boolean;
  33277. /** @hidden */
  33278. private _sceneRootNodesIndex;
  33279. /**
  33280. * Gets a boolean indicating if the node has been disposed
  33281. * @returns true if the node was disposed
  33282. */
  33283. isDisposed(): boolean;
  33284. /**
  33285. * Gets or sets the parent of the node (without keeping the current position in the scene)
  33286. * @see https://doc.babylonjs.com/how_to/parenting
  33287. */
  33288. set parent(parent: Nullable<Node>);
  33289. get parent(): Nullable<Node>;
  33290. /** @hidden */
  33291. _addToSceneRootNodes(): void;
  33292. /** @hidden */
  33293. _removeFromSceneRootNodes(): void;
  33294. private _animationPropertiesOverride;
  33295. /**
  33296. * Gets or sets the animation properties override
  33297. */
  33298. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  33299. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  33300. /**
  33301. * Gets a string idenfifying the name of the class
  33302. * @returns "Node" string
  33303. */
  33304. getClassName(): string;
  33305. /** @hidden */
  33306. readonly _isNode: boolean;
  33307. /**
  33308. * An event triggered when the mesh is disposed
  33309. */
  33310. onDisposeObservable: Observable<Node>;
  33311. private _onDisposeObserver;
  33312. /**
  33313. * Sets a callback that will be raised when the node will be disposed
  33314. */
  33315. set onDispose(callback: () => void);
  33316. /**
  33317. * Creates a new Node
  33318. * @param name the name and id to be given to this node
  33319. * @param scene the scene this node will be added to
  33320. */
  33321. constructor(name: string, scene?: Nullable<Scene>);
  33322. /**
  33323. * Gets the scene of the node
  33324. * @returns a scene
  33325. */
  33326. getScene(): Scene;
  33327. /**
  33328. * Gets the engine of the node
  33329. * @returns a Engine
  33330. */
  33331. getEngine(): Engine;
  33332. private _behaviors;
  33333. /**
  33334. * Attach a behavior to the node
  33335. * @see https://doc.babylonjs.com/features/behaviour
  33336. * @param behavior defines the behavior to attach
  33337. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  33338. * @returns the current Node
  33339. */
  33340. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  33341. /**
  33342. * Remove an attached behavior
  33343. * @see https://doc.babylonjs.com/features/behaviour
  33344. * @param behavior defines the behavior to attach
  33345. * @returns the current Node
  33346. */
  33347. removeBehavior(behavior: Behavior<Node>): Node;
  33348. /**
  33349. * Gets the list of attached behaviors
  33350. * @see https://doc.babylonjs.com/features/behaviour
  33351. */
  33352. get behaviors(): Behavior<Node>[];
  33353. /**
  33354. * Gets an attached behavior by name
  33355. * @param name defines the name of the behavior to look for
  33356. * @see https://doc.babylonjs.com/features/behaviour
  33357. * @returns null if behavior was not found else the requested behavior
  33358. */
  33359. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  33360. /**
  33361. * Returns the latest update of the World matrix
  33362. * @returns a Matrix
  33363. */
  33364. getWorldMatrix(): Matrix;
  33365. /** @hidden */
  33366. _getWorldMatrixDeterminant(): number;
  33367. /**
  33368. * Returns directly the latest state of the mesh World matrix.
  33369. * A Matrix is returned.
  33370. */
  33371. get worldMatrixFromCache(): Matrix;
  33372. /** @hidden */
  33373. _initCache(): void;
  33374. /** @hidden */
  33375. updateCache(force?: boolean): void;
  33376. /** @hidden */
  33377. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33378. /** @hidden */
  33379. _updateCache(ignoreParentClass?: boolean): void;
  33380. /** @hidden */
  33381. _isSynchronized(): boolean;
  33382. /** @hidden */
  33383. _markSyncedWithParent(): void;
  33384. /** @hidden */
  33385. isSynchronizedWithParent(): boolean;
  33386. /** @hidden */
  33387. isSynchronized(): boolean;
  33388. /**
  33389. * Is this node ready to be used/rendered
  33390. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  33391. * @return true if the node is ready
  33392. */
  33393. isReady(completeCheck?: boolean): boolean;
  33394. /**
  33395. * Is this node enabled?
  33396. * 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
  33397. * @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
  33398. * @return whether this node (and its parent) is enabled
  33399. */
  33400. isEnabled(checkAncestors?: boolean): boolean;
  33401. /** @hidden */
  33402. protected _syncParentEnabledState(): void;
  33403. /**
  33404. * Set the enabled state of this node
  33405. * @param value defines the new enabled state
  33406. */
  33407. setEnabled(value: boolean): void;
  33408. /**
  33409. * Is this node a descendant of the given node?
  33410. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  33411. * @param ancestor defines the parent node to inspect
  33412. * @returns a boolean indicating if this node is a descendant of the given node
  33413. */
  33414. isDescendantOf(ancestor: Node): boolean;
  33415. /** @hidden */
  33416. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  33417. /**
  33418. * Will return all nodes that have this node as ascendant
  33419. * @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
  33420. * @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
  33421. * @return all children nodes of all types
  33422. */
  33423. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  33424. /**
  33425. * Get all child-meshes of this node
  33426. * @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)
  33427. * @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
  33428. * @returns an array of AbstractMesh
  33429. */
  33430. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  33431. /**
  33432. * Get all direct children of this node
  33433. * @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
  33434. * @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)
  33435. * @returns an array of Node
  33436. */
  33437. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  33438. /** @hidden */
  33439. _setReady(state: boolean): void;
  33440. /**
  33441. * Get an animation by name
  33442. * @param name defines the name of the animation to look for
  33443. * @returns null if not found else the requested animation
  33444. */
  33445. getAnimationByName(name: string): Nullable<Animation>;
  33446. /**
  33447. * Creates an animation range for this node
  33448. * @param name defines the name of the range
  33449. * @param from defines the starting key
  33450. * @param to defines the end key
  33451. */
  33452. createAnimationRange(name: string, from: number, to: number): void;
  33453. /**
  33454. * Delete a specific animation range
  33455. * @param name defines the name of the range to delete
  33456. * @param deleteFrames defines if animation frames from the range must be deleted as well
  33457. */
  33458. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  33459. /**
  33460. * Get an animation range by name
  33461. * @param name defines the name of the animation range to look for
  33462. * @returns null if not found else the requested animation range
  33463. */
  33464. getAnimationRange(name: string): Nullable<AnimationRange>;
  33465. /**
  33466. * Gets the list of all animation ranges defined on this node
  33467. * @returns an array
  33468. */
  33469. getAnimationRanges(): Nullable<AnimationRange>[];
  33470. /**
  33471. * Will start the animation sequence
  33472. * @param name defines the range frames for animation sequence
  33473. * @param loop defines if the animation should loop (false by default)
  33474. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  33475. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  33476. * @returns the object created for this animation. If range does not exist, it will return null
  33477. */
  33478. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  33479. /**
  33480. * Serialize animation ranges into a JSON compatible object
  33481. * @returns serialization object
  33482. */
  33483. serializeAnimationRanges(): any;
  33484. /**
  33485. * Computes the world matrix of the node
  33486. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  33487. * @returns the world matrix
  33488. */
  33489. computeWorldMatrix(force?: boolean): Matrix;
  33490. /**
  33491. * Releases resources associated with this node.
  33492. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33493. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33494. */
  33495. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33496. /**
  33497. * Parse animation range data from a serialization object and store them into a given node
  33498. * @param node defines where to store the animation ranges
  33499. * @param parsedNode defines the serialization object to read data from
  33500. * @param scene defines the hosting scene
  33501. */
  33502. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  33503. /**
  33504. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  33505. * @param includeDescendants Include bounding info from descendants as well (true by default)
  33506. * @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
  33507. * @returns the new bounding vectors
  33508. */
  33509. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  33510. min: Vector3;
  33511. max: Vector3;
  33512. };
  33513. }
  33514. }
  33515. declare module "babylonjs/Animations/animation" {
  33516. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  33517. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  33518. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33519. import { Nullable } from "babylonjs/types";
  33520. import { Scene } from "babylonjs/scene";
  33521. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  33522. import { AnimationRange } from "babylonjs/Animations/animationRange";
  33523. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  33524. import { Node } from "babylonjs/node";
  33525. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33526. import { Size } from "babylonjs/Maths/math.size";
  33527. import { Animatable } from "babylonjs/Animations/animatable";
  33528. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  33529. /**
  33530. * @hidden
  33531. */
  33532. export class _IAnimationState {
  33533. key: number;
  33534. repeatCount: number;
  33535. workValue?: any;
  33536. loopMode?: number;
  33537. offsetValue?: any;
  33538. highLimitValue?: any;
  33539. }
  33540. /**
  33541. * Class used to store any kind of animation
  33542. */
  33543. export class Animation {
  33544. /**Name of the animation */
  33545. name: string;
  33546. /**Property to animate */
  33547. targetProperty: string;
  33548. /**The frames per second of the animation */
  33549. framePerSecond: number;
  33550. /**The data type of the animation */
  33551. dataType: number;
  33552. /**The loop mode of the animation */
  33553. loopMode?: number | undefined;
  33554. /**Specifies if blending should be enabled */
  33555. enableBlending?: boolean | undefined;
  33556. /**
  33557. * Use matrix interpolation instead of using direct key value when animating matrices
  33558. */
  33559. static AllowMatricesInterpolation: boolean;
  33560. /**
  33561. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  33562. */
  33563. static AllowMatrixDecomposeForInterpolation: boolean;
  33564. /** Define the Url to load snippets */
  33565. static SnippetUrl: string;
  33566. /** Snippet ID if the animation was created from the snippet server */
  33567. snippetId: string;
  33568. /**
  33569. * Stores the key frames of the animation
  33570. */
  33571. private _keys;
  33572. /**
  33573. * Stores the easing function of the animation
  33574. */
  33575. private _easingFunction;
  33576. /**
  33577. * @hidden Internal use only
  33578. */
  33579. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  33580. /**
  33581. * The set of event that will be linked to this animation
  33582. */
  33583. private _events;
  33584. /**
  33585. * Stores an array of target property paths
  33586. */
  33587. targetPropertyPath: string[];
  33588. /**
  33589. * Stores the blending speed of the animation
  33590. */
  33591. blendingSpeed: number;
  33592. /**
  33593. * Stores the animation ranges for the animation
  33594. */
  33595. private _ranges;
  33596. /**
  33597. * @hidden Internal use
  33598. */
  33599. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  33600. /**
  33601. * Sets up an animation
  33602. * @param property The property to animate
  33603. * @param animationType The animation type to apply
  33604. * @param framePerSecond The frames per second of the animation
  33605. * @param easingFunction The easing function used in the animation
  33606. * @returns The created animation
  33607. */
  33608. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  33609. /**
  33610. * Create and start an animation on a node
  33611. * @param name defines the name of the global animation that will be run on all nodes
  33612. * @param node defines the root node where the animation will take place
  33613. * @param targetProperty defines property to animate
  33614. * @param framePerSecond defines the number of frame per second yo use
  33615. * @param totalFrame defines the number of frames in total
  33616. * @param from defines the initial value
  33617. * @param to defines the final value
  33618. * @param loopMode defines which loop mode you want to use (off by default)
  33619. * @param easingFunction defines the easing function to use (linear by default)
  33620. * @param onAnimationEnd defines the callback to call when animation end
  33621. * @returns the animatable created for this animation
  33622. */
  33623. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33624. /**
  33625. * Create and start an animation on a node and its descendants
  33626. * @param name defines the name of the global animation that will be run on all nodes
  33627. * @param node defines the root node where the animation will take place
  33628. * @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
  33629. * @param targetProperty defines property to animate
  33630. * @param framePerSecond defines the number of frame per second to use
  33631. * @param totalFrame defines the number of frames in total
  33632. * @param from defines the initial value
  33633. * @param to defines the final value
  33634. * @param loopMode defines which loop mode you want to use (off by default)
  33635. * @param easingFunction defines the easing function to use (linear by default)
  33636. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  33637. * @returns the list of animatables created for all nodes
  33638. * @example https://www.babylonjs-playground.com/#MH0VLI
  33639. */
  33640. 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[]>;
  33641. /**
  33642. * Creates a new animation, merges it with the existing animations and starts it
  33643. * @param name Name of the animation
  33644. * @param node Node which contains the scene that begins the animations
  33645. * @param targetProperty Specifies which property to animate
  33646. * @param framePerSecond The frames per second of the animation
  33647. * @param totalFrame The total number of frames
  33648. * @param from The frame at the beginning of the animation
  33649. * @param to The frame at the end of the animation
  33650. * @param loopMode Specifies the loop mode of the animation
  33651. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  33652. * @param onAnimationEnd Callback to run once the animation is complete
  33653. * @returns Nullable animation
  33654. */
  33655. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  33656. /**
  33657. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  33658. * @param sourceAnimation defines the Animation containing keyframes to convert
  33659. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  33660. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  33661. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  33662. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  33663. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  33664. */
  33665. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  33666. /**
  33667. * Transition property of an host to the target Value
  33668. * @param property The property to transition
  33669. * @param targetValue The target Value of the property
  33670. * @param host The object where the property to animate belongs
  33671. * @param scene Scene used to run the animation
  33672. * @param frameRate Framerate (in frame/s) to use
  33673. * @param transition The transition type we want to use
  33674. * @param duration The duration of the animation, in milliseconds
  33675. * @param onAnimationEnd Callback trigger at the end of the animation
  33676. * @returns Nullable animation
  33677. */
  33678. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  33679. /**
  33680. * Return the array of runtime animations currently using this animation
  33681. */
  33682. get runtimeAnimations(): RuntimeAnimation[];
  33683. /**
  33684. * Specifies if any of the runtime animations are currently running
  33685. */
  33686. get hasRunningRuntimeAnimations(): boolean;
  33687. /**
  33688. * Initializes the animation
  33689. * @param name Name of the animation
  33690. * @param targetProperty Property to animate
  33691. * @param framePerSecond The frames per second of the animation
  33692. * @param dataType The data type of the animation
  33693. * @param loopMode The loop mode of the animation
  33694. * @param enableBlending Specifies if blending should be enabled
  33695. */
  33696. constructor(
  33697. /**Name of the animation */
  33698. name: string,
  33699. /**Property to animate */
  33700. targetProperty: string,
  33701. /**The frames per second of the animation */
  33702. framePerSecond: number,
  33703. /**The data type of the animation */
  33704. dataType: number,
  33705. /**The loop mode of the animation */
  33706. loopMode?: number | undefined,
  33707. /**Specifies if blending should be enabled */
  33708. enableBlending?: boolean | undefined);
  33709. /**
  33710. * Converts the animation to a string
  33711. * @param fullDetails support for multiple levels of logging within scene loading
  33712. * @returns String form of the animation
  33713. */
  33714. toString(fullDetails?: boolean): string;
  33715. /**
  33716. * Add an event to this animation
  33717. * @param event Event to add
  33718. */
  33719. addEvent(event: AnimationEvent): void;
  33720. /**
  33721. * Remove all events found at the given frame
  33722. * @param frame The frame to remove events from
  33723. */
  33724. removeEvents(frame: number): void;
  33725. /**
  33726. * Retrieves all the events from the animation
  33727. * @returns Events from the animation
  33728. */
  33729. getEvents(): AnimationEvent[];
  33730. /**
  33731. * Creates an animation range
  33732. * @param name Name of the animation range
  33733. * @param from Starting frame of the animation range
  33734. * @param to Ending frame of the animation
  33735. */
  33736. createRange(name: string, from: number, to: number): void;
  33737. /**
  33738. * Deletes an animation range by name
  33739. * @param name Name of the animation range to delete
  33740. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  33741. */
  33742. deleteRange(name: string, deleteFrames?: boolean): void;
  33743. /**
  33744. * Gets the animation range by name, or null if not defined
  33745. * @param name Name of the animation range
  33746. * @returns Nullable animation range
  33747. */
  33748. getRange(name: string): Nullable<AnimationRange>;
  33749. /**
  33750. * Gets the key frames from the animation
  33751. * @returns The key frames of the animation
  33752. */
  33753. getKeys(): Array<IAnimationKey>;
  33754. /**
  33755. * Gets the highest frame rate of the animation
  33756. * @returns Highest frame rate of the animation
  33757. */
  33758. getHighestFrame(): number;
  33759. /**
  33760. * Gets the easing function of the animation
  33761. * @returns Easing function of the animation
  33762. */
  33763. getEasingFunction(): IEasingFunction;
  33764. /**
  33765. * Sets the easing function of the animation
  33766. * @param easingFunction A custom mathematical formula for animation
  33767. */
  33768. setEasingFunction(easingFunction: EasingFunction): void;
  33769. /**
  33770. * Interpolates a scalar linearly
  33771. * @param startValue Start value of the animation curve
  33772. * @param endValue End value of the animation curve
  33773. * @param gradient Scalar amount to interpolate
  33774. * @returns Interpolated scalar value
  33775. */
  33776. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  33777. /**
  33778. * Interpolates a scalar cubically
  33779. * @param startValue Start value of the animation curve
  33780. * @param outTangent End tangent of the animation
  33781. * @param endValue End value of the animation curve
  33782. * @param inTangent Start tangent of the animation curve
  33783. * @param gradient Scalar amount to interpolate
  33784. * @returns Interpolated scalar value
  33785. */
  33786. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  33787. /**
  33788. * Interpolates a quaternion using a spherical linear interpolation
  33789. * @param startValue Start value of the animation curve
  33790. * @param endValue End value of the animation curve
  33791. * @param gradient Scalar amount to interpolate
  33792. * @returns Interpolated quaternion value
  33793. */
  33794. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  33795. /**
  33796. * Interpolates a quaternion cubically
  33797. * @param startValue Start value of the animation curve
  33798. * @param outTangent End tangent of the animation curve
  33799. * @param endValue End value of the animation curve
  33800. * @param inTangent Start tangent of the animation curve
  33801. * @param gradient Scalar amount to interpolate
  33802. * @returns Interpolated quaternion value
  33803. */
  33804. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  33805. /**
  33806. * Interpolates a Vector3 linearl
  33807. * @param startValue Start value of the animation curve
  33808. * @param endValue End value of the animation curve
  33809. * @param gradient Scalar amount to interpolate
  33810. * @returns Interpolated scalar value
  33811. */
  33812. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  33813. /**
  33814. * Interpolates a Vector3 cubically
  33815. * @param startValue Start value of the animation curve
  33816. * @param outTangent End tangent of the animation
  33817. * @param endValue End value of the animation curve
  33818. * @param inTangent Start tangent of the animation curve
  33819. * @param gradient Scalar amount to interpolate
  33820. * @returns InterpolatedVector3 value
  33821. */
  33822. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  33823. /**
  33824. * Interpolates a Vector2 linearly
  33825. * @param startValue Start value of the animation curve
  33826. * @param endValue End value of the animation curve
  33827. * @param gradient Scalar amount to interpolate
  33828. * @returns Interpolated Vector2 value
  33829. */
  33830. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  33831. /**
  33832. * Interpolates a Vector2 cubically
  33833. * @param startValue Start value of the animation curve
  33834. * @param outTangent End tangent of the animation
  33835. * @param endValue End value of the animation curve
  33836. * @param inTangent Start tangent of the animation curve
  33837. * @param gradient Scalar amount to interpolate
  33838. * @returns Interpolated Vector2 value
  33839. */
  33840. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  33841. /**
  33842. * Interpolates a size linearly
  33843. * @param startValue Start value of the animation curve
  33844. * @param endValue End value of the animation curve
  33845. * @param gradient Scalar amount to interpolate
  33846. * @returns Interpolated Size value
  33847. */
  33848. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  33849. /**
  33850. * Interpolates a Color3 linearly
  33851. * @param startValue Start value of the animation curve
  33852. * @param endValue End value of the animation curve
  33853. * @param gradient Scalar amount to interpolate
  33854. * @returns Interpolated Color3 value
  33855. */
  33856. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  33857. /**
  33858. * Interpolates a Color4 linearly
  33859. * @param startValue Start value of the animation curve
  33860. * @param endValue End value of the animation curve
  33861. * @param gradient Scalar amount to interpolate
  33862. * @returns Interpolated Color3 value
  33863. */
  33864. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  33865. /**
  33866. * @hidden Internal use only
  33867. */
  33868. _getKeyValue(value: any): any;
  33869. /**
  33870. * @hidden Internal use only
  33871. */
  33872. _interpolate(currentFrame: number, state: _IAnimationState): any;
  33873. /**
  33874. * Defines the function to use to interpolate matrices
  33875. * @param startValue defines the start matrix
  33876. * @param endValue defines the end matrix
  33877. * @param gradient defines the gradient between both matrices
  33878. * @param result defines an optional target matrix where to store the interpolation
  33879. * @returns the interpolated matrix
  33880. */
  33881. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  33882. /**
  33883. * Makes a copy of the animation
  33884. * @returns Cloned animation
  33885. */
  33886. clone(): Animation;
  33887. /**
  33888. * Sets the key frames of the animation
  33889. * @param values The animation key frames to set
  33890. */
  33891. setKeys(values: Array<IAnimationKey>): void;
  33892. /**
  33893. * Serializes the animation to an object
  33894. * @returns Serialized object
  33895. */
  33896. serialize(): any;
  33897. /**
  33898. * Float animation type
  33899. */
  33900. static readonly ANIMATIONTYPE_FLOAT: number;
  33901. /**
  33902. * Vector3 animation type
  33903. */
  33904. static readonly ANIMATIONTYPE_VECTOR3: number;
  33905. /**
  33906. * Quaternion animation type
  33907. */
  33908. static readonly ANIMATIONTYPE_QUATERNION: number;
  33909. /**
  33910. * Matrix animation type
  33911. */
  33912. static readonly ANIMATIONTYPE_MATRIX: number;
  33913. /**
  33914. * Color3 animation type
  33915. */
  33916. static readonly ANIMATIONTYPE_COLOR3: number;
  33917. /**
  33918. * Color3 animation type
  33919. */
  33920. static readonly ANIMATIONTYPE_COLOR4: number;
  33921. /**
  33922. * Vector2 animation type
  33923. */
  33924. static readonly ANIMATIONTYPE_VECTOR2: number;
  33925. /**
  33926. * Size animation type
  33927. */
  33928. static readonly ANIMATIONTYPE_SIZE: number;
  33929. /**
  33930. * Relative Loop Mode
  33931. */
  33932. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  33933. /**
  33934. * Cycle Loop Mode
  33935. */
  33936. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  33937. /**
  33938. * Constant Loop Mode
  33939. */
  33940. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  33941. /** @hidden */
  33942. static _UniversalLerp(left: any, right: any, amount: number): any;
  33943. /**
  33944. * Parses an animation object and creates an animation
  33945. * @param parsedAnimation Parsed animation object
  33946. * @returns Animation object
  33947. */
  33948. static Parse(parsedAnimation: any): Animation;
  33949. /**
  33950. * Appends the serialized animations from the source animations
  33951. * @param source Source containing the animations
  33952. * @param destination Target to store the animations
  33953. */
  33954. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  33955. /**
  33956. * Creates a new animation or an array of animations from a snippet saved in a remote file
  33957. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  33958. * @param url defines the url to load from
  33959. * @returns a promise that will resolve to the new animation or an array of animations
  33960. */
  33961. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  33962. /**
  33963. * Creates an animation or an array of animations from a snippet saved by the Inspector
  33964. * @param snippetId defines the snippet to load
  33965. * @returns a promise that will resolve to the new animation or a new array of animations
  33966. */
  33967. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  33968. }
  33969. }
  33970. declare module "babylonjs/Animations/animatable.interface" {
  33971. import { Nullable } from "babylonjs/types";
  33972. import { Animation } from "babylonjs/Animations/animation";
  33973. /**
  33974. * Interface containing an array of animations
  33975. */
  33976. export interface IAnimatable {
  33977. /**
  33978. * Array of animations
  33979. */
  33980. animations: Nullable<Array<Animation>>;
  33981. }
  33982. }
  33983. declare module "babylonjs/Misc/decorators" {
  33984. import { Nullable } from "babylonjs/types";
  33985. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33986. import { Scene } from "babylonjs/scene";
  33987. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33988. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  33989. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  33990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33991. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  33992. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33993. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33994. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33995. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33996. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33997. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33998. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  33999. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34000. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34001. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34002. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34003. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34004. /**
  34005. * Decorator used to define property that can be serialized as reference to a camera
  34006. * @param sourceName defines the name of the property to decorate
  34007. */
  34008. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  34009. /**
  34010. * Class used to help serialization objects
  34011. */
  34012. export class SerializationHelper {
  34013. /** @hidden */
  34014. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  34015. /** @hidden */
  34016. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  34017. /** @hidden */
  34018. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  34019. /** @hidden */
  34020. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  34021. /**
  34022. * Appends the serialized animations from the source animations
  34023. * @param source Source containing the animations
  34024. * @param destination Target to store the animations
  34025. */
  34026. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  34027. /**
  34028. * Static function used to serialized a specific entity
  34029. * @param entity defines the entity to serialize
  34030. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  34031. * @returns a JSON compatible object representing the serialization of the entity
  34032. */
  34033. static Serialize<T>(entity: T, serializationObject?: any): any;
  34034. /**
  34035. * Creates a new entity from a serialization data object
  34036. * @param creationFunction defines a function used to instanciated the new entity
  34037. * @param source defines the source serialization data
  34038. * @param scene defines the hosting scene
  34039. * @param rootUrl defines the root url for resources
  34040. * @returns a new entity
  34041. */
  34042. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  34043. /**
  34044. * Clones an object
  34045. * @param creationFunction defines the function used to instanciate the new object
  34046. * @param source defines the source object
  34047. * @returns the cloned object
  34048. */
  34049. static Clone<T>(creationFunction: () => T, source: T): T;
  34050. /**
  34051. * Instanciates a new object based on a source one (some data will be shared between both object)
  34052. * @param creationFunction defines the function used to instanciate the new object
  34053. * @param source defines the source object
  34054. * @returns the new object
  34055. */
  34056. static Instanciate<T>(creationFunction: () => T, source: T): T;
  34057. }
  34058. }
  34059. declare module "babylonjs/Materials/Textures/baseTexture" {
  34060. import { Observable } from "babylonjs/Misc/observable";
  34061. import { Nullable } from "babylonjs/types";
  34062. import { Scene } from "babylonjs/scene";
  34063. import { Matrix } from "babylonjs/Maths/math.vector";
  34064. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34065. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34066. import { ISize } from "babylonjs/Maths/math.size";
  34067. import "babylonjs/Misc/fileTools";
  34068. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34069. /**
  34070. * Base class of all the textures in babylon.
  34071. * It groups all the common properties the materials, post process, lights... might need
  34072. * in order to make a correct use of the texture.
  34073. */
  34074. export class BaseTexture implements IAnimatable {
  34075. /**
  34076. * Default anisotropic filtering level for the application.
  34077. * It is set to 4 as a good tradeoff between perf and quality.
  34078. */
  34079. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  34080. /**
  34081. * Gets or sets the unique id of the texture
  34082. */
  34083. uniqueId: number;
  34084. /**
  34085. * Define the name of the texture.
  34086. */
  34087. name: string;
  34088. /**
  34089. * Gets or sets an object used to store user defined information.
  34090. */
  34091. metadata: any;
  34092. /**
  34093. * For internal use only. Please do not use.
  34094. */
  34095. reservedDataStore: any;
  34096. private _hasAlpha;
  34097. /**
  34098. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  34099. */
  34100. set hasAlpha(value: boolean);
  34101. get hasAlpha(): boolean;
  34102. /**
  34103. * Defines if the alpha value should be determined via the rgb values.
  34104. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  34105. */
  34106. getAlphaFromRGB: boolean;
  34107. /**
  34108. * Intensity or strength of the texture.
  34109. * It is commonly used by materials to fine tune the intensity of the texture
  34110. */
  34111. level: number;
  34112. /**
  34113. * Define the UV chanel to use starting from 0 and defaulting to 0.
  34114. * This is part of the texture as textures usually maps to one uv set.
  34115. */
  34116. coordinatesIndex: number;
  34117. private _coordinatesMode;
  34118. /**
  34119. * How a texture is mapped.
  34120. *
  34121. * | Value | Type | Description |
  34122. * | ----- | ----------------------------------- | ----------- |
  34123. * | 0 | EXPLICIT_MODE | |
  34124. * | 1 | SPHERICAL_MODE | |
  34125. * | 2 | PLANAR_MODE | |
  34126. * | 3 | CUBIC_MODE | |
  34127. * | 4 | PROJECTION_MODE | |
  34128. * | 5 | SKYBOX_MODE | |
  34129. * | 6 | INVCUBIC_MODE | |
  34130. * | 7 | EQUIRECTANGULAR_MODE | |
  34131. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  34132. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  34133. */
  34134. set coordinatesMode(value: number);
  34135. get coordinatesMode(): number;
  34136. /**
  34137. * | Value | Type | Description |
  34138. * | ----- | ------------------ | ----------- |
  34139. * | 0 | CLAMP_ADDRESSMODE | |
  34140. * | 1 | WRAP_ADDRESSMODE | |
  34141. * | 2 | MIRROR_ADDRESSMODE | |
  34142. */
  34143. wrapU: number;
  34144. /**
  34145. * | Value | Type | Description |
  34146. * | ----- | ------------------ | ----------- |
  34147. * | 0 | CLAMP_ADDRESSMODE | |
  34148. * | 1 | WRAP_ADDRESSMODE | |
  34149. * | 2 | MIRROR_ADDRESSMODE | |
  34150. */
  34151. wrapV: number;
  34152. /**
  34153. * | Value | Type | Description |
  34154. * | ----- | ------------------ | ----------- |
  34155. * | 0 | CLAMP_ADDRESSMODE | |
  34156. * | 1 | WRAP_ADDRESSMODE | |
  34157. * | 2 | MIRROR_ADDRESSMODE | |
  34158. */
  34159. wrapR: number;
  34160. /**
  34161. * With compliant hardware and browser (supporting anisotropic filtering)
  34162. * this defines the level of anisotropic filtering in the texture.
  34163. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  34164. */
  34165. anisotropicFilteringLevel: number;
  34166. /**
  34167. * Define if the texture is a cube texture or if false a 2d texture.
  34168. */
  34169. get isCube(): boolean;
  34170. set isCube(value: boolean);
  34171. /**
  34172. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  34173. */
  34174. get is3D(): boolean;
  34175. set is3D(value: boolean);
  34176. /**
  34177. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  34178. */
  34179. get is2DArray(): boolean;
  34180. set is2DArray(value: boolean);
  34181. /**
  34182. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  34183. * HDR texture are usually stored in linear space.
  34184. * This only impacts the PBR and Background materials
  34185. */
  34186. gammaSpace: boolean;
  34187. /**
  34188. * Gets or sets whether or not the texture contains RGBD data.
  34189. */
  34190. get isRGBD(): boolean;
  34191. set isRGBD(value: boolean);
  34192. /**
  34193. * Is Z inverted in the texture (useful in a cube texture).
  34194. */
  34195. invertZ: boolean;
  34196. /**
  34197. * Are mip maps generated for this texture or not.
  34198. */
  34199. get noMipmap(): boolean;
  34200. /**
  34201. * @hidden
  34202. */
  34203. lodLevelInAlpha: boolean;
  34204. /**
  34205. * With prefiltered texture, defined the offset used during the prefiltering steps.
  34206. */
  34207. get lodGenerationOffset(): number;
  34208. set lodGenerationOffset(value: number);
  34209. /**
  34210. * With prefiltered texture, defined the scale used during the prefiltering steps.
  34211. */
  34212. get lodGenerationScale(): number;
  34213. set lodGenerationScale(value: number);
  34214. /**
  34215. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  34216. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  34217. * average roughness values.
  34218. */
  34219. get linearSpecularLOD(): boolean;
  34220. set linearSpecularLOD(value: boolean);
  34221. /**
  34222. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  34223. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  34224. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  34225. */
  34226. get irradianceTexture(): Nullable<BaseTexture>;
  34227. set irradianceTexture(value: Nullable<BaseTexture>);
  34228. /**
  34229. * Define if the texture is a render target.
  34230. */
  34231. isRenderTarget: boolean;
  34232. /**
  34233. * Define the unique id of the texture in the scene.
  34234. */
  34235. get uid(): string;
  34236. /** @hidden */
  34237. _prefiltered: boolean;
  34238. /**
  34239. * Return a string representation of the texture.
  34240. * @returns the texture as a string
  34241. */
  34242. toString(): string;
  34243. /**
  34244. * Get the class name of the texture.
  34245. * @returns "BaseTexture"
  34246. */
  34247. getClassName(): string;
  34248. /**
  34249. * Define the list of animation attached to the texture.
  34250. */
  34251. animations: import("babylonjs/Animations/animation").Animation[];
  34252. /**
  34253. * An event triggered when the texture is disposed.
  34254. */
  34255. onDisposeObservable: Observable<BaseTexture>;
  34256. private _onDisposeObserver;
  34257. /**
  34258. * Callback triggered when the texture has been disposed.
  34259. * Kept for back compatibility, you can use the onDisposeObservable instead.
  34260. */
  34261. set onDispose(callback: () => void);
  34262. /**
  34263. * Define the current state of the loading sequence when in delayed load mode.
  34264. */
  34265. delayLoadState: number;
  34266. private _scene;
  34267. private _engine;
  34268. /** @hidden */
  34269. _texture: Nullable<InternalTexture>;
  34270. private _uid;
  34271. /**
  34272. * Define if the texture is preventinga material to render or not.
  34273. * If not and the texture is not ready, the engine will use a default black texture instead.
  34274. */
  34275. get isBlocking(): boolean;
  34276. /**
  34277. * Instantiates a new BaseTexture.
  34278. * Base class of all the textures in babylon.
  34279. * It groups all the common properties the materials, post process, lights... might need
  34280. * in order to make a correct use of the texture.
  34281. * @param sceneOrEngine Define the scene or engine the texture blongs to
  34282. */
  34283. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  34284. /**
  34285. * Get the scene the texture belongs to.
  34286. * @returns the scene or null if undefined
  34287. */
  34288. getScene(): Nullable<Scene>;
  34289. /** @hidden */
  34290. protected _getEngine(): Nullable<ThinEngine>;
  34291. /**
  34292. * Get the texture transform matrix used to offset tile the texture for istance.
  34293. * @returns the transformation matrix
  34294. */
  34295. getTextureMatrix(): Matrix;
  34296. /**
  34297. * Get the texture reflection matrix used to rotate/transform the reflection.
  34298. * @returns the reflection matrix
  34299. */
  34300. getReflectionTextureMatrix(): Matrix;
  34301. /**
  34302. * Get the underlying lower level texture from Babylon.
  34303. * @returns the insternal texture
  34304. */
  34305. getInternalTexture(): Nullable<InternalTexture>;
  34306. /**
  34307. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  34308. * @returns true if ready or not blocking
  34309. */
  34310. isReadyOrNotBlocking(): boolean;
  34311. /**
  34312. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  34313. * @returns true if fully ready
  34314. */
  34315. isReady(): boolean;
  34316. private _cachedSize;
  34317. /**
  34318. * Get the size of the texture.
  34319. * @returns the texture size.
  34320. */
  34321. getSize(): ISize;
  34322. /**
  34323. * Get the base size of the texture.
  34324. * It can be different from the size if the texture has been resized for POT for instance
  34325. * @returns the base size
  34326. */
  34327. getBaseSize(): ISize;
  34328. /**
  34329. * Update the sampling mode of the texture.
  34330. * Default is Trilinear mode.
  34331. *
  34332. * | Value | Type | Description |
  34333. * | ----- | ------------------ | ----------- |
  34334. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  34335. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  34336. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  34337. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  34338. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  34339. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  34340. * | 7 | NEAREST_LINEAR | |
  34341. * | 8 | NEAREST_NEAREST | |
  34342. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  34343. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  34344. * | 11 | LINEAR_LINEAR | |
  34345. * | 12 | LINEAR_NEAREST | |
  34346. *
  34347. * > _mag_: magnification filter (close to the viewer)
  34348. * > _min_: minification filter (far from the viewer)
  34349. * > _mip_: filter used between mip map levels
  34350. *@param samplingMode Define the new sampling mode of the texture
  34351. */
  34352. updateSamplingMode(samplingMode: number): void;
  34353. /**
  34354. * Scales the texture if is `canRescale()`
  34355. * @param ratio the resize factor we want to use to rescale
  34356. */
  34357. scale(ratio: number): void;
  34358. /**
  34359. * Get if the texture can rescale.
  34360. */
  34361. get canRescale(): boolean;
  34362. /** @hidden */
  34363. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  34364. /** @hidden */
  34365. _rebuild(): void;
  34366. /**
  34367. * Triggers the load sequence in delayed load mode.
  34368. */
  34369. delayLoad(): void;
  34370. /**
  34371. * Clones the texture.
  34372. * @returns the cloned texture
  34373. */
  34374. clone(): Nullable<BaseTexture>;
  34375. /**
  34376. * Get the texture underlying type (INT, FLOAT...)
  34377. */
  34378. get textureType(): number;
  34379. /**
  34380. * Get the texture underlying format (RGB, RGBA...)
  34381. */
  34382. get textureFormat(): number;
  34383. /**
  34384. * Indicates that textures need to be re-calculated for all materials
  34385. */
  34386. protected _markAllSubMeshesAsTexturesDirty(): void;
  34387. /**
  34388. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  34389. * This will returns an RGBA array buffer containing either in values (0-255) or
  34390. * float values (0-1) depending of the underlying buffer type.
  34391. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  34392. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  34393. * @param buffer defines a user defined buffer to fill with data (can be null)
  34394. * @returns The Array buffer containing the pixels data.
  34395. */
  34396. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  34397. /**
  34398. * Release and destroy the underlying lower level texture aka internalTexture.
  34399. */
  34400. releaseInternalTexture(): void;
  34401. /** @hidden */
  34402. get _lodTextureHigh(): Nullable<BaseTexture>;
  34403. /** @hidden */
  34404. get _lodTextureMid(): Nullable<BaseTexture>;
  34405. /** @hidden */
  34406. get _lodTextureLow(): Nullable<BaseTexture>;
  34407. /**
  34408. * Dispose the texture and release its associated resources.
  34409. */
  34410. dispose(): void;
  34411. /**
  34412. * Serialize the texture into a JSON representation that can be parsed later on.
  34413. * @returns the JSON representation of the texture
  34414. */
  34415. serialize(): any;
  34416. /**
  34417. * Helper function to be called back once a list of texture contains only ready textures.
  34418. * @param textures Define the list of textures to wait for
  34419. * @param callback Define the callback triggered once the entire list will be ready
  34420. */
  34421. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  34422. private static _isScene;
  34423. }
  34424. }
  34425. declare module "babylonjs/Materials/effect" {
  34426. import { Observable } from "babylonjs/Misc/observable";
  34427. import { Nullable } from "babylonjs/types";
  34428. import { IDisposable } from "babylonjs/scene";
  34429. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34430. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34431. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  34432. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  34433. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  34434. import { Engine } from "babylonjs/Engines/engine";
  34435. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34436. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34438. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34439. /**
  34440. * Options to be used when creating an effect.
  34441. */
  34442. export interface IEffectCreationOptions {
  34443. /**
  34444. * Atrributes that will be used in the shader.
  34445. */
  34446. attributes: string[];
  34447. /**
  34448. * Uniform varible names that will be set in the shader.
  34449. */
  34450. uniformsNames: string[];
  34451. /**
  34452. * Uniform buffer variable names that will be set in the shader.
  34453. */
  34454. uniformBuffersNames: string[];
  34455. /**
  34456. * Sampler texture variable names that will be set in the shader.
  34457. */
  34458. samplers: string[];
  34459. /**
  34460. * Define statements that will be set in the shader.
  34461. */
  34462. defines: any;
  34463. /**
  34464. * Possible fallbacks for this effect to improve performance when needed.
  34465. */
  34466. fallbacks: Nullable<IEffectFallbacks>;
  34467. /**
  34468. * Callback that will be called when the shader is compiled.
  34469. */
  34470. onCompiled: Nullable<(effect: Effect) => void>;
  34471. /**
  34472. * Callback that will be called if an error occurs during shader compilation.
  34473. */
  34474. onError: Nullable<(effect: Effect, errors: string) => void>;
  34475. /**
  34476. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34477. */
  34478. indexParameters?: any;
  34479. /**
  34480. * Max number of lights that can be used in the shader.
  34481. */
  34482. maxSimultaneousLights?: number;
  34483. /**
  34484. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  34485. */
  34486. transformFeedbackVaryings?: Nullable<string[]>;
  34487. /**
  34488. * 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
  34489. */
  34490. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  34491. /**
  34492. * Is this effect rendering to several color attachments ?
  34493. */
  34494. multiTarget?: boolean;
  34495. }
  34496. /**
  34497. * Effect containing vertex and fragment shader that can be executed on an object.
  34498. */
  34499. export class Effect implements IDisposable {
  34500. /**
  34501. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  34502. */
  34503. static ShadersRepository: string;
  34504. /**
  34505. * Enable logging of the shader code when a compilation error occurs
  34506. */
  34507. static LogShaderCodeOnCompilationError: boolean;
  34508. /**
  34509. * Name of the effect.
  34510. */
  34511. name: any;
  34512. /**
  34513. * String container all the define statements that should be set on the shader.
  34514. */
  34515. defines: string;
  34516. /**
  34517. * Callback that will be called when the shader is compiled.
  34518. */
  34519. onCompiled: Nullable<(effect: Effect) => void>;
  34520. /**
  34521. * Callback that will be called if an error occurs during shader compilation.
  34522. */
  34523. onError: Nullable<(effect: Effect, errors: string) => void>;
  34524. /**
  34525. * Callback that will be called when effect is bound.
  34526. */
  34527. onBind: Nullable<(effect: Effect) => void>;
  34528. /**
  34529. * Unique ID of the effect.
  34530. */
  34531. uniqueId: number;
  34532. /**
  34533. * Observable that will be called when the shader is compiled.
  34534. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  34535. */
  34536. onCompileObservable: Observable<Effect>;
  34537. /**
  34538. * Observable that will be called if an error occurs during shader compilation.
  34539. */
  34540. onErrorObservable: Observable<Effect>;
  34541. /** @hidden */
  34542. _onBindObservable: Nullable<Observable<Effect>>;
  34543. /**
  34544. * @hidden
  34545. * Specifies if the effect was previously ready
  34546. */
  34547. _wasPreviouslyReady: boolean;
  34548. /**
  34549. * Observable that will be called when effect is bound.
  34550. */
  34551. get onBindObservable(): Observable<Effect>;
  34552. /** @hidden */
  34553. _bonesComputationForcedToCPU: boolean;
  34554. /** @hidden */
  34555. _multiTarget: boolean;
  34556. private static _uniqueIdSeed;
  34557. private _engine;
  34558. private _uniformBuffersNames;
  34559. private _uniformBuffersNamesList;
  34560. private _uniformsNames;
  34561. private _samplerList;
  34562. private _samplers;
  34563. private _isReady;
  34564. private _compilationError;
  34565. private _allFallbacksProcessed;
  34566. private _attributesNames;
  34567. private _attributes;
  34568. private _attributeLocationByName;
  34569. private _uniforms;
  34570. /**
  34571. * Key for the effect.
  34572. * @hidden
  34573. */
  34574. _key: string;
  34575. private _indexParameters;
  34576. private _fallbacks;
  34577. private _vertexSourceCode;
  34578. private _fragmentSourceCode;
  34579. private _vertexSourceCodeOverride;
  34580. private _fragmentSourceCodeOverride;
  34581. private _transformFeedbackVaryings;
  34582. /**
  34583. * Compiled shader to webGL program.
  34584. * @hidden
  34585. */
  34586. _pipelineContext: Nullable<IPipelineContext>;
  34587. private _valueCache;
  34588. private static _baseCache;
  34589. /**
  34590. * Instantiates an effect.
  34591. * An effect can be used to create/manage/execute vertex and fragment shaders.
  34592. * @param baseName Name of the effect.
  34593. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  34594. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  34595. * @param samplers List of sampler variables that will be passed to the shader.
  34596. * @param engine Engine to be used to render the effect
  34597. * @param defines Define statements to be added to the shader.
  34598. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  34599. * @param onCompiled Callback that will be called when the shader is compiled.
  34600. * @param onError Callback that will be called if an error occurs during shader compilation.
  34601. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  34602. */
  34603. 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);
  34604. private _useFinalCode;
  34605. /**
  34606. * Unique key for this effect
  34607. */
  34608. get key(): string;
  34609. /**
  34610. * If the effect has been compiled and prepared.
  34611. * @returns if the effect is compiled and prepared.
  34612. */
  34613. isReady(): boolean;
  34614. private _isReadyInternal;
  34615. /**
  34616. * The engine the effect was initialized with.
  34617. * @returns the engine.
  34618. */
  34619. getEngine(): Engine;
  34620. /**
  34621. * The pipeline context for this effect
  34622. * @returns the associated pipeline context
  34623. */
  34624. getPipelineContext(): Nullable<IPipelineContext>;
  34625. /**
  34626. * The set of names of attribute variables for the shader.
  34627. * @returns An array of attribute names.
  34628. */
  34629. getAttributesNames(): string[];
  34630. /**
  34631. * Returns the attribute at the given index.
  34632. * @param index The index of the attribute.
  34633. * @returns The location of the attribute.
  34634. */
  34635. getAttributeLocation(index: number): number;
  34636. /**
  34637. * Returns the attribute based on the name of the variable.
  34638. * @param name of the attribute to look up.
  34639. * @returns the attribute location.
  34640. */
  34641. getAttributeLocationByName(name: string): number;
  34642. /**
  34643. * The number of attributes.
  34644. * @returns the numnber of attributes.
  34645. */
  34646. getAttributesCount(): number;
  34647. /**
  34648. * Gets the index of a uniform variable.
  34649. * @param uniformName of the uniform to look up.
  34650. * @returns the index.
  34651. */
  34652. getUniformIndex(uniformName: string): number;
  34653. /**
  34654. * Returns the attribute based on the name of the variable.
  34655. * @param uniformName of the uniform to look up.
  34656. * @returns the location of the uniform.
  34657. */
  34658. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  34659. /**
  34660. * Returns an array of sampler variable names
  34661. * @returns The array of sampler variable names.
  34662. */
  34663. getSamplers(): string[];
  34664. /**
  34665. * Returns an array of uniform variable names
  34666. * @returns The array of uniform variable names.
  34667. */
  34668. getUniformNames(): string[];
  34669. /**
  34670. * Returns an array of uniform buffer variable names
  34671. * @returns The array of uniform buffer variable names.
  34672. */
  34673. getUniformBuffersNames(): string[];
  34674. /**
  34675. * Returns the index parameters used to create the effect
  34676. * @returns The index parameters object
  34677. */
  34678. getIndexParameters(): any;
  34679. /**
  34680. * The error from the last compilation.
  34681. * @returns the error string.
  34682. */
  34683. getCompilationError(): string;
  34684. /**
  34685. * Gets a boolean indicating that all fallbacks were used during compilation
  34686. * @returns true if all fallbacks were used
  34687. */
  34688. allFallbacksProcessed(): boolean;
  34689. /**
  34690. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  34691. * @param func The callback to be used.
  34692. */
  34693. executeWhenCompiled(func: (effect: Effect) => void): void;
  34694. private _checkIsReady;
  34695. private _loadShader;
  34696. /**
  34697. * Gets the vertex shader source code of this effect
  34698. */
  34699. get vertexSourceCode(): string;
  34700. /**
  34701. * Gets the fragment shader source code of this effect
  34702. */
  34703. get fragmentSourceCode(): string;
  34704. /**
  34705. * Recompiles the webGL program
  34706. * @param vertexSourceCode The source code for the vertex shader.
  34707. * @param fragmentSourceCode The source code for the fragment shader.
  34708. * @param onCompiled Callback called when completed.
  34709. * @param onError Callback called on error.
  34710. * @hidden
  34711. */
  34712. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  34713. /**
  34714. * Prepares the effect
  34715. * @hidden
  34716. */
  34717. _prepareEffect(): void;
  34718. private _getShaderCodeAndErrorLine;
  34719. private _processCompilationErrors;
  34720. /**
  34721. * Checks if the effect is supported. (Must be called after compilation)
  34722. */
  34723. get isSupported(): boolean;
  34724. /**
  34725. * Binds a texture to the engine to be used as output of the shader.
  34726. * @param channel Name of the output variable.
  34727. * @param texture Texture to bind.
  34728. * @hidden
  34729. */
  34730. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  34731. /**
  34732. * Sets a texture on the engine to be used in the shader.
  34733. * @param channel Name of the sampler variable.
  34734. * @param texture Texture to set.
  34735. */
  34736. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  34737. /**
  34738. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  34739. * @param channel Name of the sampler variable.
  34740. * @param texture Texture to set.
  34741. */
  34742. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  34743. /**
  34744. * Sets an array of textures on the engine to be used in the shader.
  34745. * @param channel Name of the variable.
  34746. * @param textures Textures to set.
  34747. */
  34748. setTextureArray(channel: string, textures: BaseTexture[]): void;
  34749. /**
  34750. * 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)
  34751. * @param channel Name of the sampler variable.
  34752. * @param postProcess Post process to get the input texture from.
  34753. */
  34754. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  34755. /**
  34756. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  34757. * 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)
  34758. * @param channel Name of the sampler variable.
  34759. * @param postProcess Post process to get the output texture from.
  34760. */
  34761. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  34762. /** @hidden */
  34763. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  34764. /** @hidden */
  34765. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  34766. /** @hidden */
  34767. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  34768. /** @hidden */
  34769. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  34770. /**
  34771. * Binds a buffer to a uniform.
  34772. * @param buffer Buffer to bind.
  34773. * @param name Name of the uniform variable to bind to.
  34774. */
  34775. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  34776. /**
  34777. * Binds block to a uniform.
  34778. * @param blockName Name of the block to bind.
  34779. * @param index Index to bind.
  34780. */
  34781. bindUniformBlock(blockName: string, index: number): void;
  34782. /**
  34783. * Sets an interger value on a uniform variable.
  34784. * @param uniformName Name of the variable.
  34785. * @param value Value to be set.
  34786. * @returns this effect.
  34787. */
  34788. setInt(uniformName: string, value: number): Effect;
  34789. /**
  34790. * Sets an int array on a uniform variable.
  34791. * @param uniformName Name of the variable.
  34792. * @param array array to be set.
  34793. * @returns this effect.
  34794. */
  34795. setIntArray(uniformName: string, array: Int32Array): Effect;
  34796. /**
  34797. * 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)
  34798. * @param uniformName Name of the variable.
  34799. * @param array array to be set.
  34800. * @returns this effect.
  34801. */
  34802. setIntArray2(uniformName: string, array: Int32Array): Effect;
  34803. /**
  34804. * 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)
  34805. * @param uniformName Name of the variable.
  34806. * @param array array to be set.
  34807. * @returns this effect.
  34808. */
  34809. setIntArray3(uniformName: string, array: Int32Array): Effect;
  34810. /**
  34811. * 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)
  34812. * @param uniformName Name of the variable.
  34813. * @param array array to be set.
  34814. * @returns this effect.
  34815. */
  34816. setIntArray4(uniformName: string, array: Int32Array): Effect;
  34817. /**
  34818. * Sets an float array on a uniform variable.
  34819. * @param uniformName Name of the variable.
  34820. * @param array array to be set.
  34821. * @returns this effect.
  34822. */
  34823. setFloatArray(uniformName: string, array: Float32Array): Effect;
  34824. /**
  34825. * 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)
  34826. * @param uniformName Name of the variable.
  34827. * @param array array to be set.
  34828. * @returns this effect.
  34829. */
  34830. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  34831. /**
  34832. * 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)
  34833. * @param uniformName Name of the variable.
  34834. * @param array array to be set.
  34835. * @returns this effect.
  34836. */
  34837. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  34838. /**
  34839. * 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)
  34840. * @param uniformName Name of the variable.
  34841. * @param array array to be set.
  34842. * @returns this effect.
  34843. */
  34844. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  34845. /**
  34846. * Sets an array on a uniform variable.
  34847. * @param uniformName Name of the variable.
  34848. * @param array array to be set.
  34849. * @returns this effect.
  34850. */
  34851. setArray(uniformName: string, array: number[]): Effect;
  34852. /**
  34853. * 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)
  34854. * @param uniformName Name of the variable.
  34855. * @param array array to be set.
  34856. * @returns this effect.
  34857. */
  34858. setArray2(uniformName: string, array: number[]): Effect;
  34859. /**
  34860. * 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)
  34861. * @param uniformName Name of the variable.
  34862. * @param array array to be set.
  34863. * @returns this effect.
  34864. */
  34865. setArray3(uniformName: string, array: number[]): Effect;
  34866. /**
  34867. * 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)
  34868. * @param uniformName Name of the variable.
  34869. * @param array array to be set.
  34870. * @returns this effect.
  34871. */
  34872. setArray4(uniformName: string, array: number[]): Effect;
  34873. /**
  34874. * Sets matrices on a uniform variable.
  34875. * @param uniformName Name of the variable.
  34876. * @param matrices matrices to be set.
  34877. * @returns this effect.
  34878. */
  34879. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  34880. /**
  34881. * Sets matrix on a uniform variable.
  34882. * @param uniformName Name of the variable.
  34883. * @param matrix matrix to be set.
  34884. * @returns this effect.
  34885. */
  34886. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  34887. /**
  34888. * 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)
  34889. * @param uniformName Name of the variable.
  34890. * @param matrix matrix to be set.
  34891. * @returns this effect.
  34892. */
  34893. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  34894. /**
  34895. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  34896. * @param uniformName Name of the variable.
  34897. * @param matrix matrix to be set.
  34898. * @returns this effect.
  34899. */
  34900. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  34901. /**
  34902. * Sets a float on a uniform variable.
  34903. * @param uniformName Name of the variable.
  34904. * @param value value to be set.
  34905. * @returns this effect.
  34906. */
  34907. setFloat(uniformName: string, value: number): Effect;
  34908. /**
  34909. * Sets a boolean on a uniform variable.
  34910. * @param uniformName Name of the variable.
  34911. * @param bool value to be set.
  34912. * @returns this effect.
  34913. */
  34914. setBool(uniformName: string, bool: boolean): Effect;
  34915. /**
  34916. * Sets a Vector2 on a uniform variable.
  34917. * @param uniformName Name of the variable.
  34918. * @param vector2 vector2 to be set.
  34919. * @returns this effect.
  34920. */
  34921. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  34922. /**
  34923. * Sets a float2 on a uniform variable.
  34924. * @param uniformName Name of the variable.
  34925. * @param x First float in float2.
  34926. * @param y Second float in float2.
  34927. * @returns this effect.
  34928. */
  34929. setFloat2(uniformName: string, x: number, y: number): Effect;
  34930. /**
  34931. * Sets a Vector3 on a uniform variable.
  34932. * @param uniformName Name of the variable.
  34933. * @param vector3 Value to be set.
  34934. * @returns this effect.
  34935. */
  34936. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  34937. /**
  34938. * Sets a float3 on a uniform variable.
  34939. * @param uniformName Name of the variable.
  34940. * @param x First float in float3.
  34941. * @param y Second float in float3.
  34942. * @param z Third float in float3.
  34943. * @returns this effect.
  34944. */
  34945. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  34946. /**
  34947. * Sets a Vector4 on a uniform variable.
  34948. * @param uniformName Name of the variable.
  34949. * @param vector4 Value to be set.
  34950. * @returns this effect.
  34951. */
  34952. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  34953. /**
  34954. * Sets a float4 on a uniform variable.
  34955. * @param uniformName Name of the variable.
  34956. * @param x First float in float4.
  34957. * @param y Second float in float4.
  34958. * @param z Third float in float4.
  34959. * @param w Fourth float in float4.
  34960. * @returns this effect.
  34961. */
  34962. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  34963. /**
  34964. * Sets a Color3 on a uniform variable.
  34965. * @param uniformName Name of the variable.
  34966. * @param color3 Value to be set.
  34967. * @returns this effect.
  34968. */
  34969. setColor3(uniformName: string, color3: IColor3Like): Effect;
  34970. /**
  34971. * Sets a Color4 on a uniform variable.
  34972. * @param uniformName Name of the variable.
  34973. * @param color3 Value to be set.
  34974. * @param alpha Alpha value to be set.
  34975. * @returns this effect.
  34976. */
  34977. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  34978. /**
  34979. * Sets a Color4 on a uniform variable
  34980. * @param uniformName defines the name of the variable
  34981. * @param color4 defines the value to be set
  34982. * @returns this effect.
  34983. */
  34984. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  34985. /** Release all associated resources */
  34986. dispose(): void;
  34987. /**
  34988. * This function will add a new shader to the shader store
  34989. * @param name the name of the shader
  34990. * @param pixelShader optional pixel shader content
  34991. * @param vertexShader optional vertex shader content
  34992. */
  34993. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  34994. /**
  34995. * Store of each shader (The can be looked up using effect.key)
  34996. */
  34997. static ShadersStore: {
  34998. [key: string]: string;
  34999. };
  35000. /**
  35001. * Store of each included file for a shader (The can be looked up using effect.key)
  35002. */
  35003. static IncludesShadersStore: {
  35004. [key: string]: string;
  35005. };
  35006. /**
  35007. * Resets the cache of effects.
  35008. */
  35009. static ResetCache(): void;
  35010. }
  35011. }
  35012. declare module "babylonjs/Engines/engineCapabilities" {
  35013. /**
  35014. * Interface used to describe the capabilities of the engine relatively to the current browser
  35015. */
  35016. export interface EngineCapabilities {
  35017. /** Maximum textures units per fragment shader */
  35018. maxTexturesImageUnits: number;
  35019. /** Maximum texture units per vertex shader */
  35020. maxVertexTextureImageUnits: number;
  35021. /** Maximum textures units in the entire pipeline */
  35022. maxCombinedTexturesImageUnits: number;
  35023. /** Maximum texture size */
  35024. maxTextureSize: number;
  35025. /** Maximum texture samples */
  35026. maxSamples?: number;
  35027. /** Maximum cube texture size */
  35028. maxCubemapTextureSize: number;
  35029. /** Maximum render texture size */
  35030. maxRenderTextureSize: number;
  35031. /** Maximum number of vertex attributes */
  35032. maxVertexAttribs: number;
  35033. /** Maximum number of varyings */
  35034. maxVaryingVectors: number;
  35035. /** Maximum number of uniforms per vertex shader */
  35036. maxVertexUniformVectors: number;
  35037. /** Maximum number of uniforms per fragment shader */
  35038. maxFragmentUniformVectors: number;
  35039. /** Defines if standard derivates (dx/dy) are supported */
  35040. standardDerivatives: boolean;
  35041. /** Defines if s3tc texture compression is supported */
  35042. s3tc?: WEBGL_compressed_texture_s3tc;
  35043. /** Defines if pvrtc texture compression is supported */
  35044. pvrtc: any;
  35045. /** Defines if etc1 texture compression is supported */
  35046. etc1: any;
  35047. /** Defines if etc2 texture compression is supported */
  35048. etc2: any;
  35049. /** Defines if astc texture compression is supported */
  35050. astc: any;
  35051. /** Defines if float textures are supported */
  35052. textureFloat: boolean;
  35053. /** Defines if vertex array objects are supported */
  35054. vertexArrayObject: boolean;
  35055. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  35056. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  35057. /** Gets the maximum level of anisotropy supported */
  35058. maxAnisotropy: number;
  35059. /** Defines if instancing is supported */
  35060. instancedArrays: boolean;
  35061. /** Defines if 32 bits indices are supported */
  35062. uintIndices: boolean;
  35063. /** Defines if high precision shaders are supported */
  35064. highPrecisionShaderSupported: boolean;
  35065. /** Defines if depth reading in the fragment shader is supported */
  35066. fragmentDepthSupported: boolean;
  35067. /** Defines if float texture linear filtering is supported*/
  35068. textureFloatLinearFiltering: boolean;
  35069. /** Defines if rendering to float textures is supported */
  35070. textureFloatRender: boolean;
  35071. /** Defines if half float textures are supported*/
  35072. textureHalfFloat: boolean;
  35073. /** Defines if half float texture linear filtering is supported*/
  35074. textureHalfFloatLinearFiltering: boolean;
  35075. /** Defines if rendering to half float textures is supported */
  35076. textureHalfFloatRender: boolean;
  35077. /** Defines if textureLOD shader command is supported */
  35078. textureLOD: boolean;
  35079. /** Defines if draw buffers extension is supported */
  35080. drawBuffersExtension: boolean;
  35081. /** Defines if depth textures are supported */
  35082. depthTextureExtension: boolean;
  35083. /** Defines if float color buffer are supported */
  35084. colorBufferFloat: boolean;
  35085. /** Gets disjoint timer query extension (null if not supported) */
  35086. timerQuery?: EXT_disjoint_timer_query;
  35087. /** Defines if timestamp can be used with timer query */
  35088. canUseTimestampForTimerQuery: boolean;
  35089. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  35090. multiview?: any;
  35091. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  35092. oculusMultiview?: any;
  35093. /** Function used to let the system compiles shaders in background */
  35094. parallelShaderCompile?: {
  35095. COMPLETION_STATUS_KHR: number;
  35096. };
  35097. /** Max number of texture samples for MSAA */
  35098. maxMSAASamples: number;
  35099. /** Defines if the blend min max extension is supported */
  35100. blendMinMax: boolean;
  35101. }
  35102. }
  35103. declare module "babylonjs/States/depthCullingState" {
  35104. import { Nullable } from "babylonjs/types";
  35105. /**
  35106. * @hidden
  35107. **/
  35108. export class DepthCullingState {
  35109. private _isDepthTestDirty;
  35110. private _isDepthMaskDirty;
  35111. private _isDepthFuncDirty;
  35112. private _isCullFaceDirty;
  35113. private _isCullDirty;
  35114. private _isZOffsetDirty;
  35115. private _isFrontFaceDirty;
  35116. private _depthTest;
  35117. private _depthMask;
  35118. private _depthFunc;
  35119. private _cull;
  35120. private _cullFace;
  35121. private _zOffset;
  35122. private _frontFace;
  35123. /**
  35124. * Initializes the state.
  35125. */
  35126. constructor();
  35127. get isDirty(): boolean;
  35128. get zOffset(): number;
  35129. set zOffset(value: number);
  35130. get cullFace(): Nullable<number>;
  35131. set cullFace(value: Nullable<number>);
  35132. get cull(): Nullable<boolean>;
  35133. set cull(value: Nullable<boolean>);
  35134. get depthFunc(): Nullable<number>;
  35135. set depthFunc(value: Nullable<number>);
  35136. get depthMask(): boolean;
  35137. set depthMask(value: boolean);
  35138. get depthTest(): boolean;
  35139. set depthTest(value: boolean);
  35140. get frontFace(): Nullable<number>;
  35141. set frontFace(value: Nullable<number>);
  35142. reset(): void;
  35143. apply(gl: WebGLRenderingContext): void;
  35144. }
  35145. }
  35146. declare module "babylonjs/States/stencilState" {
  35147. /**
  35148. * @hidden
  35149. **/
  35150. export class StencilState {
  35151. /** 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 */
  35152. static readonly ALWAYS: number;
  35153. /** Passed to stencilOperation to specify that stencil value must be kept */
  35154. static readonly KEEP: number;
  35155. /** Passed to stencilOperation to specify that stencil value must be replaced */
  35156. static readonly REPLACE: number;
  35157. private _isStencilTestDirty;
  35158. private _isStencilMaskDirty;
  35159. private _isStencilFuncDirty;
  35160. private _isStencilOpDirty;
  35161. private _stencilTest;
  35162. private _stencilMask;
  35163. private _stencilFunc;
  35164. private _stencilFuncRef;
  35165. private _stencilFuncMask;
  35166. private _stencilOpStencilFail;
  35167. private _stencilOpDepthFail;
  35168. private _stencilOpStencilDepthPass;
  35169. get isDirty(): boolean;
  35170. get stencilFunc(): number;
  35171. set stencilFunc(value: number);
  35172. get stencilFuncRef(): number;
  35173. set stencilFuncRef(value: number);
  35174. get stencilFuncMask(): number;
  35175. set stencilFuncMask(value: number);
  35176. get stencilOpStencilFail(): number;
  35177. set stencilOpStencilFail(value: number);
  35178. get stencilOpDepthFail(): number;
  35179. set stencilOpDepthFail(value: number);
  35180. get stencilOpStencilDepthPass(): number;
  35181. set stencilOpStencilDepthPass(value: number);
  35182. get stencilMask(): number;
  35183. set stencilMask(value: number);
  35184. get stencilTest(): boolean;
  35185. set stencilTest(value: boolean);
  35186. constructor();
  35187. reset(): void;
  35188. apply(gl: WebGLRenderingContext): void;
  35189. }
  35190. }
  35191. declare module "babylonjs/States/alphaCullingState" {
  35192. /**
  35193. * @hidden
  35194. **/
  35195. export class AlphaState {
  35196. private _isAlphaBlendDirty;
  35197. private _isBlendFunctionParametersDirty;
  35198. private _isBlendEquationParametersDirty;
  35199. private _isBlendConstantsDirty;
  35200. private _alphaBlend;
  35201. private _blendFunctionParameters;
  35202. private _blendEquationParameters;
  35203. private _blendConstants;
  35204. /**
  35205. * Initializes the state.
  35206. */
  35207. constructor();
  35208. get isDirty(): boolean;
  35209. get alphaBlend(): boolean;
  35210. set alphaBlend(value: boolean);
  35211. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  35212. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  35213. setAlphaEquationParameters(rgb: number, alpha: number): void;
  35214. reset(): void;
  35215. apply(gl: WebGLRenderingContext): void;
  35216. }
  35217. }
  35218. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  35219. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35220. /** @hidden */
  35221. export class WebGL2ShaderProcessor implements IShaderProcessor {
  35222. attributeProcessor(attribute: string): string;
  35223. varyingProcessor(varying: string, isFragment: boolean): string;
  35224. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  35225. }
  35226. }
  35227. declare module "babylonjs/Engines/instancingAttributeInfo" {
  35228. /**
  35229. * Interface for attribute information associated with buffer instanciation
  35230. */
  35231. export interface InstancingAttributeInfo {
  35232. /**
  35233. * Name of the GLSL attribute
  35234. * if attribute index is not specified, this is used to retrieve the index from the effect
  35235. */
  35236. attributeName: string;
  35237. /**
  35238. * Index/offset of the attribute in the vertex shader
  35239. * if not specified, this will be computes from the name.
  35240. */
  35241. index?: number;
  35242. /**
  35243. * size of the attribute, 1, 2, 3 or 4
  35244. */
  35245. attributeSize: number;
  35246. /**
  35247. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  35248. */
  35249. offset: number;
  35250. /**
  35251. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  35252. * default to 1
  35253. */
  35254. divisor?: number;
  35255. /**
  35256. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  35257. * default is FLOAT
  35258. */
  35259. attributeType?: number;
  35260. /**
  35261. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  35262. */
  35263. normalized?: boolean;
  35264. }
  35265. }
  35266. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  35267. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35268. import { Nullable } from "babylonjs/types";
  35269. module "babylonjs/Engines/thinEngine" {
  35270. interface ThinEngine {
  35271. /**
  35272. * Update a video texture
  35273. * @param texture defines the texture to update
  35274. * @param video defines the video element to use
  35275. * @param invertY defines if data must be stored with Y axis inverted
  35276. */
  35277. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  35278. }
  35279. }
  35280. }
  35281. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  35282. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35283. import { Nullable } from "babylonjs/types";
  35284. module "babylonjs/Engines/thinEngine" {
  35285. interface ThinEngine {
  35286. /**
  35287. * Creates a dynamic texture
  35288. * @param width defines the width of the texture
  35289. * @param height defines the height of the texture
  35290. * @param generateMipMaps defines if the engine should generate the mip levels
  35291. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  35292. * @returns the dynamic texture inside an InternalTexture
  35293. */
  35294. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  35295. /**
  35296. * Update the content of a dynamic texture
  35297. * @param texture defines the texture to update
  35298. * @param canvas defines the canvas containing the source
  35299. * @param invertY defines if data must be stored with Y axis inverted
  35300. * @param premulAlpha defines if alpha is stored as premultiplied
  35301. * @param format defines the format of the data
  35302. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  35303. */
  35304. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  35305. }
  35306. }
  35307. }
  35308. declare module "babylonjs/Materials/Textures/videoTexture" {
  35309. import { Observable } from "babylonjs/Misc/observable";
  35310. import { Nullable } from "babylonjs/types";
  35311. import { Scene } from "babylonjs/scene";
  35312. import { Texture } from "babylonjs/Materials/Textures/texture";
  35313. import "babylonjs/Engines/Extensions/engine.videoTexture";
  35314. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  35315. /**
  35316. * Settings for finer control over video usage
  35317. */
  35318. export interface VideoTextureSettings {
  35319. /**
  35320. * Applies `autoplay` to video, if specified
  35321. */
  35322. autoPlay?: boolean;
  35323. /**
  35324. * Applies `loop` to video, if specified
  35325. */
  35326. loop?: boolean;
  35327. /**
  35328. * Automatically updates internal texture from video at every frame in the render loop
  35329. */
  35330. autoUpdateTexture: boolean;
  35331. /**
  35332. * Image src displayed during the video loading or until the user interacts with the video.
  35333. */
  35334. poster?: string;
  35335. }
  35336. /**
  35337. * If you want to display a video in your scene, this is the special texture for that.
  35338. * This special texture works similar to other textures, with the exception of a few parameters.
  35339. * @see https://doc.babylonjs.com/how_to/video_texture
  35340. */
  35341. export class VideoTexture extends Texture {
  35342. /**
  35343. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  35344. */
  35345. readonly autoUpdateTexture: boolean;
  35346. /**
  35347. * The video instance used by the texture internally
  35348. */
  35349. readonly video: HTMLVideoElement;
  35350. private _onUserActionRequestedObservable;
  35351. /**
  35352. * Event triggerd when a dom action is required by the user to play the video.
  35353. * This happens due to recent changes in browser policies preventing video to auto start.
  35354. */
  35355. get onUserActionRequestedObservable(): Observable<Texture>;
  35356. private _generateMipMaps;
  35357. private _stillImageCaptured;
  35358. private _displayingPosterTexture;
  35359. private _settings;
  35360. private _createInternalTextureOnEvent;
  35361. private _frameId;
  35362. private _currentSrc;
  35363. /**
  35364. * Creates a video texture.
  35365. * If you want to display a video in your scene, this is the special texture for that.
  35366. * This special texture works similar to other textures, with the exception of a few parameters.
  35367. * @see https://doc.babylonjs.com/how_to/video_texture
  35368. * @param name optional name, will detect from video source, if not defined
  35369. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  35370. * @param scene is obviously the current scene.
  35371. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  35372. * @param invertY is false by default but can be used to invert video on Y axis
  35373. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  35374. * @param settings allows finer control over video usage
  35375. */
  35376. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  35377. private _getName;
  35378. private _getVideo;
  35379. private _createInternalTexture;
  35380. private reset;
  35381. /**
  35382. * @hidden Internal method to initiate `update`.
  35383. */
  35384. _rebuild(): void;
  35385. /**
  35386. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  35387. */
  35388. update(): void;
  35389. /**
  35390. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  35391. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  35392. */
  35393. updateTexture(isVisible: boolean): void;
  35394. protected _updateInternalTexture: () => void;
  35395. /**
  35396. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  35397. * @param url New url.
  35398. */
  35399. updateURL(url: string): void;
  35400. /**
  35401. * Clones the texture.
  35402. * @returns the cloned texture
  35403. */
  35404. clone(): VideoTexture;
  35405. /**
  35406. * Dispose the texture and release its associated resources.
  35407. */
  35408. dispose(): void;
  35409. /**
  35410. * Creates a video texture straight from a stream.
  35411. * @param scene Define the scene the texture should be created in
  35412. * @param stream Define the stream the texture should be created from
  35413. * @returns The created video texture as a promise
  35414. */
  35415. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  35416. /**
  35417. * Creates a video texture straight from your WebCam video feed.
  35418. * @param scene Define the scene the texture should be created in
  35419. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35420. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35421. * @returns The created video texture as a promise
  35422. */
  35423. static CreateFromWebCamAsync(scene: Scene, constraints: {
  35424. minWidth: number;
  35425. maxWidth: number;
  35426. minHeight: number;
  35427. maxHeight: number;
  35428. deviceId: string;
  35429. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  35430. /**
  35431. * Creates a video texture straight from your WebCam video feed.
  35432. * @param scene Define the scene the texture should be created in
  35433. * @param onReady Define a callback to triggered once the texture will be ready
  35434. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  35435. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  35436. */
  35437. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  35438. minWidth: number;
  35439. maxWidth: number;
  35440. minHeight: number;
  35441. maxHeight: number;
  35442. deviceId: string;
  35443. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  35444. }
  35445. }
  35446. declare module "babylonjs/Engines/thinEngine" {
  35447. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  35448. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  35449. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  35450. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  35451. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  35452. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  35453. import { Observable } from "babylonjs/Misc/observable";
  35454. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  35455. import { StencilState } from "babylonjs/States/stencilState";
  35456. import { AlphaState } from "babylonjs/States/alphaCullingState";
  35457. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35458. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  35459. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35460. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35461. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35462. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  35463. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  35464. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  35465. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35466. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35467. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35468. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  35469. import { WebRequest } from "babylonjs/Misc/webRequest";
  35470. import { LoadFileError } from "babylonjs/Misc/fileTools";
  35471. /**
  35472. * Defines the interface used by objects working like Scene
  35473. * @hidden
  35474. */
  35475. export interface ISceneLike {
  35476. _addPendingData(data: any): void;
  35477. _removePendingData(data: any): void;
  35478. offlineProvider: IOfflineProvider;
  35479. }
  35480. /** Interface defining initialization parameters for Engine class */
  35481. export interface EngineOptions extends WebGLContextAttributes {
  35482. /**
  35483. * Defines if the engine should no exceed a specified device ratio
  35484. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  35485. */
  35486. limitDeviceRatio?: number;
  35487. /**
  35488. * Defines if webvr should be enabled automatically
  35489. * @see https://doc.babylonjs.com/how_to/webvr_camera
  35490. */
  35491. autoEnableWebVR?: boolean;
  35492. /**
  35493. * Defines if webgl2 should be turned off even if supported
  35494. * @see https://doc.babylonjs.com/features/webgl2
  35495. */
  35496. disableWebGL2Support?: boolean;
  35497. /**
  35498. * Defines if webaudio should be initialized as well
  35499. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  35500. */
  35501. audioEngine?: boolean;
  35502. /**
  35503. * Defines if animations should run using a deterministic lock step
  35504. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  35505. */
  35506. deterministicLockstep?: boolean;
  35507. /** Defines the maximum steps to use with deterministic lock step mode */
  35508. lockstepMaxSteps?: number;
  35509. /** Defines the seconds between each deterministic lock step */
  35510. timeStep?: number;
  35511. /**
  35512. * Defines that engine should ignore context lost events
  35513. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  35514. */
  35515. doNotHandleContextLost?: boolean;
  35516. /**
  35517. * Defines that engine should ignore modifying touch action attribute and style
  35518. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  35519. */
  35520. doNotHandleTouchAction?: boolean;
  35521. /**
  35522. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  35523. */
  35524. useHighPrecisionFloats?: boolean;
  35525. /**
  35526. * Make the canvas XR Compatible for XR sessions
  35527. */
  35528. xrCompatible?: boolean;
  35529. }
  35530. /**
  35531. * The base engine class (root of all engines)
  35532. */
  35533. export class ThinEngine {
  35534. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  35535. static ExceptionList: ({
  35536. key: string;
  35537. capture: string;
  35538. captureConstraint: number;
  35539. targets: string[];
  35540. } | {
  35541. key: string;
  35542. capture: null;
  35543. captureConstraint: null;
  35544. targets: string[];
  35545. })[];
  35546. /** @hidden */
  35547. static _TextureLoaders: IInternalTextureLoader[];
  35548. /**
  35549. * Returns the current npm package of the sdk
  35550. */
  35551. static get NpmPackage(): string;
  35552. /**
  35553. * Returns the current version of the framework
  35554. */
  35555. static get Version(): string;
  35556. /**
  35557. * Returns a string describing the current engine
  35558. */
  35559. get description(): string;
  35560. /**
  35561. * Gets or sets the epsilon value used by collision engine
  35562. */
  35563. static CollisionsEpsilon: number;
  35564. /**
  35565. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35566. */
  35567. static get ShadersRepository(): string;
  35568. static set ShadersRepository(value: string);
  35569. /** @hidden */
  35570. _shaderProcessor: IShaderProcessor;
  35571. /**
  35572. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  35573. */
  35574. forcePOTTextures: boolean;
  35575. /**
  35576. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  35577. */
  35578. isFullscreen: boolean;
  35579. /**
  35580. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  35581. */
  35582. cullBackFaces: boolean;
  35583. /**
  35584. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  35585. */
  35586. renderEvenInBackground: boolean;
  35587. /**
  35588. * Gets or sets a boolean indicating that cache can be kept between frames
  35589. */
  35590. preventCacheWipeBetweenFrames: boolean;
  35591. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  35592. validateShaderPrograms: boolean;
  35593. /**
  35594. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  35595. * This can provide greater z depth for distant objects.
  35596. */
  35597. useReverseDepthBuffer: boolean;
  35598. /**
  35599. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  35600. */
  35601. disableUniformBuffers: boolean;
  35602. /** @hidden */
  35603. _uniformBuffers: UniformBuffer[];
  35604. /**
  35605. * Gets a boolean indicating that the engine supports uniform buffers
  35606. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  35607. */
  35608. get supportsUniformBuffers(): boolean;
  35609. /** @hidden */
  35610. _gl: WebGLRenderingContext;
  35611. /** @hidden */
  35612. _webGLVersion: number;
  35613. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  35614. protected _windowIsBackground: boolean;
  35615. protected _creationOptions: EngineOptions;
  35616. protected _highPrecisionShadersAllowed: boolean;
  35617. /** @hidden */
  35618. get _shouldUseHighPrecisionShader(): boolean;
  35619. /**
  35620. * Gets a boolean indicating that only power of 2 textures are supported
  35621. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  35622. */
  35623. get needPOTTextures(): boolean;
  35624. /** @hidden */
  35625. _badOS: boolean;
  35626. /** @hidden */
  35627. _badDesktopOS: boolean;
  35628. private _hardwareScalingLevel;
  35629. /** @hidden */
  35630. _caps: EngineCapabilities;
  35631. private _isStencilEnable;
  35632. private _glVersion;
  35633. private _glRenderer;
  35634. private _glVendor;
  35635. /** @hidden */
  35636. _videoTextureSupported: boolean;
  35637. protected _renderingQueueLaunched: boolean;
  35638. protected _activeRenderLoops: (() => void)[];
  35639. /**
  35640. * Observable signaled when a context lost event is raised
  35641. */
  35642. onContextLostObservable: Observable<ThinEngine>;
  35643. /**
  35644. * Observable signaled when a context restored event is raised
  35645. */
  35646. onContextRestoredObservable: Observable<ThinEngine>;
  35647. private _onContextLost;
  35648. private _onContextRestored;
  35649. protected _contextWasLost: boolean;
  35650. /** @hidden */
  35651. _doNotHandleContextLost: boolean;
  35652. /**
  35653. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  35654. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  35655. */
  35656. get doNotHandleContextLost(): boolean;
  35657. set doNotHandleContextLost(value: boolean);
  35658. /**
  35659. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  35660. */
  35661. disableVertexArrayObjects: boolean;
  35662. /** @hidden */
  35663. protected _colorWrite: boolean;
  35664. /** @hidden */
  35665. protected _colorWriteChanged: boolean;
  35666. /** @hidden */
  35667. protected _depthCullingState: DepthCullingState;
  35668. /** @hidden */
  35669. protected _stencilState: StencilState;
  35670. /** @hidden */
  35671. _alphaState: AlphaState;
  35672. /** @hidden */
  35673. _alphaMode: number;
  35674. /** @hidden */
  35675. _alphaEquation: number;
  35676. /** @hidden */
  35677. _internalTexturesCache: InternalTexture[];
  35678. /** @hidden */
  35679. protected _activeChannel: number;
  35680. private _currentTextureChannel;
  35681. /** @hidden */
  35682. protected _boundTexturesCache: {
  35683. [key: string]: Nullable<InternalTexture>;
  35684. };
  35685. /** @hidden */
  35686. protected _currentEffect: Nullable<Effect>;
  35687. /** @hidden */
  35688. protected _currentProgram: Nullable<WebGLProgram>;
  35689. private _compiledEffects;
  35690. private _vertexAttribArraysEnabled;
  35691. /** @hidden */
  35692. protected _cachedViewport: Nullable<IViewportLike>;
  35693. private _cachedVertexArrayObject;
  35694. /** @hidden */
  35695. protected _cachedVertexBuffers: any;
  35696. /** @hidden */
  35697. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  35698. /** @hidden */
  35699. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  35700. /** @hidden */
  35701. _currentRenderTarget: Nullable<InternalTexture>;
  35702. private _uintIndicesCurrentlySet;
  35703. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  35704. /** @hidden */
  35705. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  35706. /** @hidden */
  35707. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  35708. private _currentBufferPointers;
  35709. private _currentInstanceLocations;
  35710. private _currentInstanceBuffers;
  35711. private _textureUnits;
  35712. /** @hidden */
  35713. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  35714. /** @hidden */
  35715. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  35716. /** @hidden */
  35717. _boundRenderFunction: any;
  35718. private _vaoRecordInProgress;
  35719. private _mustWipeVertexAttributes;
  35720. private _emptyTexture;
  35721. private _emptyCubeTexture;
  35722. private _emptyTexture3D;
  35723. private _emptyTexture2DArray;
  35724. /** @hidden */
  35725. _frameHandler: number;
  35726. private _nextFreeTextureSlots;
  35727. private _maxSimultaneousTextures;
  35728. private _activeRequests;
  35729. /** @hidden */
  35730. _transformTextureUrl: Nullable<(url: string) => string>;
  35731. protected get _supportsHardwareTextureRescaling(): boolean;
  35732. private _framebufferDimensionsObject;
  35733. /**
  35734. * sets the object from which width and height will be taken from when getting render width and height
  35735. * Will fallback to the gl object
  35736. * @param dimensions the framebuffer width and height that will be used.
  35737. */
  35738. set framebufferDimensionsObject(dimensions: Nullable<{
  35739. framebufferWidth: number;
  35740. framebufferHeight: number;
  35741. }>);
  35742. /**
  35743. * Gets the current viewport
  35744. */
  35745. get currentViewport(): Nullable<IViewportLike>;
  35746. /**
  35747. * Gets the default empty texture
  35748. */
  35749. get emptyTexture(): InternalTexture;
  35750. /**
  35751. * Gets the default empty 3D texture
  35752. */
  35753. get emptyTexture3D(): InternalTexture;
  35754. /**
  35755. * Gets the default empty 2D array texture
  35756. */
  35757. get emptyTexture2DArray(): InternalTexture;
  35758. /**
  35759. * Gets the default empty cube texture
  35760. */
  35761. get emptyCubeTexture(): InternalTexture;
  35762. /**
  35763. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  35764. */
  35765. readonly premultipliedAlpha: boolean;
  35766. /**
  35767. * Observable event triggered before each texture is initialized
  35768. */
  35769. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  35770. /**
  35771. * Creates a new engine
  35772. * @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
  35773. * @param antialias defines enable antialiasing (default: false)
  35774. * @param options defines further options to be sent to the getContext() function
  35775. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  35776. */
  35777. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  35778. private _rebuildInternalTextures;
  35779. private _rebuildEffects;
  35780. /**
  35781. * Gets a boolean indicating if all created effects are ready
  35782. * @returns true if all effects are ready
  35783. */
  35784. areAllEffectsReady(): boolean;
  35785. protected _rebuildBuffers(): void;
  35786. protected _initGLContext(): void;
  35787. /**
  35788. * Gets version of the current webGL context
  35789. */
  35790. get webGLVersion(): number;
  35791. /**
  35792. * Gets a string idenfifying the name of the class
  35793. * @returns "Engine" string
  35794. */
  35795. getClassName(): string;
  35796. /**
  35797. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  35798. */
  35799. get isStencilEnable(): boolean;
  35800. /** @hidden */
  35801. _prepareWorkingCanvas(): void;
  35802. /**
  35803. * Reset the texture cache to empty state
  35804. */
  35805. resetTextureCache(): void;
  35806. /**
  35807. * Gets an object containing information about the current webGL context
  35808. * @returns an object containing the vender, the renderer and the version of the current webGL context
  35809. */
  35810. getGlInfo(): {
  35811. vendor: string;
  35812. renderer: string;
  35813. version: string;
  35814. };
  35815. /**
  35816. * Defines the hardware scaling level.
  35817. * By default the hardware scaling level is computed from the window device ratio.
  35818. * 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.
  35819. * @param level defines the level to use
  35820. */
  35821. setHardwareScalingLevel(level: number): void;
  35822. /**
  35823. * Gets the current hardware scaling level.
  35824. * By default the hardware scaling level is computed from the window device ratio.
  35825. * 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.
  35826. * @returns a number indicating the current hardware scaling level
  35827. */
  35828. getHardwareScalingLevel(): number;
  35829. /**
  35830. * Gets the list of loaded textures
  35831. * @returns an array containing all loaded textures
  35832. */
  35833. getLoadedTexturesCache(): InternalTexture[];
  35834. /**
  35835. * Gets the object containing all engine capabilities
  35836. * @returns the EngineCapabilities object
  35837. */
  35838. getCaps(): EngineCapabilities;
  35839. /**
  35840. * stop executing a render loop function and remove it from the execution array
  35841. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  35842. */
  35843. stopRenderLoop(renderFunction?: () => void): void;
  35844. /** @hidden */
  35845. _renderLoop(): void;
  35846. /**
  35847. * Gets the HTML canvas attached with the current webGL context
  35848. * @returns a HTML canvas
  35849. */
  35850. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  35851. /**
  35852. * Gets host window
  35853. * @returns the host window object
  35854. */
  35855. getHostWindow(): Nullable<Window>;
  35856. /**
  35857. * Gets the current render width
  35858. * @param useScreen defines if screen size must be used (or the current render target if any)
  35859. * @returns a number defining the current render width
  35860. */
  35861. getRenderWidth(useScreen?: boolean): number;
  35862. /**
  35863. * Gets the current render height
  35864. * @param useScreen defines if screen size must be used (or the current render target if any)
  35865. * @returns a number defining the current render height
  35866. */
  35867. getRenderHeight(useScreen?: boolean): number;
  35868. /**
  35869. * Can be used to override the current requestAnimationFrame requester.
  35870. * @hidden
  35871. */
  35872. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  35873. /**
  35874. * Register and execute a render loop. The engine can have more than one render function
  35875. * @param renderFunction defines the function to continuously execute
  35876. */
  35877. runRenderLoop(renderFunction: () => void): void;
  35878. /**
  35879. * Clear the current render buffer or the current render target (if any is set up)
  35880. * @param color defines the color to use
  35881. * @param backBuffer defines if the back buffer must be cleared
  35882. * @param depth defines if the depth buffer must be cleared
  35883. * @param stencil defines if the stencil buffer must be cleared
  35884. */
  35885. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  35886. private _viewportCached;
  35887. /** @hidden */
  35888. _viewport(x: number, y: number, width: number, height: number): void;
  35889. /**
  35890. * Set the WebGL's viewport
  35891. * @param viewport defines the viewport element to be used
  35892. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  35893. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  35894. */
  35895. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  35896. /**
  35897. * Begin a new frame
  35898. */
  35899. beginFrame(): void;
  35900. /**
  35901. * Enf the current frame
  35902. */
  35903. endFrame(): void;
  35904. /**
  35905. * Resize the view according to the canvas' size
  35906. */
  35907. resize(): void;
  35908. /**
  35909. * Force a specific size of the canvas
  35910. * @param width defines the new canvas' width
  35911. * @param height defines the new canvas' height
  35912. * @returns true if the size was changed
  35913. */
  35914. setSize(width: number, height: number): boolean;
  35915. /**
  35916. * Binds the frame buffer to the specified texture.
  35917. * @param texture The texture to render to or null for the default canvas
  35918. * @param faceIndex The face of the texture to render to in case of cube texture
  35919. * @param requiredWidth The width of the target to render to
  35920. * @param requiredHeight The height of the target to render to
  35921. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  35922. * @param lodLevel defines the lod level to bind to the frame buffer
  35923. * @param layer defines the 2d array index to bind to frame buffer to
  35924. */
  35925. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  35926. /** @hidden */
  35927. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  35928. /**
  35929. * Unbind the current render target texture from the webGL context
  35930. * @param texture defines the render target texture to unbind
  35931. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  35932. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  35933. */
  35934. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  35935. /**
  35936. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  35937. */
  35938. flushFramebuffer(): void;
  35939. /**
  35940. * Unbind the current render target and bind the default framebuffer
  35941. */
  35942. restoreDefaultFramebuffer(): void;
  35943. /** @hidden */
  35944. protected _resetVertexBufferBinding(): void;
  35945. /**
  35946. * Creates a vertex buffer
  35947. * @param data the data for the vertex buffer
  35948. * @returns the new WebGL static buffer
  35949. */
  35950. createVertexBuffer(data: DataArray): DataBuffer;
  35951. private _createVertexBuffer;
  35952. /**
  35953. * Creates a dynamic vertex buffer
  35954. * @param data the data for the dynamic vertex buffer
  35955. * @returns the new WebGL dynamic buffer
  35956. */
  35957. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  35958. protected _resetIndexBufferBinding(): void;
  35959. /**
  35960. * Creates a new index buffer
  35961. * @param indices defines the content of the index buffer
  35962. * @param updatable defines if the index buffer must be updatable
  35963. * @returns a new webGL buffer
  35964. */
  35965. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  35966. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  35967. /**
  35968. * Bind a webGL buffer to the webGL context
  35969. * @param buffer defines the buffer to bind
  35970. */
  35971. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  35972. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  35973. private bindBuffer;
  35974. /**
  35975. * update the bound buffer with the given data
  35976. * @param data defines the data to update
  35977. */
  35978. updateArrayBuffer(data: Float32Array): void;
  35979. private _vertexAttribPointer;
  35980. /** @hidden */
  35981. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  35982. private _bindVertexBuffersAttributes;
  35983. /**
  35984. * Records a vertex array object
  35985. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35986. * @param vertexBuffers defines the list of vertex buffers to store
  35987. * @param indexBuffer defines the index buffer to store
  35988. * @param effect defines the effect to store
  35989. * @returns the new vertex array object
  35990. */
  35991. recordVertexArrayObject(vertexBuffers: {
  35992. [key: string]: VertexBuffer;
  35993. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  35994. /**
  35995. * Bind a specific vertex array object
  35996. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  35997. * @param vertexArrayObject defines the vertex array object to bind
  35998. * @param indexBuffer defines the index buffer to bind
  35999. */
  36000. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  36001. /**
  36002. * Bind webGl buffers directly to the webGL context
  36003. * @param vertexBuffer defines the vertex buffer to bind
  36004. * @param indexBuffer defines the index buffer to bind
  36005. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  36006. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  36007. * @param effect defines the effect associated with the vertex buffer
  36008. */
  36009. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  36010. private _unbindVertexArrayObject;
  36011. /**
  36012. * Bind a list of vertex buffers to the webGL context
  36013. * @param vertexBuffers defines the list of vertex buffers to bind
  36014. * @param indexBuffer defines the index buffer to bind
  36015. * @param effect defines the effect associated with the vertex buffers
  36016. */
  36017. bindBuffers(vertexBuffers: {
  36018. [key: string]: Nullable<VertexBuffer>;
  36019. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  36020. /**
  36021. * Unbind all instance attributes
  36022. */
  36023. unbindInstanceAttributes(): void;
  36024. /**
  36025. * Release and free the memory of a vertex array object
  36026. * @param vao defines the vertex array object to delete
  36027. */
  36028. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  36029. /** @hidden */
  36030. _releaseBuffer(buffer: DataBuffer): boolean;
  36031. protected _deleteBuffer(buffer: DataBuffer): void;
  36032. /**
  36033. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  36034. * @param instancesBuffer defines the webGL buffer to update and bind
  36035. * @param data defines the data to store in the buffer
  36036. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  36037. */
  36038. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  36039. /**
  36040. * Bind the content of a webGL buffer used with instantiation
  36041. * @param instancesBuffer defines the webGL buffer to bind
  36042. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  36043. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  36044. */
  36045. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  36046. /**
  36047. * Disable the instance attribute corresponding to the name in parameter
  36048. * @param name defines the name of the attribute to disable
  36049. */
  36050. disableInstanceAttributeByName(name: string): void;
  36051. /**
  36052. * Disable the instance attribute corresponding to the location in parameter
  36053. * @param attributeLocation defines the attribute location of the attribute to disable
  36054. */
  36055. disableInstanceAttribute(attributeLocation: number): void;
  36056. /**
  36057. * Disable the attribute corresponding to the location in parameter
  36058. * @param attributeLocation defines the attribute location of the attribute to disable
  36059. */
  36060. disableAttributeByIndex(attributeLocation: number): void;
  36061. /**
  36062. * Send a draw order
  36063. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36064. * @param indexStart defines the starting index
  36065. * @param indexCount defines the number of index to draw
  36066. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36067. */
  36068. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  36069. /**
  36070. * Draw a list of points
  36071. * @param verticesStart defines the index of first vertex to draw
  36072. * @param verticesCount defines the count of vertices to draw
  36073. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36074. */
  36075. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36076. /**
  36077. * Draw a list of unindexed primitives
  36078. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  36079. * @param verticesStart defines the index of first vertex to draw
  36080. * @param verticesCount defines the count of vertices to draw
  36081. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36082. */
  36083. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36084. /**
  36085. * Draw a list of indexed primitives
  36086. * @param fillMode defines the primitive to use
  36087. * @param indexStart defines the starting index
  36088. * @param indexCount defines the number of index to draw
  36089. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36090. */
  36091. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  36092. /**
  36093. * Draw a list of unindexed primitives
  36094. * @param fillMode defines the primitive to use
  36095. * @param verticesStart defines the index of first vertex to draw
  36096. * @param verticesCount defines the count of vertices to draw
  36097. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  36098. */
  36099. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  36100. private _drawMode;
  36101. /** @hidden */
  36102. protected _reportDrawCall(): void;
  36103. /** @hidden */
  36104. _releaseEffect(effect: Effect): void;
  36105. /** @hidden */
  36106. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  36107. /**
  36108. * Create a new effect (used to store vertex/fragment shaders)
  36109. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  36110. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  36111. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  36112. * @param samplers defines an array of string used to represent textures
  36113. * @param defines defines the string containing the defines to use to compile the shaders
  36114. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  36115. * @param onCompiled defines a function to call when the effect creation is successful
  36116. * @param onError defines a function to call when the effect creation has failed
  36117. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  36118. * @returns the new Effect
  36119. */
  36120. 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;
  36121. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  36122. private _compileShader;
  36123. private _compileRawShader;
  36124. /** @hidden */
  36125. _getShaderSource(shader: WebGLShader): Nullable<string>;
  36126. /**
  36127. * Directly creates a webGL program
  36128. * @param pipelineContext defines the pipeline context to attach to
  36129. * @param vertexCode defines the vertex shader code to use
  36130. * @param fragmentCode defines the fragment shader code to use
  36131. * @param context defines the webGL context to use (if not set, the current one will be used)
  36132. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36133. * @returns the new webGL program
  36134. */
  36135. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36136. /**
  36137. * Creates a webGL program
  36138. * @param pipelineContext defines the pipeline context to attach to
  36139. * @param vertexCode defines the vertex shader code to use
  36140. * @param fragmentCode defines the fragment shader code to use
  36141. * @param defines defines the string containing the defines to use to compile the shaders
  36142. * @param context defines the webGL context to use (if not set, the current one will be used)
  36143. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  36144. * @returns the new webGL program
  36145. */
  36146. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36147. /**
  36148. * Creates a new pipeline context
  36149. * @returns the new pipeline
  36150. */
  36151. createPipelineContext(): IPipelineContext;
  36152. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  36153. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  36154. /** @hidden */
  36155. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  36156. /** @hidden */
  36157. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  36158. /** @hidden */
  36159. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  36160. /**
  36161. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  36162. * @param pipelineContext defines the pipeline context to use
  36163. * @param uniformsNames defines the list of uniform names
  36164. * @returns an array of webGL uniform locations
  36165. */
  36166. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  36167. /**
  36168. * Gets the lsit of active attributes for a given webGL program
  36169. * @param pipelineContext defines the pipeline context to use
  36170. * @param attributesNames defines the list of attribute names to get
  36171. * @returns an array of indices indicating the offset of each attribute
  36172. */
  36173. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  36174. /**
  36175. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  36176. * @param effect defines the effect to activate
  36177. */
  36178. enableEffect(effect: Nullable<Effect>): void;
  36179. /**
  36180. * Set the value of an uniform to a number (int)
  36181. * @param uniform defines the webGL uniform location where to store the value
  36182. * @param value defines the int number to store
  36183. */
  36184. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36185. /**
  36186. * Set the value of an uniform to an array of int32
  36187. * @param uniform defines the webGL uniform location where to store the value
  36188. * @param array defines the array of int32 to store
  36189. */
  36190. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36191. /**
  36192. * Set the value of an uniform to an array of int32 (stored as vec2)
  36193. * @param uniform defines the webGL uniform location where to store the value
  36194. * @param array defines the array of int32 to store
  36195. */
  36196. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36197. /**
  36198. * Set the value of an uniform to an array of int32 (stored as vec3)
  36199. * @param uniform defines the webGL uniform location where to store the value
  36200. * @param array defines the array of int32 to store
  36201. */
  36202. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36203. /**
  36204. * Set the value of an uniform to an array of int32 (stored as vec4)
  36205. * @param uniform defines the webGL uniform location where to store the value
  36206. * @param array defines the array of int32 to store
  36207. */
  36208. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  36209. /**
  36210. * Set the value of an uniform to an array of number
  36211. * @param uniform defines the webGL uniform location where to store the value
  36212. * @param array defines the array of number to store
  36213. */
  36214. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36215. /**
  36216. * Set the value of an uniform to an array of number (stored as vec2)
  36217. * @param uniform defines the webGL uniform location where to store the value
  36218. * @param array defines the array of number to store
  36219. */
  36220. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36221. /**
  36222. * Set the value of an uniform to an array of number (stored as vec3)
  36223. * @param uniform defines the webGL uniform location where to store the value
  36224. * @param array defines the array of number to store
  36225. */
  36226. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36227. /**
  36228. * Set the value of an uniform to an array of number (stored as vec4)
  36229. * @param uniform defines the webGL uniform location where to store the value
  36230. * @param array defines the array of number to store
  36231. */
  36232. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  36233. /**
  36234. * Set the value of an uniform to an array of float32 (stored as matrices)
  36235. * @param uniform defines the webGL uniform location where to store the value
  36236. * @param matrices defines the array of float32 to store
  36237. */
  36238. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  36239. /**
  36240. * Set the value of an uniform to a matrix (3x3)
  36241. * @param uniform defines the webGL uniform location where to store the value
  36242. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  36243. */
  36244. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36245. /**
  36246. * Set the value of an uniform to a matrix (2x2)
  36247. * @param uniform defines the webGL uniform location where to store the value
  36248. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  36249. */
  36250. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  36251. /**
  36252. * Set the value of an uniform to a number (float)
  36253. * @param uniform defines the webGL uniform location where to store the value
  36254. * @param value defines the float number to store
  36255. */
  36256. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  36257. /**
  36258. * Set the value of an uniform to a vec2
  36259. * @param uniform defines the webGL uniform location where to store the value
  36260. * @param x defines the 1st component of the value
  36261. * @param y defines the 2nd component of the value
  36262. */
  36263. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  36264. /**
  36265. * Set the value of an uniform to a vec3
  36266. * @param uniform defines the webGL uniform location where to store the value
  36267. * @param x defines the 1st component of the value
  36268. * @param y defines the 2nd component of the value
  36269. * @param z defines the 3rd component of the value
  36270. */
  36271. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  36272. /**
  36273. * Set the value of an uniform to a vec4
  36274. * @param uniform defines the webGL uniform location where to store the value
  36275. * @param x defines the 1st component of the value
  36276. * @param y defines the 2nd component of the value
  36277. * @param z defines the 3rd component of the value
  36278. * @param w defines the 4th component of the value
  36279. */
  36280. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  36281. /**
  36282. * Apply all cached states (depth, culling, stencil and alpha)
  36283. */
  36284. applyStates(): void;
  36285. /**
  36286. * Enable or disable color writing
  36287. * @param enable defines the state to set
  36288. */
  36289. setColorWrite(enable: boolean): void;
  36290. /**
  36291. * Gets a boolean indicating if color writing is enabled
  36292. * @returns the current color writing state
  36293. */
  36294. getColorWrite(): boolean;
  36295. /**
  36296. * Gets the depth culling state manager
  36297. */
  36298. get depthCullingState(): DepthCullingState;
  36299. /**
  36300. * Gets the alpha state manager
  36301. */
  36302. get alphaState(): AlphaState;
  36303. /**
  36304. * Gets the stencil state manager
  36305. */
  36306. get stencilState(): StencilState;
  36307. /**
  36308. * Clears the list of texture accessible through engine.
  36309. * This can help preventing texture load conflict due to name collision.
  36310. */
  36311. clearInternalTexturesCache(): void;
  36312. /**
  36313. * Force the entire cache to be cleared
  36314. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  36315. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  36316. */
  36317. wipeCaches(bruteForce?: boolean): void;
  36318. /** @hidden */
  36319. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  36320. min: number;
  36321. mag: number;
  36322. };
  36323. /** @hidden */
  36324. _createTexture(): WebGLTexture;
  36325. /**
  36326. * Usually called from Texture.ts.
  36327. * Passed information to create a WebGLTexture
  36328. * @param url defines a value which contains one of the following:
  36329. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  36330. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  36331. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  36332. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  36333. * @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)
  36334. * @param scene needed for loading to the correct scene
  36335. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  36336. * @param onLoad optional callback to be called upon successful completion
  36337. * @param onError optional callback to be called upon failure
  36338. * @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
  36339. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  36340. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  36341. * @param forcedExtension defines the extension to use to pick the right loader
  36342. * @param mimeType defines an optional mime type
  36343. * @returns a InternalTexture for assignment back into BABYLON.Texture
  36344. */
  36345. 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;
  36346. /**
  36347. * Loads an image as an HTMLImageElement.
  36348. * @param input url string, ArrayBuffer, or Blob to load
  36349. * @param onLoad callback called when the image successfully loads
  36350. * @param onError callback called when the image fails to load
  36351. * @param offlineProvider offline provider for caching
  36352. * @param mimeType optional mime type
  36353. * @returns the HTMLImageElement of the loaded image
  36354. * @hidden
  36355. */
  36356. 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>;
  36357. /**
  36358. * @hidden
  36359. */
  36360. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  36361. private _unpackFlipYCached;
  36362. /**
  36363. * In case you are sharing the context with other applications, it might
  36364. * be interested to not cache the unpack flip y state to ensure a consistent
  36365. * value would be set.
  36366. */
  36367. enableUnpackFlipYCached: boolean;
  36368. /** @hidden */
  36369. _unpackFlipY(value: boolean): void;
  36370. /** @hidden */
  36371. _getUnpackAlignement(): number;
  36372. private _getTextureTarget;
  36373. /**
  36374. * Update the sampling mode of a given texture
  36375. * @param samplingMode defines the required sampling mode
  36376. * @param texture defines the texture to update
  36377. * @param generateMipMaps defines whether to generate mipmaps for the texture
  36378. */
  36379. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  36380. /**
  36381. * Update the sampling mode of a given texture
  36382. * @param texture defines the texture to update
  36383. * @param wrapU defines the texture wrap mode of the u coordinates
  36384. * @param wrapV defines the texture wrap mode of the v coordinates
  36385. * @param wrapR defines the texture wrap mode of the r coordinates
  36386. */
  36387. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  36388. /** @hidden */
  36389. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  36390. width: number;
  36391. height: number;
  36392. layers?: number;
  36393. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  36394. /** @hidden */
  36395. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36396. /** @hidden */
  36397. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  36398. /**
  36399. * Update a portion of an internal texture
  36400. * @param texture defines the texture to update
  36401. * @param imageData defines the data to store into the texture
  36402. * @param xOffset defines the x coordinates of the update rectangle
  36403. * @param yOffset defines the y coordinates of the update rectangle
  36404. * @param width defines the width of the update rectangle
  36405. * @param height defines the height of the update rectangle
  36406. * @param faceIndex defines the face index if texture is a cube (0 by default)
  36407. * @param lod defines the lod level to update (0 by default)
  36408. */
  36409. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  36410. /** @hidden */
  36411. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  36412. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  36413. private _prepareWebGLTexture;
  36414. /** @hidden */
  36415. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  36416. private _getDepthStencilBuffer;
  36417. /** @hidden */
  36418. _releaseFramebufferObjects(texture: InternalTexture): void;
  36419. /** @hidden */
  36420. _releaseTexture(texture: InternalTexture): void;
  36421. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  36422. protected _setProgram(program: WebGLProgram): void;
  36423. protected _boundUniforms: {
  36424. [key: number]: WebGLUniformLocation;
  36425. };
  36426. /**
  36427. * Binds an effect to the webGL context
  36428. * @param effect defines the effect to bind
  36429. */
  36430. bindSamplers(effect: Effect): void;
  36431. private _activateCurrentTexture;
  36432. /** @hidden */
  36433. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  36434. /** @hidden */
  36435. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  36436. /**
  36437. * Unbind all textures from the webGL context
  36438. */
  36439. unbindAllTextures(): void;
  36440. /**
  36441. * Sets a texture to the according uniform.
  36442. * @param channel The texture channel
  36443. * @param uniform The uniform to set
  36444. * @param texture The texture to apply
  36445. */
  36446. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  36447. private _bindSamplerUniformToChannel;
  36448. private _getTextureWrapMode;
  36449. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  36450. /**
  36451. * Sets an array of texture to the webGL context
  36452. * @param channel defines the channel where the texture array must be set
  36453. * @param uniform defines the associated uniform location
  36454. * @param textures defines the array of textures to bind
  36455. */
  36456. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  36457. /** @hidden */
  36458. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  36459. private _setTextureParameterFloat;
  36460. private _setTextureParameterInteger;
  36461. /**
  36462. * Unbind all vertex attributes from the webGL context
  36463. */
  36464. unbindAllAttributes(): void;
  36465. /**
  36466. * 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
  36467. */
  36468. releaseEffects(): void;
  36469. /**
  36470. * Dispose and release all associated resources
  36471. */
  36472. dispose(): void;
  36473. /**
  36474. * Attach a new callback raised when context lost event is fired
  36475. * @param callback defines the callback to call
  36476. */
  36477. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36478. /**
  36479. * Attach a new callback raised when context restored event is fired
  36480. * @param callback defines the callback to call
  36481. */
  36482. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  36483. /**
  36484. * Get the current error code of the webGL context
  36485. * @returns the error code
  36486. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  36487. */
  36488. getError(): number;
  36489. private _canRenderToFloatFramebuffer;
  36490. private _canRenderToHalfFloatFramebuffer;
  36491. private _canRenderToFramebuffer;
  36492. /** @hidden */
  36493. _getWebGLTextureType(type: number): number;
  36494. /** @hidden */
  36495. _getInternalFormat(format: number): number;
  36496. /** @hidden */
  36497. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  36498. /** @hidden */
  36499. _getRGBAMultiSampleBufferFormat(type: number): number;
  36500. /** @hidden */
  36501. _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;
  36502. /**
  36503. * Loads a file from a url
  36504. * @param url url to load
  36505. * @param onSuccess callback called when the file successfully loads
  36506. * @param onProgress callback called while file is loading (if the server supports this mode)
  36507. * @param offlineProvider defines the offline provider for caching
  36508. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  36509. * @param onError callback called when the file fails to load
  36510. * @returns a file request object
  36511. * @hidden
  36512. */
  36513. 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;
  36514. /**
  36515. * Reads pixels from the current frame buffer. Please note that this function can be slow
  36516. * @param x defines the x coordinate of the rectangle where pixels must be read
  36517. * @param y defines the y coordinate of the rectangle where pixels must be read
  36518. * @param width defines the width of the rectangle where pixels must be read
  36519. * @param height defines the height of the rectangle where pixels must be read
  36520. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  36521. * @returns a Uint8Array containing RGBA colors
  36522. */
  36523. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  36524. private static _isSupported;
  36525. /**
  36526. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  36527. * @returns true if the engine can be created
  36528. * @ignorenaming
  36529. */
  36530. static isSupported(): boolean;
  36531. /**
  36532. * Find the next highest power of two.
  36533. * @param x Number to start search from.
  36534. * @return Next highest power of two.
  36535. */
  36536. static CeilingPOT(x: number): number;
  36537. /**
  36538. * Find the next lowest power of two.
  36539. * @param x Number to start search from.
  36540. * @return Next lowest power of two.
  36541. */
  36542. static FloorPOT(x: number): number;
  36543. /**
  36544. * Find the nearest power of two.
  36545. * @param x Number to start search from.
  36546. * @return Next nearest power of two.
  36547. */
  36548. static NearestPOT(x: number): number;
  36549. /**
  36550. * Get the closest exponent of two
  36551. * @param value defines the value to approximate
  36552. * @param max defines the maximum value to return
  36553. * @param mode defines how to define the closest value
  36554. * @returns closest exponent of two of the given value
  36555. */
  36556. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  36557. /**
  36558. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  36559. * @param func - the function to be called
  36560. * @param requester - the object that will request the next frame. Falls back to window.
  36561. * @returns frame number
  36562. */
  36563. static QueueNewFrame(func: () => void, requester?: any): number;
  36564. /**
  36565. * Gets host document
  36566. * @returns the host document object
  36567. */
  36568. getHostDocument(): Nullable<Document>;
  36569. }
  36570. }
  36571. declare module "babylonjs/Maths/sphericalPolynomial" {
  36572. import { Vector3 } from "babylonjs/Maths/math.vector";
  36573. import { Color3 } from "babylonjs/Maths/math.color";
  36574. /**
  36575. * Class representing spherical harmonics coefficients to the 3rd degree
  36576. */
  36577. export class SphericalHarmonics {
  36578. /**
  36579. * Defines whether or not the harmonics have been prescaled for rendering.
  36580. */
  36581. preScaled: boolean;
  36582. /**
  36583. * The l0,0 coefficients of the spherical harmonics
  36584. */
  36585. l00: Vector3;
  36586. /**
  36587. * The l1,-1 coefficients of the spherical harmonics
  36588. */
  36589. l1_1: Vector3;
  36590. /**
  36591. * The l1,0 coefficients of the spherical harmonics
  36592. */
  36593. l10: Vector3;
  36594. /**
  36595. * The l1,1 coefficients of the spherical harmonics
  36596. */
  36597. l11: Vector3;
  36598. /**
  36599. * The l2,-2 coefficients of the spherical harmonics
  36600. */
  36601. l2_2: Vector3;
  36602. /**
  36603. * The l2,-1 coefficients of the spherical harmonics
  36604. */
  36605. l2_1: Vector3;
  36606. /**
  36607. * The l2,0 coefficients of the spherical harmonics
  36608. */
  36609. l20: Vector3;
  36610. /**
  36611. * The l2,1 coefficients of the spherical harmonics
  36612. */
  36613. l21: Vector3;
  36614. /**
  36615. * The l2,2 coefficients of the spherical harmonics
  36616. */
  36617. l22: Vector3;
  36618. /**
  36619. * Adds a light to the spherical harmonics
  36620. * @param direction the direction of the light
  36621. * @param color the color of the light
  36622. * @param deltaSolidAngle the delta solid angle of the light
  36623. */
  36624. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  36625. /**
  36626. * Scales the spherical harmonics by the given amount
  36627. * @param scale the amount to scale
  36628. */
  36629. scaleInPlace(scale: number): void;
  36630. /**
  36631. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  36632. *
  36633. * ```
  36634. * E_lm = A_l * L_lm
  36635. * ```
  36636. *
  36637. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  36638. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  36639. * the scaling factors are given in equation 9.
  36640. */
  36641. convertIncidentRadianceToIrradiance(): void;
  36642. /**
  36643. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  36644. *
  36645. * ```
  36646. * L = (1/pi) * E * rho
  36647. * ```
  36648. *
  36649. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  36650. */
  36651. convertIrradianceToLambertianRadiance(): void;
  36652. /**
  36653. * Integrates the reconstruction coefficients directly in to the SH preventing further
  36654. * required operations at run time.
  36655. *
  36656. * This is simply done by scaling back the SH with Ylm constants parameter.
  36657. * The trigonometric part being applied by the shader at run time.
  36658. */
  36659. preScaleForRendering(): void;
  36660. /**
  36661. * Constructs a spherical harmonics from an array.
  36662. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  36663. * @returns the spherical harmonics
  36664. */
  36665. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  36666. /**
  36667. * Gets the spherical harmonics from polynomial
  36668. * @param polynomial the spherical polynomial
  36669. * @returns the spherical harmonics
  36670. */
  36671. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  36672. }
  36673. /**
  36674. * Class representing spherical polynomial coefficients to the 3rd degree
  36675. */
  36676. export class SphericalPolynomial {
  36677. private _harmonics;
  36678. /**
  36679. * The spherical harmonics used to create the polynomials.
  36680. */
  36681. get preScaledHarmonics(): SphericalHarmonics;
  36682. /**
  36683. * The x coefficients of the spherical polynomial
  36684. */
  36685. x: Vector3;
  36686. /**
  36687. * The y coefficients of the spherical polynomial
  36688. */
  36689. y: Vector3;
  36690. /**
  36691. * The z coefficients of the spherical polynomial
  36692. */
  36693. z: Vector3;
  36694. /**
  36695. * The xx coefficients of the spherical polynomial
  36696. */
  36697. xx: Vector3;
  36698. /**
  36699. * The yy coefficients of the spherical polynomial
  36700. */
  36701. yy: Vector3;
  36702. /**
  36703. * The zz coefficients of the spherical polynomial
  36704. */
  36705. zz: Vector3;
  36706. /**
  36707. * The xy coefficients of the spherical polynomial
  36708. */
  36709. xy: Vector3;
  36710. /**
  36711. * The yz coefficients of the spherical polynomial
  36712. */
  36713. yz: Vector3;
  36714. /**
  36715. * The zx coefficients of the spherical polynomial
  36716. */
  36717. zx: Vector3;
  36718. /**
  36719. * Adds an ambient color to the spherical polynomial
  36720. * @param color the color to add
  36721. */
  36722. addAmbient(color: Color3): void;
  36723. /**
  36724. * Scales the spherical polynomial by the given amount
  36725. * @param scale the amount to scale
  36726. */
  36727. scaleInPlace(scale: number): void;
  36728. /**
  36729. * Gets the spherical polynomial from harmonics
  36730. * @param harmonics the spherical harmonics
  36731. * @returns the spherical polynomial
  36732. */
  36733. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  36734. /**
  36735. * Constructs a spherical polynomial from an array.
  36736. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  36737. * @returns the spherical polynomial
  36738. */
  36739. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  36740. }
  36741. }
  36742. declare module "babylonjs/Materials/Textures/internalTexture" {
  36743. import { Observable } from "babylonjs/Misc/observable";
  36744. import { Nullable, int } from "babylonjs/types";
  36745. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  36746. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36747. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  36748. /**
  36749. * Defines the source of the internal texture
  36750. */
  36751. export enum InternalTextureSource {
  36752. /**
  36753. * The source of the texture data is unknown
  36754. */
  36755. Unknown = 0,
  36756. /**
  36757. * Texture data comes from an URL
  36758. */
  36759. Url = 1,
  36760. /**
  36761. * Texture data is only used for temporary storage
  36762. */
  36763. Temp = 2,
  36764. /**
  36765. * Texture data comes from raw data (ArrayBuffer)
  36766. */
  36767. Raw = 3,
  36768. /**
  36769. * Texture content is dynamic (video or dynamic texture)
  36770. */
  36771. Dynamic = 4,
  36772. /**
  36773. * Texture content is generated by rendering to it
  36774. */
  36775. RenderTarget = 5,
  36776. /**
  36777. * Texture content is part of a multi render target process
  36778. */
  36779. MultiRenderTarget = 6,
  36780. /**
  36781. * Texture data comes from a cube data file
  36782. */
  36783. Cube = 7,
  36784. /**
  36785. * Texture data comes from a raw cube data
  36786. */
  36787. CubeRaw = 8,
  36788. /**
  36789. * Texture data come from a prefiltered cube data file
  36790. */
  36791. CubePrefiltered = 9,
  36792. /**
  36793. * Texture content is raw 3D data
  36794. */
  36795. Raw3D = 10,
  36796. /**
  36797. * Texture content is raw 2D array data
  36798. */
  36799. Raw2DArray = 11,
  36800. /**
  36801. * Texture content is a depth texture
  36802. */
  36803. Depth = 12,
  36804. /**
  36805. * Texture data comes from a raw cube data encoded with RGBD
  36806. */
  36807. CubeRawRGBD = 13
  36808. }
  36809. /**
  36810. * Class used to store data associated with WebGL texture data for the engine
  36811. * This class should not be used directly
  36812. */
  36813. export class InternalTexture {
  36814. /** @hidden */
  36815. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  36816. /**
  36817. * Defines if the texture is ready
  36818. */
  36819. isReady: boolean;
  36820. /**
  36821. * Defines if the texture is a cube texture
  36822. */
  36823. isCube: boolean;
  36824. /**
  36825. * Defines if the texture contains 3D data
  36826. */
  36827. is3D: boolean;
  36828. /**
  36829. * Defines if the texture contains 2D array data
  36830. */
  36831. is2DArray: boolean;
  36832. /**
  36833. * Defines if the texture contains multiview data
  36834. */
  36835. isMultiview: boolean;
  36836. /**
  36837. * Gets the URL used to load this texture
  36838. */
  36839. url: string;
  36840. /**
  36841. * Gets the sampling mode of the texture
  36842. */
  36843. samplingMode: number;
  36844. /**
  36845. * Gets a boolean indicating if the texture needs mipmaps generation
  36846. */
  36847. generateMipMaps: boolean;
  36848. /**
  36849. * Gets the number of samples used by the texture (WebGL2+ only)
  36850. */
  36851. samples: number;
  36852. /**
  36853. * Gets the type of the texture (int, float...)
  36854. */
  36855. type: number;
  36856. /**
  36857. * Gets the format of the texture (RGB, RGBA...)
  36858. */
  36859. format: number;
  36860. /**
  36861. * Observable called when the texture is loaded
  36862. */
  36863. onLoadedObservable: Observable<InternalTexture>;
  36864. /**
  36865. * Gets the width of the texture
  36866. */
  36867. width: number;
  36868. /**
  36869. * Gets the height of the texture
  36870. */
  36871. height: number;
  36872. /**
  36873. * Gets the depth of the texture
  36874. */
  36875. depth: number;
  36876. /**
  36877. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  36878. */
  36879. baseWidth: number;
  36880. /**
  36881. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  36882. */
  36883. baseHeight: number;
  36884. /**
  36885. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  36886. */
  36887. baseDepth: number;
  36888. /**
  36889. * Gets a boolean indicating if the texture is inverted on Y axis
  36890. */
  36891. invertY: boolean;
  36892. /** @hidden */
  36893. _invertVScale: boolean;
  36894. /** @hidden */
  36895. _associatedChannel: number;
  36896. /** @hidden */
  36897. _source: InternalTextureSource;
  36898. /** @hidden */
  36899. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  36900. /** @hidden */
  36901. _bufferView: Nullable<ArrayBufferView>;
  36902. /** @hidden */
  36903. _bufferViewArray: Nullable<ArrayBufferView[]>;
  36904. /** @hidden */
  36905. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  36906. /** @hidden */
  36907. _size: number;
  36908. /** @hidden */
  36909. _extension: string;
  36910. /** @hidden */
  36911. _files: Nullable<string[]>;
  36912. /** @hidden */
  36913. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36914. /** @hidden */
  36915. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36916. /** @hidden */
  36917. _framebuffer: Nullable<WebGLFramebuffer>;
  36918. /** @hidden */
  36919. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  36920. /** @hidden */
  36921. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  36922. /** @hidden */
  36923. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  36924. /** @hidden */
  36925. _attachments: Nullable<number[]>;
  36926. /** @hidden */
  36927. _textureArray: Nullable<InternalTexture[]>;
  36928. /** @hidden */
  36929. _cachedCoordinatesMode: Nullable<number>;
  36930. /** @hidden */
  36931. _cachedWrapU: Nullable<number>;
  36932. /** @hidden */
  36933. _cachedWrapV: Nullable<number>;
  36934. /** @hidden */
  36935. _cachedWrapR: Nullable<number>;
  36936. /** @hidden */
  36937. _cachedAnisotropicFilteringLevel: Nullable<number>;
  36938. /** @hidden */
  36939. _isDisabled: boolean;
  36940. /** @hidden */
  36941. _compression: Nullable<string>;
  36942. /** @hidden */
  36943. _generateStencilBuffer: boolean;
  36944. /** @hidden */
  36945. _generateDepthBuffer: boolean;
  36946. /** @hidden */
  36947. _comparisonFunction: number;
  36948. /** @hidden */
  36949. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  36950. /** @hidden */
  36951. _lodGenerationScale: number;
  36952. /** @hidden */
  36953. _lodGenerationOffset: number;
  36954. /** @hidden */
  36955. _depthStencilTexture: Nullable<InternalTexture>;
  36956. /** @hidden */
  36957. _colorTextureArray: Nullable<WebGLTexture>;
  36958. /** @hidden */
  36959. _depthStencilTextureArray: Nullable<WebGLTexture>;
  36960. /** @hidden */
  36961. _lodTextureHigh: Nullable<BaseTexture>;
  36962. /** @hidden */
  36963. _lodTextureMid: Nullable<BaseTexture>;
  36964. /** @hidden */
  36965. _lodTextureLow: Nullable<BaseTexture>;
  36966. /** @hidden */
  36967. _isRGBD: boolean;
  36968. /** @hidden */
  36969. _linearSpecularLOD: boolean;
  36970. /** @hidden */
  36971. _irradianceTexture: Nullable<BaseTexture>;
  36972. /** @hidden */
  36973. _webGLTexture: Nullable<WebGLTexture>;
  36974. /** @hidden */
  36975. _references: number;
  36976. private _engine;
  36977. /**
  36978. * Gets the Engine the texture belongs to.
  36979. * @returns The babylon engine
  36980. */
  36981. getEngine(): ThinEngine;
  36982. /**
  36983. * Gets the data source type of the texture
  36984. */
  36985. get source(): InternalTextureSource;
  36986. /**
  36987. * Creates a new InternalTexture
  36988. * @param engine defines the engine to use
  36989. * @param source defines the type of data that will be used
  36990. * @param delayAllocation if the texture allocation should be delayed (default: false)
  36991. */
  36992. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  36993. /**
  36994. * Increments the number of references (ie. the number of Texture that point to it)
  36995. */
  36996. incrementReferences(): void;
  36997. /**
  36998. * Change the size of the texture (not the size of the content)
  36999. * @param width defines the new width
  37000. * @param height defines the new height
  37001. * @param depth defines the new depth (1 by default)
  37002. */
  37003. updateSize(width: int, height: int, depth?: int): void;
  37004. /** @hidden */
  37005. _rebuild(): void;
  37006. /** @hidden */
  37007. _swapAndDie(target: InternalTexture): void;
  37008. /**
  37009. * Dispose the current allocated resources
  37010. */
  37011. dispose(): void;
  37012. }
  37013. }
  37014. declare module "babylonjs/Audio/analyser" {
  37015. import { Scene } from "babylonjs/scene";
  37016. /**
  37017. * Class used to work with sound analyzer using fast fourier transform (FFT)
  37018. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37019. */
  37020. export class Analyser {
  37021. /**
  37022. * Gets or sets the smoothing
  37023. * @ignorenaming
  37024. */
  37025. SMOOTHING: number;
  37026. /**
  37027. * Gets or sets the FFT table size
  37028. * @ignorenaming
  37029. */
  37030. FFT_SIZE: number;
  37031. /**
  37032. * Gets or sets the bar graph amplitude
  37033. * @ignorenaming
  37034. */
  37035. BARGRAPHAMPLITUDE: number;
  37036. /**
  37037. * Gets or sets the position of the debug canvas
  37038. * @ignorenaming
  37039. */
  37040. DEBUGCANVASPOS: {
  37041. x: number;
  37042. y: number;
  37043. };
  37044. /**
  37045. * Gets or sets the debug canvas size
  37046. * @ignorenaming
  37047. */
  37048. DEBUGCANVASSIZE: {
  37049. width: number;
  37050. height: number;
  37051. };
  37052. private _byteFreqs;
  37053. private _byteTime;
  37054. private _floatFreqs;
  37055. private _webAudioAnalyser;
  37056. private _debugCanvas;
  37057. private _debugCanvasContext;
  37058. private _scene;
  37059. private _registerFunc;
  37060. private _audioEngine;
  37061. /**
  37062. * Creates a new analyser
  37063. * @param scene defines hosting scene
  37064. */
  37065. constructor(scene: Scene);
  37066. /**
  37067. * Get the number of data values you will have to play with for the visualization
  37068. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  37069. * @returns a number
  37070. */
  37071. getFrequencyBinCount(): number;
  37072. /**
  37073. * Gets the current frequency data as a byte array
  37074. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37075. * @returns a Uint8Array
  37076. */
  37077. getByteFrequencyData(): Uint8Array;
  37078. /**
  37079. * Gets the current waveform as a byte array
  37080. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  37081. * @returns a Uint8Array
  37082. */
  37083. getByteTimeDomainData(): Uint8Array;
  37084. /**
  37085. * Gets the current frequency data as a float array
  37086. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  37087. * @returns a Float32Array
  37088. */
  37089. getFloatFrequencyData(): Float32Array;
  37090. /**
  37091. * Renders the debug canvas
  37092. */
  37093. drawDebugCanvas(): void;
  37094. /**
  37095. * Stops rendering the debug canvas and removes it
  37096. */
  37097. stopDebugCanvas(): void;
  37098. /**
  37099. * Connects two audio nodes
  37100. * @param inputAudioNode defines first node to connect
  37101. * @param outputAudioNode defines second node to connect
  37102. */
  37103. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  37104. /**
  37105. * Releases all associated resources
  37106. */
  37107. dispose(): void;
  37108. }
  37109. }
  37110. declare module "babylonjs/Audio/audioEngine" {
  37111. import { IDisposable } from "babylonjs/scene";
  37112. import { Analyser } from "babylonjs/Audio/analyser";
  37113. import { Nullable } from "babylonjs/types";
  37114. import { Observable } from "babylonjs/Misc/observable";
  37115. /**
  37116. * This represents an audio engine and it is responsible
  37117. * to play, synchronize and analyse sounds throughout the application.
  37118. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37119. */
  37120. export interface IAudioEngine extends IDisposable {
  37121. /**
  37122. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37123. */
  37124. readonly canUseWebAudio: boolean;
  37125. /**
  37126. * Gets the current AudioContext if available.
  37127. */
  37128. readonly audioContext: Nullable<AudioContext>;
  37129. /**
  37130. * The master gain node defines the global audio volume of your audio engine.
  37131. */
  37132. readonly masterGain: GainNode;
  37133. /**
  37134. * Gets whether or not mp3 are supported by your browser.
  37135. */
  37136. readonly isMP3supported: boolean;
  37137. /**
  37138. * Gets whether or not ogg are supported by your browser.
  37139. */
  37140. readonly isOGGsupported: boolean;
  37141. /**
  37142. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37143. * @ignoreNaming
  37144. */
  37145. WarnedWebAudioUnsupported: boolean;
  37146. /**
  37147. * Defines if the audio engine relies on a custom unlocked button.
  37148. * In this case, the embedded button will not be displayed.
  37149. */
  37150. useCustomUnlockedButton: boolean;
  37151. /**
  37152. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  37153. */
  37154. readonly unlocked: boolean;
  37155. /**
  37156. * Event raised when audio has been unlocked on the browser.
  37157. */
  37158. onAudioUnlockedObservable: Observable<AudioEngine>;
  37159. /**
  37160. * Event raised when audio has been locked on the browser.
  37161. */
  37162. onAudioLockedObservable: Observable<AudioEngine>;
  37163. /**
  37164. * Flags the audio engine in Locked state.
  37165. * This happens due to new browser policies preventing audio to autoplay.
  37166. */
  37167. lock(): void;
  37168. /**
  37169. * Unlocks the audio engine once a user action has been done on the dom.
  37170. * This is helpful to resume play once browser policies have been satisfied.
  37171. */
  37172. unlock(): void;
  37173. /**
  37174. * Gets the global volume sets on the master gain.
  37175. * @returns the global volume if set or -1 otherwise
  37176. */
  37177. getGlobalVolume(): number;
  37178. /**
  37179. * Sets the global volume of your experience (sets on the master gain).
  37180. * @param newVolume Defines the new global volume of the application
  37181. */
  37182. setGlobalVolume(newVolume: number): void;
  37183. /**
  37184. * Connect the audio engine to an audio analyser allowing some amazing
  37185. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37186. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37187. * @param analyser The analyser to connect to the engine
  37188. */
  37189. connectToAnalyser(analyser: Analyser): void;
  37190. }
  37191. /**
  37192. * This represents the default audio engine used in babylon.
  37193. * It is responsible to play, synchronize and analyse sounds throughout the application.
  37194. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37195. */
  37196. export class AudioEngine implements IAudioEngine {
  37197. private _audioContext;
  37198. private _audioContextInitialized;
  37199. private _muteButton;
  37200. private _hostElement;
  37201. /**
  37202. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  37203. */
  37204. canUseWebAudio: boolean;
  37205. /**
  37206. * The master gain node defines the global audio volume of your audio engine.
  37207. */
  37208. masterGain: GainNode;
  37209. /**
  37210. * Defines if Babylon should emit a warning if WebAudio is not supported.
  37211. * @ignoreNaming
  37212. */
  37213. WarnedWebAudioUnsupported: boolean;
  37214. /**
  37215. * Gets whether or not mp3 are supported by your browser.
  37216. */
  37217. isMP3supported: boolean;
  37218. /**
  37219. * Gets whether or not ogg are supported by your browser.
  37220. */
  37221. isOGGsupported: boolean;
  37222. /**
  37223. * Gets whether audio has been unlocked on the device.
  37224. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  37225. * a user interaction has happened.
  37226. */
  37227. unlocked: boolean;
  37228. /**
  37229. * Defines if the audio engine relies on a custom unlocked button.
  37230. * In this case, the embedded button will not be displayed.
  37231. */
  37232. useCustomUnlockedButton: boolean;
  37233. /**
  37234. * Event raised when audio has been unlocked on the browser.
  37235. */
  37236. onAudioUnlockedObservable: Observable<AudioEngine>;
  37237. /**
  37238. * Event raised when audio has been locked on the browser.
  37239. */
  37240. onAudioLockedObservable: Observable<AudioEngine>;
  37241. /**
  37242. * Gets the current AudioContext if available.
  37243. */
  37244. get audioContext(): Nullable<AudioContext>;
  37245. private _connectedAnalyser;
  37246. /**
  37247. * Instantiates a new audio engine.
  37248. *
  37249. * There should be only one per page as some browsers restrict the number
  37250. * of audio contexts you can create.
  37251. * @param hostElement defines the host element where to display the mute icon if necessary
  37252. */
  37253. constructor(hostElement?: Nullable<HTMLElement>);
  37254. /**
  37255. * Flags the audio engine in Locked state.
  37256. * This happens due to new browser policies preventing audio to autoplay.
  37257. */
  37258. lock(): void;
  37259. /**
  37260. * Unlocks the audio engine once a user action has been done on the dom.
  37261. * This is helpful to resume play once browser policies have been satisfied.
  37262. */
  37263. unlock(): void;
  37264. private _resumeAudioContext;
  37265. private _initializeAudioContext;
  37266. private _tryToRun;
  37267. private _triggerRunningState;
  37268. private _triggerSuspendedState;
  37269. private _displayMuteButton;
  37270. private _moveButtonToTopLeft;
  37271. private _onResize;
  37272. private _hideMuteButton;
  37273. /**
  37274. * Destroy and release the resources associated with the audio ccontext.
  37275. */
  37276. dispose(): void;
  37277. /**
  37278. * Gets the global volume sets on the master gain.
  37279. * @returns the global volume if set or -1 otherwise
  37280. */
  37281. getGlobalVolume(): number;
  37282. /**
  37283. * Sets the global volume of your experience (sets on the master gain).
  37284. * @param newVolume Defines the new global volume of the application
  37285. */
  37286. setGlobalVolume(newVolume: number): void;
  37287. /**
  37288. * Connect the audio engine to an audio analyser allowing some amazing
  37289. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  37290. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  37291. * @param analyser The analyser to connect to the engine
  37292. */
  37293. connectToAnalyser(analyser: Analyser): void;
  37294. }
  37295. }
  37296. declare module "babylonjs/Loading/loadingScreen" {
  37297. /**
  37298. * Interface used to present a loading screen while loading a scene
  37299. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37300. */
  37301. export interface ILoadingScreen {
  37302. /**
  37303. * Function called to display the loading screen
  37304. */
  37305. displayLoadingUI: () => void;
  37306. /**
  37307. * Function called to hide the loading screen
  37308. */
  37309. hideLoadingUI: () => void;
  37310. /**
  37311. * Gets or sets the color to use for the background
  37312. */
  37313. loadingUIBackgroundColor: string;
  37314. /**
  37315. * Gets or sets the text to display while loading
  37316. */
  37317. loadingUIText: string;
  37318. }
  37319. /**
  37320. * Class used for the default loading screen
  37321. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  37322. */
  37323. export class DefaultLoadingScreen implements ILoadingScreen {
  37324. private _renderingCanvas;
  37325. private _loadingText;
  37326. private _loadingDivBackgroundColor;
  37327. private _loadingDiv;
  37328. private _loadingTextDiv;
  37329. /** Gets or sets the logo url to use for the default loading screen */
  37330. static DefaultLogoUrl: string;
  37331. /** Gets or sets the spinner url to use for the default loading screen */
  37332. static DefaultSpinnerUrl: string;
  37333. /**
  37334. * Creates a new default loading screen
  37335. * @param _renderingCanvas defines the canvas used to render the scene
  37336. * @param _loadingText defines the default text to display
  37337. * @param _loadingDivBackgroundColor defines the default background color
  37338. */
  37339. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  37340. /**
  37341. * Function called to display the loading screen
  37342. */
  37343. displayLoadingUI(): void;
  37344. /**
  37345. * Function called to hide the loading screen
  37346. */
  37347. hideLoadingUI(): void;
  37348. /**
  37349. * Gets or sets the text to display while loading
  37350. */
  37351. set loadingUIText(text: string);
  37352. get loadingUIText(): string;
  37353. /**
  37354. * Gets or sets the color to use for the background
  37355. */
  37356. get loadingUIBackgroundColor(): string;
  37357. set loadingUIBackgroundColor(color: string);
  37358. private _resizeLoadingUI;
  37359. }
  37360. }
  37361. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  37362. /**
  37363. * Interface for any object that can request an animation frame
  37364. */
  37365. export interface ICustomAnimationFrameRequester {
  37366. /**
  37367. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  37368. */
  37369. renderFunction?: Function;
  37370. /**
  37371. * Called to request the next frame to render to
  37372. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  37373. */
  37374. requestAnimationFrame: Function;
  37375. /**
  37376. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  37377. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  37378. */
  37379. requestID?: number;
  37380. }
  37381. }
  37382. declare module "babylonjs/Misc/performanceMonitor" {
  37383. /**
  37384. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  37385. */
  37386. export class PerformanceMonitor {
  37387. private _enabled;
  37388. private _rollingFrameTime;
  37389. private _lastFrameTimeMs;
  37390. /**
  37391. * constructor
  37392. * @param frameSampleSize The number of samples required to saturate the sliding window
  37393. */
  37394. constructor(frameSampleSize?: number);
  37395. /**
  37396. * Samples current frame
  37397. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  37398. */
  37399. sampleFrame(timeMs?: number): void;
  37400. /**
  37401. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37402. */
  37403. get averageFrameTime(): number;
  37404. /**
  37405. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  37406. */
  37407. get averageFrameTimeVariance(): number;
  37408. /**
  37409. * Returns the frame time of the most recent frame
  37410. */
  37411. get instantaneousFrameTime(): number;
  37412. /**
  37413. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  37414. */
  37415. get averageFPS(): number;
  37416. /**
  37417. * Returns the average framerate in frames per second using the most recent frame time
  37418. */
  37419. get instantaneousFPS(): number;
  37420. /**
  37421. * Returns true if enough samples have been taken to completely fill the sliding window
  37422. */
  37423. get isSaturated(): boolean;
  37424. /**
  37425. * Enables contributions to the sliding window sample set
  37426. */
  37427. enable(): void;
  37428. /**
  37429. * Disables contributions to the sliding window sample set
  37430. * Samples will not be interpolated over the disabled period
  37431. */
  37432. disable(): void;
  37433. /**
  37434. * Returns true if sampling is enabled
  37435. */
  37436. get isEnabled(): boolean;
  37437. /**
  37438. * Resets performance monitor
  37439. */
  37440. reset(): void;
  37441. }
  37442. /**
  37443. * RollingAverage
  37444. *
  37445. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  37446. */
  37447. export class RollingAverage {
  37448. /**
  37449. * Current average
  37450. */
  37451. average: number;
  37452. /**
  37453. * Current variance
  37454. */
  37455. variance: number;
  37456. protected _samples: Array<number>;
  37457. protected _sampleCount: number;
  37458. protected _pos: number;
  37459. protected _m2: number;
  37460. /**
  37461. * constructor
  37462. * @param length The number of samples required to saturate the sliding window
  37463. */
  37464. constructor(length: number);
  37465. /**
  37466. * Adds a sample to the sample set
  37467. * @param v The sample value
  37468. */
  37469. add(v: number): void;
  37470. /**
  37471. * Returns previously added values or null if outside of history or outside the sliding window domain
  37472. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  37473. * @return Value previously recorded with add() or null if outside of range
  37474. */
  37475. history(i: number): number;
  37476. /**
  37477. * Returns true if enough samples have been taken to completely fill the sliding window
  37478. * @return true if sample-set saturated
  37479. */
  37480. isSaturated(): boolean;
  37481. /**
  37482. * Resets the rolling average (equivalent to 0 samples taken so far)
  37483. */
  37484. reset(): void;
  37485. /**
  37486. * Wraps a value around the sample range boundaries
  37487. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  37488. * @return Wrapped position in sample range
  37489. */
  37490. protected _wrapPosition(i: number): number;
  37491. }
  37492. }
  37493. declare module "babylonjs/Misc/perfCounter" {
  37494. /**
  37495. * This class is used to track a performance counter which is number based.
  37496. * The user has access to many properties which give statistics of different nature.
  37497. *
  37498. * The implementer can track two kinds of Performance Counter: time and count.
  37499. * 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.
  37500. * 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.
  37501. */
  37502. export class PerfCounter {
  37503. /**
  37504. * Gets or sets a global boolean to turn on and off all the counters
  37505. */
  37506. static Enabled: boolean;
  37507. /**
  37508. * Returns the smallest value ever
  37509. */
  37510. get min(): number;
  37511. /**
  37512. * Returns the biggest value ever
  37513. */
  37514. get max(): number;
  37515. /**
  37516. * Returns the average value since the performance counter is running
  37517. */
  37518. get average(): number;
  37519. /**
  37520. * Returns the average value of the last second the counter was monitored
  37521. */
  37522. get lastSecAverage(): number;
  37523. /**
  37524. * Returns the current value
  37525. */
  37526. get current(): number;
  37527. /**
  37528. * Gets the accumulated total
  37529. */
  37530. get total(): number;
  37531. /**
  37532. * Gets the total value count
  37533. */
  37534. get count(): number;
  37535. /**
  37536. * Creates a new counter
  37537. */
  37538. constructor();
  37539. /**
  37540. * Call this method to start monitoring a new frame.
  37541. * 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.
  37542. */
  37543. fetchNewFrame(): void;
  37544. /**
  37545. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  37546. * @param newCount the count value to add to the monitored count
  37547. * @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.
  37548. */
  37549. addCount(newCount: number, fetchResult: boolean): void;
  37550. /**
  37551. * Start monitoring this performance counter
  37552. */
  37553. beginMonitoring(): void;
  37554. /**
  37555. * Compute the time lapsed since the previous beginMonitoring() call.
  37556. * @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
  37557. */
  37558. endMonitoring(newFrame?: boolean): void;
  37559. private _fetchResult;
  37560. private _startMonitoringTime;
  37561. private _min;
  37562. private _max;
  37563. private _average;
  37564. private _current;
  37565. private _totalValueCount;
  37566. private _totalAccumulated;
  37567. private _lastSecAverage;
  37568. private _lastSecAccumulated;
  37569. private _lastSecTime;
  37570. private _lastSecValueCount;
  37571. }
  37572. }
  37573. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  37574. module "babylonjs/Engines/thinEngine" {
  37575. interface ThinEngine {
  37576. /**
  37577. * Sets alpha constants used by some alpha blending modes
  37578. * @param r defines the red component
  37579. * @param g defines the green component
  37580. * @param b defines the blue component
  37581. * @param a defines the alpha component
  37582. */
  37583. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  37584. /**
  37585. * Sets the current alpha mode
  37586. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  37587. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  37588. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37589. */
  37590. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  37591. /**
  37592. * Gets the current alpha mode
  37593. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  37594. * @returns the current alpha mode
  37595. */
  37596. getAlphaMode(): number;
  37597. /**
  37598. * Sets the current alpha equation
  37599. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  37600. */
  37601. setAlphaEquation(equation: number): void;
  37602. /**
  37603. * Gets the current alpha equation.
  37604. * @returns the current alpha equation
  37605. */
  37606. getAlphaEquation(): number;
  37607. }
  37608. }
  37609. }
  37610. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  37611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37612. import { Nullable } from "babylonjs/types";
  37613. module "babylonjs/Engines/thinEngine" {
  37614. interface ThinEngine {
  37615. /** @hidden */
  37616. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  37617. }
  37618. }
  37619. }
  37620. declare module "babylonjs/Engines/engine" {
  37621. import { Observable } from "babylonjs/Misc/observable";
  37622. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  37623. import { Scene } from "babylonjs/scene";
  37624. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  37625. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  37626. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  37627. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  37628. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  37629. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  37630. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  37631. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  37632. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  37633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  37634. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  37635. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  37636. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  37637. import "babylonjs/Engines/Extensions/engine.alpha";
  37638. import "babylonjs/Engines/Extensions/engine.readTexture";
  37639. import { Material } from "babylonjs/Materials/material";
  37640. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  37641. /**
  37642. * Defines the interface used by display changed events
  37643. */
  37644. export interface IDisplayChangedEventArgs {
  37645. /** Gets the vrDisplay object (if any) */
  37646. vrDisplay: Nullable<any>;
  37647. /** Gets a boolean indicating if webVR is supported */
  37648. vrSupported: boolean;
  37649. }
  37650. /**
  37651. * Defines the interface used by objects containing a viewport (like a camera)
  37652. */
  37653. interface IViewportOwnerLike {
  37654. /**
  37655. * Gets or sets the viewport
  37656. */
  37657. viewport: IViewportLike;
  37658. }
  37659. /**
  37660. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  37661. */
  37662. export class Engine extends ThinEngine {
  37663. /** Defines that alpha blending is disabled */
  37664. static readonly ALPHA_DISABLE: number;
  37665. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  37666. static readonly ALPHA_ADD: number;
  37667. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  37668. static readonly ALPHA_COMBINE: number;
  37669. /** Defines that alpha blending to DEST - SRC * DEST */
  37670. static readonly ALPHA_SUBTRACT: number;
  37671. /** Defines that alpha blending to SRC * DEST */
  37672. static readonly ALPHA_MULTIPLY: number;
  37673. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  37674. static readonly ALPHA_MAXIMIZED: number;
  37675. /** Defines that alpha blending to SRC + DEST */
  37676. static readonly ALPHA_ONEONE: number;
  37677. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  37678. static readonly ALPHA_PREMULTIPLIED: number;
  37679. /**
  37680. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  37681. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  37682. */
  37683. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  37684. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  37685. static readonly ALPHA_INTERPOLATE: number;
  37686. /**
  37687. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  37688. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  37689. */
  37690. static readonly ALPHA_SCREENMODE: number;
  37691. /** Defines that the ressource is not delayed*/
  37692. static readonly DELAYLOADSTATE_NONE: number;
  37693. /** Defines that the ressource was successfully delay loaded */
  37694. static readonly DELAYLOADSTATE_LOADED: number;
  37695. /** Defines that the ressource is currently delay loading */
  37696. static readonly DELAYLOADSTATE_LOADING: number;
  37697. /** Defines that the ressource is delayed and has not started loading */
  37698. static readonly DELAYLOADSTATE_NOTLOADED: number;
  37699. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  37700. static readonly NEVER: number;
  37701. /** 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 */
  37702. static readonly ALWAYS: number;
  37703. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  37704. static readonly LESS: number;
  37705. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  37706. static readonly EQUAL: number;
  37707. /** 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 */
  37708. static readonly LEQUAL: number;
  37709. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  37710. static readonly GREATER: number;
  37711. /** 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 */
  37712. static readonly GEQUAL: number;
  37713. /** 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 */
  37714. static readonly NOTEQUAL: number;
  37715. /** Passed to stencilOperation to specify that stencil value must be kept */
  37716. static readonly KEEP: number;
  37717. /** Passed to stencilOperation to specify that stencil value must be replaced */
  37718. static readonly REPLACE: number;
  37719. /** Passed to stencilOperation to specify that stencil value must be incremented */
  37720. static readonly INCR: number;
  37721. /** Passed to stencilOperation to specify that stencil value must be decremented */
  37722. static readonly DECR: number;
  37723. /** Passed to stencilOperation to specify that stencil value must be inverted */
  37724. static readonly INVERT: number;
  37725. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  37726. static readonly INCR_WRAP: number;
  37727. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  37728. static readonly DECR_WRAP: number;
  37729. /** Texture is not repeating outside of 0..1 UVs */
  37730. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  37731. /** Texture is repeating outside of 0..1 UVs */
  37732. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  37733. /** Texture is repeating and mirrored */
  37734. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  37735. /** ALPHA */
  37736. static readonly TEXTUREFORMAT_ALPHA: number;
  37737. /** LUMINANCE */
  37738. static readonly TEXTUREFORMAT_LUMINANCE: number;
  37739. /** LUMINANCE_ALPHA */
  37740. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  37741. /** RGB */
  37742. static readonly TEXTUREFORMAT_RGB: number;
  37743. /** RGBA */
  37744. static readonly TEXTUREFORMAT_RGBA: number;
  37745. /** RED */
  37746. static readonly TEXTUREFORMAT_RED: number;
  37747. /** RED (2nd reference) */
  37748. static readonly TEXTUREFORMAT_R: number;
  37749. /** RG */
  37750. static readonly TEXTUREFORMAT_RG: number;
  37751. /** RED_INTEGER */
  37752. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  37753. /** RED_INTEGER (2nd reference) */
  37754. static readonly TEXTUREFORMAT_R_INTEGER: number;
  37755. /** RG_INTEGER */
  37756. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  37757. /** RGB_INTEGER */
  37758. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  37759. /** RGBA_INTEGER */
  37760. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  37761. /** UNSIGNED_BYTE */
  37762. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  37763. /** UNSIGNED_BYTE (2nd reference) */
  37764. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  37765. /** FLOAT */
  37766. static readonly TEXTURETYPE_FLOAT: number;
  37767. /** HALF_FLOAT */
  37768. static readonly TEXTURETYPE_HALF_FLOAT: number;
  37769. /** BYTE */
  37770. static readonly TEXTURETYPE_BYTE: number;
  37771. /** SHORT */
  37772. static readonly TEXTURETYPE_SHORT: number;
  37773. /** UNSIGNED_SHORT */
  37774. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  37775. /** INT */
  37776. static readonly TEXTURETYPE_INT: number;
  37777. /** UNSIGNED_INT */
  37778. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  37779. /** UNSIGNED_SHORT_4_4_4_4 */
  37780. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  37781. /** UNSIGNED_SHORT_5_5_5_1 */
  37782. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  37783. /** UNSIGNED_SHORT_5_6_5 */
  37784. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  37785. /** UNSIGNED_INT_2_10_10_10_REV */
  37786. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  37787. /** UNSIGNED_INT_24_8 */
  37788. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  37789. /** UNSIGNED_INT_10F_11F_11F_REV */
  37790. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  37791. /** UNSIGNED_INT_5_9_9_9_REV */
  37792. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  37793. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  37794. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  37795. /** nearest is mag = nearest and min = nearest and mip = linear */
  37796. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  37797. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37798. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  37799. /** Trilinear is mag = linear and min = linear and mip = linear */
  37800. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  37801. /** nearest is mag = nearest and min = nearest and mip = linear */
  37802. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  37803. /** Bilinear is mag = linear and min = linear and mip = nearest */
  37804. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  37805. /** Trilinear is mag = linear and min = linear and mip = linear */
  37806. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  37807. /** mag = nearest and min = nearest and mip = nearest */
  37808. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  37809. /** mag = nearest and min = linear and mip = nearest */
  37810. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  37811. /** mag = nearest and min = linear and mip = linear */
  37812. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  37813. /** mag = nearest and min = linear and mip = none */
  37814. static readonly TEXTURE_NEAREST_LINEAR: number;
  37815. /** mag = nearest and min = nearest and mip = none */
  37816. static readonly TEXTURE_NEAREST_NEAREST: number;
  37817. /** mag = linear and min = nearest and mip = nearest */
  37818. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  37819. /** mag = linear and min = nearest and mip = linear */
  37820. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  37821. /** mag = linear and min = linear and mip = none */
  37822. static readonly TEXTURE_LINEAR_LINEAR: number;
  37823. /** mag = linear and min = nearest and mip = none */
  37824. static readonly TEXTURE_LINEAR_NEAREST: number;
  37825. /** Explicit coordinates mode */
  37826. static readonly TEXTURE_EXPLICIT_MODE: number;
  37827. /** Spherical coordinates mode */
  37828. static readonly TEXTURE_SPHERICAL_MODE: number;
  37829. /** Planar coordinates mode */
  37830. static readonly TEXTURE_PLANAR_MODE: number;
  37831. /** Cubic coordinates mode */
  37832. static readonly TEXTURE_CUBIC_MODE: number;
  37833. /** Projection coordinates mode */
  37834. static readonly TEXTURE_PROJECTION_MODE: number;
  37835. /** Skybox coordinates mode */
  37836. static readonly TEXTURE_SKYBOX_MODE: number;
  37837. /** Inverse Cubic coordinates mode */
  37838. static readonly TEXTURE_INVCUBIC_MODE: number;
  37839. /** Equirectangular coordinates mode */
  37840. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  37841. /** Equirectangular Fixed coordinates mode */
  37842. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  37843. /** Equirectangular Fixed Mirrored coordinates mode */
  37844. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  37845. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  37846. static readonly SCALEMODE_FLOOR: number;
  37847. /** Defines that texture rescaling will look for the nearest power of 2 size */
  37848. static readonly SCALEMODE_NEAREST: number;
  37849. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  37850. static readonly SCALEMODE_CEILING: number;
  37851. /**
  37852. * Returns the current npm package of the sdk
  37853. */
  37854. static get NpmPackage(): string;
  37855. /**
  37856. * Returns the current version of the framework
  37857. */
  37858. static get Version(): string;
  37859. /** Gets the list of created engines */
  37860. static get Instances(): Engine[];
  37861. /**
  37862. * Gets the latest created engine
  37863. */
  37864. static get LastCreatedEngine(): Nullable<Engine>;
  37865. /**
  37866. * Gets the latest created scene
  37867. */
  37868. static get LastCreatedScene(): Nullable<Scene>;
  37869. /**
  37870. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  37871. * @param flag defines which part of the materials must be marked as dirty
  37872. * @param predicate defines a predicate used to filter which materials should be affected
  37873. */
  37874. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37875. /**
  37876. * Method called to create the default loading screen.
  37877. * This can be overriden in your own app.
  37878. * @param canvas The rendering canvas element
  37879. * @returns The loading screen
  37880. */
  37881. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  37882. /**
  37883. * Method called to create the default rescale post process on each engine.
  37884. */
  37885. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  37886. /**
  37887. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  37888. **/
  37889. enableOfflineSupport: boolean;
  37890. /**
  37891. * 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)
  37892. **/
  37893. disableManifestCheck: boolean;
  37894. /**
  37895. * Gets the list of created scenes
  37896. */
  37897. scenes: Scene[];
  37898. /**
  37899. * Event raised when a new scene is created
  37900. */
  37901. onNewSceneAddedObservable: Observable<Scene>;
  37902. /**
  37903. * Gets the list of created postprocesses
  37904. */
  37905. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  37906. /**
  37907. * Gets a boolean indicating if the pointer is currently locked
  37908. */
  37909. isPointerLock: boolean;
  37910. /**
  37911. * Observable event triggered each time the rendering canvas is resized
  37912. */
  37913. onResizeObservable: Observable<Engine>;
  37914. /**
  37915. * Observable event triggered each time the canvas loses focus
  37916. */
  37917. onCanvasBlurObservable: Observable<Engine>;
  37918. /**
  37919. * Observable event triggered each time the canvas gains focus
  37920. */
  37921. onCanvasFocusObservable: Observable<Engine>;
  37922. /**
  37923. * Observable event triggered each time the canvas receives pointerout event
  37924. */
  37925. onCanvasPointerOutObservable: Observable<PointerEvent>;
  37926. /**
  37927. * Observable raised when the engine begins a new frame
  37928. */
  37929. onBeginFrameObservable: Observable<Engine>;
  37930. /**
  37931. * If set, will be used to request the next animation frame for the render loop
  37932. */
  37933. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  37934. /**
  37935. * Observable raised when the engine ends the current frame
  37936. */
  37937. onEndFrameObservable: Observable<Engine>;
  37938. /**
  37939. * Observable raised when the engine is about to compile a shader
  37940. */
  37941. onBeforeShaderCompilationObservable: Observable<Engine>;
  37942. /**
  37943. * Observable raised when the engine has jsut compiled a shader
  37944. */
  37945. onAfterShaderCompilationObservable: Observable<Engine>;
  37946. /**
  37947. * Gets the audio engine
  37948. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  37949. * @ignorenaming
  37950. */
  37951. static audioEngine: IAudioEngine;
  37952. /**
  37953. * Default AudioEngine factory responsible of creating the Audio Engine.
  37954. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  37955. */
  37956. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  37957. /**
  37958. * Default offline support factory responsible of creating a tool used to store data locally.
  37959. * By default, this will create a Database object if the workload has been embedded.
  37960. */
  37961. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  37962. private _loadingScreen;
  37963. private _pointerLockRequested;
  37964. private _rescalePostProcess;
  37965. private _deterministicLockstep;
  37966. private _lockstepMaxSteps;
  37967. private _timeStep;
  37968. protected get _supportsHardwareTextureRescaling(): boolean;
  37969. private _fps;
  37970. private _deltaTime;
  37971. /** @hidden */
  37972. _drawCalls: PerfCounter;
  37973. /** 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 */
  37974. canvasTabIndex: number;
  37975. /**
  37976. * Turn this value on if you want to pause FPS computation when in background
  37977. */
  37978. disablePerformanceMonitorInBackground: boolean;
  37979. private _performanceMonitor;
  37980. /**
  37981. * Gets the performance monitor attached to this engine
  37982. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  37983. */
  37984. get performanceMonitor(): PerformanceMonitor;
  37985. private _onFocus;
  37986. private _onBlur;
  37987. private _onCanvasPointerOut;
  37988. private _onCanvasBlur;
  37989. private _onCanvasFocus;
  37990. private _onFullscreenChange;
  37991. private _onPointerLockChange;
  37992. /**
  37993. * Gets the HTML element used to attach event listeners
  37994. * @returns a HTML element
  37995. */
  37996. getInputElement(): Nullable<HTMLElement>;
  37997. /**
  37998. * Creates a new engine
  37999. * @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
  38000. * @param antialias defines enable antialiasing (default: false)
  38001. * @param options defines further options to be sent to the getContext() function
  38002. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38003. */
  38004. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38005. /**
  38006. * Gets current aspect ratio
  38007. * @param viewportOwner defines the camera to use to get the aspect ratio
  38008. * @param useScreen defines if screen size must be used (or the current render target if any)
  38009. * @returns a number defining the aspect ratio
  38010. */
  38011. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  38012. /**
  38013. * Gets current screen aspect ratio
  38014. * @returns a number defining the aspect ratio
  38015. */
  38016. getScreenAspectRatio(): number;
  38017. /**
  38018. * Gets the client rect of the HTML canvas attached with the current webGL context
  38019. * @returns a client rectanglee
  38020. */
  38021. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  38022. /**
  38023. * Gets the client rect of the HTML element used for events
  38024. * @returns a client rectanglee
  38025. */
  38026. getInputElementClientRect(): Nullable<ClientRect>;
  38027. /**
  38028. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  38029. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38030. * @returns true if engine is in deterministic lock step mode
  38031. */
  38032. isDeterministicLockStep(): boolean;
  38033. /**
  38034. * Gets the max steps when engine is running in deterministic lock step
  38035. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38036. * @returns the max steps
  38037. */
  38038. getLockstepMaxSteps(): number;
  38039. /**
  38040. * Returns the time in ms between steps when using deterministic lock step.
  38041. * @returns time step in (ms)
  38042. */
  38043. getTimeStep(): number;
  38044. /**
  38045. * Force the mipmap generation for the given render target texture
  38046. * @param texture defines the render target texture to use
  38047. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  38048. */
  38049. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  38050. /** States */
  38051. /**
  38052. * Set various states to the webGL context
  38053. * @param culling defines backface culling state
  38054. * @param zOffset defines the value to apply to zOffset (0 by default)
  38055. * @param force defines if states must be applied even if cache is up to date
  38056. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  38057. */
  38058. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  38059. /**
  38060. * Set the z offset to apply to current rendering
  38061. * @param value defines the offset to apply
  38062. */
  38063. setZOffset(value: number): void;
  38064. /**
  38065. * Gets the current value of the zOffset
  38066. * @returns the current zOffset state
  38067. */
  38068. getZOffset(): number;
  38069. /**
  38070. * Enable or disable depth buffering
  38071. * @param enable defines the state to set
  38072. */
  38073. setDepthBuffer(enable: boolean): void;
  38074. /**
  38075. * Gets a boolean indicating if depth writing is enabled
  38076. * @returns the current depth writing state
  38077. */
  38078. getDepthWrite(): boolean;
  38079. /**
  38080. * Enable or disable depth writing
  38081. * @param enable defines the state to set
  38082. */
  38083. setDepthWrite(enable: boolean): void;
  38084. /**
  38085. * Gets a boolean indicating if stencil buffer is enabled
  38086. * @returns the current stencil buffer state
  38087. */
  38088. getStencilBuffer(): boolean;
  38089. /**
  38090. * Enable or disable the stencil buffer
  38091. * @param enable defines if the stencil buffer must be enabled or disabled
  38092. */
  38093. setStencilBuffer(enable: boolean): void;
  38094. /**
  38095. * Gets the current stencil mask
  38096. * @returns a number defining the new stencil mask to use
  38097. */
  38098. getStencilMask(): number;
  38099. /**
  38100. * Sets the current stencil mask
  38101. * @param mask defines the new stencil mask to use
  38102. */
  38103. setStencilMask(mask: number): void;
  38104. /**
  38105. * Gets the current stencil function
  38106. * @returns a number defining the stencil function to use
  38107. */
  38108. getStencilFunction(): number;
  38109. /**
  38110. * Gets the current stencil reference value
  38111. * @returns a number defining the stencil reference value to use
  38112. */
  38113. getStencilFunctionReference(): number;
  38114. /**
  38115. * Gets the current stencil mask
  38116. * @returns a number defining the stencil mask to use
  38117. */
  38118. getStencilFunctionMask(): number;
  38119. /**
  38120. * Sets the current stencil function
  38121. * @param stencilFunc defines the new stencil function to use
  38122. */
  38123. setStencilFunction(stencilFunc: number): void;
  38124. /**
  38125. * Sets the current stencil reference
  38126. * @param reference defines the new stencil reference to use
  38127. */
  38128. setStencilFunctionReference(reference: number): void;
  38129. /**
  38130. * Sets the current stencil mask
  38131. * @param mask defines the new stencil mask to use
  38132. */
  38133. setStencilFunctionMask(mask: number): void;
  38134. /**
  38135. * Gets the current stencil operation when stencil fails
  38136. * @returns a number defining stencil operation to use when stencil fails
  38137. */
  38138. getStencilOperationFail(): number;
  38139. /**
  38140. * Gets the current stencil operation when depth fails
  38141. * @returns a number defining stencil operation to use when depth fails
  38142. */
  38143. getStencilOperationDepthFail(): number;
  38144. /**
  38145. * Gets the current stencil operation when stencil passes
  38146. * @returns a number defining stencil operation to use when stencil passes
  38147. */
  38148. getStencilOperationPass(): number;
  38149. /**
  38150. * Sets the stencil operation to use when stencil fails
  38151. * @param operation defines the stencil operation to use when stencil fails
  38152. */
  38153. setStencilOperationFail(operation: number): void;
  38154. /**
  38155. * Sets the stencil operation to use when depth fails
  38156. * @param operation defines the stencil operation to use when depth fails
  38157. */
  38158. setStencilOperationDepthFail(operation: number): void;
  38159. /**
  38160. * Sets the stencil operation to use when stencil passes
  38161. * @param operation defines the stencil operation to use when stencil passes
  38162. */
  38163. setStencilOperationPass(operation: number): void;
  38164. /**
  38165. * Sets a boolean indicating if the dithering state is enabled or disabled
  38166. * @param value defines the dithering state
  38167. */
  38168. setDitheringState(value: boolean): void;
  38169. /**
  38170. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  38171. * @param value defines the rasterizer state
  38172. */
  38173. setRasterizerState(value: boolean): void;
  38174. /**
  38175. * Gets the current depth function
  38176. * @returns a number defining the depth function
  38177. */
  38178. getDepthFunction(): Nullable<number>;
  38179. /**
  38180. * Sets the current depth function
  38181. * @param depthFunc defines the function to use
  38182. */
  38183. setDepthFunction(depthFunc: number): void;
  38184. /**
  38185. * Sets the current depth function to GREATER
  38186. */
  38187. setDepthFunctionToGreater(): void;
  38188. /**
  38189. * Sets the current depth function to GEQUAL
  38190. */
  38191. setDepthFunctionToGreaterOrEqual(): void;
  38192. /**
  38193. * Sets the current depth function to LESS
  38194. */
  38195. setDepthFunctionToLess(): void;
  38196. /**
  38197. * Sets the current depth function to LEQUAL
  38198. */
  38199. setDepthFunctionToLessOrEqual(): void;
  38200. private _cachedStencilBuffer;
  38201. private _cachedStencilFunction;
  38202. private _cachedStencilMask;
  38203. private _cachedStencilOperationPass;
  38204. private _cachedStencilOperationFail;
  38205. private _cachedStencilOperationDepthFail;
  38206. private _cachedStencilReference;
  38207. /**
  38208. * Caches the the state of the stencil buffer
  38209. */
  38210. cacheStencilState(): void;
  38211. /**
  38212. * Restores the state of the stencil buffer
  38213. */
  38214. restoreStencilState(): void;
  38215. /**
  38216. * Directly set the WebGL Viewport
  38217. * @param x defines the x coordinate of the viewport (in screen space)
  38218. * @param y defines the y coordinate of the viewport (in screen space)
  38219. * @param width defines the width of the viewport (in screen space)
  38220. * @param height defines the height of the viewport (in screen space)
  38221. * @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
  38222. */
  38223. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  38224. /**
  38225. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  38226. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38227. * @param y defines the y-coordinate of the corner of the clear rectangle
  38228. * @param width defines the width of the clear rectangle
  38229. * @param height defines the height of the clear rectangle
  38230. * @param clearColor defines the clear color
  38231. */
  38232. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  38233. /**
  38234. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  38235. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  38236. * @param y defines the y-coordinate of the corner of the clear rectangle
  38237. * @param width defines the width of the clear rectangle
  38238. * @param height defines the height of the clear rectangle
  38239. */
  38240. enableScissor(x: number, y: number, width: number, height: number): void;
  38241. /**
  38242. * Disable previously set scissor test rectangle
  38243. */
  38244. disableScissor(): void;
  38245. protected _reportDrawCall(): void;
  38246. /**
  38247. * Initializes a webVR display and starts listening to display change events
  38248. * The onVRDisplayChangedObservable will be notified upon these changes
  38249. * @returns The onVRDisplayChangedObservable
  38250. */
  38251. initWebVR(): Observable<IDisplayChangedEventArgs>;
  38252. /** @hidden */
  38253. _prepareVRComponent(): void;
  38254. /** @hidden */
  38255. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  38256. /** @hidden */
  38257. _submitVRFrame(): void;
  38258. /**
  38259. * Call this function to leave webVR mode
  38260. * Will do nothing if webVR is not supported or if there is no webVR device
  38261. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38262. */
  38263. disableVR(): void;
  38264. /**
  38265. * Gets a boolean indicating that the system is in VR mode and is presenting
  38266. * @returns true if VR mode is engaged
  38267. */
  38268. isVRPresenting(): boolean;
  38269. /** @hidden */
  38270. _requestVRFrame(): void;
  38271. /** @hidden */
  38272. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38273. /**
  38274. * Gets the source code of the vertex shader associated with a specific webGL program
  38275. * @param program defines the program to use
  38276. * @returns a string containing the source code of the vertex shader associated with the program
  38277. */
  38278. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  38279. /**
  38280. * Gets the source code of the fragment shader associated with a specific webGL program
  38281. * @param program defines the program to use
  38282. * @returns a string containing the source code of the fragment shader associated with the program
  38283. */
  38284. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  38285. /**
  38286. * Sets a depth stencil texture from a render target to the according uniform.
  38287. * @param channel The texture channel
  38288. * @param uniform The uniform to set
  38289. * @param texture The render target texture containing the depth stencil texture to apply
  38290. */
  38291. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  38292. /**
  38293. * Sets a texture to the webGL context from a postprocess
  38294. * @param channel defines the channel to use
  38295. * @param postProcess defines the source postprocess
  38296. */
  38297. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  38298. /**
  38299. * Binds the output of the passed in post process to the texture channel specified
  38300. * @param channel The channel the texture should be bound to
  38301. * @param postProcess The post process which's output should be bound
  38302. */
  38303. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  38304. protected _rebuildBuffers(): void;
  38305. /** @hidden */
  38306. _renderFrame(): void;
  38307. _renderLoop(): void;
  38308. /** @hidden */
  38309. _renderViews(): boolean;
  38310. /**
  38311. * Toggle full screen mode
  38312. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38313. */
  38314. switchFullscreen(requestPointerLock: boolean): void;
  38315. /**
  38316. * Enters full screen mode
  38317. * @param requestPointerLock defines if a pointer lock should be requested from the user
  38318. */
  38319. enterFullscreen(requestPointerLock: boolean): void;
  38320. /**
  38321. * Exits full screen mode
  38322. */
  38323. exitFullscreen(): void;
  38324. /**
  38325. * Enters Pointerlock mode
  38326. */
  38327. enterPointerlock(): void;
  38328. /**
  38329. * Exits Pointerlock mode
  38330. */
  38331. exitPointerlock(): void;
  38332. /**
  38333. * Begin a new frame
  38334. */
  38335. beginFrame(): void;
  38336. /**
  38337. * Enf the current frame
  38338. */
  38339. endFrame(): void;
  38340. resize(): void;
  38341. /**
  38342. * Force a specific size of the canvas
  38343. * @param width defines the new canvas' width
  38344. * @param height defines the new canvas' height
  38345. * @returns true if the size was changed
  38346. */
  38347. setSize(width: number, height: number): boolean;
  38348. /**
  38349. * Updates a dynamic vertex buffer.
  38350. * @param vertexBuffer the vertex buffer to update
  38351. * @param data the data used to update the vertex buffer
  38352. * @param byteOffset the byte offset of the data
  38353. * @param byteLength the byte length of the data
  38354. */
  38355. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  38356. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38357. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38358. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38359. _releaseTexture(texture: InternalTexture): void;
  38360. /**
  38361. * @hidden
  38362. * Rescales a texture
  38363. * @param source input texutre
  38364. * @param destination destination texture
  38365. * @param scene scene to use to render the resize
  38366. * @param internalFormat format to use when resizing
  38367. * @param onComplete callback to be called when resize has completed
  38368. */
  38369. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  38370. /**
  38371. * Gets the current framerate
  38372. * @returns a number representing the framerate
  38373. */
  38374. getFps(): number;
  38375. /**
  38376. * Gets the time spent between current and previous frame
  38377. * @returns a number representing the delta time in ms
  38378. */
  38379. getDeltaTime(): number;
  38380. private _measureFps;
  38381. /** @hidden */
  38382. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  38383. /**
  38384. * Update a dynamic index buffer
  38385. * @param indexBuffer defines the target index buffer
  38386. * @param indices defines the data to update
  38387. * @param offset defines the offset in the target index buffer where update should start
  38388. */
  38389. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  38390. /**
  38391. * Updates the sample count of a render target texture
  38392. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  38393. * @param texture defines the texture to update
  38394. * @param samples defines the sample count to set
  38395. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  38396. */
  38397. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  38398. /**
  38399. * Updates a depth texture Comparison Mode and Function.
  38400. * If the comparison Function is equal to 0, the mode will be set to none.
  38401. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  38402. * @param texture The texture to set the comparison function for
  38403. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  38404. */
  38405. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  38406. /**
  38407. * Creates a webGL buffer to use with instanciation
  38408. * @param capacity defines the size of the buffer
  38409. * @returns the webGL buffer
  38410. */
  38411. createInstancesBuffer(capacity: number): DataBuffer;
  38412. /**
  38413. * Delete a webGL buffer used with instanciation
  38414. * @param buffer defines the webGL buffer to delete
  38415. */
  38416. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  38417. private _clientWaitAsync;
  38418. /** @hidden */
  38419. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  38420. dispose(): void;
  38421. private _disableTouchAction;
  38422. /**
  38423. * Display the loading screen
  38424. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38425. */
  38426. displayLoadingUI(): void;
  38427. /**
  38428. * Hide the loading screen
  38429. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38430. */
  38431. hideLoadingUI(): void;
  38432. /**
  38433. * Gets the current loading screen object
  38434. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38435. */
  38436. get loadingScreen(): ILoadingScreen;
  38437. /**
  38438. * Sets the current loading screen object
  38439. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38440. */
  38441. set loadingScreen(loadingScreen: ILoadingScreen);
  38442. /**
  38443. * Sets the current loading screen text
  38444. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38445. */
  38446. set loadingUIText(text: string);
  38447. /**
  38448. * Sets the current loading screen background color
  38449. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38450. */
  38451. set loadingUIBackgroundColor(color: string);
  38452. /** Pointerlock and fullscreen */
  38453. /**
  38454. * Ask the browser to promote the current element to pointerlock mode
  38455. * @param element defines the DOM element to promote
  38456. */
  38457. static _RequestPointerlock(element: HTMLElement): void;
  38458. /**
  38459. * Asks the browser to exit pointerlock mode
  38460. */
  38461. static _ExitPointerlock(): void;
  38462. /**
  38463. * Ask the browser to promote the current element to fullscreen rendering mode
  38464. * @param element defines the DOM element to promote
  38465. */
  38466. static _RequestFullscreen(element: HTMLElement): void;
  38467. /**
  38468. * Asks the browser to exit fullscreen mode
  38469. */
  38470. static _ExitFullscreen(): void;
  38471. }
  38472. }
  38473. declare module "babylonjs/Engines/engineStore" {
  38474. import { Nullable } from "babylonjs/types";
  38475. import { Engine } from "babylonjs/Engines/engine";
  38476. import { Scene } from "babylonjs/scene";
  38477. /**
  38478. * The engine store class is responsible to hold all the instances of Engine and Scene created
  38479. * during the life time of the application.
  38480. */
  38481. export class EngineStore {
  38482. /** Gets the list of created engines */
  38483. static Instances: import("babylonjs/Engines/engine").Engine[];
  38484. /** @hidden */
  38485. static _LastCreatedScene: Nullable<Scene>;
  38486. /**
  38487. * Gets the latest created engine
  38488. */
  38489. static get LastCreatedEngine(): Nullable<Engine>;
  38490. /**
  38491. * Gets the latest created scene
  38492. */
  38493. static get LastCreatedScene(): Nullable<Scene>;
  38494. /**
  38495. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38496. * @ignorenaming
  38497. */
  38498. static UseFallbackTexture: boolean;
  38499. /**
  38500. * Texture content used if a texture cannot loaded
  38501. * @ignorenaming
  38502. */
  38503. static FallbackTexture: string;
  38504. }
  38505. }
  38506. declare module "babylonjs/Misc/promise" {
  38507. /**
  38508. * Helper class that provides a small promise polyfill
  38509. */
  38510. export class PromisePolyfill {
  38511. /**
  38512. * Static function used to check if the polyfill is required
  38513. * If this is the case then the function will inject the polyfill to window.Promise
  38514. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  38515. */
  38516. static Apply(force?: boolean): void;
  38517. }
  38518. }
  38519. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  38520. /**
  38521. * Interface for screenshot methods with describe argument called `size` as object with options
  38522. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  38523. */
  38524. export interface IScreenshotSize {
  38525. /**
  38526. * number in pixels for canvas height
  38527. */
  38528. height?: number;
  38529. /**
  38530. * multiplier allowing render at a higher or lower resolution
  38531. * If value is defined then height and width will be ignored and taken from camera
  38532. */
  38533. precision?: number;
  38534. /**
  38535. * number in pixels for canvas width
  38536. */
  38537. width?: number;
  38538. }
  38539. }
  38540. declare module "babylonjs/Misc/tools" {
  38541. import { Nullable, float } from "babylonjs/types";
  38542. import { DomManagement } from "babylonjs/Misc/domManagement";
  38543. import { WebRequest } from "babylonjs/Misc/webRequest";
  38544. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  38545. import { ReadFileError } from "babylonjs/Misc/fileTools";
  38546. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38547. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  38548. import { Camera } from "babylonjs/Cameras/camera";
  38549. import { Engine } from "babylonjs/Engines/engine";
  38550. interface IColor4Like {
  38551. r: float;
  38552. g: float;
  38553. b: float;
  38554. a: float;
  38555. }
  38556. /**
  38557. * Class containing a set of static utilities functions
  38558. */
  38559. export class Tools {
  38560. /**
  38561. * Gets or sets the base URL to use to load assets
  38562. */
  38563. static get BaseUrl(): string;
  38564. static set BaseUrl(value: string);
  38565. /**
  38566. * Enable/Disable Custom HTTP Request Headers globally.
  38567. * default = false
  38568. * @see CustomRequestHeaders
  38569. */
  38570. static UseCustomRequestHeaders: boolean;
  38571. /**
  38572. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  38573. * i.e. when loading files, where the server/service expects an Authorization header
  38574. */
  38575. static CustomRequestHeaders: {
  38576. [key: string]: string;
  38577. };
  38578. /**
  38579. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  38580. */
  38581. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  38582. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  38583. /**
  38584. * Default behaviour for cors in the application.
  38585. * It can be a string if the expected behavior is identical in the entire app.
  38586. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  38587. */
  38588. static get CorsBehavior(): string | ((url: string | string[]) => string);
  38589. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  38590. /**
  38591. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  38592. * @ignorenaming
  38593. */
  38594. static get UseFallbackTexture(): boolean;
  38595. static set UseFallbackTexture(value: boolean);
  38596. /**
  38597. * Use this object to register external classes like custom textures or material
  38598. * to allow the laoders to instantiate them
  38599. */
  38600. static get RegisteredExternalClasses(): {
  38601. [key: string]: Object;
  38602. };
  38603. static set RegisteredExternalClasses(classes: {
  38604. [key: string]: Object;
  38605. });
  38606. /**
  38607. * Texture content used if a texture cannot loaded
  38608. * @ignorenaming
  38609. */
  38610. static get fallbackTexture(): string;
  38611. static set fallbackTexture(value: string);
  38612. /**
  38613. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  38614. * @param u defines the coordinate on X axis
  38615. * @param v defines the coordinate on Y axis
  38616. * @param width defines the width of the source data
  38617. * @param height defines the height of the source data
  38618. * @param pixels defines the source byte array
  38619. * @param color defines the output color
  38620. */
  38621. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  38622. /**
  38623. * Interpolates between a and b via alpha
  38624. * @param a The lower value (returned when alpha = 0)
  38625. * @param b The upper value (returned when alpha = 1)
  38626. * @param alpha The interpolation-factor
  38627. * @return The mixed value
  38628. */
  38629. static Mix(a: number, b: number, alpha: number): number;
  38630. /**
  38631. * Tries to instantiate a new object from a given class name
  38632. * @param className defines the class name to instantiate
  38633. * @returns the new object or null if the system was not able to do the instantiation
  38634. */
  38635. static Instantiate(className: string): any;
  38636. /**
  38637. * Provides a slice function that will work even on IE
  38638. * @param data defines the array to slice
  38639. * @param start defines the start of the data (optional)
  38640. * @param end defines the end of the data (optional)
  38641. * @returns the new sliced array
  38642. */
  38643. static Slice<T>(data: T, start?: number, end?: number): T;
  38644. /**
  38645. * Polyfill for setImmediate
  38646. * @param action defines the action to execute after the current execution block
  38647. */
  38648. static SetImmediate(action: () => void): void;
  38649. /**
  38650. * Function indicating if a number is an exponent of 2
  38651. * @param value defines the value to test
  38652. * @returns true if the value is an exponent of 2
  38653. */
  38654. static IsExponentOfTwo(value: number): boolean;
  38655. private static _tmpFloatArray;
  38656. /**
  38657. * Returns the nearest 32-bit single precision float representation of a Number
  38658. * @param value A Number. If the parameter is of a different type, it will get converted
  38659. * to a number or to NaN if it cannot be converted
  38660. * @returns number
  38661. */
  38662. static FloatRound(value: number): number;
  38663. /**
  38664. * Extracts the filename from a path
  38665. * @param path defines the path to use
  38666. * @returns the filename
  38667. */
  38668. static GetFilename(path: string): string;
  38669. /**
  38670. * Extracts the "folder" part of a path (everything before the filename).
  38671. * @param uri The URI to extract the info from
  38672. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  38673. * @returns The "folder" part of the path
  38674. */
  38675. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  38676. /**
  38677. * Extracts text content from a DOM element hierarchy
  38678. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  38679. */
  38680. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  38681. /**
  38682. * Convert an angle in radians to degrees
  38683. * @param angle defines the angle to convert
  38684. * @returns the angle in degrees
  38685. */
  38686. static ToDegrees(angle: number): number;
  38687. /**
  38688. * Convert an angle in degrees to radians
  38689. * @param angle defines the angle to convert
  38690. * @returns the angle in radians
  38691. */
  38692. static ToRadians(angle: number): number;
  38693. /**
  38694. * Returns an array if obj is not an array
  38695. * @param obj defines the object to evaluate as an array
  38696. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  38697. * @returns either obj directly if obj is an array or a new array containing obj
  38698. */
  38699. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  38700. /**
  38701. * Gets the pointer prefix to use
  38702. * @param engine defines the engine we are finding the prefix for
  38703. * @returns "pointer" if touch is enabled. Else returns "mouse"
  38704. */
  38705. static GetPointerPrefix(engine: Engine): string;
  38706. /**
  38707. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  38708. * @param url define the url we are trying
  38709. * @param element define the dom element where to configure the cors policy
  38710. */
  38711. static SetCorsBehavior(url: string | string[], element: {
  38712. crossOrigin: string | null;
  38713. }): void;
  38714. /**
  38715. * Removes unwanted characters from an url
  38716. * @param url defines the url to clean
  38717. * @returns the cleaned url
  38718. */
  38719. static CleanUrl(url: string): string;
  38720. /**
  38721. * Gets or sets a function used to pre-process url before using them to load assets
  38722. */
  38723. static get PreprocessUrl(): (url: string) => string;
  38724. static set PreprocessUrl(processor: (url: string) => string);
  38725. /**
  38726. * Loads an image as an HTMLImageElement.
  38727. * @param input url string, ArrayBuffer, or Blob to load
  38728. * @param onLoad callback called when the image successfully loads
  38729. * @param onError callback called when the image fails to load
  38730. * @param offlineProvider offline provider for caching
  38731. * @param mimeType optional mime type
  38732. * @returns the HTMLImageElement of the loaded image
  38733. */
  38734. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  38735. /**
  38736. * Loads a file from a url
  38737. * @param url url string, ArrayBuffer, or Blob to load
  38738. * @param onSuccess callback called when the file successfully loads
  38739. * @param onProgress callback called while file is loading (if the server supports this mode)
  38740. * @param offlineProvider defines the offline provider for caching
  38741. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38742. * @param onError callback called when the file fails to load
  38743. * @returns a file request object
  38744. */
  38745. 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;
  38746. /**
  38747. * Loads a file from a url
  38748. * @param url the file url to load
  38749. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  38750. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  38751. */
  38752. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  38753. /**
  38754. * Load a script (identified by an url). When the url returns, the
  38755. * content of this file is added into a new script element, attached to the DOM (body element)
  38756. * @param scriptUrl defines the url of the script to laod
  38757. * @param onSuccess defines the callback called when the script is loaded
  38758. * @param onError defines the callback to call if an error occurs
  38759. * @param scriptId defines the id of the script element
  38760. */
  38761. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  38762. /**
  38763. * Load an asynchronous script (identified by an url). When the url returns, the
  38764. * content of this file is added into a new script element, attached to the DOM (body element)
  38765. * @param scriptUrl defines the url of the script to laod
  38766. * @param scriptId defines the id of the script element
  38767. * @returns a promise request object
  38768. */
  38769. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  38770. /**
  38771. * Loads a file from a blob
  38772. * @param fileToLoad defines the blob to use
  38773. * @param callback defines the callback to call when data is loaded
  38774. * @param progressCallback defines the callback to call during loading process
  38775. * @returns a file request object
  38776. */
  38777. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  38778. /**
  38779. * Reads a file from a File object
  38780. * @param file defines the file to load
  38781. * @param onSuccess defines the callback to call when data is loaded
  38782. * @param onProgress defines the callback to call during loading process
  38783. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  38784. * @param onError defines the callback to call when an error occurs
  38785. * @returns a file request object
  38786. */
  38787. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38788. /**
  38789. * Creates a data url from a given string content
  38790. * @param content defines the content to convert
  38791. * @returns the new data url link
  38792. */
  38793. static FileAsURL(content: string): string;
  38794. /**
  38795. * Format the given number to a specific decimal format
  38796. * @param value defines the number to format
  38797. * @param decimals defines the number of decimals to use
  38798. * @returns the formatted string
  38799. */
  38800. static Format(value: number, decimals?: number): string;
  38801. /**
  38802. * Tries to copy an object by duplicating every property
  38803. * @param source defines the source object
  38804. * @param destination defines the target object
  38805. * @param doNotCopyList defines a list of properties to avoid
  38806. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  38807. */
  38808. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  38809. /**
  38810. * Gets a boolean indicating if the given object has no own property
  38811. * @param obj defines the object to test
  38812. * @returns true if object has no own property
  38813. */
  38814. static IsEmpty(obj: any): boolean;
  38815. /**
  38816. * Function used to register events at window level
  38817. * @param windowElement defines the Window object to use
  38818. * @param events defines the events to register
  38819. */
  38820. static RegisterTopRootEvents(windowElement: Window, events: {
  38821. name: string;
  38822. handler: Nullable<(e: FocusEvent) => any>;
  38823. }[]): void;
  38824. /**
  38825. * Function used to unregister events from window level
  38826. * @param windowElement defines the Window object to use
  38827. * @param events defines the events to unregister
  38828. */
  38829. static UnregisterTopRootEvents(windowElement: Window, events: {
  38830. name: string;
  38831. handler: Nullable<(e: FocusEvent) => any>;
  38832. }[]): void;
  38833. /**
  38834. * @ignore
  38835. */
  38836. static _ScreenshotCanvas: HTMLCanvasElement;
  38837. /**
  38838. * Dumps the current bound framebuffer
  38839. * @param width defines the rendering width
  38840. * @param height defines the rendering height
  38841. * @param engine defines the hosting engine
  38842. * @param successCallback defines the callback triggered once the data are available
  38843. * @param mimeType defines the mime type of the result
  38844. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  38845. */
  38846. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38847. /**
  38848. * Converts the canvas data to blob.
  38849. * This acts as a polyfill for browsers not supporting the to blob function.
  38850. * @param canvas Defines the canvas to extract the data from
  38851. * @param successCallback Defines the callback triggered once the data are available
  38852. * @param mimeType Defines the mime type of the result
  38853. */
  38854. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  38855. /**
  38856. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  38857. * @param successCallback defines the callback triggered once the data are available
  38858. * @param mimeType defines the mime type of the result
  38859. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  38860. */
  38861. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  38862. /**
  38863. * Downloads a blob in the browser
  38864. * @param blob defines the blob to download
  38865. * @param fileName defines the name of the downloaded file
  38866. */
  38867. static Download(blob: Blob, fileName: string): void;
  38868. /**
  38869. * Captures a screenshot of the current rendering
  38870. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38871. * @param engine defines the rendering engine
  38872. * @param camera defines the source camera
  38873. * @param size This parameter can be set to a single number or to an object with the
  38874. * following (optional) properties: precision, width, height. If a single number is passed,
  38875. * it will be used for both width and height. If an object is passed, the screenshot size
  38876. * will be derived from the parameters. The precision property is a multiplier allowing
  38877. * rendering at a higher or lower resolution
  38878. * @param successCallback defines the callback receives a single parameter which contains the
  38879. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38880. * src parameter of an <img> to display it
  38881. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38882. * Check your browser for supported MIME types
  38883. */
  38884. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  38885. /**
  38886. * Captures a screenshot of the current rendering
  38887. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38888. * @param engine defines the rendering engine
  38889. * @param camera defines the source camera
  38890. * @param size This parameter can be set to a single number or to an object with the
  38891. * following (optional) properties: precision, width, height. If a single number is passed,
  38892. * it will be used for both width and height. If an object is passed, the screenshot size
  38893. * will be derived from the parameters. The precision property is a multiplier allowing
  38894. * rendering at a higher or lower resolution
  38895. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  38896. * Check your browser for supported MIME types
  38897. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38898. * to the src parameter of an <img> to display it
  38899. */
  38900. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  38901. /**
  38902. * Generates an image screenshot from the specified camera.
  38903. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38904. * @param engine The engine to use for rendering
  38905. * @param camera The camera to use for rendering
  38906. * @param size This parameter can be set to a single number or to an object with the
  38907. * following (optional) properties: precision, width, height. If a single number is passed,
  38908. * it will be used for both width and height. If an object is passed, the screenshot size
  38909. * will be derived from the parameters. The precision property is a multiplier allowing
  38910. * rendering at a higher or lower resolution
  38911. * @param successCallback The callback receives a single parameter which contains the
  38912. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  38913. * src parameter of an <img> to display it
  38914. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38915. * Check your browser for supported MIME types
  38916. * @param samples Texture samples (default: 1)
  38917. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38918. * @param fileName A name for for the downloaded file.
  38919. */
  38920. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  38921. /**
  38922. * Generates an image screenshot from the specified camera.
  38923. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  38924. * @param engine The engine to use for rendering
  38925. * @param camera The camera to use for rendering
  38926. * @param size This parameter can be set to a single number or to an object with the
  38927. * following (optional) properties: precision, width, height. If a single number is passed,
  38928. * it will be used for both width and height. If an object is passed, the screenshot size
  38929. * will be derived from the parameters. The precision property is a multiplier allowing
  38930. * rendering at a higher or lower resolution
  38931. * @param mimeType The MIME type of the screenshot image (default: image/png).
  38932. * Check your browser for supported MIME types
  38933. * @param samples Texture samples (default: 1)
  38934. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  38935. * @param fileName A name for for the downloaded file.
  38936. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  38937. * to the src parameter of an <img> to display it
  38938. */
  38939. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  38940. /**
  38941. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  38942. * Be aware Math.random() could cause collisions, but:
  38943. * "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"
  38944. * @returns a pseudo random id
  38945. */
  38946. static RandomId(): string;
  38947. /**
  38948. * Test if the given uri is a base64 string
  38949. * @param uri The uri to test
  38950. * @return True if the uri is a base64 string or false otherwise
  38951. */
  38952. static IsBase64(uri: string): boolean;
  38953. /**
  38954. * Decode the given base64 uri.
  38955. * @param uri The uri to decode
  38956. * @return The decoded base64 data.
  38957. */
  38958. static DecodeBase64(uri: string): ArrayBuffer;
  38959. /**
  38960. * Gets the absolute url.
  38961. * @param url the input url
  38962. * @return the absolute url
  38963. */
  38964. static GetAbsoluteUrl(url: string): string;
  38965. /**
  38966. * No log
  38967. */
  38968. static readonly NoneLogLevel: number;
  38969. /**
  38970. * Only message logs
  38971. */
  38972. static readonly MessageLogLevel: number;
  38973. /**
  38974. * Only warning logs
  38975. */
  38976. static readonly WarningLogLevel: number;
  38977. /**
  38978. * Only error logs
  38979. */
  38980. static readonly ErrorLogLevel: number;
  38981. /**
  38982. * All logs
  38983. */
  38984. static readonly AllLogLevel: number;
  38985. /**
  38986. * Gets a value indicating the number of loading errors
  38987. * @ignorenaming
  38988. */
  38989. static get errorsCount(): number;
  38990. /**
  38991. * Callback called when a new log is added
  38992. */
  38993. static OnNewCacheEntry: (entry: string) => void;
  38994. /**
  38995. * Log a message to the console
  38996. * @param message defines the message to log
  38997. */
  38998. static Log(message: string): void;
  38999. /**
  39000. * Write a warning message to the console
  39001. * @param message defines the message to log
  39002. */
  39003. static Warn(message: string): void;
  39004. /**
  39005. * Write an error message to the console
  39006. * @param message defines the message to log
  39007. */
  39008. static Error(message: string): void;
  39009. /**
  39010. * Gets current log cache (list of logs)
  39011. */
  39012. static get LogCache(): string;
  39013. /**
  39014. * Clears the log cache
  39015. */
  39016. static ClearLogCache(): void;
  39017. /**
  39018. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  39019. */
  39020. static set LogLevels(level: number);
  39021. /**
  39022. * Checks if the window object exists
  39023. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  39024. */
  39025. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  39026. /**
  39027. * No performance log
  39028. */
  39029. static readonly PerformanceNoneLogLevel: number;
  39030. /**
  39031. * Use user marks to log performance
  39032. */
  39033. static readonly PerformanceUserMarkLogLevel: number;
  39034. /**
  39035. * Log performance to the console
  39036. */
  39037. static readonly PerformanceConsoleLogLevel: number;
  39038. private static _performance;
  39039. /**
  39040. * Sets the current performance log level
  39041. */
  39042. static set PerformanceLogLevel(level: number);
  39043. private static _StartPerformanceCounterDisabled;
  39044. private static _EndPerformanceCounterDisabled;
  39045. private static _StartUserMark;
  39046. private static _EndUserMark;
  39047. private static _StartPerformanceConsole;
  39048. private static _EndPerformanceConsole;
  39049. /**
  39050. * Starts a performance counter
  39051. */
  39052. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39053. /**
  39054. * Ends a specific performance coutner
  39055. */
  39056. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  39057. /**
  39058. * Gets either window.performance.now() if supported or Date.now() else
  39059. */
  39060. static get Now(): number;
  39061. /**
  39062. * This method will return the name of the class used to create the instance of the given object.
  39063. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  39064. * @param object the object to get the class name from
  39065. * @param isType defines if the object is actually a type
  39066. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  39067. */
  39068. static GetClassName(object: any, isType?: boolean): string;
  39069. /**
  39070. * Gets the first element of an array satisfying a given predicate
  39071. * @param array defines the array to browse
  39072. * @param predicate defines the predicate to use
  39073. * @returns null if not found or the element
  39074. */
  39075. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  39076. /**
  39077. * This method will return the name of the full name of the class, including its owning module (if any).
  39078. * 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).
  39079. * @param object the object to get the class name from
  39080. * @param isType defines if the object is actually a type
  39081. * @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.
  39082. * @ignorenaming
  39083. */
  39084. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  39085. /**
  39086. * Returns a promise that resolves after the given amount of time.
  39087. * @param delay Number of milliseconds to delay
  39088. * @returns Promise that resolves after the given amount of time
  39089. */
  39090. static DelayAsync(delay: number): Promise<void>;
  39091. /**
  39092. * Utility function to detect if the current user agent is Safari
  39093. * @returns whether or not the current user agent is safari
  39094. */
  39095. static IsSafari(): boolean;
  39096. }
  39097. /**
  39098. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  39099. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  39100. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  39101. * @param name The name of the class, case should be preserved
  39102. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  39103. */
  39104. export function className(name: string, module?: string): (target: Object) => void;
  39105. /**
  39106. * An implementation of a loop for asynchronous functions.
  39107. */
  39108. export class AsyncLoop {
  39109. /**
  39110. * Defines the number of iterations for the loop
  39111. */
  39112. iterations: number;
  39113. /**
  39114. * Defines the current index of the loop.
  39115. */
  39116. index: number;
  39117. private _done;
  39118. private _fn;
  39119. private _successCallback;
  39120. /**
  39121. * Constructor.
  39122. * @param iterations the number of iterations.
  39123. * @param func the function to run each iteration
  39124. * @param successCallback the callback that will be called upon succesful execution
  39125. * @param offset starting offset.
  39126. */
  39127. constructor(
  39128. /**
  39129. * Defines the number of iterations for the loop
  39130. */
  39131. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  39132. /**
  39133. * Execute the next iteration. Must be called after the last iteration was finished.
  39134. */
  39135. executeNext(): void;
  39136. /**
  39137. * Break the loop and run the success callback.
  39138. */
  39139. breakLoop(): void;
  39140. /**
  39141. * Create and run an async loop.
  39142. * @param iterations the number of iterations.
  39143. * @param fn the function to run each iteration
  39144. * @param successCallback the callback that will be called upon succesful execution
  39145. * @param offset starting offset.
  39146. * @returns the created async loop object
  39147. */
  39148. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  39149. /**
  39150. * A for-loop that will run a given number of iterations synchronous and the rest async.
  39151. * @param iterations total number of iterations
  39152. * @param syncedIterations number of synchronous iterations in each async iteration.
  39153. * @param fn the function to call each iteration.
  39154. * @param callback a success call back that will be called when iterating stops.
  39155. * @param breakFunction a break condition (optional)
  39156. * @param timeout timeout settings for the setTimeout function. default - 0.
  39157. * @returns the created async loop object
  39158. */
  39159. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  39160. }
  39161. }
  39162. declare module "babylonjs/Misc/stringDictionary" {
  39163. import { Nullable } from "babylonjs/types";
  39164. /**
  39165. * This class implement a typical dictionary using a string as key and the generic type T as value.
  39166. * The underlying implementation relies on an associative array to ensure the best performances.
  39167. * The value can be anything including 'null' but except 'undefined'
  39168. */
  39169. export class StringDictionary<T> {
  39170. /**
  39171. * This will clear this dictionary and copy the content from the 'source' one.
  39172. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  39173. * @param source the dictionary to take the content from and copy to this dictionary
  39174. */
  39175. copyFrom(source: StringDictionary<T>): void;
  39176. /**
  39177. * Get a value based from its key
  39178. * @param key the given key to get the matching value from
  39179. * @return the value if found, otherwise undefined is returned
  39180. */
  39181. get(key: string): T | undefined;
  39182. /**
  39183. * Get a value from its key or add it if it doesn't exist.
  39184. * This method will ensure you that a given key/data will be present in the dictionary.
  39185. * @param key the given key to get the matching value from
  39186. * @param factory the factory that will create the value if the key is not present in the dictionary.
  39187. * The factory will only be invoked if there's no data for the given key.
  39188. * @return the value corresponding to the key.
  39189. */
  39190. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  39191. /**
  39192. * Get a value from its key if present in the dictionary otherwise add it
  39193. * @param key the key to get the value from
  39194. * @param val if there's no such key/value pair in the dictionary add it with this value
  39195. * @return the value corresponding to the key
  39196. */
  39197. getOrAdd(key: string, val: T): T;
  39198. /**
  39199. * Check if there's a given key in the dictionary
  39200. * @param key the key to check for
  39201. * @return true if the key is present, false otherwise
  39202. */
  39203. contains(key: string): boolean;
  39204. /**
  39205. * Add a new key and its corresponding value
  39206. * @param key the key to add
  39207. * @param value the value corresponding to the key
  39208. * @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
  39209. */
  39210. add(key: string, value: T): boolean;
  39211. /**
  39212. * Update a specific value associated to a key
  39213. * @param key defines the key to use
  39214. * @param value defines the value to store
  39215. * @returns true if the value was updated (or false if the key was not found)
  39216. */
  39217. set(key: string, value: T): boolean;
  39218. /**
  39219. * Get the element of the given key and remove it from the dictionary
  39220. * @param key defines the key to search
  39221. * @returns the value associated with the key or null if not found
  39222. */
  39223. getAndRemove(key: string): Nullable<T>;
  39224. /**
  39225. * Remove a key/value from the dictionary.
  39226. * @param key the key to remove
  39227. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  39228. */
  39229. remove(key: string): boolean;
  39230. /**
  39231. * Clear the whole content of the dictionary
  39232. */
  39233. clear(): void;
  39234. /**
  39235. * Gets the current count
  39236. */
  39237. get count(): number;
  39238. /**
  39239. * Execute a callback on each key/val of the dictionary.
  39240. * Note that you can remove any element in this dictionary in the callback implementation
  39241. * @param callback the callback to execute on a given key/value pair
  39242. */
  39243. forEach(callback: (key: string, val: T) => void): void;
  39244. /**
  39245. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  39246. * If the callback returns null or undefined the method will iterate to the next key/value pair
  39247. * Note that you can remove any element in this dictionary in the callback implementation
  39248. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  39249. * @returns the first item
  39250. */
  39251. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  39252. private _count;
  39253. private _data;
  39254. }
  39255. }
  39256. declare module "babylonjs/Collisions/collisionCoordinator" {
  39257. import { Nullable } from "babylonjs/types";
  39258. import { Scene } from "babylonjs/scene";
  39259. import { Vector3 } from "babylonjs/Maths/math.vector";
  39260. import { Collider } from "babylonjs/Collisions/collider";
  39261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39262. /** @hidden */
  39263. export interface ICollisionCoordinator {
  39264. createCollider(): Collider;
  39265. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39266. init(scene: Scene): void;
  39267. }
  39268. /** @hidden */
  39269. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  39270. private _scene;
  39271. private _scaledPosition;
  39272. private _scaledVelocity;
  39273. private _finalPosition;
  39274. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  39275. createCollider(): Collider;
  39276. init(scene: Scene): void;
  39277. private _collideWithWorld;
  39278. }
  39279. }
  39280. declare module "babylonjs/Inputs/scene.inputManager" {
  39281. import { Nullable } from "babylonjs/types";
  39282. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39283. import { Vector2 } from "babylonjs/Maths/math.vector";
  39284. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39285. import { Scene } from "babylonjs/scene";
  39286. /**
  39287. * Class used to manage all inputs for the scene.
  39288. */
  39289. export class InputManager {
  39290. /** The distance in pixel that you have to move to prevent some events */
  39291. static DragMovementThreshold: number;
  39292. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  39293. static LongPressDelay: number;
  39294. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  39295. static DoubleClickDelay: number;
  39296. /** If you need to check double click without raising a single click at first click, enable this flag */
  39297. static ExclusiveDoubleClickMode: boolean;
  39298. private _wheelEventName;
  39299. private _onPointerMove;
  39300. private _onPointerDown;
  39301. private _onPointerUp;
  39302. private _initClickEvent;
  39303. private _initActionManager;
  39304. private _delayedSimpleClick;
  39305. private _delayedSimpleClickTimeout;
  39306. private _previousDelayedSimpleClickTimeout;
  39307. private _meshPickProceed;
  39308. private _previousButtonPressed;
  39309. private _currentPickResult;
  39310. private _previousPickResult;
  39311. private _totalPointersPressed;
  39312. private _doubleClickOccured;
  39313. private _pointerOverMesh;
  39314. private _pickedDownMesh;
  39315. private _pickedUpMesh;
  39316. private _pointerX;
  39317. private _pointerY;
  39318. private _unTranslatedPointerX;
  39319. private _unTranslatedPointerY;
  39320. private _startingPointerPosition;
  39321. private _previousStartingPointerPosition;
  39322. private _startingPointerTime;
  39323. private _previousStartingPointerTime;
  39324. private _pointerCaptures;
  39325. private _onKeyDown;
  39326. private _onKeyUp;
  39327. private _onCanvasFocusObserver;
  39328. private _onCanvasBlurObserver;
  39329. private _scene;
  39330. /**
  39331. * Creates a new InputManager
  39332. * @param scene defines the hosting scene
  39333. */
  39334. constructor(scene: Scene);
  39335. /**
  39336. * Gets the mesh that is currently under the pointer
  39337. */
  39338. get meshUnderPointer(): Nullable<AbstractMesh>;
  39339. /**
  39340. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  39341. */
  39342. get unTranslatedPointer(): Vector2;
  39343. /**
  39344. * Gets or sets the current on-screen X position of the pointer
  39345. */
  39346. get pointerX(): number;
  39347. set pointerX(value: number);
  39348. /**
  39349. * Gets or sets the current on-screen Y position of the pointer
  39350. */
  39351. get pointerY(): number;
  39352. set pointerY(value: number);
  39353. private _updatePointerPosition;
  39354. private _processPointerMove;
  39355. private _setRayOnPointerInfo;
  39356. private _checkPrePointerObservable;
  39357. /**
  39358. * Use this method to simulate a pointer move on a mesh
  39359. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39360. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39361. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39362. */
  39363. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39364. /**
  39365. * Use this method to simulate a pointer down on a mesh
  39366. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39367. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39368. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39369. */
  39370. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  39371. private _processPointerDown;
  39372. /** @hidden */
  39373. _isPointerSwiping(): boolean;
  39374. /**
  39375. * Use this method to simulate a pointer up on a mesh
  39376. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  39377. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  39378. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  39379. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  39380. */
  39381. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  39382. private _processPointerUp;
  39383. /**
  39384. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  39385. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  39386. * @returns true if the pointer was captured
  39387. */
  39388. isPointerCaptured(pointerId?: number): boolean;
  39389. /**
  39390. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  39391. * @param attachUp defines if you want to attach events to pointerup
  39392. * @param attachDown defines if you want to attach events to pointerdown
  39393. * @param attachMove defines if you want to attach events to pointermove
  39394. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  39395. */
  39396. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  39397. /**
  39398. * Detaches all event handlers
  39399. */
  39400. detachControl(): void;
  39401. /**
  39402. * Force the value of meshUnderPointer
  39403. * @param mesh defines the mesh to use
  39404. */
  39405. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  39406. /**
  39407. * Gets the mesh under the pointer
  39408. * @returns a Mesh or null if no mesh is under the pointer
  39409. */
  39410. getPointerOverMesh(): Nullable<AbstractMesh>;
  39411. }
  39412. }
  39413. declare module "babylonjs/Animations/animationGroup" {
  39414. import { Animatable } from "babylonjs/Animations/animatable";
  39415. import { Animation } from "babylonjs/Animations/animation";
  39416. import { Scene, IDisposable } from "babylonjs/scene";
  39417. import { Observable } from "babylonjs/Misc/observable";
  39418. import { Nullable } from "babylonjs/types";
  39419. import "babylonjs/Animations/animatable";
  39420. /**
  39421. * This class defines the direct association between an animation and a target
  39422. */
  39423. export class TargetedAnimation {
  39424. /**
  39425. * Animation to perform
  39426. */
  39427. animation: Animation;
  39428. /**
  39429. * Target to animate
  39430. */
  39431. target: any;
  39432. /**
  39433. * Returns the string "TargetedAnimation"
  39434. * @returns "TargetedAnimation"
  39435. */
  39436. getClassName(): string;
  39437. /**
  39438. * Serialize the object
  39439. * @returns the JSON object representing the current entity
  39440. */
  39441. serialize(): any;
  39442. }
  39443. /**
  39444. * Use this class to create coordinated animations on multiple targets
  39445. */
  39446. export class AnimationGroup implements IDisposable {
  39447. /** The name of the animation group */
  39448. name: string;
  39449. private _scene;
  39450. private _targetedAnimations;
  39451. private _animatables;
  39452. private _from;
  39453. private _to;
  39454. private _isStarted;
  39455. private _isPaused;
  39456. private _speedRatio;
  39457. private _loopAnimation;
  39458. private _isAdditive;
  39459. /**
  39460. * Gets or sets the unique id of the node
  39461. */
  39462. uniqueId: number;
  39463. /**
  39464. * This observable will notify when one animation have ended
  39465. */
  39466. onAnimationEndObservable: Observable<TargetedAnimation>;
  39467. /**
  39468. * Observer raised when one animation loops
  39469. */
  39470. onAnimationLoopObservable: Observable<TargetedAnimation>;
  39471. /**
  39472. * Observer raised when all animations have looped
  39473. */
  39474. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  39475. /**
  39476. * This observable will notify when all animations have ended.
  39477. */
  39478. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  39479. /**
  39480. * This observable will notify when all animations have paused.
  39481. */
  39482. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  39483. /**
  39484. * This observable will notify when all animations are playing.
  39485. */
  39486. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  39487. /**
  39488. * Gets the first frame
  39489. */
  39490. get from(): number;
  39491. /**
  39492. * Gets the last frame
  39493. */
  39494. get to(): number;
  39495. /**
  39496. * Define if the animations are started
  39497. */
  39498. get isStarted(): boolean;
  39499. /**
  39500. * Gets a value indicating that the current group is playing
  39501. */
  39502. get isPlaying(): boolean;
  39503. /**
  39504. * Gets or sets the speed ratio to use for all animations
  39505. */
  39506. get speedRatio(): number;
  39507. /**
  39508. * Gets or sets the speed ratio to use for all animations
  39509. */
  39510. set speedRatio(value: number);
  39511. /**
  39512. * Gets or sets if all animations should loop or not
  39513. */
  39514. get loopAnimation(): boolean;
  39515. set loopAnimation(value: boolean);
  39516. /**
  39517. * Gets or sets if all animations should be evaluated additively
  39518. */
  39519. get isAdditive(): boolean;
  39520. set isAdditive(value: boolean);
  39521. /**
  39522. * Gets the targeted animations for this animation group
  39523. */
  39524. get targetedAnimations(): Array<TargetedAnimation>;
  39525. /**
  39526. * returning the list of animatables controlled by this animation group.
  39527. */
  39528. get animatables(): Array<Animatable>;
  39529. /**
  39530. * Gets the list of target animations
  39531. */
  39532. get children(): TargetedAnimation[];
  39533. /**
  39534. * Instantiates a new Animation Group.
  39535. * This helps managing several animations at once.
  39536. * @see https://doc.babylonjs.com/how_to/group
  39537. * @param name Defines the name of the group
  39538. * @param scene Defines the scene the group belongs to
  39539. */
  39540. constructor(
  39541. /** The name of the animation group */
  39542. name: string, scene?: Nullable<Scene>);
  39543. /**
  39544. * Add an animation (with its target) in the group
  39545. * @param animation defines the animation we want to add
  39546. * @param target defines the target of the animation
  39547. * @returns the TargetedAnimation object
  39548. */
  39549. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  39550. /**
  39551. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  39552. * It can add constant keys at begin or end
  39553. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  39554. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  39555. * @returns the animation group
  39556. */
  39557. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  39558. private _animationLoopCount;
  39559. private _animationLoopFlags;
  39560. private _processLoop;
  39561. /**
  39562. * Start all animations on given targets
  39563. * @param loop defines if animations must loop
  39564. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  39565. * @param from defines the from key (optional)
  39566. * @param to defines the to key (optional)
  39567. * @param isAdditive defines the additive state for the resulting animatables (optional)
  39568. * @returns the current animation group
  39569. */
  39570. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  39571. /**
  39572. * Pause all animations
  39573. * @returns the animation group
  39574. */
  39575. pause(): AnimationGroup;
  39576. /**
  39577. * Play all animations to initial state
  39578. * This function will start() the animations if they were not started or will restart() them if they were paused
  39579. * @param loop defines if animations must loop
  39580. * @returns the animation group
  39581. */
  39582. play(loop?: boolean): AnimationGroup;
  39583. /**
  39584. * Reset all animations to initial state
  39585. * @returns the animation group
  39586. */
  39587. reset(): AnimationGroup;
  39588. /**
  39589. * Restart animations from key 0
  39590. * @returns the animation group
  39591. */
  39592. restart(): AnimationGroup;
  39593. /**
  39594. * Stop all animations
  39595. * @returns the animation group
  39596. */
  39597. stop(): AnimationGroup;
  39598. /**
  39599. * Set animation weight for all animatables
  39600. * @param weight defines the weight to use
  39601. * @return the animationGroup
  39602. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39603. */
  39604. setWeightForAllAnimatables(weight: number): AnimationGroup;
  39605. /**
  39606. * Synchronize and normalize all animatables with a source animatable
  39607. * @param root defines the root animatable to synchronize with
  39608. * @return the animationGroup
  39609. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  39610. */
  39611. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  39612. /**
  39613. * Goes to a specific frame in this animation group
  39614. * @param frame the frame number to go to
  39615. * @return the animationGroup
  39616. */
  39617. goToFrame(frame: number): AnimationGroup;
  39618. /**
  39619. * Dispose all associated resources
  39620. */
  39621. dispose(): void;
  39622. private _checkAnimationGroupEnded;
  39623. /**
  39624. * Clone the current animation group and returns a copy
  39625. * @param newName defines the name of the new group
  39626. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  39627. * @returns the new aniamtion group
  39628. */
  39629. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  39630. /**
  39631. * Serializes the animationGroup to an object
  39632. * @returns Serialized object
  39633. */
  39634. serialize(): any;
  39635. /**
  39636. * Returns a new AnimationGroup object parsed from the source provided.
  39637. * @param parsedAnimationGroup defines the source
  39638. * @param scene defines the scene that will receive the animationGroup
  39639. * @returns a new AnimationGroup
  39640. */
  39641. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  39642. /**
  39643. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  39644. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  39645. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  39646. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  39647. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  39648. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  39649. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  39650. */
  39651. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  39652. /**
  39653. * Returns the string "AnimationGroup"
  39654. * @returns "AnimationGroup"
  39655. */
  39656. getClassName(): string;
  39657. /**
  39658. * Creates a detailled string about the object
  39659. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  39660. * @returns a string representing the object
  39661. */
  39662. toString(fullDetails?: boolean): string;
  39663. }
  39664. }
  39665. declare module "babylonjs/scene" {
  39666. import { Nullable } from "babylonjs/types";
  39667. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  39668. import { Observable } from "babylonjs/Misc/observable";
  39669. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  39670. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  39671. import { Geometry } from "babylonjs/Meshes/geometry";
  39672. import { TransformNode } from "babylonjs/Meshes/transformNode";
  39673. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39675. import { Mesh } from "babylonjs/Meshes/mesh";
  39676. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  39677. import { Bone } from "babylonjs/Bones/bone";
  39678. import { Skeleton } from "babylonjs/Bones/skeleton";
  39679. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  39680. import { Camera } from "babylonjs/Cameras/camera";
  39681. import { AbstractScene } from "babylonjs/abstractScene";
  39682. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39683. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39684. import { Material } from "babylonjs/Materials/material";
  39685. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  39686. import { Effect } from "babylonjs/Materials/effect";
  39687. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  39688. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  39689. import { Light } from "babylonjs/Lights/light";
  39690. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  39691. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  39692. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  39693. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  39694. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39695. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  39696. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39697. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  39698. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  39699. import { Engine } from "babylonjs/Engines/engine";
  39700. import { Node } from "babylonjs/node";
  39701. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  39702. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  39703. import { WebRequest } from "babylonjs/Misc/webRequest";
  39704. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  39705. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  39706. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39707. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  39708. import { Plane } from "babylonjs/Maths/math.plane";
  39709. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  39710. import { Ray } from "babylonjs/Culling/ray";
  39711. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  39712. import { Animation } from "babylonjs/Animations/animation";
  39713. import { Animatable } from "babylonjs/Animations/animatable";
  39714. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  39715. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  39716. import { Collider } from "babylonjs/Collisions/collider";
  39717. /**
  39718. * Define an interface for all classes that will hold resources
  39719. */
  39720. export interface IDisposable {
  39721. /**
  39722. * Releases all held resources
  39723. */
  39724. dispose(): void;
  39725. }
  39726. /** Interface defining initialization parameters for Scene class */
  39727. export interface SceneOptions {
  39728. /**
  39729. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  39730. * It will improve performance when the number of geometries becomes important.
  39731. */
  39732. useGeometryUniqueIdsMap?: boolean;
  39733. /**
  39734. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  39735. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39736. */
  39737. useMaterialMeshMap?: boolean;
  39738. /**
  39739. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  39740. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  39741. */
  39742. useClonedMeshMap?: boolean;
  39743. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  39744. virtual?: boolean;
  39745. }
  39746. /**
  39747. * Represents a scene to be rendered by the engine.
  39748. * @see https://doc.babylonjs.com/features/scene
  39749. */
  39750. export class Scene extends AbstractScene implements IAnimatable {
  39751. /** The fog is deactivated */
  39752. static readonly FOGMODE_NONE: number;
  39753. /** The fog density is following an exponential function */
  39754. static readonly FOGMODE_EXP: number;
  39755. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  39756. static readonly FOGMODE_EXP2: number;
  39757. /** The fog density is following a linear function. */
  39758. static readonly FOGMODE_LINEAR: number;
  39759. /**
  39760. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  39761. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39762. */
  39763. static MinDeltaTime: number;
  39764. /**
  39765. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  39766. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39767. */
  39768. static MaxDeltaTime: number;
  39769. /**
  39770. * Factory used to create the default material.
  39771. * @param name The name of the material to create
  39772. * @param scene The scene to create the material for
  39773. * @returns The default material
  39774. */
  39775. static DefaultMaterialFactory(scene: Scene): Material;
  39776. /**
  39777. * Factory used to create the a collision coordinator.
  39778. * @returns The collision coordinator
  39779. */
  39780. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  39781. /** @hidden */
  39782. _inputManager: InputManager;
  39783. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  39784. cameraToUseForPointers: Nullable<Camera>;
  39785. /** @hidden */
  39786. readonly _isScene: boolean;
  39787. /** @hidden */
  39788. _blockEntityCollection: boolean;
  39789. /**
  39790. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  39791. */
  39792. autoClear: boolean;
  39793. /**
  39794. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  39795. */
  39796. autoClearDepthAndStencil: boolean;
  39797. /**
  39798. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  39799. */
  39800. clearColor: Color4;
  39801. /**
  39802. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  39803. */
  39804. ambientColor: Color3;
  39805. /**
  39806. * This is use to store the default BRDF lookup for PBR materials in your scene.
  39807. * It should only be one of the following (if not the default embedded one):
  39808. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  39809. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  39810. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  39811. * The material properties need to be setup according to the type of texture in use.
  39812. */
  39813. environmentBRDFTexture: BaseTexture;
  39814. /** @hidden */
  39815. protected _environmentTexture: Nullable<BaseTexture>;
  39816. /**
  39817. * Texture used in all pbr material as the reflection texture.
  39818. * As in the majority of the scene they are the same (exception for multi room and so on),
  39819. * this is easier to reference from here than from all the materials.
  39820. */
  39821. get environmentTexture(): Nullable<BaseTexture>;
  39822. /**
  39823. * Texture used in all pbr material as the reflection texture.
  39824. * As in the majority of the scene they are the same (exception for multi room and so on),
  39825. * this is easier to set here than in all the materials.
  39826. */
  39827. set environmentTexture(value: Nullable<BaseTexture>);
  39828. /** @hidden */
  39829. protected _environmentIntensity: number;
  39830. /**
  39831. * Intensity of the environment in all pbr material.
  39832. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39833. * As in the majority of the scene they are the same (exception for multi room and so on),
  39834. * this is easier to reference from here than from all the materials.
  39835. */
  39836. get environmentIntensity(): number;
  39837. /**
  39838. * Intensity of the environment in all pbr material.
  39839. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  39840. * As in the majority of the scene they are the same (exception for multi room and so on),
  39841. * this is easier to set here than in all the materials.
  39842. */
  39843. set environmentIntensity(value: number);
  39844. /** @hidden */
  39845. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39846. /**
  39847. * Default image processing configuration used either in the rendering
  39848. * Forward main pass or through the imageProcessingPostProcess if present.
  39849. * As in the majority of the scene they are the same (exception for multi camera),
  39850. * this is easier to reference from here than from all the materials and post process.
  39851. *
  39852. * No setter as we it is a shared configuration, you can set the values instead.
  39853. */
  39854. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  39855. private _forceWireframe;
  39856. /**
  39857. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  39858. */
  39859. set forceWireframe(value: boolean);
  39860. get forceWireframe(): boolean;
  39861. private _skipFrustumClipping;
  39862. /**
  39863. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  39864. */
  39865. set skipFrustumClipping(value: boolean);
  39866. get skipFrustumClipping(): boolean;
  39867. private _forcePointsCloud;
  39868. /**
  39869. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  39870. */
  39871. set forcePointsCloud(value: boolean);
  39872. get forcePointsCloud(): boolean;
  39873. /**
  39874. * Gets or sets the active clipplane 1
  39875. */
  39876. clipPlane: Nullable<Plane>;
  39877. /**
  39878. * Gets or sets the active clipplane 2
  39879. */
  39880. clipPlane2: Nullable<Plane>;
  39881. /**
  39882. * Gets or sets the active clipplane 3
  39883. */
  39884. clipPlane3: Nullable<Plane>;
  39885. /**
  39886. * Gets or sets the active clipplane 4
  39887. */
  39888. clipPlane4: Nullable<Plane>;
  39889. /**
  39890. * Gets or sets the active clipplane 5
  39891. */
  39892. clipPlane5: Nullable<Plane>;
  39893. /**
  39894. * Gets or sets the active clipplane 6
  39895. */
  39896. clipPlane6: Nullable<Plane>;
  39897. /**
  39898. * Gets or sets a boolean indicating if animations are enabled
  39899. */
  39900. animationsEnabled: boolean;
  39901. private _animationPropertiesOverride;
  39902. /**
  39903. * Gets or sets the animation properties override
  39904. */
  39905. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  39906. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  39907. /**
  39908. * Gets or sets a boolean indicating if a constant deltatime has to be used
  39909. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  39910. */
  39911. useConstantAnimationDeltaTime: boolean;
  39912. /**
  39913. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  39914. * Please note that it requires to run a ray cast through the scene on every frame
  39915. */
  39916. constantlyUpdateMeshUnderPointer: boolean;
  39917. /**
  39918. * Defines the HTML cursor to use when hovering over interactive elements
  39919. */
  39920. hoverCursor: string;
  39921. /**
  39922. * Defines the HTML default cursor to use (empty by default)
  39923. */
  39924. defaultCursor: string;
  39925. /**
  39926. * Defines whether cursors are handled by the scene.
  39927. */
  39928. doNotHandleCursors: boolean;
  39929. /**
  39930. * This is used to call preventDefault() on pointer down
  39931. * in order to block unwanted artifacts like system double clicks
  39932. */
  39933. preventDefaultOnPointerDown: boolean;
  39934. /**
  39935. * This is used to call preventDefault() on pointer up
  39936. * in order to block unwanted artifacts like system double clicks
  39937. */
  39938. preventDefaultOnPointerUp: boolean;
  39939. /**
  39940. * Gets or sets user defined metadata
  39941. */
  39942. metadata: any;
  39943. /**
  39944. * For internal use only. Please do not use.
  39945. */
  39946. reservedDataStore: any;
  39947. /**
  39948. * Gets the name of the plugin used to load this scene (null by default)
  39949. */
  39950. loadingPluginName: string;
  39951. /**
  39952. * Use this array to add regular expressions used to disable offline support for specific urls
  39953. */
  39954. disableOfflineSupportExceptionRules: RegExp[];
  39955. /**
  39956. * An event triggered when the scene is disposed.
  39957. */
  39958. onDisposeObservable: Observable<Scene>;
  39959. private _onDisposeObserver;
  39960. /** Sets a function to be executed when this scene is disposed. */
  39961. set onDispose(callback: () => void);
  39962. /**
  39963. * An event triggered before rendering the scene (right after animations and physics)
  39964. */
  39965. onBeforeRenderObservable: Observable<Scene>;
  39966. private _onBeforeRenderObserver;
  39967. /** Sets a function to be executed before rendering this scene */
  39968. set beforeRender(callback: Nullable<() => void>);
  39969. /**
  39970. * An event triggered after rendering the scene
  39971. */
  39972. onAfterRenderObservable: Observable<Scene>;
  39973. /**
  39974. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  39975. */
  39976. onAfterRenderCameraObservable: Observable<Camera>;
  39977. private _onAfterRenderObserver;
  39978. /** Sets a function to be executed after rendering this scene */
  39979. set afterRender(callback: Nullable<() => void>);
  39980. /**
  39981. * An event triggered before animating the scene
  39982. */
  39983. onBeforeAnimationsObservable: Observable<Scene>;
  39984. /**
  39985. * An event triggered after animations processing
  39986. */
  39987. onAfterAnimationsObservable: Observable<Scene>;
  39988. /**
  39989. * An event triggered before draw calls are ready to be sent
  39990. */
  39991. onBeforeDrawPhaseObservable: Observable<Scene>;
  39992. /**
  39993. * An event triggered after draw calls have been sent
  39994. */
  39995. onAfterDrawPhaseObservable: Observable<Scene>;
  39996. /**
  39997. * An event triggered when the scene is ready
  39998. */
  39999. onReadyObservable: Observable<Scene>;
  40000. /**
  40001. * An event triggered before rendering a camera
  40002. */
  40003. onBeforeCameraRenderObservable: Observable<Camera>;
  40004. private _onBeforeCameraRenderObserver;
  40005. /** Sets a function to be executed before rendering a camera*/
  40006. set beforeCameraRender(callback: () => void);
  40007. /**
  40008. * An event triggered after rendering a camera
  40009. */
  40010. onAfterCameraRenderObservable: Observable<Camera>;
  40011. private _onAfterCameraRenderObserver;
  40012. /** Sets a function to be executed after rendering a camera*/
  40013. set afterCameraRender(callback: () => void);
  40014. /**
  40015. * An event triggered when active meshes evaluation is about to start
  40016. */
  40017. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  40018. /**
  40019. * An event triggered when active meshes evaluation is done
  40020. */
  40021. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  40022. /**
  40023. * An event triggered when particles rendering is about to start
  40024. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40025. */
  40026. onBeforeParticlesRenderingObservable: Observable<Scene>;
  40027. /**
  40028. * An event triggered when particles rendering is done
  40029. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  40030. */
  40031. onAfterParticlesRenderingObservable: Observable<Scene>;
  40032. /**
  40033. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  40034. */
  40035. onDataLoadedObservable: Observable<Scene>;
  40036. /**
  40037. * An event triggered when a camera is created
  40038. */
  40039. onNewCameraAddedObservable: Observable<Camera>;
  40040. /**
  40041. * An event triggered when a camera is removed
  40042. */
  40043. onCameraRemovedObservable: Observable<Camera>;
  40044. /**
  40045. * An event triggered when a light is created
  40046. */
  40047. onNewLightAddedObservable: Observable<Light>;
  40048. /**
  40049. * An event triggered when a light is removed
  40050. */
  40051. onLightRemovedObservable: Observable<Light>;
  40052. /**
  40053. * An event triggered when a geometry is created
  40054. */
  40055. onNewGeometryAddedObservable: Observable<Geometry>;
  40056. /**
  40057. * An event triggered when a geometry is removed
  40058. */
  40059. onGeometryRemovedObservable: Observable<Geometry>;
  40060. /**
  40061. * An event triggered when a transform node is created
  40062. */
  40063. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  40064. /**
  40065. * An event triggered when a transform node is removed
  40066. */
  40067. onTransformNodeRemovedObservable: Observable<TransformNode>;
  40068. /**
  40069. * An event triggered when a mesh is created
  40070. */
  40071. onNewMeshAddedObservable: Observable<AbstractMesh>;
  40072. /**
  40073. * An event triggered when a mesh is removed
  40074. */
  40075. onMeshRemovedObservable: Observable<AbstractMesh>;
  40076. /**
  40077. * An event triggered when a skeleton is created
  40078. */
  40079. onNewSkeletonAddedObservable: Observable<Skeleton>;
  40080. /**
  40081. * An event triggered when a skeleton is removed
  40082. */
  40083. onSkeletonRemovedObservable: Observable<Skeleton>;
  40084. /**
  40085. * An event triggered when a material is created
  40086. */
  40087. onNewMaterialAddedObservable: Observable<Material>;
  40088. /**
  40089. * An event triggered when a material is removed
  40090. */
  40091. onMaterialRemovedObservable: Observable<Material>;
  40092. /**
  40093. * An event triggered when a texture is created
  40094. */
  40095. onNewTextureAddedObservable: Observable<BaseTexture>;
  40096. /**
  40097. * An event triggered when a texture is removed
  40098. */
  40099. onTextureRemovedObservable: Observable<BaseTexture>;
  40100. /**
  40101. * An event triggered when render targets are about to be rendered
  40102. * Can happen multiple times per frame.
  40103. */
  40104. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  40105. /**
  40106. * An event triggered when render targets were rendered.
  40107. * Can happen multiple times per frame.
  40108. */
  40109. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  40110. /**
  40111. * An event triggered before calculating deterministic simulation step
  40112. */
  40113. onBeforeStepObservable: Observable<Scene>;
  40114. /**
  40115. * An event triggered after calculating deterministic simulation step
  40116. */
  40117. onAfterStepObservable: Observable<Scene>;
  40118. /**
  40119. * An event triggered when the activeCamera property is updated
  40120. */
  40121. onActiveCameraChanged: Observable<Scene>;
  40122. /**
  40123. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  40124. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40125. * 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)
  40126. */
  40127. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40128. /**
  40129. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  40130. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  40131. * 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)
  40132. */
  40133. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  40134. /**
  40135. * This Observable will when a mesh has been imported into the scene.
  40136. */
  40137. onMeshImportedObservable: Observable<AbstractMesh>;
  40138. /**
  40139. * This Observable will when an animation file has been imported into the scene.
  40140. */
  40141. onAnimationFileImportedObservable: Observable<Scene>;
  40142. /**
  40143. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  40144. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  40145. */
  40146. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  40147. /** @hidden */
  40148. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  40149. /**
  40150. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  40151. */
  40152. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  40153. /**
  40154. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  40155. */
  40156. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  40157. /**
  40158. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  40159. */
  40160. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  40161. /** Callback called when a pointer move is detected */
  40162. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40163. /** Callback called when a pointer down is detected */
  40164. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  40165. /** Callback called when a pointer up is detected */
  40166. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  40167. /** Callback called when a pointer pick is detected */
  40168. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  40169. /**
  40170. * 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).
  40171. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  40172. */
  40173. onPrePointerObservable: Observable<PointerInfoPre>;
  40174. /**
  40175. * Observable event triggered each time an input event is received from the rendering canvas
  40176. */
  40177. onPointerObservable: Observable<PointerInfo>;
  40178. /**
  40179. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  40180. */
  40181. get unTranslatedPointer(): Vector2;
  40182. /**
  40183. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  40184. */
  40185. static get DragMovementThreshold(): number;
  40186. static set DragMovementThreshold(value: number);
  40187. /**
  40188. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  40189. */
  40190. static get LongPressDelay(): number;
  40191. static set LongPressDelay(value: number);
  40192. /**
  40193. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  40194. */
  40195. static get DoubleClickDelay(): number;
  40196. static set DoubleClickDelay(value: number);
  40197. /** If you need to check double click without raising a single click at first click, enable this flag */
  40198. static get ExclusiveDoubleClickMode(): boolean;
  40199. static set ExclusiveDoubleClickMode(value: boolean);
  40200. /** @hidden */
  40201. _mirroredCameraPosition: Nullable<Vector3>;
  40202. /**
  40203. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  40204. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  40205. */
  40206. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  40207. /**
  40208. * Observable event triggered each time an keyboard event is received from the hosting window
  40209. */
  40210. onKeyboardObservable: Observable<KeyboardInfo>;
  40211. private _useRightHandedSystem;
  40212. /**
  40213. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  40214. */
  40215. set useRightHandedSystem(value: boolean);
  40216. get useRightHandedSystem(): boolean;
  40217. private _timeAccumulator;
  40218. private _currentStepId;
  40219. private _currentInternalStep;
  40220. /**
  40221. * Sets the step Id used by deterministic lock step
  40222. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40223. * @param newStepId defines the step Id
  40224. */
  40225. setStepId(newStepId: number): void;
  40226. /**
  40227. * Gets the step Id used by deterministic lock step
  40228. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40229. * @returns the step Id
  40230. */
  40231. getStepId(): number;
  40232. /**
  40233. * Gets the internal step used by deterministic lock step
  40234. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40235. * @returns the internal step
  40236. */
  40237. getInternalStep(): number;
  40238. private _fogEnabled;
  40239. /**
  40240. * Gets or sets a boolean indicating if fog is enabled on this scene
  40241. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40242. * (Default is true)
  40243. */
  40244. set fogEnabled(value: boolean);
  40245. get fogEnabled(): boolean;
  40246. private _fogMode;
  40247. /**
  40248. * Gets or sets the fog mode to use
  40249. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40250. * | mode | value |
  40251. * | --- | --- |
  40252. * | FOGMODE_NONE | 0 |
  40253. * | FOGMODE_EXP | 1 |
  40254. * | FOGMODE_EXP2 | 2 |
  40255. * | FOGMODE_LINEAR | 3 |
  40256. */
  40257. set fogMode(value: number);
  40258. get fogMode(): number;
  40259. /**
  40260. * Gets or sets the fog color to use
  40261. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40262. * (Default is Color3(0.2, 0.2, 0.3))
  40263. */
  40264. fogColor: Color3;
  40265. /**
  40266. * Gets or sets the fog density to use
  40267. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40268. * (Default is 0.1)
  40269. */
  40270. fogDensity: number;
  40271. /**
  40272. * Gets or sets the fog start distance to use
  40273. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40274. * (Default is 0)
  40275. */
  40276. fogStart: number;
  40277. /**
  40278. * Gets or sets the fog end distance to use
  40279. * @see https://doc.babylonjs.com/babylon101/environment#fog
  40280. * (Default is 1000)
  40281. */
  40282. fogEnd: number;
  40283. /**
  40284. * Flag indicating that the frame buffer binding is handled by another component
  40285. */
  40286. prePass: boolean;
  40287. private _shadowsEnabled;
  40288. /**
  40289. * Gets or sets a boolean indicating if shadows are enabled on this scene
  40290. */
  40291. set shadowsEnabled(value: boolean);
  40292. get shadowsEnabled(): boolean;
  40293. private _lightsEnabled;
  40294. /**
  40295. * Gets or sets a boolean indicating if lights are enabled on this scene
  40296. */
  40297. set lightsEnabled(value: boolean);
  40298. get lightsEnabled(): boolean;
  40299. /** All of the active cameras added to this scene. */
  40300. activeCameras: Camera[];
  40301. /** @hidden */
  40302. _activeCamera: Nullable<Camera>;
  40303. /** Gets or sets the current active camera */
  40304. get activeCamera(): Nullable<Camera>;
  40305. set activeCamera(value: Nullable<Camera>);
  40306. private _defaultMaterial;
  40307. /** The default material used on meshes when no material is affected */
  40308. get defaultMaterial(): Material;
  40309. /** The default material used on meshes when no material is affected */
  40310. set defaultMaterial(value: Material);
  40311. private _texturesEnabled;
  40312. /**
  40313. * Gets or sets a boolean indicating if textures are enabled on this scene
  40314. */
  40315. set texturesEnabled(value: boolean);
  40316. get texturesEnabled(): boolean;
  40317. /**
  40318. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  40319. */
  40320. physicsEnabled: boolean;
  40321. /**
  40322. * Gets or sets a boolean indicating if particles are enabled on this scene
  40323. */
  40324. particlesEnabled: boolean;
  40325. /**
  40326. * Gets or sets a boolean indicating if sprites are enabled on this scene
  40327. */
  40328. spritesEnabled: boolean;
  40329. private _skeletonsEnabled;
  40330. /**
  40331. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  40332. */
  40333. set skeletonsEnabled(value: boolean);
  40334. get skeletonsEnabled(): boolean;
  40335. /**
  40336. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  40337. */
  40338. lensFlaresEnabled: boolean;
  40339. /**
  40340. * Gets or sets a boolean indicating if collisions are enabled on this scene
  40341. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40342. */
  40343. collisionsEnabled: boolean;
  40344. private _collisionCoordinator;
  40345. /** @hidden */
  40346. get collisionCoordinator(): ICollisionCoordinator;
  40347. /**
  40348. * Defines the gravity applied to this scene (used only for collisions)
  40349. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  40350. */
  40351. gravity: Vector3;
  40352. /**
  40353. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  40354. */
  40355. postProcessesEnabled: boolean;
  40356. /**
  40357. * The list of postprocesses added to the scene
  40358. */
  40359. postProcesses: PostProcess[];
  40360. /**
  40361. * Gets the current postprocess manager
  40362. */
  40363. postProcessManager: PostProcessManager;
  40364. /**
  40365. * Gets or sets a boolean indicating if render targets are enabled on this scene
  40366. */
  40367. renderTargetsEnabled: boolean;
  40368. /**
  40369. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  40370. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  40371. */
  40372. dumpNextRenderTargets: boolean;
  40373. /**
  40374. * The list of user defined render targets added to the scene
  40375. */
  40376. customRenderTargets: RenderTargetTexture[];
  40377. /**
  40378. * Defines if texture loading must be delayed
  40379. * If true, textures will only be loaded when they need to be rendered
  40380. */
  40381. useDelayedTextureLoading: boolean;
  40382. /**
  40383. * Gets the list of meshes imported to the scene through SceneLoader
  40384. */
  40385. importedMeshesFiles: String[];
  40386. /**
  40387. * Gets or sets a boolean indicating if probes are enabled on this scene
  40388. */
  40389. probesEnabled: boolean;
  40390. /**
  40391. * Gets or sets the current offline provider to use to store scene data
  40392. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  40393. */
  40394. offlineProvider: IOfflineProvider;
  40395. /**
  40396. * Gets or sets the action manager associated with the scene
  40397. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  40398. */
  40399. actionManager: AbstractActionManager;
  40400. private _meshesForIntersections;
  40401. /**
  40402. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  40403. */
  40404. proceduralTexturesEnabled: boolean;
  40405. private _engine;
  40406. private _totalVertices;
  40407. /** @hidden */
  40408. _activeIndices: PerfCounter;
  40409. /** @hidden */
  40410. _activeParticles: PerfCounter;
  40411. /** @hidden */
  40412. _activeBones: PerfCounter;
  40413. private _animationRatio;
  40414. /** @hidden */
  40415. _animationTimeLast: number;
  40416. /** @hidden */
  40417. _animationTime: number;
  40418. /**
  40419. * Gets or sets a general scale for animation speed
  40420. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  40421. */
  40422. animationTimeScale: number;
  40423. /** @hidden */
  40424. _cachedMaterial: Nullable<Material>;
  40425. /** @hidden */
  40426. _cachedEffect: Nullable<Effect>;
  40427. /** @hidden */
  40428. _cachedVisibility: Nullable<number>;
  40429. private _renderId;
  40430. private _frameId;
  40431. private _executeWhenReadyTimeoutId;
  40432. private _intermediateRendering;
  40433. private _viewUpdateFlag;
  40434. private _projectionUpdateFlag;
  40435. /** @hidden */
  40436. _toBeDisposed: Nullable<IDisposable>[];
  40437. private _activeRequests;
  40438. /** @hidden */
  40439. _pendingData: any[];
  40440. private _isDisposed;
  40441. /**
  40442. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  40443. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  40444. */
  40445. dispatchAllSubMeshesOfActiveMeshes: boolean;
  40446. private _activeMeshes;
  40447. private _processedMaterials;
  40448. private _renderTargets;
  40449. /** @hidden */
  40450. _activeParticleSystems: SmartArray<IParticleSystem>;
  40451. private _activeSkeletons;
  40452. private _softwareSkinnedMeshes;
  40453. private _renderingManager;
  40454. /** @hidden */
  40455. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  40456. private _transformMatrix;
  40457. private _sceneUbo;
  40458. /** @hidden */
  40459. _viewMatrix: Matrix;
  40460. private _projectionMatrix;
  40461. /** @hidden */
  40462. _forcedViewPosition: Nullable<Vector3>;
  40463. /** @hidden */
  40464. _frustumPlanes: Plane[];
  40465. /**
  40466. * Gets the list of frustum planes (built from the active camera)
  40467. */
  40468. get frustumPlanes(): Plane[];
  40469. /**
  40470. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  40471. * This is useful if there are more lights that the maximum simulteanous authorized
  40472. */
  40473. requireLightSorting: boolean;
  40474. /** @hidden */
  40475. readonly useMaterialMeshMap: boolean;
  40476. /** @hidden */
  40477. readonly useClonedMeshMap: boolean;
  40478. private _externalData;
  40479. private _uid;
  40480. /**
  40481. * @hidden
  40482. * Backing store of defined scene components.
  40483. */
  40484. _components: ISceneComponent[];
  40485. /**
  40486. * @hidden
  40487. * Backing store of defined scene components.
  40488. */
  40489. _serializableComponents: ISceneSerializableComponent[];
  40490. /**
  40491. * List of components to register on the next registration step.
  40492. */
  40493. private _transientComponents;
  40494. /**
  40495. * Registers the transient components if needed.
  40496. */
  40497. private _registerTransientComponents;
  40498. /**
  40499. * @hidden
  40500. * Add a component to the scene.
  40501. * Note that the ccomponent could be registered on th next frame if this is called after
  40502. * the register component stage.
  40503. * @param component Defines the component to add to the scene
  40504. */
  40505. _addComponent(component: ISceneComponent): void;
  40506. /**
  40507. * @hidden
  40508. * Gets a component from the scene.
  40509. * @param name defines the name of the component to retrieve
  40510. * @returns the component or null if not present
  40511. */
  40512. _getComponent(name: string): Nullable<ISceneComponent>;
  40513. /**
  40514. * @hidden
  40515. * Defines the actions happening before camera updates.
  40516. */
  40517. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  40518. /**
  40519. * @hidden
  40520. * Defines the actions happening before clear the canvas.
  40521. */
  40522. _beforeClearStage: Stage<SimpleStageAction>;
  40523. /**
  40524. * @hidden
  40525. * Defines the actions when collecting render targets for the frame.
  40526. */
  40527. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40528. /**
  40529. * @hidden
  40530. * Defines the actions happening for one camera in the frame.
  40531. */
  40532. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  40533. /**
  40534. * @hidden
  40535. * Defines the actions happening during the per mesh ready checks.
  40536. */
  40537. _isReadyForMeshStage: Stage<MeshStageAction>;
  40538. /**
  40539. * @hidden
  40540. * Defines the actions happening before evaluate active mesh checks.
  40541. */
  40542. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  40543. /**
  40544. * @hidden
  40545. * Defines the actions happening during the evaluate sub mesh checks.
  40546. */
  40547. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  40548. /**
  40549. * @hidden
  40550. * Defines the actions happening during the active mesh stage.
  40551. */
  40552. _activeMeshStage: Stage<ActiveMeshStageAction>;
  40553. /**
  40554. * @hidden
  40555. * Defines the actions happening during the per camera render target step.
  40556. */
  40557. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  40558. /**
  40559. * @hidden
  40560. * Defines the actions happening just before the active camera is drawing.
  40561. */
  40562. _beforeCameraDrawStage: Stage<CameraStageAction>;
  40563. /**
  40564. * @hidden
  40565. * Defines the actions happening just before a render target is drawing.
  40566. */
  40567. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40568. /**
  40569. * @hidden
  40570. * Defines the actions happening just before a rendering group is drawing.
  40571. */
  40572. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40573. /**
  40574. * @hidden
  40575. * Defines the actions happening just before a mesh is drawing.
  40576. */
  40577. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40578. /**
  40579. * @hidden
  40580. * Defines the actions happening just after a mesh has been drawn.
  40581. */
  40582. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  40583. /**
  40584. * @hidden
  40585. * Defines the actions happening just after a rendering group has been drawn.
  40586. */
  40587. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  40588. /**
  40589. * @hidden
  40590. * Defines the actions happening just after the active camera has been drawn.
  40591. */
  40592. _afterCameraDrawStage: Stage<CameraStageAction>;
  40593. /**
  40594. * @hidden
  40595. * Defines the actions happening just after a render target has been drawn.
  40596. */
  40597. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  40598. /**
  40599. * @hidden
  40600. * Defines the actions happening just after rendering all cameras and computing intersections.
  40601. */
  40602. _afterRenderStage: Stage<SimpleStageAction>;
  40603. /**
  40604. * @hidden
  40605. * Defines the actions happening when a pointer move event happens.
  40606. */
  40607. _pointerMoveStage: Stage<PointerMoveStageAction>;
  40608. /**
  40609. * @hidden
  40610. * Defines the actions happening when a pointer down event happens.
  40611. */
  40612. _pointerDownStage: Stage<PointerUpDownStageAction>;
  40613. /**
  40614. * @hidden
  40615. * Defines the actions happening when a pointer up event happens.
  40616. */
  40617. _pointerUpStage: Stage<PointerUpDownStageAction>;
  40618. /**
  40619. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  40620. */
  40621. private geometriesByUniqueId;
  40622. /**
  40623. * Creates a new Scene
  40624. * @param engine defines the engine to use to render this scene
  40625. * @param options defines the scene options
  40626. */
  40627. constructor(engine: Engine, options?: SceneOptions);
  40628. /**
  40629. * Gets a string idenfifying the name of the class
  40630. * @returns "Scene" string
  40631. */
  40632. getClassName(): string;
  40633. private _defaultMeshCandidates;
  40634. /**
  40635. * @hidden
  40636. */
  40637. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  40638. private _defaultSubMeshCandidates;
  40639. /**
  40640. * @hidden
  40641. */
  40642. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  40643. /**
  40644. * Sets the default candidate providers for the scene.
  40645. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  40646. * and getCollidingSubMeshCandidates to their default function
  40647. */
  40648. setDefaultCandidateProviders(): void;
  40649. /**
  40650. * Gets the mesh that is currently under the pointer
  40651. */
  40652. get meshUnderPointer(): Nullable<AbstractMesh>;
  40653. /**
  40654. * Gets or sets the current on-screen X position of the pointer
  40655. */
  40656. get pointerX(): number;
  40657. set pointerX(value: number);
  40658. /**
  40659. * Gets or sets the current on-screen Y position of the pointer
  40660. */
  40661. get pointerY(): number;
  40662. set pointerY(value: number);
  40663. /**
  40664. * Gets the cached material (ie. the latest rendered one)
  40665. * @returns the cached material
  40666. */
  40667. getCachedMaterial(): Nullable<Material>;
  40668. /**
  40669. * Gets the cached effect (ie. the latest rendered one)
  40670. * @returns the cached effect
  40671. */
  40672. getCachedEffect(): Nullable<Effect>;
  40673. /**
  40674. * Gets the cached visibility state (ie. the latest rendered one)
  40675. * @returns the cached visibility state
  40676. */
  40677. getCachedVisibility(): Nullable<number>;
  40678. /**
  40679. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  40680. * @param material defines the current material
  40681. * @param effect defines the current effect
  40682. * @param visibility defines the current visibility state
  40683. * @returns true if one parameter is not cached
  40684. */
  40685. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  40686. /**
  40687. * Gets the engine associated with the scene
  40688. * @returns an Engine
  40689. */
  40690. getEngine(): Engine;
  40691. /**
  40692. * Gets the total number of vertices rendered per frame
  40693. * @returns the total number of vertices rendered per frame
  40694. */
  40695. getTotalVertices(): number;
  40696. /**
  40697. * Gets the performance counter for total vertices
  40698. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40699. */
  40700. get totalVerticesPerfCounter(): PerfCounter;
  40701. /**
  40702. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  40703. * @returns the total number of active indices rendered per frame
  40704. */
  40705. getActiveIndices(): number;
  40706. /**
  40707. * Gets the performance counter for active indices
  40708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40709. */
  40710. get totalActiveIndicesPerfCounter(): PerfCounter;
  40711. /**
  40712. * Gets the total number of active particles rendered per frame
  40713. * @returns the total number of active particles rendered per frame
  40714. */
  40715. getActiveParticles(): number;
  40716. /**
  40717. * Gets the performance counter for active particles
  40718. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40719. */
  40720. get activeParticlesPerfCounter(): PerfCounter;
  40721. /**
  40722. * Gets the total number of active bones rendered per frame
  40723. * @returns the total number of active bones rendered per frame
  40724. */
  40725. getActiveBones(): number;
  40726. /**
  40727. * Gets the performance counter for active bones
  40728. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  40729. */
  40730. get activeBonesPerfCounter(): PerfCounter;
  40731. /**
  40732. * Gets the array of active meshes
  40733. * @returns an array of AbstractMesh
  40734. */
  40735. getActiveMeshes(): SmartArray<AbstractMesh>;
  40736. /**
  40737. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  40738. * @returns a number
  40739. */
  40740. getAnimationRatio(): number;
  40741. /**
  40742. * Gets an unique Id for the current render phase
  40743. * @returns a number
  40744. */
  40745. getRenderId(): number;
  40746. /**
  40747. * Gets an unique Id for the current frame
  40748. * @returns a number
  40749. */
  40750. getFrameId(): number;
  40751. /** Call this function if you want to manually increment the render Id*/
  40752. incrementRenderId(): void;
  40753. private _createUbo;
  40754. /**
  40755. * Use this method to simulate a pointer move on a mesh
  40756. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40757. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40758. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40759. * @returns the current scene
  40760. */
  40761. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40762. /**
  40763. * Use this method to simulate a pointer down on a mesh
  40764. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40765. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40766. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40767. * @returns the current scene
  40768. */
  40769. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  40770. /**
  40771. * Use this method to simulate a pointer up on a mesh
  40772. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40773. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40774. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40775. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40776. * @returns the current scene
  40777. */
  40778. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  40779. /**
  40780. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40781. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40782. * @returns true if the pointer was captured
  40783. */
  40784. isPointerCaptured(pointerId?: number): boolean;
  40785. /**
  40786. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40787. * @param attachUp defines if you want to attach events to pointerup
  40788. * @param attachDown defines if you want to attach events to pointerdown
  40789. * @param attachMove defines if you want to attach events to pointermove
  40790. */
  40791. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  40792. /** Detaches all event handlers*/
  40793. detachControl(): void;
  40794. /**
  40795. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  40796. * Delay loaded resources are not taking in account
  40797. * @return true if all required resources are ready
  40798. */
  40799. isReady(): boolean;
  40800. /** Resets all cached information relative to material (including effect and visibility) */
  40801. resetCachedMaterial(): void;
  40802. /**
  40803. * Registers a function to be called before every frame render
  40804. * @param func defines the function to register
  40805. */
  40806. registerBeforeRender(func: () => void): void;
  40807. /**
  40808. * Unregisters a function called before every frame render
  40809. * @param func defines the function to unregister
  40810. */
  40811. unregisterBeforeRender(func: () => void): void;
  40812. /**
  40813. * Registers a function to be called after every frame render
  40814. * @param func defines the function to register
  40815. */
  40816. registerAfterRender(func: () => void): void;
  40817. /**
  40818. * Unregisters a function called after every frame render
  40819. * @param func defines the function to unregister
  40820. */
  40821. unregisterAfterRender(func: () => void): void;
  40822. private _executeOnceBeforeRender;
  40823. /**
  40824. * The provided function will run before render once and will be disposed afterwards.
  40825. * A timeout delay can be provided so that the function will be executed in N ms.
  40826. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  40827. * @param func The function to be executed.
  40828. * @param timeout optional delay in ms
  40829. */
  40830. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  40831. /** @hidden */
  40832. _addPendingData(data: any): void;
  40833. /** @hidden */
  40834. _removePendingData(data: any): void;
  40835. /**
  40836. * Returns the number of items waiting to be loaded
  40837. * @returns the number of items waiting to be loaded
  40838. */
  40839. getWaitingItemsCount(): number;
  40840. /**
  40841. * Returns a boolean indicating if the scene is still loading data
  40842. */
  40843. get isLoading(): boolean;
  40844. /**
  40845. * Registers a function to be executed when the scene is ready
  40846. * @param {Function} func - the function to be executed
  40847. */
  40848. executeWhenReady(func: () => void): void;
  40849. /**
  40850. * Returns a promise that resolves when the scene is ready
  40851. * @returns A promise that resolves when the scene is ready
  40852. */
  40853. whenReadyAsync(): Promise<void>;
  40854. /** @hidden */
  40855. _checkIsReady(): void;
  40856. /**
  40857. * Gets all animatable attached to the scene
  40858. */
  40859. get animatables(): Animatable[];
  40860. /**
  40861. * Resets the last animation time frame.
  40862. * Useful to override when animations start running when loading a scene for the first time.
  40863. */
  40864. resetLastAnimationTimeFrame(): void;
  40865. /**
  40866. * Gets the current view matrix
  40867. * @returns a Matrix
  40868. */
  40869. getViewMatrix(): Matrix;
  40870. /**
  40871. * Gets the current projection matrix
  40872. * @returns a Matrix
  40873. */
  40874. getProjectionMatrix(): Matrix;
  40875. /**
  40876. * Gets the current transform matrix
  40877. * @returns a Matrix made of View * Projection
  40878. */
  40879. getTransformMatrix(): Matrix;
  40880. /**
  40881. * Sets the current transform matrix
  40882. * @param viewL defines the View matrix to use
  40883. * @param projectionL defines the Projection matrix to use
  40884. * @param viewR defines the right View matrix to use (if provided)
  40885. * @param projectionR defines the right Projection matrix to use (if provided)
  40886. */
  40887. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  40888. /**
  40889. * Gets the uniform buffer used to store scene data
  40890. * @returns a UniformBuffer
  40891. */
  40892. getSceneUniformBuffer(): UniformBuffer;
  40893. /**
  40894. * Gets an unique (relatively to the current scene) Id
  40895. * @returns an unique number for the scene
  40896. */
  40897. getUniqueId(): number;
  40898. /**
  40899. * Add a mesh to the list of scene's meshes
  40900. * @param newMesh defines the mesh to add
  40901. * @param recursive if all child meshes should also be added to the scene
  40902. */
  40903. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  40904. /**
  40905. * Remove a mesh for the list of scene's meshes
  40906. * @param toRemove defines the mesh to remove
  40907. * @param recursive if all child meshes should also be removed from the scene
  40908. * @returns the index where the mesh was in the mesh list
  40909. */
  40910. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  40911. /**
  40912. * Add a transform node to the list of scene's transform nodes
  40913. * @param newTransformNode defines the transform node to add
  40914. */
  40915. addTransformNode(newTransformNode: TransformNode): void;
  40916. /**
  40917. * Remove a transform node for the list of scene's transform nodes
  40918. * @param toRemove defines the transform node to remove
  40919. * @returns the index where the transform node was in the transform node list
  40920. */
  40921. removeTransformNode(toRemove: TransformNode): number;
  40922. /**
  40923. * Remove a skeleton for the list of scene's skeletons
  40924. * @param toRemove defines the skeleton to remove
  40925. * @returns the index where the skeleton was in the skeleton list
  40926. */
  40927. removeSkeleton(toRemove: Skeleton): number;
  40928. /**
  40929. * Remove a morph target for the list of scene's morph targets
  40930. * @param toRemove defines the morph target to remove
  40931. * @returns the index where the morph target was in the morph target list
  40932. */
  40933. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  40934. /**
  40935. * Remove a light for the list of scene's lights
  40936. * @param toRemove defines the light to remove
  40937. * @returns the index where the light was in the light list
  40938. */
  40939. removeLight(toRemove: Light): number;
  40940. /**
  40941. * Remove a camera for the list of scene's cameras
  40942. * @param toRemove defines the camera to remove
  40943. * @returns the index where the camera was in the camera list
  40944. */
  40945. removeCamera(toRemove: Camera): number;
  40946. /**
  40947. * Remove a particle system for the list of scene's particle systems
  40948. * @param toRemove defines the particle system to remove
  40949. * @returns the index where the particle system was in the particle system list
  40950. */
  40951. removeParticleSystem(toRemove: IParticleSystem): number;
  40952. /**
  40953. * Remove a animation for the list of scene's animations
  40954. * @param toRemove defines the animation to remove
  40955. * @returns the index where the animation was in the animation list
  40956. */
  40957. removeAnimation(toRemove: Animation): number;
  40958. /**
  40959. * Will stop the animation of the given target
  40960. * @param target - the target
  40961. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  40962. * @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)
  40963. */
  40964. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  40965. /**
  40966. * Removes the given animation group from this scene.
  40967. * @param toRemove The animation group to remove
  40968. * @returns The index of the removed animation group
  40969. */
  40970. removeAnimationGroup(toRemove: AnimationGroup): number;
  40971. /**
  40972. * Removes the given multi-material from this scene.
  40973. * @param toRemove The multi-material to remove
  40974. * @returns The index of the removed multi-material
  40975. */
  40976. removeMultiMaterial(toRemove: MultiMaterial): number;
  40977. /**
  40978. * Removes the given material from this scene.
  40979. * @param toRemove The material to remove
  40980. * @returns The index of the removed material
  40981. */
  40982. removeMaterial(toRemove: Material): number;
  40983. /**
  40984. * Removes the given action manager from this scene.
  40985. * @param toRemove The action manager to remove
  40986. * @returns The index of the removed action manager
  40987. */
  40988. removeActionManager(toRemove: AbstractActionManager): number;
  40989. /**
  40990. * Removes the given texture from this scene.
  40991. * @param toRemove The texture to remove
  40992. * @returns The index of the removed texture
  40993. */
  40994. removeTexture(toRemove: BaseTexture): number;
  40995. /**
  40996. * Adds the given light to this scene
  40997. * @param newLight The light to add
  40998. */
  40999. addLight(newLight: Light): void;
  41000. /**
  41001. * Sorts the list list based on light priorities
  41002. */
  41003. sortLightsByPriority(): void;
  41004. /**
  41005. * Adds the given camera to this scene
  41006. * @param newCamera The camera to add
  41007. */
  41008. addCamera(newCamera: Camera): void;
  41009. /**
  41010. * Adds the given skeleton to this scene
  41011. * @param newSkeleton The skeleton to add
  41012. */
  41013. addSkeleton(newSkeleton: Skeleton): void;
  41014. /**
  41015. * Adds the given particle system to this scene
  41016. * @param newParticleSystem The particle system to add
  41017. */
  41018. addParticleSystem(newParticleSystem: IParticleSystem): void;
  41019. /**
  41020. * Adds the given animation to this scene
  41021. * @param newAnimation The animation to add
  41022. */
  41023. addAnimation(newAnimation: Animation): void;
  41024. /**
  41025. * Adds the given animation group to this scene.
  41026. * @param newAnimationGroup The animation group to add
  41027. */
  41028. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  41029. /**
  41030. * Adds the given multi-material to this scene
  41031. * @param newMultiMaterial The multi-material to add
  41032. */
  41033. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  41034. /**
  41035. * Adds the given material to this scene
  41036. * @param newMaterial The material to add
  41037. */
  41038. addMaterial(newMaterial: Material): void;
  41039. /**
  41040. * Adds the given morph target to this scene
  41041. * @param newMorphTargetManager The morph target to add
  41042. */
  41043. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  41044. /**
  41045. * Adds the given geometry to this scene
  41046. * @param newGeometry The geometry to add
  41047. */
  41048. addGeometry(newGeometry: Geometry): void;
  41049. /**
  41050. * Adds the given action manager to this scene
  41051. * @param newActionManager The action manager to add
  41052. */
  41053. addActionManager(newActionManager: AbstractActionManager): void;
  41054. /**
  41055. * Adds the given texture to this scene.
  41056. * @param newTexture The texture to add
  41057. */
  41058. addTexture(newTexture: BaseTexture): void;
  41059. /**
  41060. * Switch active camera
  41061. * @param newCamera defines the new active camera
  41062. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  41063. */
  41064. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  41065. /**
  41066. * sets the active camera of the scene using its ID
  41067. * @param id defines the camera's ID
  41068. * @return the new active camera or null if none found.
  41069. */
  41070. setActiveCameraByID(id: string): Nullable<Camera>;
  41071. /**
  41072. * sets the active camera of the scene using its name
  41073. * @param name defines the camera's name
  41074. * @returns the new active camera or null if none found.
  41075. */
  41076. setActiveCameraByName(name: string): Nullable<Camera>;
  41077. /**
  41078. * get an animation group using its name
  41079. * @param name defines the material's name
  41080. * @return the animation group or null if none found.
  41081. */
  41082. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  41083. /**
  41084. * Get a material using its unique id
  41085. * @param uniqueId defines the material's unique id
  41086. * @return the material or null if none found.
  41087. */
  41088. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  41089. /**
  41090. * get a material using its id
  41091. * @param id defines the material's ID
  41092. * @return the material or null if none found.
  41093. */
  41094. getMaterialByID(id: string): Nullable<Material>;
  41095. /**
  41096. * Gets a the last added material using a given id
  41097. * @param id defines the material's ID
  41098. * @return the last material with the given id or null if none found.
  41099. */
  41100. getLastMaterialByID(id: string): Nullable<Material>;
  41101. /**
  41102. * Gets a material using its name
  41103. * @param name defines the material's name
  41104. * @return the material or null if none found.
  41105. */
  41106. getMaterialByName(name: string): Nullable<Material>;
  41107. /**
  41108. * Get a texture using its unique id
  41109. * @param uniqueId defines the texture's unique id
  41110. * @return the texture or null if none found.
  41111. */
  41112. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  41113. /**
  41114. * Gets a camera using its id
  41115. * @param id defines the id to look for
  41116. * @returns the camera or null if not found
  41117. */
  41118. getCameraByID(id: string): Nullable<Camera>;
  41119. /**
  41120. * Gets a camera using its unique id
  41121. * @param uniqueId defines the unique id to look for
  41122. * @returns the camera or null if not found
  41123. */
  41124. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  41125. /**
  41126. * Gets a camera using its name
  41127. * @param name defines the camera's name
  41128. * @return the camera or null if none found.
  41129. */
  41130. getCameraByName(name: string): Nullable<Camera>;
  41131. /**
  41132. * Gets a bone using its id
  41133. * @param id defines the bone's id
  41134. * @return the bone or null if not found
  41135. */
  41136. getBoneByID(id: string): Nullable<Bone>;
  41137. /**
  41138. * Gets a bone using its id
  41139. * @param name defines the bone's name
  41140. * @return the bone or null if not found
  41141. */
  41142. getBoneByName(name: string): Nullable<Bone>;
  41143. /**
  41144. * Gets a light node using its name
  41145. * @param name defines the the light's name
  41146. * @return the light or null if none found.
  41147. */
  41148. getLightByName(name: string): Nullable<Light>;
  41149. /**
  41150. * Gets a light node using its id
  41151. * @param id defines the light's id
  41152. * @return the light or null if none found.
  41153. */
  41154. getLightByID(id: string): Nullable<Light>;
  41155. /**
  41156. * Gets a light node using its scene-generated unique ID
  41157. * @param uniqueId defines the light's unique id
  41158. * @return the light or null if none found.
  41159. */
  41160. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  41161. /**
  41162. * Gets a particle system by id
  41163. * @param id defines the particle system id
  41164. * @return the corresponding system or null if none found
  41165. */
  41166. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  41167. /**
  41168. * Gets a geometry using its ID
  41169. * @param id defines the geometry's id
  41170. * @return the geometry or null if none found.
  41171. */
  41172. getGeometryByID(id: string): Nullable<Geometry>;
  41173. private _getGeometryByUniqueID;
  41174. /**
  41175. * Add a new geometry to this scene
  41176. * @param geometry defines the geometry to be added to the scene.
  41177. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  41178. * @return a boolean defining if the geometry was added or not
  41179. */
  41180. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  41181. /**
  41182. * Removes an existing geometry
  41183. * @param geometry defines the geometry to be removed from the scene
  41184. * @return a boolean defining if the geometry was removed or not
  41185. */
  41186. removeGeometry(geometry: Geometry): boolean;
  41187. /**
  41188. * Gets the list of geometries attached to the scene
  41189. * @returns an array of Geometry
  41190. */
  41191. getGeometries(): Geometry[];
  41192. /**
  41193. * Gets the first added mesh found of a given ID
  41194. * @param id defines the id to search for
  41195. * @return the mesh found or null if not found at all
  41196. */
  41197. getMeshByID(id: string): Nullable<AbstractMesh>;
  41198. /**
  41199. * Gets a list of meshes using their id
  41200. * @param id defines the id to search for
  41201. * @returns a list of meshes
  41202. */
  41203. getMeshesByID(id: string): Array<AbstractMesh>;
  41204. /**
  41205. * Gets the first added transform node found of a given ID
  41206. * @param id defines the id to search for
  41207. * @return the found transform node or null if not found at all.
  41208. */
  41209. getTransformNodeByID(id: string): Nullable<TransformNode>;
  41210. /**
  41211. * Gets a transform node with its auto-generated unique id
  41212. * @param uniqueId efines the unique id to search for
  41213. * @return the found transform node or null if not found at all.
  41214. */
  41215. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  41216. /**
  41217. * Gets a list of transform nodes using their id
  41218. * @param id defines the id to search for
  41219. * @returns a list of transform nodes
  41220. */
  41221. getTransformNodesByID(id: string): Array<TransformNode>;
  41222. /**
  41223. * Gets a mesh with its auto-generated unique id
  41224. * @param uniqueId defines the unique id to search for
  41225. * @return the found mesh or null if not found at all.
  41226. */
  41227. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  41228. /**
  41229. * Gets a the last added mesh using a given id
  41230. * @param id defines the id to search for
  41231. * @return the found mesh or null if not found at all.
  41232. */
  41233. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  41234. /**
  41235. * Gets a the last added node (Mesh, Camera, Light) using a given id
  41236. * @param id defines the id to search for
  41237. * @return the found node or null if not found at all
  41238. */
  41239. getLastEntryByID(id: string): Nullable<Node>;
  41240. /**
  41241. * Gets a node (Mesh, Camera, Light) using a given id
  41242. * @param id defines the id to search for
  41243. * @return the found node or null if not found at all
  41244. */
  41245. getNodeByID(id: string): Nullable<Node>;
  41246. /**
  41247. * Gets a node (Mesh, Camera, Light) using a given name
  41248. * @param name defines the name to search for
  41249. * @return the found node or null if not found at all.
  41250. */
  41251. getNodeByName(name: string): Nullable<Node>;
  41252. /**
  41253. * Gets a mesh using a given name
  41254. * @param name defines the name to search for
  41255. * @return the found mesh or null if not found at all.
  41256. */
  41257. getMeshByName(name: string): Nullable<AbstractMesh>;
  41258. /**
  41259. * Gets a transform node using a given name
  41260. * @param name defines the name to search for
  41261. * @return the found transform node or null if not found at all.
  41262. */
  41263. getTransformNodeByName(name: string): Nullable<TransformNode>;
  41264. /**
  41265. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  41266. * @param id defines the id to search for
  41267. * @return the found skeleton or null if not found at all.
  41268. */
  41269. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  41270. /**
  41271. * Gets a skeleton using a given auto generated unique id
  41272. * @param uniqueId defines the unique id to search for
  41273. * @return the found skeleton or null if not found at all.
  41274. */
  41275. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  41276. /**
  41277. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  41278. * @param id defines the id to search for
  41279. * @return the found skeleton or null if not found at all.
  41280. */
  41281. getSkeletonById(id: string): Nullable<Skeleton>;
  41282. /**
  41283. * Gets a skeleton using a given name
  41284. * @param name defines the name to search for
  41285. * @return the found skeleton or null if not found at all.
  41286. */
  41287. getSkeletonByName(name: string): Nullable<Skeleton>;
  41288. /**
  41289. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  41290. * @param id defines the id to search for
  41291. * @return the found morph target manager or null if not found at all.
  41292. */
  41293. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  41294. /**
  41295. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  41296. * @param id defines the id to search for
  41297. * @return the found morph target or null if not found at all.
  41298. */
  41299. getMorphTargetById(id: string): Nullable<MorphTarget>;
  41300. /**
  41301. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  41302. * @param name defines the name to search for
  41303. * @return the found morph target or null if not found at all.
  41304. */
  41305. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  41306. /**
  41307. * Gets a boolean indicating if the given mesh is active
  41308. * @param mesh defines the mesh to look for
  41309. * @returns true if the mesh is in the active list
  41310. */
  41311. isActiveMesh(mesh: AbstractMesh): boolean;
  41312. /**
  41313. * Return a unique id as a string which can serve as an identifier for the scene
  41314. */
  41315. get uid(): string;
  41316. /**
  41317. * Add an externaly attached data from its key.
  41318. * This method call will fail and return false, if such key already exists.
  41319. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  41320. * @param key the unique key that identifies the data
  41321. * @param data the data object to associate to the key for this Engine instance
  41322. * @return true if no such key were already present and the data was added successfully, false otherwise
  41323. */
  41324. addExternalData<T>(key: string, data: T): boolean;
  41325. /**
  41326. * Get an externaly attached data from its key
  41327. * @param key the unique key that identifies the data
  41328. * @return the associated data, if present (can be null), or undefined if not present
  41329. */
  41330. getExternalData<T>(key: string): Nullable<T>;
  41331. /**
  41332. * Get an externaly attached data from its key, create it using a factory if it's not already present
  41333. * @param key the unique key that identifies the data
  41334. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  41335. * @return the associated data, can be null if the factory returned null.
  41336. */
  41337. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  41338. /**
  41339. * Remove an externaly attached data from the Engine instance
  41340. * @param key the unique key that identifies the data
  41341. * @return true if the data was successfully removed, false if it doesn't exist
  41342. */
  41343. removeExternalData(key: string): boolean;
  41344. private _evaluateSubMesh;
  41345. /**
  41346. * Clear the processed materials smart array preventing retention point in material dispose.
  41347. */
  41348. freeProcessedMaterials(): void;
  41349. private _preventFreeActiveMeshesAndRenderingGroups;
  41350. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  41351. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  41352. * when disposing several meshes in a row or a hierarchy of meshes.
  41353. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  41354. */
  41355. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  41356. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  41357. /**
  41358. * Clear the active meshes smart array preventing retention point in mesh dispose.
  41359. */
  41360. freeActiveMeshes(): void;
  41361. /**
  41362. * Clear the info related to rendering groups preventing retention points during dispose.
  41363. */
  41364. freeRenderingGroups(): void;
  41365. /** @hidden */
  41366. _isInIntermediateRendering(): boolean;
  41367. /**
  41368. * Lambda returning the list of potentially active meshes.
  41369. */
  41370. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  41371. /**
  41372. * Lambda returning the list of potentially active sub meshes.
  41373. */
  41374. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  41375. /**
  41376. * Lambda returning the list of potentially intersecting sub meshes.
  41377. */
  41378. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  41379. /**
  41380. * Lambda returning the list of potentially colliding sub meshes.
  41381. */
  41382. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  41383. private _activeMeshesFrozen;
  41384. private _skipEvaluateActiveMeshesCompletely;
  41385. /**
  41386. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  41387. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  41388. * @returns the current scene
  41389. */
  41390. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  41391. /**
  41392. * Use this function to restart evaluating active meshes on every frame
  41393. * @returns the current scene
  41394. */
  41395. unfreezeActiveMeshes(): Scene;
  41396. private _evaluateActiveMeshes;
  41397. private _activeMesh;
  41398. /**
  41399. * Update the transform matrix to update from the current active camera
  41400. * @param force defines a boolean used to force the update even if cache is up to date
  41401. */
  41402. updateTransformMatrix(force?: boolean): void;
  41403. private _bindFrameBuffer;
  41404. /** @hidden */
  41405. _allowPostProcessClearColor: boolean;
  41406. /** @hidden */
  41407. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  41408. private _processSubCameras;
  41409. private _checkIntersections;
  41410. /** @hidden */
  41411. _advancePhysicsEngineStep(step: number): void;
  41412. /**
  41413. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  41414. */
  41415. getDeterministicFrameTime: () => number;
  41416. /** @hidden */
  41417. _animate(): void;
  41418. /** Execute all animations (for a frame) */
  41419. animate(): void;
  41420. /**
  41421. * Render the scene
  41422. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  41423. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  41424. */
  41425. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  41426. /**
  41427. * Freeze all materials
  41428. * A frozen material will not be updatable but should be faster to render
  41429. */
  41430. freezeMaterials(): void;
  41431. /**
  41432. * Unfreeze all materials
  41433. * A frozen material will not be updatable but should be faster to render
  41434. */
  41435. unfreezeMaterials(): void;
  41436. /**
  41437. * Releases all held ressources
  41438. */
  41439. dispose(): void;
  41440. /**
  41441. * Gets if the scene is already disposed
  41442. */
  41443. get isDisposed(): boolean;
  41444. /**
  41445. * Call this function to reduce memory footprint of the scene.
  41446. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  41447. */
  41448. clearCachedVertexData(): void;
  41449. /**
  41450. * This function will remove the local cached buffer data from texture.
  41451. * It will save memory but will prevent the texture from being rebuilt
  41452. */
  41453. cleanCachedTextureBuffer(): void;
  41454. /**
  41455. * Get the world extend vectors with an optional filter
  41456. *
  41457. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  41458. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  41459. */
  41460. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  41461. min: Vector3;
  41462. max: Vector3;
  41463. };
  41464. /**
  41465. * Creates a ray that can be used to pick in the scene
  41466. * @param x defines the x coordinate of the origin (on-screen)
  41467. * @param y defines the y coordinate of the origin (on-screen)
  41468. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41469. * @param camera defines the camera to use for the picking
  41470. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41471. * @returns a Ray
  41472. */
  41473. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  41474. /**
  41475. * Creates a ray that can be used to pick in the scene
  41476. * @param x defines the x coordinate of the origin (on-screen)
  41477. * @param y defines the y coordinate of the origin (on-screen)
  41478. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  41479. * @param result defines the ray where to store the picking ray
  41480. * @param camera defines the camera to use for the picking
  41481. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  41482. * @returns the current scene
  41483. */
  41484. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  41485. /**
  41486. * Creates a ray that can be used to pick in the scene
  41487. * @param x defines the x coordinate of the origin (on-screen)
  41488. * @param y defines the y coordinate of the origin (on-screen)
  41489. * @param camera defines the camera to use for the picking
  41490. * @returns a Ray
  41491. */
  41492. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  41493. /**
  41494. * Creates a ray that can be used to pick in the scene
  41495. * @param x defines the x coordinate of the origin (on-screen)
  41496. * @param y defines the y coordinate of the origin (on-screen)
  41497. * @param result defines the ray where to store the picking ray
  41498. * @param camera defines the camera to use for the picking
  41499. * @returns the current scene
  41500. */
  41501. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  41502. /** Launch a ray to try to pick a mesh in the scene
  41503. * @param x position on screen
  41504. * @param y position on screen
  41505. * @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
  41506. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41507. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41508. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41509. * @returns a PickingInfo
  41510. */
  41511. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41512. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  41513. * @param x position on screen
  41514. * @param y position on screen
  41515. * @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
  41516. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41517. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41518. * @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)
  41519. */
  41520. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  41521. /** Use the given ray to pick a mesh in the scene
  41522. * @param ray The ray to use to pick meshes
  41523. * @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
  41524. * @param fastCheck defines if the first intersection will be used (and not the closest)
  41525. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41526. * @returns a PickingInfo
  41527. */
  41528. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  41529. /**
  41530. * Launch a ray to try to pick a mesh in the scene
  41531. * @param x X position on screen
  41532. * @param y Y position on screen
  41533. * @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
  41534. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  41535. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41536. * @returns an array of PickingInfo
  41537. */
  41538. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41539. /**
  41540. * Launch a ray to try to pick a mesh in the scene
  41541. * @param ray Ray to use
  41542. * @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
  41543. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  41544. * @returns an array of PickingInfo
  41545. */
  41546. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  41547. /**
  41548. * Force the value of meshUnderPointer
  41549. * @param mesh defines the mesh to use
  41550. */
  41551. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  41552. /**
  41553. * Gets the mesh under the pointer
  41554. * @returns a Mesh or null if no mesh is under the pointer
  41555. */
  41556. getPointerOverMesh(): Nullable<AbstractMesh>;
  41557. /** @hidden */
  41558. _rebuildGeometries(): void;
  41559. /** @hidden */
  41560. _rebuildTextures(): void;
  41561. private _getByTags;
  41562. /**
  41563. * Get a list of meshes by tags
  41564. * @param tagsQuery defines the tags query to use
  41565. * @param forEach defines a predicate used to filter results
  41566. * @returns an array of Mesh
  41567. */
  41568. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  41569. /**
  41570. * Get a list of cameras by tags
  41571. * @param tagsQuery defines the tags query to use
  41572. * @param forEach defines a predicate used to filter results
  41573. * @returns an array of Camera
  41574. */
  41575. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  41576. /**
  41577. * Get a list of lights by tags
  41578. * @param tagsQuery defines the tags query to use
  41579. * @param forEach defines a predicate used to filter results
  41580. * @returns an array of Light
  41581. */
  41582. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  41583. /**
  41584. * Get a list of materials by tags
  41585. * @param tagsQuery defines the tags query to use
  41586. * @param forEach defines a predicate used to filter results
  41587. * @returns an array of Material
  41588. */
  41589. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  41590. /**
  41591. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  41592. * This allowed control for front to back rendering or reversly depending of the special needs.
  41593. *
  41594. * @param renderingGroupId The rendering group id corresponding to its index
  41595. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  41596. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  41597. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  41598. */
  41599. 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;
  41600. /**
  41601. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  41602. *
  41603. * @param renderingGroupId The rendering group id corresponding to its index
  41604. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  41605. * @param depth Automatically clears depth between groups if true and autoClear is true.
  41606. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  41607. */
  41608. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  41609. /**
  41610. * Gets the current auto clear configuration for one rendering group of the rendering
  41611. * manager.
  41612. * @param index the rendering group index to get the information for
  41613. * @returns The auto clear setup for the requested rendering group
  41614. */
  41615. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  41616. private _blockMaterialDirtyMechanism;
  41617. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  41618. get blockMaterialDirtyMechanism(): boolean;
  41619. set blockMaterialDirtyMechanism(value: boolean);
  41620. /**
  41621. * Will flag all materials as dirty to trigger new shader compilation
  41622. * @param flag defines the flag used to specify which material part must be marked as dirty
  41623. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  41624. */
  41625. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  41626. /** @hidden */
  41627. _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;
  41628. /** @hidden */
  41629. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41630. /** @hidden */
  41631. _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;
  41632. /** @hidden */
  41633. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  41634. /** @hidden */
  41635. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41636. /** @hidden */
  41637. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  41638. }
  41639. }
  41640. declare module "babylonjs/assetContainer" {
  41641. import { AbstractScene } from "babylonjs/abstractScene";
  41642. import { Scene } from "babylonjs/scene";
  41643. import { Mesh } from "babylonjs/Meshes/mesh";
  41644. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41645. import { Skeleton } from "babylonjs/Bones/skeleton";
  41646. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41647. import { Animatable } from "babylonjs/Animations/animatable";
  41648. import { Nullable } from "babylonjs/types";
  41649. import { Node } from "babylonjs/node";
  41650. /**
  41651. * Set of assets to keep when moving a scene into an asset container.
  41652. */
  41653. export class KeepAssets extends AbstractScene {
  41654. }
  41655. /**
  41656. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  41657. */
  41658. export class InstantiatedEntries {
  41659. /**
  41660. * List of new root nodes (eg. nodes with no parent)
  41661. */
  41662. rootNodes: TransformNode[];
  41663. /**
  41664. * List of new skeletons
  41665. */
  41666. skeletons: Skeleton[];
  41667. /**
  41668. * List of new animation groups
  41669. */
  41670. animationGroups: AnimationGroup[];
  41671. }
  41672. /**
  41673. * Container with a set of assets that can be added or removed from a scene.
  41674. */
  41675. export class AssetContainer extends AbstractScene {
  41676. private _wasAddedToScene;
  41677. /**
  41678. * The scene the AssetContainer belongs to.
  41679. */
  41680. scene: Scene;
  41681. /**
  41682. * Instantiates an AssetContainer.
  41683. * @param scene The scene the AssetContainer belongs to.
  41684. */
  41685. constructor(scene: Scene);
  41686. /**
  41687. * Instantiate or clone all meshes and add the new ones to the scene.
  41688. * Skeletons and animation groups will all be cloned
  41689. * @param nameFunction defines an optional function used to get new names for clones
  41690. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  41691. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  41692. */
  41693. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  41694. /**
  41695. * Adds all the assets from the container to the scene.
  41696. */
  41697. addAllToScene(): void;
  41698. /**
  41699. * Removes all the assets in the container from the scene
  41700. */
  41701. removeAllFromScene(): void;
  41702. /**
  41703. * Disposes all the assets in the container
  41704. */
  41705. dispose(): void;
  41706. private _moveAssets;
  41707. /**
  41708. * Removes all the assets contained in the scene and adds them to the container.
  41709. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  41710. */
  41711. moveAllFromScene(keepAssets?: KeepAssets): void;
  41712. /**
  41713. * 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.
  41714. * @returns the root mesh
  41715. */
  41716. createRootMesh(): Mesh;
  41717. /**
  41718. * Merge animations (direct and animation groups) from this asset container into a scene
  41719. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41720. * @param animatables set of animatables to retarget to a node from the scene
  41721. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  41722. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  41723. */
  41724. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  41725. }
  41726. }
  41727. declare module "babylonjs/abstractScene" {
  41728. import { Scene } from "babylonjs/scene";
  41729. import { Nullable } from "babylonjs/types";
  41730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41731. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41732. import { Geometry } from "babylonjs/Meshes/geometry";
  41733. import { Skeleton } from "babylonjs/Bones/skeleton";
  41734. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  41735. import { AssetContainer } from "babylonjs/assetContainer";
  41736. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  41737. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  41738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41739. import { Material } from "babylonjs/Materials/material";
  41740. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  41741. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  41742. import { Camera } from "babylonjs/Cameras/camera";
  41743. import { Light } from "babylonjs/Lights/light";
  41744. import { Node } from "babylonjs/node";
  41745. import { Animation } from "babylonjs/Animations/animation";
  41746. /**
  41747. * Defines how the parser contract is defined.
  41748. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  41749. */
  41750. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  41751. /**
  41752. * Defines how the individual parser contract is defined.
  41753. * These parser can parse an individual asset
  41754. */
  41755. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  41756. /**
  41757. * Base class of the scene acting as a container for the different elements composing a scene.
  41758. * This class is dynamically extended by the different components of the scene increasing
  41759. * flexibility and reducing coupling
  41760. */
  41761. export abstract class AbstractScene {
  41762. /**
  41763. * Stores the list of available parsers in the application.
  41764. */
  41765. private static _BabylonFileParsers;
  41766. /**
  41767. * Stores the list of available individual parsers in the application.
  41768. */
  41769. private static _IndividualBabylonFileParsers;
  41770. /**
  41771. * Adds a parser in the list of available ones
  41772. * @param name Defines the name of the parser
  41773. * @param parser Defines the parser to add
  41774. */
  41775. static AddParser(name: string, parser: BabylonFileParser): void;
  41776. /**
  41777. * Gets a general parser from the list of avaialble ones
  41778. * @param name Defines the name of the parser
  41779. * @returns the requested parser or null
  41780. */
  41781. static GetParser(name: string): Nullable<BabylonFileParser>;
  41782. /**
  41783. * Adds n individual parser in the list of available ones
  41784. * @param name Defines the name of the parser
  41785. * @param parser Defines the parser to add
  41786. */
  41787. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  41788. /**
  41789. * Gets an individual parser from the list of avaialble ones
  41790. * @param name Defines the name of the parser
  41791. * @returns the requested parser or null
  41792. */
  41793. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  41794. /**
  41795. * Parser json data and populate both a scene and its associated container object
  41796. * @param jsonData Defines the data to parse
  41797. * @param scene Defines the scene to parse the data for
  41798. * @param container Defines the container attached to the parsing sequence
  41799. * @param rootUrl Defines the root url of the data
  41800. */
  41801. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  41802. /**
  41803. * Gets the list of root nodes (ie. nodes with no parent)
  41804. */
  41805. rootNodes: Node[];
  41806. /** All of the cameras added to this scene
  41807. * @see https://doc.babylonjs.com/babylon101/cameras
  41808. */
  41809. cameras: Camera[];
  41810. /**
  41811. * All of the lights added to this scene
  41812. * @see https://doc.babylonjs.com/babylon101/lights
  41813. */
  41814. lights: Light[];
  41815. /**
  41816. * All of the (abstract) meshes added to this scene
  41817. */
  41818. meshes: AbstractMesh[];
  41819. /**
  41820. * The list of skeletons added to the scene
  41821. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  41822. */
  41823. skeletons: Skeleton[];
  41824. /**
  41825. * All of the particle systems added to this scene
  41826. * @see https://doc.babylonjs.com/babylon101/particles
  41827. */
  41828. particleSystems: IParticleSystem[];
  41829. /**
  41830. * Gets a list of Animations associated with the scene
  41831. */
  41832. animations: Animation[];
  41833. /**
  41834. * All of the animation groups added to this scene
  41835. * @see https://doc.babylonjs.com/how_to/group
  41836. */
  41837. animationGroups: AnimationGroup[];
  41838. /**
  41839. * All of the multi-materials added to this scene
  41840. * @see https://doc.babylonjs.com/how_to/multi_materials
  41841. */
  41842. multiMaterials: MultiMaterial[];
  41843. /**
  41844. * All of the materials added to this scene
  41845. * In the context of a Scene, it is not supposed to be modified manually.
  41846. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  41847. * Note also that the order of the Material within the array is not significant and might change.
  41848. * @see https://doc.babylonjs.com/babylon101/materials
  41849. */
  41850. materials: Material[];
  41851. /**
  41852. * The list of morph target managers added to the scene
  41853. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  41854. */
  41855. morphTargetManagers: MorphTargetManager[];
  41856. /**
  41857. * The list of geometries used in the scene.
  41858. */
  41859. geometries: Geometry[];
  41860. /**
  41861. * All of the tranform nodes added to this scene
  41862. * In the context of a Scene, it is not supposed to be modified manually.
  41863. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  41864. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  41865. * @see https://doc.babylonjs.com/how_to/transformnode
  41866. */
  41867. transformNodes: TransformNode[];
  41868. /**
  41869. * ActionManagers available on the scene.
  41870. */
  41871. actionManagers: AbstractActionManager[];
  41872. /**
  41873. * Textures to keep.
  41874. */
  41875. textures: BaseTexture[];
  41876. /**
  41877. * Environment texture for the scene
  41878. */
  41879. environmentTexture: Nullable<BaseTexture>;
  41880. /**
  41881. * @returns all meshes, lights, cameras, transformNodes and bones
  41882. */
  41883. getNodes(): Array<Node>;
  41884. }
  41885. }
  41886. declare module "babylonjs/Audio/sound" {
  41887. import { Observable } from "babylonjs/Misc/observable";
  41888. import { Vector3 } from "babylonjs/Maths/math.vector";
  41889. import { Nullable } from "babylonjs/types";
  41890. import { Scene } from "babylonjs/scene";
  41891. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41892. /**
  41893. * Interface used to define options for Sound class
  41894. */
  41895. export interface ISoundOptions {
  41896. /**
  41897. * Does the sound autoplay once loaded.
  41898. */
  41899. autoplay?: boolean;
  41900. /**
  41901. * Does the sound loop after it finishes playing once.
  41902. */
  41903. loop?: boolean;
  41904. /**
  41905. * Sound's volume
  41906. */
  41907. volume?: number;
  41908. /**
  41909. * Is it a spatial sound?
  41910. */
  41911. spatialSound?: boolean;
  41912. /**
  41913. * Maximum distance to hear that sound
  41914. */
  41915. maxDistance?: number;
  41916. /**
  41917. * Uses user defined attenuation function
  41918. */
  41919. useCustomAttenuation?: boolean;
  41920. /**
  41921. * Define the roll off factor of spatial sounds.
  41922. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41923. */
  41924. rolloffFactor?: number;
  41925. /**
  41926. * Define the reference distance the sound should be heard perfectly.
  41927. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41928. */
  41929. refDistance?: number;
  41930. /**
  41931. * Define the distance attenuation model the sound will follow.
  41932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41933. */
  41934. distanceModel?: string;
  41935. /**
  41936. * Defines the playback speed (1 by default)
  41937. */
  41938. playbackRate?: number;
  41939. /**
  41940. * Defines if the sound is from a streaming source
  41941. */
  41942. streaming?: boolean;
  41943. /**
  41944. * Defines an optional length (in seconds) inside the sound file
  41945. */
  41946. length?: number;
  41947. /**
  41948. * Defines an optional offset (in seconds) inside the sound file
  41949. */
  41950. offset?: number;
  41951. /**
  41952. * If true, URLs will not be required to state the audio file codec to use.
  41953. */
  41954. skipCodecCheck?: boolean;
  41955. }
  41956. /**
  41957. * Defines a sound that can be played in the application.
  41958. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  41959. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  41960. */
  41961. export class Sound {
  41962. /**
  41963. * The name of the sound in the scene.
  41964. */
  41965. name: string;
  41966. /**
  41967. * Does the sound autoplay once loaded.
  41968. */
  41969. autoplay: boolean;
  41970. /**
  41971. * Does the sound loop after it finishes playing once.
  41972. */
  41973. loop: boolean;
  41974. /**
  41975. * Does the sound use a custom attenuation curve to simulate the falloff
  41976. * happening when the source gets further away from the camera.
  41977. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  41978. */
  41979. useCustomAttenuation: boolean;
  41980. /**
  41981. * The sound track id this sound belongs to.
  41982. */
  41983. soundTrackId: number;
  41984. /**
  41985. * Is this sound currently played.
  41986. */
  41987. isPlaying: boolean;
  41988. /**
  41989. * Is this sound currently paused.
  41990. */
  41991. isPaused: boolean;
  41992. /**
  41993. * Does this sound enables spatial sound.
  41994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  41995. */
  41996. spatialSound: boolean;
  41997. /**
  41998. * Define the reference distance the sound should be heard perfectly.
  41999. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42000. */
  42001. refDistance: number;
  42002. /**
  42003. * Define the roll off factor of spatial sounds.
  42004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42005. */
  42006. rolloffFactor: number;
  42007. /**
  42008. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  42009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42010. */
  42011. maxDistance: number;
  42012. /**
  42013. * Define the distance attenuation model the sound will follow.
  42014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42015. */
  42016. distanceModel: string;
  42017. /**
  42018. * @hidden
  42019. * Back Compat
  42020. **/
  42021. onended: () => any;
  42022. /**
  42023. * Gets or sets an object used to store user defined information for the sound.
  42024. */
  42025. metadata: any;
  42026. /**
  42027. * Observable event when the current playing sound finishes.
  42028. */
  42029. onEndedObservable: Observable<Sound>;
  42030. private _panningModel;
  42031. private _playbackRate;
  42032. private _streaming;
  42033. private _startTime;
  42034. private _startOffset;
  42035. private _position;
  42036. /** @hidden */
  42037. _positionInEmitterSpace: boolean;
  42038. private _localDirection;
  42039. private _volume;
  42040. private _isReadyToPlay;
  42041. private _isDirectional;
  42042. private _readyToPlayCallback;
  42043. private _audioBuffer;
  42044. private _soundSource;
  42045. private _streamingSource;
  42046. private _soundPanner;
  42047. private _soundGain;
  42048. private _inputAudioNode;
  42049. private _outputAudioNode;
  42050. private _coneInnerAngle;
  42051. private _coneOuterAngle;
  42052. private _coneOuterGain;
  42053. private _scene;
  42054. private _connectedTransformNode;
  42055. private _customAttenuationFunction;
  42056. private _registerFunc;
  42057. private _isOutputConnected;
  42058. private _htmlAudioElement;
  42059. private _urlType;
  42060. private _length?;
  42061. private _offset?;
  42062. /** @hidden */
  42063. static _SceneComponentInitialization: (scene: Scene) => void;
  42064. /**
  42065. * Create a sound and attach it to a scene
  42066. * @param name Name of your sound
  42067. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  42068. * @param scene defines the scene the sound belongs to
  42069. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  42070. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  42071. */
  42072. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  42073. /**
  42074. * Release the sound and its associated resources
  42075. */
  42076. dispose(): void;
  42077. /**
  42078. * Gets if the sounds is ready to be played or not.
  42079. * @returns true if ready, otherwise false
  42080. */
  42081. isReady(): boolean;
  42082. private _soundLoaded;
  42083. /**
  42084. * Sets the data of the sound from an audiobuffer
  42085. * @param audioBuffer The audioBuffer containing the data
  42086. */
  42087. setAudioBuffer(audioBuffer: AudioBuffer): void;
  42088. /**
  42089. * Updates the current sounds options such as maxdistance, loop...
  42090. * @param options A JSON object containing values named as the object properties
  42091. */
  42092. updateOptions(options: ISoundOptions): void;
  42093. private _createSpatialParameters;
  42094. private _updateSpatialParameters;
  42095. /**
  42096. * Switch the panning model to HRTF:
  42097. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42098. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42099. */
  42100. switchPanningModelToHRTF(): void;
  42101. /**
  42102. * Switch the panning model to Equal Power:
  42103. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42104. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42105. */
  42106. switchPanningModelToEqualPower(): void;
  42107. private _switchPanningModel;
  42108. /**
  42109. * Connect this sound to a sound track audio node like gain...
  42110. * @param soundTrackAudioNode the sound track audio node to connect to
  42111. */
  42112. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  42113. /**
  42114. * Transform this sound into a directional source
  42115. * @param coneInnerAngle Size of the inner cone in degree
  42116. * @param coneOuterAngle Size of the outer cone in degree
  42117. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  42118. */
  42119. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  42120. /**
  42121. * Gets or sets the inner angle for the directional cone.
  42122. */
  42123. get directionalConeInnerAngle(): number;
  42124. /**
  42125. * Gets or sets the inner angle for the directional cone.
  42126. */
  42127. set directionalConeInnerAngle(value: number);
  42128. /**
  42129. * Gets or sets the outer angle for the directional cone.
  42130. */
  42131. get directionalConeOuterAngle(): number;
  42132. /**
  42133. * Gets or sets the outer angle for the directional cone.
  42134. */
  42135. set directionalConeOuterAngle(value: number);
  42136. /**
  42137. * Sets the position of the emitter if spatial sound is enabled
  42138. * @param newPosition Defines the new posisiton
  42139. */
  42140. setPosition(newPosition: Vector3): void;
  42141. /**
  42142. * Sets the local direction of the emitter if spatial sound is enabled
  42143. * @param newLocalDirection Defines the new local direction
  42144. */
  42145. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  42146. private _updateDirection;
  42147. /** @hidden */
  42148. updateDistanceFromListener(): void;
  42149. /**
  42150. * Sets a new custom attenuation function for the sound.
  42151. * @param callback Defines the function used for the attenuation
  42152. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  42153. */
  42154. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  42155. /**
  42156. * Play the sound
  42157. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  42158. * @param offset (optional) Start the sound at a specific time in seconds
  42159. * @param length (optional) Sound duration (in seconds)
  42160. */
  42161. play(time?: number, offset?: number, length?: number): void;
  42162. private _onended;
  42163. /**
  42164. * Stop the sound
  42165. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  42166. */
  42167. stop(time?: number): void;
  42168. /**
  42169. * Put the sound in pause
  42170. */
  42171. pause(): void;
  42172. /**
  42173. * Sets a dedicated volume for this sounds
  42174. * @param newVolume Define the new volume of the sound
  42175. * @param time Define time for gradual change to new volume
  42176. */
  42177. setVolume(newVolume: number, time?: number): void;
  42178. /**
  42179. * Set the sound play back rate
  42180. * @param newPlaybackRate Define the playback rate the sound should be played at
  42181. */
  42182. setPlaybackRate(newPlaybackRate: number): void;
  42183. /**
  42184. * Gets the volume of the sound.
  42185. * @returns the volume of the sound
  42186. */
  42187. getVolume(): number;
  42188. /**
  42189. * Attach the sound to a dedicated mesh
  42190. * @param transformNode The transform node to connect the sound with
  42191. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42192. */
  42193. attachToMesh(transformNode: TransformNode): void;
  42194. /**
  42195. * Detach the sound from the previously attached mesh
  42196. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  42197. */
  42198. detachFromMesh(): void;
  42199. private _onRegisterAfterWorldMatrixUpdate;
  42200. /**
  42201. * Clone the current sound in the scene.
  42202. * @returns the new sound clone
  42203. */
  42204. clone(): Nullable<Sound>;
  42205. /**
  42206. * Gets the current underlying audio buffer containing the data
  42207. * @returns the audio buffer
  42208. */
  42209. getAudioBuffer(): Nullable<AudioBuffer>;
  42210. /**
  42211. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  42212. * @returns the source node
  42213. */
  42214. getSoundSource(): Nullable<AudioBufferSourceNode>;
  42215. /**
  42216. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  42217. * @returns the gain node
  42218. */
  42219. getSoundGain(): Nullable<GainNode>;
  42220. /**
  42221. * Serializes the Sound in a JSON representation
  42222. * @returns the JSON representation of the sound
  42223. */
  42224. serialize(): any;
  42225. /**
  42226. * Parse a JSON representation of a sound to innstantiate in a given scene
  42227. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  42228. * @param scene Define the scene the new parsed sound should be created in
  42229. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  42230. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  42231. * @returns the newly parsed sound
  42232. */
  42233. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  42234. }
  42235. }
  42236. declare module "babylonjs/Actions/directAudioActions" {
  42237. import { Action } from "babylonjs/Actions/action";
  42238. import { Condition } from "babylonjs/Actions/condition";
  42239. import { Sound } from "babylonjs/Audio/sound";
  42240. /**
  42241. * This defines an action helpful to play a defined sound on a triggered action.
  42242. */
  42243. export class PlaySoundAction extends Action {
  42244. private _sound;
  42245. /**
  42246. * Instantiate the action
  42247. * @param triggerOptions defines the trigger options
  42248. * @param sound defines the sound to play
  42249. * @param condition defines the trigger related conditions
  42250. */
  42251. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42252. /** @hidden */
  42253. _prepare(): void;
  42254. /**
  42255. * Execute the action and play the sound.
  42256. */
  42257. execute(): void;
  42258. /**
  42259. * Serializes the actions and its related information.
  42260. * @param parent defines the object to serialize in
  42261. * @returns the serialized object
  42262. */
  42263. serialize(parent: any): any;
  42264. }
  42265. /**
  42266. * This defines an action helpful to stop a defined sound on a triggered action.
  42267. */
  42268. export class StopSoundAction extends Action {
  42269. private _sound;
  42270. /**
  42271. * Instantiate the action
  42272. * @param triggerOptions defines the trigger options
  42273. * @param sound defines the sound to stop
  42274. * @param condition defines the trigger related conditions
  42275. */
  42276. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  42277. /** @hidden */
  42278. _prepare(): void;
  42279. /**
  42280. * Execute the action and stop the sound.
  42281. */
  42282. execute(): void;
  42283. /**
  42284. * Serializes the actions and its related information.
  42285. * @param parent defines the object to serialize in
  42286. * @returns the serialized object
  42287. */
  42288. serialize(parent: any): any;
  42289. }
  42290. }
  42291. declare module "babylonjs/Actions/interpolateValueAction" {
  42292. import { Action } from "babylonjs/Actions/action";
  42293. import { Condition } from "babylonjs/Actions/condition";
  42294. import { Observable } from "babylonjs/Misc/observable";
  42295. /**
  42296. * This defines an action responsible to change the value of a property
  42297. * by interpolating between its current value and the newly set one once triggered.
  42298. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42299. */
  42300. export class InterpolateValueAction extends Action {
  42301. /**
  42302. * Defines the path of the property where the value should be interpolated
  42303. */
  42304. propertyPath: string;
  42305. /**
  42306. * Defines the target value at the end of the interpolation.
  42307. */
  42308. value: any;
  42309. /**
  42310. * Defines the time it will take for the property to interpolate to the value.
  42311. */
  42312. duration: number;
  42313. /**
  42314. * Defines if the other scene animations should be stopped when the action has been triggered
  42315. */
  42316. stopOtherAnimations?: boolean;
  42317. /**
  42318. * Defines a callback raised once the interpolation animation has been done.
  42319. */
  42320. onInterpolationDone?: () => void;
  42321. /**
  42322. * Observable triggered once the interpolation animation has been done.
  42323. */
  42324. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  42325. private _target;
  42326. private _effectiveTarget;
  42327. private _property;
  42328. /**
  42329. * Instantiate the action
  42330. * @param triggerOptions defines the trigger options
  42331. * @param target defines the object containing the value to interpolate
  42332. * @param propertyPath defines the path to the property in the target object
  42333. * @param value defines the target value at the end of the interpolation
  42334. * @param duration deines the time it will take for the property to interpolate to the value.
  42335. * @param condition defines the trigger related conditions
  42336. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  42337. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  42338. */
  42339. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  42340. /** @hidden */
  42341. _prepare(): void;
  42342. /**
  42343. * Execute the action starts the value interpolation.
  42344. */
  42345. execute(): void;
  42346. /**
  42347. * Serializes the actions and its related information.
  42348. * @param parent defines the object to serialize in
  42349. * @returns the serialized object
  42350. */
  42351. serialize(parent: any): any;
  42352. }
  42353. }
  42354. declare module "babylonjs/Actions/index" {
  42355. export * from "babylonjs/Actions/abstractActionManager";
  42356. export * from "babylonjs/Actions/action";
  42357. export * from "babylonjs/Actions/actionEvent";
  42358. export * from "babylonjs/Actions/actionManager";
  42359. export * from "babylonjs/Actions/condition";
  42360. export * from "babylonjs/Actions/directActions";
  42361. export * from "babylonjs/Actions/directAudioActions";
  42362. export * from "babylonjs/Actions/interpolateValueAction";
  42363. }
  42364. declare module "babylonjs/Animations/index" {
  42365. export * from "babylonjs/Animations/animatable";
  42366. export * from "babylonjs/Animations/animation";
  42367. export * from "babylonjs/Animations/animationGroup";
  42368. export * from "babylonjs/Animations/animationPropertiesOverride";
  42369. export * from "babylonjs/Animations/easing";
  42370. export * from "babylonjs/Animations/runtimeAnimation";
  42371. export * from "babylonjs/Animations/animationEvent";
  42372. export * from "babylonjs/Animations/animationGroup";
  42373. export * from "babylonjs/Animations/animationKey";
  42374. export * from "babylonjs/Animations/animationRange";
  42375. export * from "babylonjs/Animations/animatable.interface";
  42376. }
  42377. declare module "babylonjs/Audio/soundTrack" {
  42378. import { Sound } from "babylonjs/Audio/sound";
  42379. import { Analyser } from "babylonjs/Audio/analyser";
  42380. import { Scene } from "babylonjs/scene";
  42381. /**
  42382. * Options allowed during the creation of a sound track.
  42383. */
  42384. export interface ISoundTrackOptions {
  42385. /**
  42386. * The volume the sound track should take during creation
  42387. */
  42388. volume?: number;
  42389. /**
  42390. * Define if the sound track is the main sound track of the scene
  42391. */
  42392. mainTrack?: boolean;
  42393. }
  42394. /**
  42395. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  42396. * It will be also used in a future release to apply effects on a specific track.
  42397. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42398. */
  42399. export class SoundTrack {
  42400. /**
  42401. * The unique identifier of the sound track in the scene.
  42402. */
  42403. id: number;
  42404. /**
  42405. * The list of sounds included in the sound track.
  42406. */
  42407. soundCollection: Array<Sound>;
  42408. private _outputAudioNode;
  42409. private _scene;
  42410. private _connectedAnalyser;
  42411. private _options;
  42412. private _isInitialized;
  42413. /**
  42414. * Creates a new sound track.
  42415. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  42416. * @param scene Define the scene the sound track belongs to
  42417. * @param options
  42418. */
  42419. constructor(scene: Scene, options?: ISoundTrackOptions);
  42420. private _initializeSoundTrackAudioGraph;
  42421. /**
  42422. * Release the sound track and its associated resources
  42423. */
  42424. dispose(): void;
  42425. /**
  42426. * Adds a sound to this sound track
  42427. * @param sound define the cound to add
  42428. * @ignoreNaming
  42429. */
  42430. AddSound(sound: Sound): void;
  42431. /**
  42432. * Removes a sound to this sound track
  42433. * @param sound define the cound to remove
  42434. * @ignoreNaming
  42435. */
  42436. RemoveSound(sound: Sound): void;
  42437. /**
  42438. * Set a global volume for the full sound track.
  42439. * @param newVolume Define the new volume of the sound track
  42440. */
  42441. setVolume(newVolume: number): void;
  42442. /**
  42443. * Switch the panning model to HRTF:
  42444. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  42445. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42446. */
  42447. switchPanningModelToHRTF(): void;
  42448. /**
  42449. * Switch the panning model to Equal Power:
  42450. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  42451. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  42452. */
  42453. switchPanningModelToEqualPower(): void;
  42454. /**
  42455. * Connect the sound track to an audio analyser allowing some amazing
  42456. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  42457. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  42458. * @param analyser The analyser to connect to the engine
  42459. */
  42460. connectToAnalyser(analyser: Analyser): void;
  42461. }
  42462. }
  42463. declare module "babylonjs/Audio/audioSceneComponent" {
  42464. import { Sound } from "babylonjs/Audio/sound";
  42465. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  42466. import { Nullable } from "babylonjs/types";
  42467. import { Vector3 } from "babylonjs/Maths/math.vector";
  42468. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  42469. import { Scene } from "babylonjs/scene";
  42470. import { AbstractScene } from "babylonjs/abstractScene";
  42471. import "babylonjs/Audio/audioEngine";
  42472. module "babylonjs/abstractScene" {
  42473. interface AbstractScene {
  42474. /**
  42475. * The list of sounds used in the scene.
  42476. */
  42477. sounds: Nullable<Array<Sound>>;
  42478. }
  42479. }
  42480. module "babylonjs/scene" {
  42481. interface Scene {
  42482. /**
  42483. * @hidden
  42484. * Backing field
  42485. */
  42486. _mainSoundTrack: SoundTrack;
  42487. /**
  42488. * The main sound track played by the scene.
  42489. * It cotains your primary collection of sounds.
  42490. */
  42491. mainSoundTrack: SoundTrack;
  42492. /**
  42493. * The list of sound tracks added to the scene
  42494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42495. */
  42496. soundTracks: Nullable<Array<SoundTrack>>;
  42497. /**
  42498. * Gets a sound using a given name
  42499. * @param name defines the name to search for
  42500. * @return the found sound or null if not found at all.
  42501. */
  42502. getSoundByName(name: string): Nullable<Sound>;
  42503. /**
  42504. * Gets or sets if audio support is enabled
  42505. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42506. */
  42507. audioEnabled: boolean;
  42508. /**
  42509. * Gets or sets if audio will be output to headphones
  42510. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42511. */
  42512. headphone: boolean;
  42513. /**
  42514. * Gets or sets custom audio listener position provider
  42515. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  42516. */
  42517. audioListenerPositionProvider: Nullable<() => Vector3>;
  42518. /**
  42519. * Gets or sets a refresh rate when using 3D audio positioning
  42520. */
  42521. audioPositioningRefreshRate: number;
  42522. }
  42523. }
  42524. /**
  42525. * Defines the sound scene component responsible to manage any sounds
  42526. * in a given scene.
  42527. */
  42528. export class AudioSceneComponent implements ISceneSerializableComponent {
  42529. /**
  42530. * The component name helpfull to identify the component in the list of scene components.
  42531. */
  42532. readonly name: string;
  42533. /**
  42534. * The scene the component belongs to.
  42535. */
  42536. scene: Scene;
  42537. private _audioEnabled;
  42538. /**
  42539. * Gets whether audio is enabled or not.
  42540. * Please use related enable/disable method to switch state.
  42541. */
  42542. get audioEnabled(): boolean;
  42543. private _headphone;
  42544. /**
  42545. * Gets whether audio is outputing to headphone or not.
  42546. * Please use the according Switch methods to change output.
  42547. */
  42548. get headphone(): boolean;
  42549. /**
  42550. * Gets or sets a refresh rate when using 3D audio positioning
  42551. */
  42552. audioPositioningRefreshRate: number;
  42553. private _audioListenerPositionProvider;
  42554. /**
  42555. * Gets the current audio listener position provider
  42556. */
  42557. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  42558. /**
  42559. * Sets a custom listener position for all sounds in the scene
  42560. * By default, this is the position of the first active camera
  42561. */
  42562. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  42563. /**
  42564. * Creates a new instance of the component for the given scene
  42565. * @param scene Defines the scene to register the component in
  42566. */
  42567. constructor(scene: Scene);
  42568. /**
  42569. * Registers the component in a given scene
  42570. */
  42571. register(): void;
  42572. /**
  42573. * Rebuilds the elements related to this component in case of
  42574. * context lost for instance.
  42575. */
  42576. rebuild(): void;
  42577. /**
  42578. * Serializes the component data to the specified json object
  42579. * @param serializationObject The object to serialize to
  42580. */
  42581. serialize(serializationObject: any): void;
  42582. /**
  42583. * Adds all the elements from the container to the scene
  42584. * @param container the container holding the elements
  42585. */
  42586. addFromContainer(container: AbstractScene): void;
  42587. /**
  42588. * Removes all the elements in the container from the scene
  42589. * @param container contains the elements to remove
  42590. * @param dispose if the removed element should be disposed (default: false)
  42591. */
  42592. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  42593. /**
  42594. * Disposes the component and the associated ressources.
  42595. */
  42596. dispose(): void;
  42597. /**
  42598. * Disables audio in the associated scene.
  42599. */
  42600. disableAudio(): void;
  42601. /**
  42602. * Enables audio in the associated scene.
  42603. */
  42604. enableAudio(): void;
  42605. /**
  42606. * Switch audio to headphone output.
  42607. */
  42608. switchAudioModeForHeadphones(): void;
  42609. /**
  42610. * Switch audio to normal speakers.
  42611. */
  42612. switchAudioModeForNormalSpeakers(): void;
  42613. private _cachedCameraDirection;
  42614. private _cachedCameraPosition;
  42615. private _lastCheck;
  42616. private _afterRender;
  42617. }
  42618. }
  42619. declare module "babylonjs/Audio/weightedsound" {
  42620. import { Sound } from "babylonjs/Audio/sound";
  42621. /**
  42622. * Wraps one or more Sound objects and selects one with random weight for playback.
  42623. */
  42624. export class WeightedSound {
  42625. /** When true a Sound will be selected and played when the current playing Sound completes. */
  42626. loop: boolean;
  42627. private _coneInnerAngle;
  42628. private _coneOuterAngle;
  42629. private _volume;
  42630. /** A Sound is currently playing. */
  42631. isPlaying: boolean;
  42632. /** A Sound is currently paused. */
  42633. isPaused: boolean;
  42634. private _sounds;
  42635. private _weights;
  42636. private _currentIndex?;
  42637. /**
  42638. * Creates a new WeightedSound from the list of sounds given.
  42639. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  42640. * @param sounds Array of Sounds that will be selected from.
  42641. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  42642. */
  42643. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  42644. /**
  42645. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  42646. */
  42647. get directionalConeInnerAngle(): number;
  42648. /**
  42649. * The size of cone in degress for a directional sound in which there will be no attenuation.
  42650. */
  42651. set directionalConeInnerAngle(value: number);
  42652. /**
  42653. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42654. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42655. */
  42656. get directionalConeOuterAngle(): number;
  42657. /**
  42658. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  42659. * Listener angles between innerAngle and outerAngle will falloff linearly.
  42660. */
  42661. set directionalConeOuterAngle(value: number);
  42662. /**
  42663. * Playback volume.
  42664. */
  42665. get volume(): number;
  42666. /**
  42667. * Playback volume.
  42668. */
  42669. set volume(value: number);
  42670. private _onended;
  42671. /**
  42672. * Suspend playback
  42673. */
  42674. pause(): void;
  42675. /**
  42676. * Stop playback
  42677. */
  42678. stop(): void;
  42679. /**
  42680. * Start playback.
  42681. * @param startOffset Position the clip head at a specific time in seconds.
  42682. */
  42683. play(startOffset?: number): void;
  42684. }
  42685. }
  42686. declare module "babylonjs/Audio/index" {
  42687. export * from "babylonjs/Audio/analyser";
  42688. export * from "babylonjs/Audio/audioEngine";
  42689. export * from "babylonjs/Audio/audioSceneComponent";
  42690. export * from "babylonjs/Audio/sound";
  42691. export * from "babylonjs/Audio/soundTrack";
  42692. export * from "babylonjs/Audio/weightedsound";
  42693. }
  42694. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  42695. import { Behavior } from "babylonjs/Behaviors/behavior";
  42696. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42697. import { BackEase } from "babylonjs/Animations/easing";
  42698. /**
  42699. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  42700. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  42701. */
  42702. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  42703. /**
  42704. * Gets the name of the behavior.
  42705. */
  42706. get name(): string;
  42707. /**
  42708. * The easing function used by animations
  42709. */
  42710. static EasingFunction: BackEase;
  42711. /**
  42712. * The easing mode used by animations
  42713. */
  42714. static EasingMode: number;
  42715. /**
  42716. * The duration of the animation, in milliseconds
  42717. */
  42718. transitionDuration: number;
  42719. /**
  42720. * Length of the distance animated by the transition when lower radius is reached
  42721. */
  42722. lowerRadiusTransitionRange: number;
  42723. /**
  42724. * Length of the distance animated by the transition when upper radius is reached
  42725. */
  42726. upperRadiusTransitionRange: number;
  42727. private _autoTransitionRange;
  42728. /**
  42729. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42730. */
  42731. get autoTransitionRange(): boolean;
  42732. /**
  42733. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  42734. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  42735. */
  42736. set autoTransitionRange(value: boolean);
  42737. private _attachedCamera;
  42738. private _onAfterCheckInputsObserver;
  42739. private _onMeshTargetChangedObserver;
  42740. /**
  42741. * Initializes the behavior.
  42742. */
  42743. init(): void;
  42744. /**
  42745. * Attaches the behavior to its arc rotate camera.
  42746. * @param camera Defines the camera to attach the behavior to
  42747. */
  42748. attach(camera: ArcRotateCamera): void;
  42749. /**
  42750. * Detaches the behavior from its current arc rotate camera.
  42751. */
  42752. detach(): void;
  42753. private _radiusIsAnimating;
  42754. private _radiusBounceTransition;
  42755. private _animatables;
  42756. private _cachedWheelPrecision;
  42757. /**
  42758. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  42759. * @param radiusLimit The limit to check against.
  42760. * @return Bool to indicate if at limit.
  42761. */
  42762. private _isRadiusAtLimit;
  42763. /**
  42764. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  42765. * @param radiusDelta The delta by which to animate to. Can be negative.
  42766. */
  42767. private _applyBoundRadiusAnimation;
  42768. /**
  42769. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  42770. */
  42771. protected _clearAnimationLocks(): void;
  42772. /**
  42773. * Stops and removes all animations that have been applied to the camera
  42774. */
  42775. stopAllAnimations(): void;
  42776. }
  42777. }
  42778. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  42779. import { Behavior } from "babylonjs/Behaviors/behavior";
  42780. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  42781. import { ExponentialEase } from "babylonjs/Animations/easing";
  42782. import { Nullable } from "babylonjs/types";
  42783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42784. import { Vector3 } from "babylonjs/Maths/math.vector";
  42785. /**
  42786. * 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.
  42787. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  42788. */
  42789. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  42790. /**
  42791. * Gets the name of the behavior.
  42792. */
  42793. get name(): string;
  42794. private _mode;
  42795. private _radiusScale;
  42796. private _positionScale;
  42797. private _defaultElevation;
  42798. private _elevationReturnTime;
  42799. private _elevationReturnWaitTime;
  42800. private _zoomStopsAnimation;
  42801. private _framingTime;
  42802. /**
  42803. * The easing function used by animations
  42804. */
  42805. static EasingFunction: ExponentialEase;
  42806. /**
  42807. * The easing mode used by animations
  42808. */
  42809. static EasingMode: number;
  42810. /**
  42811. * Sets the current mode used by the behavior
  42812. */
  42813. set mode(mode: number);
  42814. /**
  42815. * Gets current mode used by the behavior.
  42816. */
  42817. get mode(): number;
  42818. /**
  42819. * Sets the scale applied to the radius (1 by default)
  42820. */
  42821. set radiusScale(radius: number);
  42822. /**
  42823. * Gets the scale applied to the radius
  42824. */
  42825. get radiusScale(): number;
  42826. /**
  42827. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42828. */
  42829. set positionScale(scale: number);
  42830. /**
  42831. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  42832. */
  42833. get positionScale(): number;
  42834. /**
  42835. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42836. * behaviour is triggered, in radians.
  42837. */
  42838. set defaultElevation(elevation: number);
  42839. /**
  42840. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  42841. * behaviour is triggered, in radians.
  42842. */
  42843. get defaultElevation(): number;
  42844. /**
  42845. * Sets the time (in milliseconds) taken to return to the default beta position.
  42846. * Negative value indicates camera should not return to default.
  42847. */
  42848. set elevationReturnTime(speed: number);
  42849. /**
  42850. * Gets the time (in milliseconds) taken to return to the default beta position.
  42851. * Negative value indicates camera should not return to default.
  42852. */
  42853. get elevationReturnTime(): number;
  42854. /**
  42855. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42856. */
  42857. set elevationReturnWaitTime(time: number);
  42858. /**
  42859. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  42860. */
  42861. get elevationReturnWaitTime(): number;
  42862. /**
  42863. * Sets the flag that indicates if user zooming should stop animation.
  42864. */
  42865. set zoomStopsAnimation(flag: boolean);
  42866. /**
  42867. * Gets the flag that indicates if user zooming should stop animation.
  42868. */
  42869. get zoomStopsAnimation(): boolean;
  42870. /**
  42871. * Sets the transition time when framing the mesh, in milliseconds
  42872. */
  42873. set framingTime(time: number);
  42874. /**
  42875. * Gets the transition time when framing the mesh, in milliseconds
  42876. */
  42877. get framingTime(): number;
  42878. /**
  42879. * Define if the behavior should automatically change the configured
  42880. * camera limits and sensibilities.
  42881. */
  42882. autoCorrectCameraLimitsAndSensibility: boolean;
  42883. private _onPrePointerObservableObserver;
  42884. private _onAfterCheckInputsObserver;
  42885. private _onMeshTargetChangedObserver;
  42886. private _attachedCamera;
  42887. private _isPointerDown;
  42888. private _lastInteractionTime;
  42889. /**
  42890. * Initializes the behavior.
  42891. */
  42892. init(): void;
  42893. /**
  42894. * Attaches the behavior to its arc rotate camera.
  42895. * @param camera Defines the camera to attach the behavior to
  42896. */
  42897. attach(camera: ArcRotateCamera): void;
  42898. /**
  42899. * Detaches the behavior from its current arc rotate camera.
  42900. */
  42901. detach(): void;
  42902. private _animatables;
  42903. private _betaIsAnimating;
  42904. private _betaTransition;
  42905. private _radiusTransition;
  42906. private _vectorTransition;
  42907. /**
  42908. * Targets the given mesh and updates zoom level accordingly.
  42909. * @param mesh The mesh to target.
  42910. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42911. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42912. */
  42913. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42914. /**
  42915. * Targets the given mesh with its children and updates zoom level accordingly.
  42916. * @param mesh The mesh to target.
  42917. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42918. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42919. */
  42920. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42921. /**
  42922. * Targets the given meshes with their children and updates zoom level accordingly.
  42923. * @param meshes The mesh to target.
  42924. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42925. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42926. */
  42927. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42928. /**
  42929. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  42930. * @param minimumWorld Determines the smaller position of the bounding box extend
  42931. * @param maximumWorld Determines the bigger position of the bounding box extend
  42932. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  42933. * @param onAnimationEnd Callback triggered at the end of the framing animation
  42934. */
  42935. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  42936. /**
  42937. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  42938. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  42939. * frustum width.
  42940. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  42941. * to fully enclose the mesh in the viewing frustum.
  42942. */
  42943. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  42944. /**
  42945. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  42946. * is automatically returned to its default position (expected to be above ground plane).
  42947. */
  42948. private _maintainCameraAboveGround;
  42949. /**
  42950. * Returns the frustum slope based on the canvas ratio and camera FOV
  42951. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  42952. */
  42953. private _getFrustumSlope;
  42954. /**
  42955. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  42956. */
  42957. private _clearAnimationLocks;
  42958. /**
  42959. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  42960. */
  42961. private _applyUserInteraction;
  42962. /**
  42963. * Stops and removes all animations that have been applied to the camera
  42964. */
  42965. stopAllAnimations(): void;
  42966. /**
  42967. * Gets a value indicating if the user is moving the camera
  42968. */
  42969. get isUserIsMoving(): boolean;
  42970. /**
  42971. * The camera can move all the way towards the mesh.
  42972. */
  42973. static IgnoreBoundsSizeMode: number;
  42974. /**
  42975. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  42976. */
  42977. static FitFrustumSidesMode: number;
  42978. }
  42979. }
  42980. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  42981. import { Nullable } from "babylonjs/types";
  42982. import { Camera } from "babylonjs/Cameras/camera";
  42983. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42984. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  42985. /**
  42986. * Base class for Camera Pointer Inputs.
  42987. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  42988. * for example usage.
  42989. */
  42990. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  42991. /**
  42992. * Defines the camera the input is attached to.
  42993. */
  42994. abstract camera: Camera;
  42995. /**
  42996. * Whether keyboard modifier keys are pressed at time of last mouse event.
  42997. */
  42998. protected _altKey: boolean;
  42999. protected _ctrlKey: boolean;
  43000. protected _metaKey: boolean;
  43001. protected _shiftKey: boolean;
  43002. /**
  43003. * Which mouse buttons were pressed at time of last mouse event.
  43004. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  43005. */
  43006. protected _buttonsPressed: number;
  43007. /**
  43008. * Defines the buttons associated with the input to handle camera move.
  43009. */
  43010. buttons: number[];
  43011. /**
  43012. * Attach the input controls to a specific dom element to get the input from.
  43013. * @param element Defines the element the controls should be listened from
  43014. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43015. */
  43016. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43017. /**
  43018. * Detach the current controls from the specified dom element.
  43019. * @param element Defines the element to stop listening the inputs from
  43020. */
  43021. detachControl(element: Nullable<HTMLElement>): void;
  43022. /**
  43023. * Gets the class name of the current input.
  43024. * @returns the class name
  43025. */
  43026. getClassName(): string;
  43027. /**
  43028. * Get the friendly name associated with the input class.
  43029. * @returns the input friendly name
  43030. */
  43031. getSimpleName(): string;
  43032. /**
  43033. * Called on pointer POINTERDOUBLETAP event.
  43034. * Override this method to provide functionality on POINTERDOUBLETAP event.
  43035. */
  43036. protected onDoubleTap(type: string): void;
  43037. /**
  43038. * Called on pointer POINTERMOVE event if only a single touch is active.
  43039. * Override this method to provide functionality.
  43040. */
  43041. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43042. /**
  43043. * Called on pointer POINTERMOVE event if multiple touches are active.
  43044. * Override this method to provide functionality.
  43045. */
  43046. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43047. /**
  43048. * Called on JS contextmenu event.
  43049. * Override this method to provide functionality.
  43050. */
  43051. protected onContextMenu(evt: PointerEvent): void;
  43052. /**
  43053. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43054. * press.
  43055. * Override this method to provide functionality.
  43056. */
  43057. protected onButtonDown(evt: PointerEvent): void;
  43058. /**
  43059. * Called each time a new POINTERUP event occurs. Ie, for each button
  43060. * release.
  43061. * Override this method to provide functionality.
  43062. */
  43063. protected onButtonUp(evt: PointerEvent): void;
  43064. /**
  43065. * Called when window becomes inactive.
  43066. * Override this method to provide functionality.
  43067. */
  43068. protected onLostFocus(): void;
  43069. private _pointerInput;
  43070. private _observer;
  43071. private _onLostFocus;
  43072. private pointA;
  43073. private pointB;
  43074. }
  43075. }
  43076. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  43077. import { Nullable } from "babylonjs/types";
  43078. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43079. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  43080. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  43081. /**
  43082. * Manage the pointers inputs to control an arc rotate camera.
  43083. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43084. */
  43085. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  43086. /**
  43087. * Defines the camera the input is attached to.
  43088. */
  43089. camera: ArcRotateCamera;
  43090. /**
  43091. * Gets the class name of the current input.
  43092. * @returns the class name
  43093. */
  43094. getClassName(): string;
  43095. /**
  43096. * Defines the buttons associated with the input to handle camera move.
  43097. */
  43098. buttons: number[];
  43099. /**
  43100. * Defines the pointer angular sensibility along the X axis or how fast is
  43101. * the camera rotating.
  43102. */
  43103. angularSensibilityX: number;
  43104. /**
  43105. * Defines the pointer angular sensibility along the Y axis or how fast is
  43106. * the camera rotating.
  43107. */
  43108. angularSensibilityY: number;
  43109. /**
  43110. * Defines the pointer pinch precision or how fast is the camera zooming.
  43111. */
  43112. pinchPrecision: number;
  43113. /**
  43114. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  43115. * from 0.
  43116. * It defines the percentage of current camera.radius to use as delta when
  43117. * pinch zoom is used.
  43118. */
  43119. pinchDeltaPercentage: number;
  43120. /**
  43121. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43122. * that any object in the plane at the camera's target point will scale
  43123. * perfectly with finger motion.
  43124. * Overrides pinchDeltaPercentage and pinchPrecision.
  43125. */
  43126. useNaturalPinchZoom: boolean;
  43127. /**
  43128. * Defines the pointer panning sensibility or how fast is the camera moving.
  43129. */
  43130. panningSensibility: number;
  43131. /**
  43132. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  43133. */
  43134. multiTouchPanning: boolean;
  43135. /**
  43136. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  43137. * zoom (pinch) through multitouch.
  43138. */
  43139. multiTouchPanAndZoom: boolean;
  43140. /**
  43141. * Revers pinch action direction.
  43142. */
  43143. pinchInwards: boolean;
  43144. private _isPanClick;
  43145. private _twoFingerActivityCount;
  43146. private _isPinching;
  43147. /**
  43148. * Called on pointer POINTERMOVE event if only a single touch is active.
  43149. */
  43150. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  43151. /**
  43152. * Called on pointer POINTERDOUBLETAP event.
  43153. */
  43154. protected onDoubleTap(type: string): void;
  43155. /**
  43156. * Called on pointer POINTERMOVE event if multiple touches are active.
  43157. */
  43158. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  43159. /**
  43160. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  43161. * press.
  43162. */
  43163. protected onButtonDown(evt: PointerEvent): void;
  43164. /**
  43165. * Called each time a new POINTERUP event occurs. Ie, for each button
  43166. * release.
  43167. */
  43168. protected onButtonUp(evt: PointerEvent): void;
  43169. /**
  43170. * Called when window becomes inactive.
  43171. */
  43172. protected onLostFocus(): void;
  43173. }
  43174. }
  43175. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  43176. import { Nullable } from "babylonjs/types";
  43177. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43178. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43179. /**
  43180. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  43181. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43182. */
  43183. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  43184. /**
  43185. * Defines the camera the input is attached to.
  43186. */
  43187. camera: ArcRotateCamera;
  43188. /**
  43189. * Defines the list of key codes associated with the up action (increase alpha)
  43190. */
  43191. keysUp: number[];
  43192. /**
  43193. * Defines the list of key codes associated with the down action (decrease alpha)
  43194. */
  43195. keysDown: number[];
  43196. /**
  43197. * Defines the list of key codes associated with the left action (increase beta)
  43198. */
  43199. keysLeft: number[];
  43200. /**
  43201. * Defines the list of key codes associated with the right action (decrease beta)
  43202. */
  43203. keysRight: number[];
  43204. /**
  43205. * Defines the list of key codes associated with the reset action.
  43206. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  43207. */
  43208. keysReset: number[];
  43209. /**
  43210. * Defines the panning sensibility of the inputs.
  43211. * (How fast is the camera panning)
  43212. */
  43213. panningSensibility: number;
  43214. /**
  43215. * Defines the zooming sensibility of the inputs.
  43216. * (How fast is the camera zooming)
  43217. */
  43218. zoomingSensibility: number;
  43219. /**
  43220. * Defines whether maintaining the alt key down switch the movement mode from
  43221. * orientation to zoom.
  43222. */
  43223. useAltToZoom: boolean;
  43224. /**
  43225. * Rotation speed of the camera
  43226. */
  43227. angularSpeed: number;
  43228. private _keys;
  43229. private _ctrlPressed;
  43230. private _altPressed;
  43231. private _onCanvasBlurObserver;
  43232. private _onKeyboardObserver;
  43233. private _engine;
  43234. private _scene;
  43235. /**
  43236. * Attach the input controls to a specific dom element to get the input from.
  43237. * @param element Defines the element the controls should be listened from
  43238. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43239. */
  43240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43241. /**
  43242. * Detach the current controls from the specified dom element.
  43243. * @param element Defines the element to stop listening the inputs from
  43244. */
  43245. detachControl(element: Nullable<HTMLElement>): void;
  43246. /**
  43247. * Update the current camera state depending on the inputs that have been used this frame.
  43248. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  43249. */
  43250. checkInputs(): void;
  43251. /**
  43252. * Gets the class name of the current intput.
  43253. * @returns the class name
  43254. */
  43255. getClassName(): string;
  43256. /**
  43257. * Get the friendly name associated with the input class.
  43258. * @returns the input friendly name
  43259. */
  43260. getSimpleName(): string;
  43261. }
  43262. }
  43263. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  43264. import { Nullable } from "babylonjs/types";
  43265. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43266. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  43267. /**
  43268. * Manage the mouse wheel inputs to control an arc rotate camera.
  43269. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43270. */
  43271. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  43272. /**
  43273. * Defines the camera the input is attached to.
  43274. */
  43275. camera: ArcRotateCamera;
  43276. /**
  43277. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43278. */
  43279. wheelPrecision: number;
  43280. /**
  43281. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  43282. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  43283. */
  43284. wheelDeltaPercentage: number;
  43285. private _wheel;
  43286. private _observer;
  43287. private computeDeltaFromMouseWheelLegacyEvent;
  43288. /**
  43289. * Attach the input controls to a specific dom element to get the input from.
  43290. * @param element Defines the element the controls should be listened from
  43291. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43292. */
  43293. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  43294. /**
  43295. * Detach the current controls from the specified dom element.
  43296. * @param element Defines the element to stop listening the inputs from
  43297. */
  43298. detachControl(element: Nullable<HTMLElement>): void;
  43299. /**
  43300. * Gets the class name of the current intput.
  43301. * @returns the class name
  43302. */
  43303. getClassName(): string;
  43304. /**
  43305. * Get the friendly name associated with the input class.
  43306. * @returns the input friendly name
  43307. */
  43308. getSimpleName(): string;
  43309. }
  43310. }
  43311. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43312. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43313. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  43314. /**
  43315. * Default Inputs manager for the ArcRotateCamera.
  43316. * It groups all the default supported inputs for ease of use.
  43317. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  43318. */
  43319. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  43320. /**
  43321. * Instantiates a new ArcRotateCameraInputsManager.
  43322. * @param camera Defines the camera the inputs belong to
  43323. */
  43324. constructor(camera: ArcRotateCamera);
  43325. /**
  43326. * Add mouse wheel input support to the input manager.
  43327. * @returns the current input manager
  43328. */
  43329. addMouseWheel(): ArcRotateCameraInputsManager;
  43330. /**
  43331. * Add pointers input support to the input manager.
  43332. * @returns the current input manager
  43333. */
  43334. addPointers(): ArcRotateCameraInputsManager;
  43335. /**
  43336. * Add keyboard input support to the input manager.
  43337. * @returns the current input manager
  43338. */
  43339. addKeyboard(): ArcRotateCameraInputsManager;
  43340. }
  43341. }
  43342. declare module "babylonjs/Cameras/arcRotateCamera" {
  43343. import { Observable } from "babylonjs/Misc/observable";
  43344. import { Nullable } from "babylonjs/types";
  43345. import { Scene } from "babylonjs/scene";
  43346. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  43347. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43348. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43349. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43350. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  43351. import { Camera } from "babylonjs/Cameras/camera";
  43352. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  43353. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43354. import { Collider } from "babylonjs/Collisions/collider";
  43355. /**
  43356. * This represents an orbital type of camera.
  43357. *
  43358. * 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.
  43359. * 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.
  43360. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  43361. */
  43362. export class ArcRotateCamera extends TargetCamera {
  43363. /**
  43364. * Defines the rotation angle of the camera along the longitudinal axis.
  43365. */
  43366. alpha: number;
  43367. /**
  43368. * Defines the rotation angle of the camera along the latitudinal axis.
  43369. */
  43370. beta: number;
  43371. /**
  43372. * Defines the radius of the camera from it s target point.
  43373. */
  43374. radius: number;
  43375. protected _target: Vector3;
  43376. protected _targetHost: Nullable<AbstractMesh>;
  43377. /**
  43378. * Defines the target point of the camera.
  43379. * The camera looks towards it form the radius distance.
  43380. */
  43381. get target(): Vector3;
  43382. set target(value: Vector3);
  43383. /**
  43384. * Define the current local position of the camera in the scene
  43385. */
  43386. get position(): Vector3;
  43387. set position(newPosition: Vector3);
  43388. protected _upVector: Vector3;
  43389. protected _upToYMatrix: Matrix;
  43390. protected _YToUpMatrix: Matrix;
  43391. /**
  43392. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  43393. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  43394. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  43395. */
  43396. set upVector(vec: Vector3);
  43397. get upVector(): Vector3;
  43398. /**
  43399. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  43400. */
  43401. setMatUp(): void;
  43402. /**
  43403. * Current inertia value on the longitudinal axis.
  43404. * The bigger this number the longer it will take for the camera to stop.
  43405. */
  43406. inertialAlphaOffset: number;
  43407. /**
  43408. * Current inertia value on the latitudinal axis.
  43409. * The bigger this number the longer it will take for the camera to stop.
  43410. */
  43411. inertialBetaOffset: number;
  43412. /**
  43413. * Current inertia value on the radius axis.
  43414. * The bigger this number the longer it will take for the camera to stop.
  43415. */
  43416. inertialRadiusOffset: number;
  43417. /**
  43418. * Minimum allowed angle on the longitudinal axis.
  43419. * This can help limiting how the Camera is able to move in the scene.
  43420. */
  43421. lowerAlphaLimit: Nullable<number>;
  43422. /**
  43423. * Maximum allowed angle on the longitudinal axis.
  43424. * This can help limiting how the Camera is able to move in the scene.
  43425. */
  43426. upperAlphaLimit: Nullable<number>;
  43427. /**
  43428. * Minimum allowed angle on the latitudinal axis.
  43429. * This can help limiting how the Camera is able to move in the scene.
  43430. */
  43431. lowerBetaLimit: number;
  43432. /**
  43433. * Maximum allowed angle on the latitudinal axis.
  43434. * This can help limiting how the Camera is able to move in the scene.
  43435. */
  43436. upperBetaLimit: number;
  43437. /**
  43438. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  43439. * This can help limiting how the Camera is able to move in the scene.
  43440. */
  43441. lowerRadiusLimit: Nullable<number>;
  43442. /**
  43443. * Maximum allowed distance of the camera to the target (The camera can not get further).
  43444. * This can help limiting how the Camera is able to move in the scene.
  43445. */
  43446. upperRadiusLimit: Nullable<number>;
  43447. /**
  43448. * Defines the current inertia value used during panning of the camera along the X axis.
  43449. */
  43450. inertialPanningX: number;
  43451. /**
  43452. * Defines the current inertia value used during panning of the camera along the Y axis.
  43453. */
  43454. inertialPanningY: number;
  43455. /**
  43456. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  43457. * Basically if your fingers moves away from more than this distance you will be considered
  43458. * in pinch mode.
  43459. */
  43460. pinchToPanMaxDistance: number;
  43461. /**
  43462. * Defines the maximum distance the camera can pan.
  43463. * This could help keeping the cammera always in your scene.
  43464. */
  43465. panningDistanceLimit: Nullable<number>;
  43466. /**
  43467. * Defines the target of the camera before paning.
  43468. */
  43469. panningOriginTarget: Vector3;
  43470. /**
  43471. * Defines the value of the inertia used during panning.
  43472. * 0 would mean stop inertia and one would mean no decelleration at all.
  43473. */
  43474. panningInertia: number;
  43475. /**
  43476. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  43477. */
  43478. get angularSensibilityX(): number;
  43479. set angularSensibilityX(value: number);
  43480. /**
  43481. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  43482. */
  43483. get angularSensibilityY(): number;
  43484. set angularSensibilityY(value: number);
  43485. /**
  43486. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  43487. */
  43488. get pinchPrecision(): number;
  43489. set pinchPrecision(value: number);
  43490. /**
  43491. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  43492. * It will be used instead of pinchDeltaPrecision if different from 0.
  43493. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43494. */
  43495. get pinchDeltaPercentage(): number;
  43496. set pinchDeltaPercentage(value: number);
  43497. /**
  43498. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  43499. * and pinch delta percentage.
  43500. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  43501. * that any object in the plane at the camera's target point will scale
  43502. * perfectly with finger motion.
  43503. */
  43504. get useNaturalPinchZoom(): boolean;
  43505. set useNaturalPinchZoom(value: boolean);
  43506. /**
  43507. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  43508. */
  43509. get panningSensibility(): number;
  43510. set panningSensibility(value: number);
  43511. /**
  43512. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  43513. */
  43514. get keysUp(): number[];
  43515. set keysUp(value: number[]);
  43516. /**
  43517. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  43518. */
  43519. get keysDown(): number[];
  43520. set keysDown(value: number[]);
  43521. /**
  43522. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  43523. */
  43524. get keysLeft(): number[];
  43525. set keysLeft(value: number[]);
  43526. /**
  43527. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  43528. */
  43529. get keysRight(): number[];
  43530. set keysRight(value: number[]);
  43531. /**
  43532. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  43533. */
  43534. get wheelPrecision(): number;
  43535. set wheelPrecision(value: number);
  43536. /**
  43537. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  43538. * It will be used instead of pinchDeltaPrecision if different from 0.
  43539. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  43540. */
  43541. get wheelDeltaPercentage(): number;
  43542. set wheelDeltaPercentage(value: number);
  43543. /**
  43544. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  43545. */
  43546. zoomOnFactor: number;
  43547. /**
  43548. * Defines a screen offset for the camera position.
  43549. */
  43550. targetScreenOffset: Vector2;
  43551. /**
  43552. * Allows the camera to be completely reversed.
  43553. * If false the camera can not arrive upside down.
  43554. */
  43555. allowUpsideDown: boolean;
  43556. /**
  43557. * Define if double tap/click is used to restore the previously saved state of the camera.
  43558. */
  43559. useInputToRestoreState: boolean;
  43560. /** @hidden */
  43561. _viewMatrix: Matrix;
  43562. /** @hidden */
  43563. _useCtrlForPanning: boolean;
  43564. /** @hidden */
  43565. _panningMouseButton: number;
  43566. /**
  43567. * Defines the input associated to the camera.
  43568. */
  43569. inputs: ArcRotateCameraInputsManager;
  43570. /** @hidden */
  43571. _reset: () => void;
  43572. /**
  43573. * Defines the allowed panning axis.
  43574. */
  43575. panningAxis: Vector3;
  43576. protected _localDirection: Vector3;
  43577. protected _transformedDirection: Vector3;
  43578. private _bouncingBehavior;
  43579. /**
  43580. * Gets the bouncing behavior of the camera if it has been enabled.
  43581. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43582. */
  43583. get bouncingBehavior(): Nullable<BouncingBehavior>;
  43584. /**
  43585. * Defines if the bouncing behavior of the camera is enabled on the camera.
  43586. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43587. */
  43588. get useBouncingBehavior(): boolean;
  43589. set useBouncingBehavior(value: boolean);
  43590. private _framingBehavior;
  43591. /**
  43592. * Gets the framing behavior of the camera if it has been enabled.
  43593. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43594. */
  43595. get framingBehavior(): Nullable<FramingBehavior>;
  43596. /**
  43597. * Defines if the framing behavior of the camera is enabled on the camera.
  43598. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43599. */
  43600. get useFramingBehavior(): boolean;
  43601. set useFramingBehavior(value: boolean);
  43602. private _autoRotationBehavior;
  43603. /**
  43604. * Gets the auto rotation behavior of the camera if it has been enabled.
  43605. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43606. */
  43607. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  43608. /**
  43609. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  43610. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43611. */
  43612. get useAutoRotationBehavior(): boolean;
  43613. set useAutoRotationBehavior(value: boolean);
  43614. /**
  43615. * Observable triggered when the mesh target has been changed on the camera.
  43616. */
  43617. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  43618. /**
  43619. * Event raised when the camera is colliding with a mesh.
  43620. */
  43621. onCollide: (collidedMesh: AbstractMesh) => void;
  43622. /**
  43623. * Defines whether the camera should check collision with the objects oh the scene.
  43624. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  43625. */
  43626. checkCollisions: boolean;
  43627. /**
  43628. * Defines the collision radius of the camera.
  43629. * This simulates a sphere around the camera.
  43630. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  43631. */
  43632. collisionRadius: Vector3;
  43633. protected _collider: Collider;
  43634. protected _previousPosition: Vector3;
  43635. protected _collisionVelocity: Vector3;
  43636. protected _newPosition: Vector3;
  43637. protected _previousAlpha: number;
  43638. protected _previousBeta: number;
  43639. protected _previousRadius: number;
  43640. protected _collisionTriggered: boolean;
  43641. protected _targetBoundingCenter: Nullable<Vector3>;
  43642. private _computationVector;
  43643. /**
  43644. * Instantiates a new ArcRotateCamera in a given scene
  43645. * @param name Defines the name of the camera
  43646. * @param alpha Defines the camera rotation along the logitudinal axis
  43647. * @param beta Defines the camera rotation along the latitudinal axis
  43648. * @param radius Defines the camera distance from its target
  43649. * @param target Defines the camera target
  43650. * @param scene Defines the scene the camera belongs to
  43651. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  43652. */
  43653. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  43654. /** @hidden */
  43655. _initCache(): void;
  43656. /** @hidden */
  43657. _updateCache(ignoreParentClass?: boolean): void;
  43658. protected _getTargetPosition(): Vector3;
  43659. private _storedAlpha;
  43660. private _storedBeta;
  43661. private _storedRadius;
  43662. private _storedTarget;
  43663. private _storedTargetScreenOffset;
  43664. /**
  43665. * Stores the current state of the camera (alpha, beta, radius and target)
  43666. * @returns the camera itself
  43667. */
  43668. storeState(): Camera;
  43669. /**
  43670. * @hidden
  43671. * Restored camera state. You must call storeState() first
  43672. */
  43673. _restoreStateValues(): boolean;
  43674. /** @hidden */
  43675. _isSynchronizedViewMatrix(): boolean;
  43676. /**
  43677. * Attached controls to the current camera.
  43678. * @param element Defines the element the controls should be listened from
  43679. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  43680. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  43681. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  43682. */
  43683. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  43684. /**
  43685. * Detach the current controls from the camera.
  43686. * The camera will stop reacting to inputs.
  43687. * @param element Defines the element to stop listening the inputs from
  43688. */
  43689. detachControl(element: HTMLElement): void;
  43690. /** @hidden */
  43691. _checkInputs(): void;
  43692. protected _checkLimits(): void;
  43693. /**
  43694. * Rebuilds angles (alpha, beta) and radius from the give position and target
  43695. */
  43696. rebuildAnglesAndRadius(): void;
  43697. /**
  43698. * Use a position to define the current camera related information like alpha, beta and radius
  43699. * @param position Defines the position to set the camera at
  43700. */
  43701. setPosition(position: Vector3): void;
  43702. /**
  43703. * Defines the target the camera should look at.
  43704. * This will automatically adapt alpha beta and radius to fit within the new target.
  43705. * @param target Defines the new target as a Vector or a mesh
  43706. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  43707. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  43708. */
  43709. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  43710. /** @hidden */
  43711. _getViewMatrix(): Matrix;
  43712. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  43713. /**
  43714. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  43715. * @param meshes Defines the mesh to zoom on
  43716. * @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)
  43717. */
  43718. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  43719. /**
  43720. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  43721. * The target will be changed but the radius
  43722. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  43723. * @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)
  43724. */
  43725. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  43726. min: Vector3;
  43727. max: Vector3;
  43728. distance: number;
  43729. }, doNotUpdateMaxZ?: boolean): void;
  43730. /**
  43731. * @override
  43732. * Override Camera.createRigCamera
  43733. */
  43734. createRigCamera(name: string, cameraIndex: number): Camera;
  43735. /**
  43736. * @hidden
  43737. * @override
  43738. * Override Camera._updateRigCameras
  43739. */
  43740. _updateRigCameras(): void;
  43741. /**
  43742. * Destroy the camera and release the current resources hold by it.
  43743. */
  43744. dispose(): void;
  43745. /**
  43746. * Gets the current object class name.
  43747. * @return the class name
  43748. */
  43749. getClassName(): string;
  43750. }
  43751. }
  43752. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  43753. import { Behavior } from "babylonjs/Behaviors/behavior";
  43754. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43755. /**
  43756. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  43757. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  43758. */
  43759. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  43760. /**
  43761. * Gets the name of the behavior.
  43762. */
  43763. get name(): string;
  43764. private _zoomStopsAnimation;
  43765. private _idleRotationSpeed;
  43766. private _idleRotationWaitTime;
  43767. private _idleRotationSpinupTime;
  43768. /**
  43769. * Sets the flag that indicates if user zooming should stop animation.
  43770. */
  43771. set zoomStopsAnimation(flag: boolean);
  43772. /**
  43773. * Gets the flag that indicates if user zooming should stop animation.
  43774. */
  43775. get zoomStopsAnimation(): boolean;
  43776. /**
  43777. * Sets the default speed at which the camera rotates around the model.
  43778. */
  43779. set idleRotationSpeed(speed: number);
  43780. /**
  43781. * Gets the default speed at which the camera rotates around the model.
  43782. */
  43783. get idleRotationSpeed(): number;
  43784. /**
  43785. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  43786. */
  43787. set idleRotationWaitTime(time: number);
  43788. /**
  43789. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  43790. */
  43791. get idleRotationWaitTime(): number;
  43792. /**
  43793. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43794. */
  43795. set idleRotationSpinupTime(time: number);
  43796. /**
  43797. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  43798. */
  43799. get idleRotationSpinupTime(): number;
  43800. /**
  43801. * Gets a value indicating if the camera is currently rotating because of this behavior
  43802. */
  43803. get rotationInProgress(): boolean;
  43804. private _onPrePointerObservableObserver;
  43805. private _onAfterCheckInputsObserver;
  43806. private _attachedCamera;
  43807. private _isPointerDown;
  43808. private _lastFrameTime;
  43809. private _lastInteractionTime;
  43810. private _cameraRotationSpeed;
  43811. /**
  43812. * Initializes the behavior.
  43813. */
  43814. init(): void;
  43815. /**
  43816. * Attaches the behavior to its arc rotate camera.
  43817. * @param camera Defines the camera to attach the behavior to
  43818. */
  43819. attach(camera: ArcRotateCamera): void;
  43820. /**
  43821. * Detaches the behavior from its current arc rotate camera.
  43822. */
  43823. detach(): void;
  43824. /**
  43825. * Returns true if user is scrolling.
  43826. * @return true if user is scrolling.
  43827. */
  43828. private _userIsZooming;
  43829. private _lastFrameRadius;
  43830. private _shouldAnimationStopForInteraction;
  43831. /**
  43832. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  43833. */
  43834. private _applyUserInteraction;
  43835. private _userIsMoving;
  43836. }
  43837. }
  43838. declare module "babylonjs/Behaviors/Cameras/index" {
  43839. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  43840. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  43841. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  43842. }
  43843. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  43844. import { Mesh } from "babylonjs/Meshes/mesh";
  43845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43846. import { Behavior } from "babylonjs/Behaviors/behavior";
  43847. /**
  43848. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  43849. */
  43850. export class AttachToBoxBehavior implements Behavior<Mesh> {
  43851. private ui;
  43852. /**
  43853. * The name of the behavior
  43854. */
  43855. name: string;
  43856. /**
  43857. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  43858. */
  43859. distanceAwayFromFace: number;
  43860. /**
  43861. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  43862. */
  43863. distanceAwayFromBottomOfFace: number;
  43864. private _faceVectors;
  43865. private _target;
  43866. private _scene;
  43867. private _onRenderObserver;
  43868. private _tmpMatrix;
  43869. private _tmpVector;
  43870. /**
  43871. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  43872. * @param ui The transform node that should be attched to the mesh
  43873. */
  43874. constructor(ui: TransformNode);
  43875. /**
  43876. * Initializes the behavior
  43877. */
  43878. init(): void;
  43879. private _closestFace;
  43880. private _zeroVector;
  43881. private _lookAtTmpMatrix;
  43882. private _lookAtToRef;
  43883. /**
  43884. * Attaches the AttachToBoxBehavior to the passed in mesh
  43885. * @param target The mesh that the specified node will be attached to
  43886. */
  43887. attach(target: Mesh): void;
  43888. /**
  43889. * Detaches the behavior from the mesh
  43890. */
  43891. detach(): void;
  43892. }
  43893. }
  43894. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  43895. import { Behavior } from "babylonjs/Behaviors/behavior";
  43896. import { Mesh } from "babylonjs/Meshes/mesh";
  43897. /**
  43898. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  43899. */
  43900. export class FadeInOutBehavior implements Behavior<Mesh> {
  43901. /**
  43902. * Time in milliseconds to delay before fading in (Default: 0)
  43903. */
  43904. delay: number;
  43905. /**
  43906. * Time in milliseconds for the mesh to fade in (Default: 300)
  43907. */
  43908. fadeInTime: number;
  43909. private _millisecondsPerFrame;
  43910. private _hovered;
  43911. private _hoverValue;
  43912. private _ownerNode;
  43913. /**
  43914. * Instatiates the FadeInOutBehavior
  43915. */
  43916. constructor();
  43917. /**
  43918. * The name of the behavior
  43919. */
  43920. get name(): string;
  43921. /**
  43922. * Initializes the behavior
  43923. */
  43924. init(): void;
  43925. /**
  43926. * Attaches the fade behavior on the passed in mesh
  43927. * @param ownerNode The mesh that will be faded in/out once attached
  43928. */
  43929. attach(ownerNode: Mesh): void;
  43930. /**
  43931. * Detaches the behavior from the mesh
  43932. */
  43933. detach(): void;
  43934. /**
  43935. * Triggers the mesh to begin fading in or out
  43936. * @param value if the object should fade in or out (true to fade in)
  43937. */
  43938. fadeIn(value: boolean): void;
  43939. private _update;
  43940. private _setAllVisibility;
  43941. }
  43942. }
  43943. declare module "babylonjs/Misc/pivotTools" {
  43944. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43945. /**
  43946. * Class containing a set of static utilities functions for managing Pivots
  43947. * @hidden
  43948. */
  43949. export class PivotTools {
  43950. private static _PivotCached;
  43951. private static _OldPivotPoint;
  43952. private static _PivotTranslation;
  43953. private static _PivotTmpVector;
  43954. /** @hidden */
  43955. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  43956. /** @hidden */
  43957. static _RestorePivotPoint(mesh: AbstractMesh): void;
  43958. }
  43959. }
  43960. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  43961. import { Scene } from "babylonjs/scene";
  43962. import { Vector4 } from "babylonjs/Maths/math.vector";
  43963. import { Mesh } from "babylonjs/Meshes/mesh";
  43964. import { Nullable } from "babylonjs/types";
  43965. import { Plane } from "babylonjs/Maths/math.plane";
  43966. /**
  43967. * Class containing static functions to help procedurally build meshes
  43968. */
  43969. export class PlaneBuilder {
  43970. /**
  43971. * Creates a plane mesh
  43972. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  43973. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  43974. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  43975. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43976. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43977. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43978. * @param name defines the name of the mesh
  43979. * @param options defines the options used to create the mesh
  43980. * @param scene defines the hosting scene
  43981. * @returns the plane mesh
  43982. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  43983. */
  43984. static CreatePlane(name: string, options: {
  43985. size?: number;
  43986. width?: number;
  43987. height?: number;
  43988. sideOrientation?: number;
  43989. frontUVs?: Vector4;
  43990. backUVs?: Vector4;
  43991. updatable?: boolean;
  43992. sourcePlane?: Plane;
  43993. }, scene?: Nullable<Scene>): Mesh;
  43994. }
  43995. }
  43996. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  43997. import { Behavior } from "babylonjs/Behaviors/behavior";
  43998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43999. import { Observable } from "babylonjs/Misc/observable";
  44000. import { Vector3 } from "babylonjs/Maths/math.vector";
  44001. import { Ray } from "babylonjs/Culling/ray";
  44002. import "babylonjs/Meshes/Builders/planeBuilder";
  44003. /**
  44004. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  44005. */
  44006. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  44007. private static _AnyMouseID;
  44008. /**
  44009. * Abstract mesh the behavior is set on
  44010. */
  44011. attachedNode: AbstractMesh;
  44012. private _dragPlane;
  44013. private _scene;
  44014. private _pointerObserver;
  44015. private _beforeRenderObserver;
  44016. private static _planeScene;
  44017. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  44018. /**
  44019. * 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)
  44020. */
  44021. maxDragAngle: number;
  44022. /**
  44023. * @hidden
  44024. */
  44025. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  44026. /**
  44027. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44028. */
  44029. currentDraggingPointerID: number;
  44030. /**
  44031. * The last position where the pointer hit the drag plane in world space
  44032. */
  44033. lastDragPosition: Vector3;
  44034. /**
  44035. * If the behavior is currently in a dragging state
  44036. */
  44037. dragging: boolean;
  44038. /**
  44039. * 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)
  44040. */
  44041. dragDeltaRatio: number;
  44042. /**
  44043. * If the drag plane orientation should be updated during the dragging (Default: true)
  44044. */
  44045. updateDragPlane: boolean;
  44046. private _debugMode;
  44047. private _moving;
  44048. /**
  44049. * Fires each time the attached mesh is dragged with the pointer
  44050. * * delta between last drag position and current drag position in world space
  44051. * * dragDistance along the drag axis
  44052. * * dragPlaneNormal normal of the current drag plane used during the drag
  44053. * * dragPlanePoint in world space where the drag intersects the drag plane
  44054. */
  44055. onDragObservable: Observable<{
  44056. delta: Vector3;
  44057. dragPlanePoint: Vector3;
  44058. dragPlaneNormal: Vector3;
  44059. dragDistance: number;
  44060. pointerId: number;
  44061. }>;
  44062. /**
  44063. * Fires each time a drag begins (eg. mouse down on mesh)
  44064. */
  44065. onDragStartObservable: Observable<{
  44066. dragPlanePoint: Vector3;
  44067. pointerId: number;
  44068. }>;
  44069. /**
  44070. * Fires each time a drag ends (eg. mouse release after drag)
  44071. */
  44072. onDragEndObservable: Observable<{
  44073. dragPlanePoint: Vector3;
  44074. pointerId: number;
  44075. }>;
  44076. /**
  44077. * If the attached mesh should be moved when dragged
  44078. */
  44079. moveAttached: boolean;
  44080. /**
  44081. * If the drag behavior will react to drag events (Default: true)
  44082. */
  44083. enabled: boolean;
  44084. /**
  44085. * If pointer events should start and release the drag (Default: true)
  44086. */
  44087. startAndReleaseDragOnPointerEvents: boolean;
  44088. /**
  44089. * If camera controls should be detached during the drag
  44090. */
  44091. detachCameraControls: boolean;
  44092. /**
  44093. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  44094. */
  44095. useObjectOrientationForDragging: boolean;
  44096. private _options;
  44097. /**
  44098. * Gets the options used by the behavior
  44099. */
  44100. get options(): {
  44101. dragAxis?: Vector3;
  44102. dragPlaneNormal?: Vector3;
  44103. };
  44104. /**
  44105. * Sets the options used by the behavior
  44106. */
  44107. set options(options: {
  44108. dragAxis?: Vector3;
  44109. dragPlaneNormal?: Vector3;
  44110. });
  44111. /**
  44112. * Creates a pointer drag behavior that can be attached to a mesh
  44113. * @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)
  44114. */
  44115. constructor(options?: {
  44116. dragAxis?: Vector3;
  44117. dragPlaneNormal?: Vector3;
  44118. });
  44119. /**
  44120. * Predicate to determine if it is valid to move the object to a new position when it is moved
  44121. */
  44122. validateDrag: (targetPosition: Vector3) => boolean;
  44123. /**
  44124. * The name of the behavior
  44125. */
  44126. get name(): string;
  44127. /**
  44128. * Initializes the behavior
  44129. */
  44130. init(): void;
  44131. private _tmpVector;
  44132. private _alternatePickedPoint;
  44133. private _worldDragAxis;
  44134. private _targetPosition;
  44135. private _attachedElement;
  44136. /**
  44137. * Attaches the drag behavior the passed in mesh
  44138. * @param ownerNode The mesh that will be dragged around once attached
  44139. * @param predicate Predicate to use for pick filtering
  44140. */
  44141. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  44142. /**
  44143. * Force relase the drag action by code.
  44144. */
  44145. releaseDrag(): void;
  44146. private _startDragRay;
  44147. private _lastPointerRay;
  44148. /**
  44149. * Simulates the start of a pointer drag event on the behavior
  44150. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  44151. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  44152. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  44153. */
  44154. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  44155. private _startDrag;
  44156. private _dragDelta;
  44157. private _moveDrag;
  44158. private _pickWithRayOnDragPlane;
  44159. private _pointA;
  44160. private _pointB;
  44161. private _pointC;
  44162. private _lineA;
  44163. private _lineB;
  44164. private _localAxis;
  44165. private _lookAt;
  44166. private _updateDragPlanePosition;
  44167. /**
  44168. * Detaches the behavior from the mesh
  44169. */
  44170. detach(): void;
  44171. }
  44172. }
  44173. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  44174. import { Mesh } from "babylonjs/Meshes/mesh";
  44175. import { Behavior } from "babylonjs/Behaviors/behavior";
  44176. /**
  44177. * A behavior that when attached to a mesh will allow the mesh to be scaled
  44178. */
  44179. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  44180. private _dragBehaviorA;
  44181. private _dragBehaviorB;
  44182. private _startDistance;
  44183. private _initialScale;
  44184. private _targetScale;
  44185. private _ownerNode;
  44186. private _sceneRenderObserver;
  44187. /**
  44188. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  44189. */
  44190. constructor();
  44191. /**
  44192. * The name of the behavior
  44193. */
  44194. get name(): string;
  44195. /**
  44196. * Initializes the behavior
  44197. */
  44198. init(): void;
  44199. private _getCurrentDistance;
  44200. /**
  44201. * Attaches the scale behavior the passed in mesh
  44202. * @param ownerNode The mesh that will be scaled around once attached
  44203. */
  44204. attach(ownerNode: Mesh): void;
  44205. /**
  44206. * Detaches the behavior from the mesh
  44207. */
  44208. detach(): void;
  44209. }
  44210. }
  44211. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  44212. import { Behavior } from "babylonjs/Behaviors/behavior";
  44213. import { Mesh } from "babylonjs/Meshes/mesh";
  44214. import { Observable } from "babylonjs/Misc/observable";
  44215. /**
  44216. * 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
  44217. */
  44218. export class SixDofDragBehavior implements Behavior<Mesh> {
  44219. private static _virtualScene;
  44220. private _ownerNode;
  44221. private _sceneRenderObserver;
  44222. private _scene;
  44223. private _targetPosition;
  44224. private _virtualOriginMesh;
  44225. private _virtualDragMesh;
  44226. private _pointerObserver;
  44227. private _moving;
  44228. private _startingOrientation;
  44229. private _attachedElement;
  44230. /**
  44231. * 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)
  44232. */
  44233. private zDragFactor;
  44234. /**
  44235. * If the object should rotate to face the drag origin
  44236. */
  44237. rotateDraggedObject: boolean;
  44238. /**
  44239. * If the behavior is currently in a dragging state
  44240. */
  44241. dragging: boolean;
  44242. /**
  44243. * 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)
  44244. */
  44245. dragDeltaRatio: number;
  44246. /**
  44247. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  44248. */
  44249. currentDraggingPointerID: number;
  44250. /**
  44251. * If camera controls should be detached during the drag
  44252. */
  44253. detachCameraControls: boolean;
  44254. /**
  44255. * Fires each time a drag starts
  44256. */
  44257. onDragStartObservable: Observable<{}>;
  44258. /**
  44259. * Fires each time a drag ends (eg. mouse release after drag)
  44260. */
  44261. onDragEndObservable: Observable<{}>;
  44262. /**
  44263. * 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
  44264. */
  44265. constructor();
  44266. /**
  44267. * The name of the behavior
  44268. */
  44269. get name(): string;
  44270. /**
  44271. * Initializes the behavior
  44272. */
  44273. init(): void;
  44274. /**
  44275. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  44276. */
  44277. private get _pointerCamera();
  44278. /**
  44279. * Attaches the scale behavior the passed in mesh
  44280. * @param ownerNode The mesh that will be scaled around once attached
  44281. */
  44282. attach(ownerNode: Mesh): void;
  44283. /**
  44284. * Detaches the behavior from the mesh
  44285. */
  44286. detach(): void;
  44287. }
  44288. }
  44289. declare module "babylonjs/Behaviors/Meshes/index" {
  44290. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  44291. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  44292. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  44293. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44294. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44295. }
  44296. declare module "babylonjs/Behaviors/index" {
  44297. export * from "babylonjs/Behaviors/behavior";
  44298. export * from "babylonjs/Behaviors/Cameras/index";
  44299. export * from "babylonjs/Behaviors/Meshes/index";
  44300. }
  44301. declare module "babylonjs/Bones/boneIKController" {
  44302. import { Bone } from "babylonjs/Bones/bone";
  44303. import { Vector3 } from "babylonjs/Maths/math.vector";
  44304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44305. import { Nullable } from "babylonjs/types";
  44306. /**
  44307. * Class used to apply inverse kinematics to bones
  44308. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  44309. */
  44310. export class BoneIKController {
  44311. private static _tmpVecs;
  44312. private static _tmpQuat;
  44313. private static _tmpMats;
  44314. /**
  44315. * Gets or sets the target mesh
  44316. */
  44317. targetMesh: AbstractMesh;
  44318. /** Gets or sets the mesh used as pole */
  44319. poleTargetMesh: AbstractMesh;
  44320. /**
  44321. * Gets or sets the bone used as pole
  44322. */
  44323. poleTargetBone: Nullable<Bone>;
  44324. /**
  44325. * Gets or sets the target position
  44326. */
  44327. targetPosition: Vector3;
  44328. /**
  44329. * Gets or sets the pole target position
  44330. */
  44331. poleTargetPosition: Vector3;
  44332. /**
  44333. * Gets or sets the pole target local offset
  44334. */
  44335. poleTargetLocalOffset: Vector3;
  44336. /**
  44337. * Gets or sets the pole angle
  44338. */
  44339. poleAngle: number;
  44340. /**
  44341. * Gets or sets the mesh associated with the controller
  44342. */
  44343. mesh: AbstractMesh;
  44344. /**
  44345. * 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)
  44346. */
  44347. slerpAmount: number;
  44348. private _bone1Quat;
  44349. private _bone1Mat;
  44350. private _bone2Ang;
  44351. private _bone1;
  44352. private _bone2;
  44353. private _bone1Length;
  44354. private _bone2Length;
  44355. private _maxAngle;
  44356. private _maxReach;
  44357. private _rightHandedSystem;
  44358. private _bendAxis;
  44359. private _slerping;
  44360. private _adjustRoll;
  44361. /**
  44362. * Gets or sets maximum allowed angle
  44363. */
  44364. get maxAngle(): number;
  44365. set maxAngle(value: number);
  44366. /**
  44367. * Creates a new BoneIKController
  44368. * @param mesh defines the mesh to control
  44369. * @param bone defines the bone to control
  44370. * @param options defines options to set up the controller
  44371. */
  44372. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  44373. targetMesh?: AbstractMesh;
  44374. poleTargetMesh?: AbstractMesh;
  44375. poleTargetBone?: Bone;
  44376. poleTargetLocalOffset?: Vector3;
  44377. poleAngle?: number;
  44378. bendAxis?: Vector3;
  44379. maxAngle?: number;
  44380. slerpAmount?: number;
  44381. });
  44382. private _setMaxAngle;
  44383. /**
  44384. * Force the controller to update the bones
  44385. */
  44386. update(): void;
  44387. }
  44388. }
  44389. declare module "babylonjs/Bones/boneLookController" {
  44390. import { Vector3 } from "babylonjs/Maths/math.vector";
  44391. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44392. import { Bone } from "babylonjs/Bones/bone";
  44393. import { Space } from "babylonjs/Maths/math.axis";
  44394. /**
  44395. * Class used to make a bone look toward a point in space
  44396. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  44397. */
  44398. export class BoneLookController {
  44399. private static _tmpVecs;
  44400. private static _tmpQuat;
  44401. private static _tmpMats;
  44402. /**
  44403. * The target Vector3 that the bone will look at
  44404. */
  44405. target: Vector3;
  44406. /**
  44407. * The mesh that the bone is attached to
  44408. */
  44409. mesh: AbstractMesh;
  44410. /**
  44411. * The bone that will be looking to the target
  44412. */
  44413. bone: Bone;
  44414. /**
  44415. * The up axis of the coordinate system that is used when the bone is rotated
  44416. */
  44417. upAxis: Vector3;
  44418. /**
  44419. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  44420. */
  44421. upAxisSpace: Space;
  44422. /**
  44423. * Used to make an adjustment to the yaw of the bone
  44424. */
  44425. adjustYaw: number;
  44426. /**
  44427. * Used to make an adjustment to the pitch of the bone
  44428. */
  44429. adjustPitch: number;
  44430. /**
  44431. * Used to make an adjustment to the roll of the bone
  44432. */
  44433. adjustRoll: number;
  44434. /**
  44435. * 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)
  44436. */
  44437. slerpAmount: number;
  44438. private _minYaw;
  44439. private _maxYaw;
  44440. private _minPitch;
  44441. private _maxPitch;
  44442. private _minYawSin;
  44443. private _minYawCos;
  44444. private _maxYawSin;
  44445. private _maxYawCos;
  44446. private _midYawConstraint;
  44447. private _minPitchTan;
  44448. private _maxPitchTan;
  44449. private _boneQuat;
  44450. private _slerping;
  44451. private _transformYawPitch;
  44452. private _transformYawPitchInv;
  44453. private _firstFrameSkipped;
  44454. private _yawRange;
  44455. private _fowardAxis;
  44456. /**
  44457. * Gets or sets the minimum yaw angle that the bone can look to
  44458. */
  44459. get minYaw(): number;
  44460. set minYaw(value: number);
  44461. /**
  44462. * Gets or sets the maximum yaw angle that the bone can look to
  44463. */
  44464. get maxYaw(): number;
  44465. set maxYaw(value: number);
  44466. /**
  44467. * Gets or sets the minimum pitch angle that the bone can look to
  44468. */
  44469. get minPitch(): number;
  44470. set minPitch(value: number);
  44471. /**
  44472. * Gets or sets the maximum pitch angle that the bone can look to
  44473. */
  44474. get maxPitch(): number;
  44475. set maxPitch(value: number);
  44476. /**
  44477. * Create a BoneLookController
  44478. * @param mesh the mesh that the bone belongs to
  44479. * @param bone the bone that will be looking to the target
  44480. * @param target the target Vector3 to look at
  44481. * @param options optional settings:
  44482. * * maxYaw: the maximum angle the bone will yaw to
  44483. * * minYaw: the minimum angle the bone will yaw to
  44484. * * maxPitch: the maximum angle the bone will pitch to
  44485. * * minPitch: the minimum angle the bone will yaw to
  44486. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  44487. * * upAxis: the up axis of the coordinate system
  44488. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  44489. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  44490. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  44491. * * adjustYaw: used to make an adjustment to the yaw of the bone
  44492. * * adjustPitch: used to make an adjustment to the pitch of the bone
  44493. * * adjustRoll: used to make an adjustment to the roll of the bone
  44494. **/
  44495. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  44496. maxYaw?: number;
  44497. minYaw?: number;
  44498. maxPitch?: number;
  44499. minPitch?: number;
  44500. slerpAmount?: number;
  44501. upAxis?: Vector3;
  44502. upAxisSpace?: Space;
  44503. yawAxis?: Vector3;
  44504. pitchAxis?: Vector3;
  44505. adjustYaw?: number;
  44506. adjustPitch?: number;
  44507. adjustRoll?: number;
  44508. });
  44509. /**
  44510. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  44511. */
  44512. update(): void;
  44513. private _getAngleDiff;
  44514. private _getAngleBetween;
  44515. private _isAngleBetween;
  44516. }
  44517. }
  44518. declare module "babylonjs/Bones/index" {
  44519. export * from "babylonjs/Bones/bone";
  44520. export * from "babylonjs/Bones/boneIKController";
  44521. export * from "babylonjs/Bones/boneLookController";
  44522. export * from "babylonjs/Bones/skeleton";
  44523. }
  44524. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  44525. import { Nullable } from "babylonjs/types";
  44526. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44527. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44528. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  44529. /**
  44530. * Manage the gamepad inputs to control an arc rotate camera.
  44531. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44532. */
  44533. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  44534. /**
  44535. * Defines the camera the input is attached to.
  44536. */
  44537. camera: ArcRotateCamera;
  44538. /**
  44539. * Defines the gamepad the input is gathering event from.
  44540. */
  44541. gamepad: Nullable<Gamepad>;
  44542. /**
  44543. * Defines the gamepad rotation sensiblity.
  44544. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  44545. */
  44546. gamepadRotationSensibility: number;
  44547. /**
  44548. * Defines the gamepad move sensiblity.
  44549. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  44550. */
  44551. gamepadMoveSensibility: number;
  44552. private _yAxisScale;
  44553. /**
  44554. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  44555. */
  44556. get invertYAxis(): boolean;
  44557. set invertYAxis(value: boolean);
  44558. private _onGamepadConnectedObserver;
  44559. private _onGamepadDisconnectedObserver;
  44560. /**
  44561. * Attach the input controls to a specific dom element to get the input from.
  44562. * @param element Defines the element the controls should be listened from
  44563. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44564. */
  44565. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44566. /**
  44567. * Detach the current controls from the specified dom element.
  44568. * @param element Defines the element to stop listening the inputs from
  44569. */
  44570. detachControl(element: Nullable<HTMLElement>): void;
  44571. /**
  44572. * Update the current camera state depending on the inputs that have been used this frame.
  44573. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44574. */
  44575. checkInputs(): void;
  44576. /**
  44577. * Gets the class name of the current intput.
  44578. * @returns the class name
  44579. */
  44580. getClassName(): string;
  44581. /**
  44582. * Get the friendly name associated with the input class.
  44583. * @returns the input friendly name
  44584. */
  44585. getSimpleName(): string;
  44586. }
  44587. }
  44588. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  44589. import { Nullable } from "babylonjs/types";
  44590. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44591. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44592. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44593. interface ArcRotateCameraInputsManager {
  44594. /**
  44595. * Add orientation input support to the input manager.
  44596. * @returns the current input manager
  44597. */
  44598. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  44599. }
  44600. }
  44601. /**
  44602. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  44603. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44604. */
  44605. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  44606. /**
  44607. * Defines the camera the input is attached to.
  44608. */
  44609. camera: ArcRotateCamera;
  44610. /**
  44611. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  44612. */
  44613. alphaCorrection: number;
  44614. /**
  44615. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  44616. */
  44617. gammaCorrection: number;
  44618. private _alpha;
  44619. private _gamma;
  44620. private _dirty;
  44621. private _deviceOrientationHandler;
  44622. /**
  44623. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  44624. */
  44625. constructor();
  44626. /**
  44627. * Attach the input controls to a specific dom element to get the input from.
  44628. * @param element Defines the element the controls should be listened from
  44629. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44630. */
  44631. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44632. /** @hidden */
  44633. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  44634. /**
  44635. * Update the current camera state depending on the inputs that have been used this frame.
  44636. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44637. */
  44638. checkInputs(): void;
  44639. /**
  44640. * Detach the current controls from the specified dom element.
  44641. * @param element Defines the element to stop listening the inputs from
  44642. */
  44643. detachControl(element: Nullable<HTMLElement>): void;
  44644. /**
  44645. * Gets the class name of the current intput.
  44646. * @returns the class name
  44647. */
  44648. getClassName(): string;
  44649. /**
  44650. * Get the friendly name associated with the input class.
  44651. * @returns the input friendly name
  44652. */
  44653. getSimpleName(): string;
  44654. }
  44655. }
  44656. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  44657. import { Nullable } from "babylonjs/types";
  44658. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44659. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44660. /**
  44661. * Listen to mouse events to control the camera.
  44662. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44663. */
  44664. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  44665. /**
  44666. * Defines the camera the input is attached to.
  44667. */
  44668. camera: FlyCamera;
  44669. /**
  44670. * Defines if touch is enabled. (Default is true.)
  44671. */
  44672. touchEnabled: boolean;
  44673. /**
  44674. * Defines the buttons associated with the input to handle camera rotation.
  44675. */
  44676. buttons: number[];
  44677. /**
  44678. * Assign buttons for Yaw control.
  44679. */
  44680. buttonsYaw: number[];
  44681. /**
  44682. * Assign buttons for Pitch control.
  44683. */
  44684. buttonsPitch: number[];
  44685. /**
  44686. * Assign buttons for Roll control.
  44687. */
  44688. buttonsRoll: number[];
  44689. /**
  44690. * Detect if any button is being pressed while mouse is moved.
  44691. * -1 = Mouse locked.
  44692. * 0 = Left button.
  44693. * 1 = Middle Button.
  44694. * 2 = Right Button.
  44695. */
  44696. activeButton: number;
  44697. /**
  44698. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  44699. * Higher values reduce its sensitivity.
  44700. */
  44701. angularSensibility: number;
  44702. private _mousemoveCallback;
  44703. private _observer;
  44704. private _rollObserver;
  44705. private previousPosition;
  44706. private noPreventDefault;
  44707. private element;
  44708. /**
  44709. * Listen to mouse events to control the camera.
  44710. * @param touchEnabled Define if touch is enabled. (Default is true.)
  44711. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44712. */
  44713. constructor(touchEnabled?: boolean);
  44714. /**
  44715. * Attach the mouse control to the HTML DOM element.
  44716. * @param element Defines the element that listens to the input events.
  44717. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  44718. */
  44719. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44720. /**
  44721. * Detach the current controls from the specified dom element.
  44722. * @param element Defines the element to stop listening the inputs from
  44723. */
  44724. detachControl(element: Nullable<HTMLElement>): void;
  44725. /**
  44726. * Gets the class name of the current input.
  44727. * @returns the class name.
  44728. */
  44729. getClassName(): string;
  44730. /**
  44731. * Get the friendly name associated with the input class.
  44732. * @returns the input's friendly name.
  44733. */
  44734. getSimpleName(): string;
  44735. private _pointerInput;
  44736. private _onMouseMove;
  44737. /**
  44738. * Rotate camera by mouse offset.
  44739. */
  44740. private rotateCamera;
  44741. }
  44742. }
  44743. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  44744. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44745. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44746. /**
  44747. * Default Inputs manager for the FlyCamera.
  44748. * It groups all the default supported inputs for ease of use.
  44749. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44750. */
  44751. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  44752. /**
  44753. * Instantiates a new FlyCameraInputsManager.
  44754. * @param camera Defines the camera the inputs belong to.
  44755. */
  44756. constructor(camera: FlyCamera);
  44757. /**
  44758. * Add keyboard input support to the input manager.
  44759. * @returns the new FlyCameraKeyboardMoveInput().
  44760. */
  44761. addKeyboard(): FlyCameraInputsManager;
  44762. /**
  44763. * Add mouse input support to the input manager.
  44764. * @param touchEnabled Enable touch screen support.
  44765. * @returns the new FlyCameraMouseInput().
  44766. */
  44767. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  44768. }
  44769. }
  44770. declare module "babylonjs/Cameras/flyCamera" {
  44771. import { Scene } from "babylonjs/scene";
  44772. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  44773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44774. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44775. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  44776. /**
  44777. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44778. * such as in a 3D Space Shooter or a Flight Simulator.
  44779. */
  44780. export class FlyCamera extends TargetCamera {
  44781. /**
  44782. * Define the collision ellipsoid of the camera.
  44783. * This is helpful for simulating a camera body, like a player's body.
  44784. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44785. */
  44786. ellipsoid: Vector3;
  44787. /**
  44788. * Define an offset for the position of the ellipsoid around the camera.
  44789. * This can be helpful if the camera is attached away from the player's body center,
  44790. * such as at its head.
  44791. */
  44792. ellipsoidOffset: Vector3;
  44793. /**
  44794. * Enable or disable collisions of the camera with the rest of the scene objects.
  44795. */
  44796. checkCollisions: boolean;
  44797. /**
  44798. * Enable or disable gravity on the camera.
  44799. */
  44800. applyGravity: boolean;
  44801. /**
  44802. * Define the current direction the camera is moving to.
  44803. */
  44804. cameraDirection: Vector3;
  44805. /**
  44806. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  44807. * This overrides and empties cameraRotation.
  44808. */
  44809. rotationQuaternion: Quaternion;
  44810. /**
  44811. * Track Roll to maintain the wanted Rolling when looking around.
  44812. */
  44813. _trackRoll: number;
  44814. /**
  44815. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  44816. */
  44817. rollCorrect: number;
  44818. /**
  44819. * Mimic a banked turn, Rolling the camera when Yawing.
  44820. * It's recommended to use rollCorrect = 10 for faster banking correction.
  44821. */
  44822. bankedTurn: boolean;
  44823. /**
  44824. * Limit in radians for how much Roll banking will add. (Default: 90°)
  44825. */
  44826. bankedTurnLimit: number;
  44827. /**
  44828. * Value of 0 disables the banked Roll.
  44829. * Value of 1 is equal to the Yaw angle in radians.
  44830. */
  44831. bankedTurnMultiplier: number;
  44832. /**
  44833. * The inputs manager loads all the input sources, such as keyboard and mouse.
  44834. */
  44835. inputs: FlyCameraInputsManager;
  44836. /**
  44837. * Gets the input sensibility for mouse input.
  44838. * Higher values reduce sensitivity.
  44839. */
  44840. get angularSensibility(): number;
  44841. /**
  44842. * Sets the input sensibility for a mouse input.
  44843. * Higher values reduce sensitivity.
  44844. */
  44845. set angularSensibility(value: number);
  44846. /**
  44847. * Get the keys for camera movement forward.
  44848. */
  44849. get keysForward(): number[];
  44850. /**
  44851. * Set the keys for camera movement forward.
  44852. */
  44853. set keysForward(value: number[]);
  44854. /**
  44855. * Get the keys for camera movement backward.
  44856. */
  44857. get keysBackward(): number[];
  44858. set keysBackward(value: number[]);
  44859. /**
  44860. * Get the keys for camera movement up.
  44861. */
  44862. get keysUp(): number[];
  44863. /**
  44864. * Set the keys for camera movement up.
  44865. */
  44866. set keysUp(value: number[]);
  44867. /**
  44868. * Get the keys for camera movement down.
  44869. */
  44870. get keysDown(): number[];
  44871. /**
  44872. * Set the keys for camera movement down.
  44873. */
  44874. set keysDown(value: number[]);
  44875. /**
  44876. * Get the keys for camera movement left.
  44877. */
  44878. get keysLeft(): number[];
  44879. /**
  44880. * Set the keys for camera movement left.
  44881. */
  44882. set keysLeft(value: number[]);
  44883. /**
  44884. * Set the keys for camera movement right.
  44885. */
  44886. get keysRight(): number[];
  44887. /**
  44888. * Set the keys for camera movement right.
  44889. */
  44890. set keysRight(value: number[]);
  44891. /**
  44892. * Event raised when the camera collides with a mesh in the scene.
  44893. */
  44894. onCollide: (collidedMesh: AbstractMesh) => void;
  44895. private _collider;
  44896. private _needMoveForGravity;
  44897. private _oldPosition;
  44898. private _diffPosition;
  44899. private _newPosition;
  44900. /** @hidden */
  44901. _localDirection: Vector3;
  44902. /** @hidden */
  44903. _transformedDirection: Vector3;
  44904. /**
  44905. * Instantiates a FlyCamera.
  44906. * This is a flying camera, designed for 3D movement and rotation in all directions,
  44907. * such as in a 3D Space Shooter or a Flight Simulator.
  44908. * @param name Define the name of the camera in the scene.
  44909. * @param position Define the starting position of the camera in the scene.
  44910. * @param scene Define the scene the camera belongs to.
  44911. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  44912. */
  44913. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44914. /**
  44915. * Attach a control to the HTML DOM element.
  44916. * @param element Defines the element that listens to the input events.
  44917. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  44918. */
  44919. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44920. /**
  44921. * Detach a control from the HTML DOM element.
  44922. * The camera will stop reacting to that input.
  44923. * @param element Defines the element that listens to the input events.
  44924. */
  44925. detachControl(element: HTMLElement): void;
  44926. private _collisionMask;
  44927. /**
  44928. * Get the mask that the camera ignores in collision events.
  44929. */
  44930. get collisionMask(): number;
  44931. /**
  44932. * Set the mask that the camera ignores in collision events.
  44933. */
  44934. set collisionMask(mask: number);
  44935. /** @hidden */
  44936. _collideWithWorld(displacement: Vector3): void;
  44937. /** @hidden */
  44938. private _onCollisionPositionChange;
  44939. /** @hidden */
  44940. _checkInputs(): void;
  44941. /** @hidden */
  44942. _decideIfNeedsToMove(): boolean;
  44943. /** @hidden */
  44944. _updatePosition(): void;
  44945. /**
  44946. * Restore the Roll to its target value at the rate specified.
  44947. * @param rate - Higher means slower restoring.
  44948. * @hidden
  44949. */
  44950. restoreRoll(rate: number): void;
  44951. /**
  44952. * Destroy the camera and release the current resources held by it.
  44953. */
  44954. dispose(): void;
  44955. /**
  44956. * Get the current object class name.
  44957. * @returns the class name.
  44958. */
  44959. getClassName(): string;
  44960. }
  44961. }
  44962. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  44963. import { Nullable } from "babylonjs/types";
  44964. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44965. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  44966. /**
  44967. * Listen to keyboard events to control the camera.
  44968. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44969. */
  44970. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  44971. /**
  44972. * Defines the camera the input is attached to.
  44973. */
  44974. camera: FlyCamera;
  44975. /**
  44976. * The list of keyboard keys used to control the forward move of the camera.
  44977. */
  44978. keysForward: number[];
  44979. /**
  44980. * The list of keyboard keys used to control the backward move of the camera.
  44981. */
  44982. keysBackward: number[];
  44983. /**
  44984. * The list of keyboard keys used to control the forward move of the camera.
  44985. */
  44986. keysUp: number[];
  44987. /**
  44988. * The list of keyboard keys used to control the backward move of the camera.
  44989. */
  44990. keysDown: number[];
  44991. /**
  44992. * The list of keyboard keys used to control the right strafe move of the camera.
  44993. */
  44994. keysRight: number[];
  44995. /**
  44996. * The list of keyboard keys used to control the left strafe move of the camera.
  44997. */
  44998. keysLeft: number[];
  44999. private _keys;
  45000. private _onCanvasBlurObserver;
  45001. private _onKeyboardObserver;
  45002. private _engine;
  45003. private _scene;
  45004. /**
  45005. * Attach the input controls to a specific dom element to get the input from.
  45006. * @param element Defines the element the controls should be listened from
  45007. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45008. */
  45009. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45010. /**
  45011. * Detach the current controls from the specified dom element.
  45012. * @param element Defines the element to stop listening the inputs from
  45013. */
  45014. detachControl(element: Nullable<HTMLElement>): void;
  45015. /**
  45016. * Gets the class name of the current intput.
  45017. * @returns the class name
  45018. */
  45019. getClassName(): string;
  45020. /** @hidden */
  45021. _onLostFocus(e: FocusEvent): void;
  45022. /**
  45023. * Get the friendly name associated with the input class.
  45024. * @returns the input friendly name
  45025. */
  45026. getSimpleName(): string;
  45027. /**
  45028. * Update the current camera state depending on the inputs that have been used this frame.
  45029. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45030. */
  45031. checkInputs(): void;
  45032. }
  45033. }
  45034. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  45035. import { Nullable } from "babylonjs/types";
  45036. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45037. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45038. /**
  45039. * Manage the mouse wheel inputs to control a follow camera.
  45040. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45041. */
  45042. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  45043. /**
  45044. * Defines the camera the input is attached to.
  45045. */
  45046. camera: FollowCamera;
  45047. /**
  45048. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  45049. */
  45050. axisControlRadius: boolean;
  45051. /**
  45052. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  45053. */
  45054. axisControlHeight: boolean;
  45055. /**
  45056. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  45057. */
  45058. axisControlRotation: boolean;
  45059. /**
  45060. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  45061. * relation to mouseWheel events.
  45062. */
  45063. wheelPrecision: number;
  45064. /**
  45065. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45066. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45067. */
  45068. wheelDeltaPercentage: number;
  45069. private _wheel;
  45070. private _observer;
  45071. /**
  45072. * Attach the input controls to a specific dom element to get the input from.
  45073. * @param element Defines the element the controls should be listened from
  45074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45075. */
  45076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45077. /**
  45078. * Detach the current controls from the specified dom element.
  45079. * @param element Defines the element to stop listening the inputs from
  45080. */
  45081. detachControl(element: Nullable<HTMLElement>): void;
  45082. /**
  45083. * Gets the class name of the current intput.
  45084. * @returns the class name
  45085. */
  45086. getClassName(): string;
  45087. /**
  45088. * Get the friendly name associated with the input class.
  45089. * @returns the input friendly name
  45090. */
  45091. getSimpleName(): string;
  45092. }
  45093. }
  45094. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  45095. import { Nullable } from "babylonjs/types";
  45096. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45097. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  45098. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  45099. /**
  45100. * Manage the pointers inputs to control an follow camera.
  45101. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45102. */
  45103. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  45104. /**
  45105. * Defines the camera the input is attached to.
  45106. */
  45107. camera: FollowCamera;
  45108. /**
  45109. * Gets the class name of the current input.
  45110. * @returns the class name
  45111. */
  45112. getClassName(): string;
  45113. /**
  45114. * Defines the pointer angular sensibility along the X axis or how fast is
  45115. * the camera rotating.
  45116. * A negative number will reverse the axis direction.
  45117. */
  45118. angularSensibilityX: number;
  45119. /**
  45120. * Defines the pointer angular sensibility along the Y axis or how fast is
  45121. * the camera rotating.
  45122. * A negative number will reverse the axis direction.
  45123. */
  45124. angularSensibilityY: number;
  45125. /**
  45126. * Defines the pointer pinch precision or how fast is the camera zooming.
  45127. * A negative number will reverse the axis direction.
  45128. */
  45129. pinchPrecision: number;
  45130. /**
  45131. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45132. * from 0.
  45133. * It defines the percentage of current camera.radius to use as delta when
  45134. * pinch zoom is used.
  45135. */
  45136. pinchDeltaPercentage: number;
  45137. /**
  45138. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  45139. */
  45140. axisXControlRadius: boolean;
  45141. /**
  45142. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  45143. */
  45144. axisXControlHeight: boolean;
  45145. /**
  45146. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  45147. */
  45148. axisXControlRotation: boolean;
  45149. /**
  45150. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  45151. */
  45152. axisYControlRadius: boolean;
  45153. /**
  45154. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  45155. */
  45156. axisYControlHeight: boolean;
  45157. /**
  45158. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  45159. */
  45160. axisYControlRotation: boolean;
  45161. /**
  45162. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  45163. */
  45164. axisPinchControlRadius: boolean;
  45165. /**
  45166. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  45167. */
  45168. axisPinchControlHeight: boolean;
  45169. /**
  45170. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  45171. */
  45172. axisPinchControlRotation: boolean;
  45173. /**
  45174. * Log error messages if basic misconfiguration has occurred.
  45175. */
  45176. warningEnable: boolean;
  45177. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45178. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45179. private _warningCounter;
  45180. private _warning;
  45181. }
  45182. }
  45183. declare module "babylonjs/Cameras/followCameraInputsManager" {
  45184. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45185. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45186. /**
  45187. * Default Inputs manager for the FollowCamera.
  45188. * It groups all the default supported inputs for ease of use.
  45189. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45190. */
  45191. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  45192. /**
  45193. * Instantiates a new FollowCameraInputsManager.
  45194. * @param camera Defines the camera the inputs belong to
  45195. */
  45196. constructor(camera: FollowCamera);
  45197. /**
  45198. * Add keyboard input support to the input manager.
  45199. * @returns the current input manager
  45200. */
  45201. addKeyboard(): FollowCameraInputsManager;
  45202. /**
  45203. * Add mouse wheel input support to the input manager.
  45204. * @returns the current input manager
  45205. */
  45206. addMouseWheel(): FollowCameraInputsManager;
  45207. /**
  45208. * Add pointers input support to the input manager.
  45209. * @returns the current input manager
  45210. */
  45211. addPointers(): FollowCameraInputsManager;
  45212. /**
  45213. * Add orientation input support to the input manager.
  45214. * @returns the current input manager
  45215. */
  45216. addVRDeviceOrientation(): FollowCameraInputsManager;
  45217. }
  45218. }
  45219. declare module "babylonjs/Cameras/followCamera" {
  45220. import { Nullable } from "babylonjs/types";
  45221. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45222. import { Scene } from "babylonjs/scene";
  45223. import { Vector3 } from "babylonjs/Maths/math.vector";
  45224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45225. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  45226. /**
  45227. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  45228. * an arc rotate version arcFollowCamera are available.
  45229. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45230. */
  45231. export class FollowCamera extends TargetCamera {
  45232. /**
  45233. * Distance the follow camera should follow an object at
  45234. */
  45235. radius: number;
  45236. /**
  45237. * Minimum allowed distance of the camera to the axis of rotation
  45238. * (The camera can not get closer).
  45239. * This can help limiting how the Camera is able to move in the scene.
  45240. */
  45241. lowerRadiusLimit: Nullable<number>;
  45242. /**
  45243. * Maximum allowed distance of the camera to the axis of rotation
  45244. * (The camera can not get further).
  45245. * This can help limiting how the Camera is able to move in the scene.
  45246. */
  45247. upperRadiusLimit: Nullable<number>;
  45248. /**
  45249. * Define a rotation offset between the camera and the object it follows
  45250. */
  45251. rotationOffset: number;
  45252. /**
  45253. * Minimum allowed angle to camera position relative to target object.
  45254. * This can help limiting how the Camera is able to move in the scene.
  45255. */
  45256. lowerRotationOffsetLimit: Nullable<number>;
  45257. /**
  45258. * Maximum allowed angle to camera position relative to target object.
  45259. * This can help limiting how the Camera is able to move in the scene.
  45260. */
  45261. upperRotationOffsetLimit: Nullable<number>;
  45262. /**
  45263. * Define a height offset between the camera and the object it follows.
  45264. * It can help following an object from the top (like a car chaing a plane)
  45265. */
  45266. heightOffset: number;
  45267. /**
  45268. * Minimum allowed height of camera position relative to target object.
  45269. * This can help limiting how the Camera is able to move in the scene.
  45270. */
  45271. lowerHeightOffsetLimit: Nullable<number>;
  45272. /**
  45273. * Maximum allowed height of camera position relative to target object.
  45274. * This can help limiting how the Camera is able to move in the scene.
  45275. */
  45276. upperHeightOffsetLimit: Nullable<number>;
  45277. /**
  45278. * Define how fast the camera can accelerate to follow it s target.
  45279. */
  45280. cameraAcceleration: number;
  45281. /**
  45282. * Define the speed limit of the camera following an object.
  45283. */
  45284. maxCameraSpeed: number;
  45285. /**
  45286. * Define the target of the camera.
  45287. */
  45288. lockedTarget: Nullable<AbstractMesh>;
  45289. /**
  45290. * Defines the input associated with the camera.
  45291. */
  45292. inputs: FollowCameraInputsManager;
  45293. /**
  45294. * Instantiates the follow camera.
  45295. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45296. * @param name Define the name of the camera in the scene
  45297. * @param position Define the position of the camera
  45298. * @param scene Define the scene the camera belong to
  45299. * @param lockedTarget Define the target of the camera
  45300. */
  45301. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  45302. private _follow;
  45303. /**
  45304. * Attached controls to the current camera.
  45305. * @param element Defines the element the controls should be listened from
  45306. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45307. */
  45308. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45309. /**
  45310. * Detach the current controls from the camera.
  45311. * The camera will stop reacting to inputs.
  45312. * @param element Defines the element to stop listening the inputs from
  45313. */
  45314. detachControl(element: HTMLElement): void;
  45315. /** @hidden */
  45316. _checkInputs(): void;
  45317. private _checkLimits;
  45318. /**
  45319. * Gets the camera class name.
  45320. * @returns the class name
  45321. */
  45322. getClassName(): string;
  45323. }
  45324. /**
  45325. * Arc Rotate version of the follow camera.
  45326. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  45327. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45328. */
  45329. export class ArcFollowCamera extends TargetCamera {
  45330. /** The longitudinal angle of the camera */
  45331. alpha: number;
  45332. /** The latitudinal angle of the camera */
  45333. beta: number;
  45334. /** The radius of the camera from its target */
  45335. radius: number;
  45336. /** Define the camera target (the mesh it should follow) */
  45337. target: Nullable<AbstractMesh>;
  45338. private _cartesianCoordinates;
  45339. /**
  45340. * Instantiates a new ArcFollowCamera
  45341. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  45342. * @param name Define the name of the camera
  45343. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  45344. * @param beta Define the rotation angle of the camera around the elevation axis
  45345. * @param radius Define the radius of the camera from its target point
  45346. * @param target Define the target of the camera
  45347. * @param scene Define the scene the camera belongs to
  45348. */
  45349. constructor(name: string,
  45350. /** The longitudinal angle of the camera */
  45351. alpha: number,
  45352. /** The latitudinal angle of the camera */
  45353. beta: number,
  45354. /** The radius of the camera from its target */
  45355. radius: number,
  45356. /** Define the camera target (the mesh it should follow) */
  45357. target: Nullable<AbstractMesh>, scene: Scene);
  45358. private _follow;
  45359. /** @hidden */
  45360. _checkInputs(): void;
  45361. /**
  45362. * Returns the class name of the object.
  45363. * It is mostly used internally for serialization purposes.
  45364. */
  45365. getClassName(): string;
  45366. }
  45367. }
  45368. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  45369. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45370. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  45371. import { Nullable } from "babylonjs/types";
  45372. /**
  45373. * Manage the keyboard inputs to control the movement of a follow camera.
  45374. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45375. */
  45376. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  45377. /**
  45378. * Defines the camera the input is attached to.
  45379. */
  45380. camera: FollowCamera;
  45381. /**
  45382. * Defines the list of key codes associated with the up action (increase heightOffset)
  45383. */
  45384. keysHeightOffsetIncr: number[];
  45385. /**
  45386. * Defines the list of key codes associated with the down action (decrease heightOffset)
  45387. */
  45388. keysHeightOffsetDecr: number[];
  45389. /**
  45390. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  45391. */
  45392. keysHeightOffsetModifierAlt: boolean;
  45393. /**
  45394. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  45395. */
  45396. keysHeightOffsetModifierCtrl: boolean;
  45397. /**
  45398. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  45399. */
  45400. keysHeightOffsetModifierShift: boolean;
  45401. /**
  45402. * Defines the list of key codes associated with the left action (increase rotationOffset)
  45403. */
  45404. keysRotationOffsetIncr: number[];
  45405. /**
  45406. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  45407. */
  45408. keysRotationOffsetDecr: number[];
  45409. /**
  45410. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  45411. */
  45412. keysRotationOffsetModifierAlt: boolean;
  45413. /**
  45414. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  45415. */
  45416. keysRotationOffsetModifierCtrl: boolean;
  45417. /**
  45418. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  45419. */
  45420. keysRotationOffsetModifierShift: boolean;
  45421. /**
  45422. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  45423. */
  45424. keysRadiusIncr: number[];
  45425. /**
  45426. * Defines the list of key codes associated with the zoom-out action (increase radius)
  45427. */
  45428. keysRadiusDecr: number[];
  45429. /**
  45430. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  45431. */
  45432. keysRadiusModifierAlt: boolean;
  45433. /**
  45434. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  45435. */
  45436. keysRadiusModifierCtrl: boolean;
  45437. /**
  45438. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  45439. */
  45440. keysRadiusModifierShift: boolean;
  45441. /**
  45442. * Defines the rate of change of heightOffset.
  45443. */
  45444. heightSensibility: number;
  45445. /**
  45446. * Defines the rate of change of rotationOffset.
  45447. */
  45448. rotationSensibility: number;
  45449. /**
  45450. * Defines the rate of change of radius.
  45451. */
  45452. radiusSensibility: number;
  45453. private _keys;
  45454. private _ctrlPressed;
  45455. private _altPressed;
  45456. private _shiftPressed;
  45457. private _onCanvasBlurObserver;
  45458. private _onKeyboardObserver;
  45459. private _engine;
  45460. private _scene;
  45461. /**
  45462. * Attach the input controls to a specific dom element to get the input from.
  45463. * @param element Defines the element the controls should be listened from
  45464. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45465. */
  45466. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45467. /**
  45468. * Detach the current controls from the specified dom element.
  45469. * @param element Defines the element to stop listening the inputs from
  45470. */
  45471. detachControl(element: Nullable<HTMLElement>): void;
  45472. /**
  45473. * Update the current camera state depending on the inputs that have been used this frame.
  45474. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45475. */
  45476. checkInputs(): void;
  45477. /**
  45478. * Gets the class name of the current input.
  45479. * @returns the class name
  45480. */
  45481. getClassName(): string;
  45482. /**
  45483. * Get the friendly name associated with the input class.
  45484. * @returns the input friendly name
  45485. */
  45486. getSimpleName(): string;
  45487. /**
  45488. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45489. * allow modification of the heightOffset value.
  45490. */
  45491. private _modifierHeightOffset;
  45492. /**
  45493. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45494. * allow modification of the rotationOffset value.
  45495. */
  45496. private _modifierRotationOffset;
  45497. /**
  45498. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  45499. * allow modification of the radius value.
  45500. */
  45501. private _modifierRadius;
  45502. }
  45503. }
  45504. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  45505. import { Nullable } from "babylonjs/types";
  45506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45507. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45508. import { Observable } from "babylonjs/Misc/observable";
  45509. module "babylonjs/Cameras/freeCameraInputsManager" {
  45510. interface FreeCameraInputsManager {
  45511. /**
  45512. * @hidden
  45513. */
  45514. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  45515. /**
  45516. * Add orientation input support to the input manager.
  45517. * @returns the current input manager
  45518. */
  45519. addDeviceOrientation(): FreeCameraInputsManager;
  45520. }
  45521. }
  45522. /**
  45523. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  45524. * Screen rotation is taken into account.
  45525. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45526. */
  45527. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  45528. private _camera;
  45529. private _screenOrientationAngle;
  45530. private _constantTranform;
  45531. private _screenQuaternion;
  45532. private _alpha;
  45533. private _beta;
  45534. private _gamma;
  45535. /**
  45536. * Can be used to detect if a device orientation sensor is available on a device
  45537. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  45538. * @returns a promise that will resolve on orientation change
  45539. */
  45540. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  45541. /**
  45542. * @hidden
  45543. */
  45544. _onDeviceOrientationChangedObservable: Observable<void>;
  45545. /**
  45546. * Instantiates a new input
  45547. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45548. */
  45549. constructor();
  45550. /**
  45551. * Define the camera controlled by the input.
  45552. */
  45553. get camera(): FreeCamera;
  45554. set camera(camera: FreeCamera);
  45555. /**
  45556. * Attach the input controls to a specific dom element to get the input from.
  45557. * @param element Defines the element the controls should be listened from
  45558. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45559. */
  45560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45561. private _orientationChanged;
  45562. private _deviceOrientation;
  45563. /**
  45564. * Detach the current controls from the specified dom element.
  45565. * @param element Defines the element to stop listening the inputs from
  45566. */
  45567. detachControl(element: Nullable<HTMLElement>): void;
  45568. /**
  45569. * Update the current camera state depending on the inputs that have been used this frame.
  45570. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45571. */
  45572. checkInputs(): void;
  45573. /**
  45574. * Gets the class name of the current intput.
  45575. * @returns the class name
  45576. */
  45577. getClassName(): string;
  45578. /**
  45579. * Get the friendly name associated with the input class.
  45580. * @returns the input friendly name
  45581. */
  45582. getSimpleName(): string;
  45583. }
  45584. }
  45585. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  45586. import { Nullable } from "babylonjs/types";
  45587. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45588. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45589. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45590. /**
  45591. * Manage the gamepad inputs to control a free camera.
  45592. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45593. */
  45594. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  45595. /**
  45596. * Define the camera the input is attached to.
  45597. */
  45598. camera: FreeCamera;
  45599. /**
  45600. * Define the Gamepad controlling the input
  45601. */
  45602. gamepad: Nullable<Gamepad>;
  45603. /**
  45604. * Defines the gamepad rotation sensiblity.
  45605. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45606. */
  45607. gamepadAngularSensibility: number;
  45608. /**
  45609. * Defines the gamepad move sensiblity.
  45610. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45611. */
  45612. gamepadMoveSensibility: number;
  45613. private _yAxisScale;
  45614. /**
  45615. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45616. */
  45617. get invertYAxis(): boolean;
  45618. set invertYAxis(value: boolean);
  45619. private _onGamepadConnectedObserver;
  45620. private _onGamepadDisconnectedObserver;
  45621. private _cameraTransform;
  45622. private _deltaTransform;
  45623. private _vector3;
  45624. private _vector2;
  45625. /**
  45626. * Attach the input controls to a specific dom element to get the input from.
  45627. * @param element Defines the element the controls should be listened from
  45628. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45629. */
  45630. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45631. /**
  45632. * Detach the current controls from the specified dom element.
  45633. * @param element Defines the element to stop listening the inputs from
  45634. */
  45635. detachControl(element: Nullable<HTMLElement>): void;
  45636. /**
  45637. * Update the current camera state depending on the inputs that have been used this frame.
  45638. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45639. */
  45640. checkInputs(): void;
  45641. /**
  45642. * Gets the class name of the current intput.
  45643. * @returns the class name
  45644. */
  45645. getClassName(): string;
  45646. /**
  45647. * Get the friendly name associated with the input class.
  45648. * @returns the input friendly name
  45649. */
  45650. getSimpleName(): string;
  45651. }
  45652. }
  45653. declare module "babylonjs/Misc/virtualJoystick" {
  45654. import { Nullable } from "babylonjs/types";
  45655. import { Vector3 } from "babylonjs/Maths/math.vector";
  45656. /**
  45657. * Defines the potential axis of a Joystick
  45658. */
  45659. export enum JoystickAxis {
  45660. /** X axis */
  45661. X = 0,
  45662. /** Y axis */
  45663. Y = 1,
  45664. /** Z axis */
  45665. Z = 2
  45666. }
  45667. /**
  45668. * Represents the different customization options available
  45669. * for VirtualJoystick
  45670. */
  45671. interface VirtualJoystickCustomizations {
  45672. /**
  45673. * Size of the joystick's puck
  45674. */
  45675. puckSize: number;
  45676. /**
  45677. * Size of the joystick's container
  45678. */
  45679. containerSize: number;
  45680. /**
  45681. * Color of the joystick && puck
  45682. */
  45683. color: string;
  45684. /**
  45685. * Image URL for the joystick's puck
  45686. */
  45687. puckImage?: string;
  45688. /**
  45689. * Image URL for the joystick's container
  45690. */
  45691. containerImage?: string;
  45692. /**
  45693. * Defines the unmoving position of the joystick container
  45694. */
  45695. position?: {
  45696. x: number;
  45697. y: number;
  45698. };
  45699. /**
  45700. * Defines whether or not the joystick container is always visible
  45701. */
  45702. alwaysVisible: boolean;
  45703. /**
  45704. * Defines whether or not to limit the movement of the puck to the joystick's container
  45705. */
  45706. limitToContainer: boolean;
  45707. }
  45708. /**
  45709. * Class used to define virtual joystick (used in touch mode)
  45710. */
  45711. export class VirtualJoystick {
  45712. /**
  45713. * Gets or sets a boolean indicating that left and right values must be inverted
  45714. */
  45715. reverseLeftRight: boolean;
  45716. /**
  45717. * Gets or sets a boolean indicating that up and down values must be inverted
  45718. */
  45719. reverseUpDown: boolean;
  45720. /**
  45721. * Gets the offset value for the position (ie. the change of the position value)
  45722. */
  45723. deltaPosition: Vector3;
  45724. /**
  45725. * Gets a boolean indicating if the virtual joystick was pressed
  45726. */
  45727. pressed: boolean;
  45728. /**
  45729. * Canvas the virtual joystick will render onto, default z-index of this is 5
  45730. */
  45731. static Canvas: Nullable<HTMLCanvasElement>;
  45732. /**
  45733. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  45734. */
  45735. limitToContainer: boolean;
  45736. private static _globalJoystickIndex;
  45737. private static _alwaysVisibleSticks;
  45738. private static vjCanvasContext;
  45739. private static vjCanvasWidth;
  45740. private static vjCanvasHeight;
  45741. private static halfWidth;
  45742. private static _GetDefaultOptions;
  45743. private _action;
  45744. private _axisTargetedByLeftAndRight;
  45745. private _axisTargetedByUpAndDown;
  45746. private _joystickSensibility;
  45747. private _inversedSensibility;
  45748. private _joystickPointerID;
  45749. private _joystickColor;
  45750. private _joystickPointerPos;
  45751. private _joystickPreviousPointerPos;
  45752. private _joystickPointerStartPos;
  45753. private _deltaJoystickVector;
  45754. private _leftJoystick;
  45755. private _touches;
  45756. private _joystickPosition;
  45757. private _alwaysVisible;
  45758. private _puckImage;
  45759. private _containerImage;
  45760. private _joystickPuckSize;
  45761. private _joystickContainerSize;
  45762. private _clearPuckSize;
  45763. private _clearContainerSize;
  45764. private _clearPuckSizeOffset;
  45765. private _clearContainerSizeOffset;
  45766. private _onPointerDownHandlerRef;
  45767. private _onPointerMoveHandlerRef;
  45768. private _onPointerUpHandlerRef;
  45769. private _onResize;
  45770. /**
  45771. * Creates a new virtual joystick
  45772. * @param leftJoystick defines that the joystick is for left hand (false by default)
  45773. * @param customizations Defines the options we want to customize the VirtualJoystick
  45774. */
  45775. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  45776. /**
  45777. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  45778. * @param newJoystickSensibility defines the new sensibility
  45779. */
  45780. setJoystickSensibility(newJoystickSensibility: number): void;
  45781. private _onPointerDown;
  45782. private _onPointerMove;
  45783. private _onPointerUp;
  45784. /**
  45785. * Change the color of the virtual joystick
  45786. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  45787. */
  45788. setJoystickColor(newColor: string): void;
  45789. /**
  45790. * Size of the joystick's container
  45791. */
  45792. set containerSize(newSize: number);
  45793. get containerSize(): number;
  45794. /**
  45795. * Size of the joystick's puck
  45796. */
  45797. set puckSize(newSize: number);
  45798. get puckSize(): number;
  45799. /**
  45800. * Clears the set position of the joystick
  45801. */
  45802. clearPosition(): void;
  45803. /**
  45804. * Defines whether or not the joystick container is always visible
  45805. */
  45806. set alwaysVisible(value: boolean);
  45807. get alwaysVisible(): boolean;
  45808. /**
  45809. * Sets the constant position of the Joystick container
  45810. * @param x X axis coordinate
  45811. * @param y Y axis coordinate
  45812. */
  45813. setPosition(x: number, y: number): void;
  45814. /**
  45815. * Defines a callback to call when the joystick is touched
  45816. * @param action defines the callback
  45817. */
  45818. setActionOnTouch(action: () => any): void;
  45819. /**
  45820. * Defines which axis you'd like to control for left & right
  45821. * @param axis defines the axis to use
  45822. */
  45823. setAxisForLeftRight(axis: JoystickAxis): void;
  45824. /**
  45825. * Defines which axis you'd like to control for up & down
  45826. * @param axis defines the axis to use
  45827. */
  45828. setAxisForUpDown(axis: JoystickAxis): void;
  45829. /**
  45830. * Clears the canvas from the previous puck / container draw
  45831. */
  45832. private _clearPreviousDraw;
  45833. /**
  45834. * Loads `urlPath` to be used for the container's image
  45835. * @param urlPath defines the urlPath of an image to use
  45836. */
  45837. setContainerImage(urlPath: string): void;
  45838. /**
  45839. * Loads `urlPath` to be used for the puck's image
  45840. * @param urlPath defines the urlPath of an image to use
  45841. */
  45842. setPuckImage(urlPath: string): void;
  45843. /**
  45844. * Draws the Virtual Joystick's container
  45845. */
  45846. private _drawContainer;
  45847. /**
  45848. * Draws the Virtual Joystick's puck
  45849. */
  45850. private _drawPuck;
  45851. private _drawVirtualJoystick;
  45852. /**
  45853. * Release internal HTML canvas
  45854. */
  45855. releaseCanvas(): void;
  45856. }
  45857. }
  45858. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  45859. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  45860. import { Nullable } from "babylonjs/types";
  45861. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45862. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45863. module "babylonjs/Cameras/freeCameraInputsManager" {
  45864. interface FreeCameraInputsManager {
  45865. /**
  45866. * Add virtual joystick input support to the input manager.
  45867. * @returns the current input manager
  45868. */
  45869. addVirtualJoystick(): FreeCameraInputsManager;
  45870. }
  45871. }
  45872. /**
  45873. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  45874. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45875. */
  45876. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  45877. /**
  45878. * Defines the camera the input is attached to.
  45879. */
  45880. camera: FreeCamera;
  45881. private _leftjoystick;
  45882. private _rightjoystick;
  45883. /**
  45884. * Gets the left stick of the virtual joystick.
  45885. * @returns The virtual Joystick
  45886. */
  45887. getLeftJoystick(): VirtualJoystick;
  45888. /**
  45889. * Gets the right stick of the virtual joystick.
  45890. * @returns The virtual Joystick
  45891. */
  45892. getRightJoystick(): VirtualJoystick;
  45893. /**
  45894. * Update the current camera state depending on the inputs that have been used this frame.
  45895. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45896. */
  45897. checkInputs(): void;
  45898. /**
  45899. * Attach the input controls to a specific dom element to get the input from.
  45900. * @param element Defines the element the controls should be listened from
  45901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45902. */
  45903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45904. /**
  45905. * Detach the current controls from the specified dom element.
  45906. * @param element Defines the element to stop listening the inputs from
  45907. */
  45908. detachControl(element: Nullable<HTMLElement>): void;
  45909. /**
  45910. * Gets the class name of the current intput.
  45911. * @returns the class name
  45912. */
  45913. getClassName(): string;
  45914. /**
  45915. * Get the friendly name associated with the input class.
  45916. * @returns the input friendly name
  45917. */
  45918. getSimpleName(): string;
  45919. }
  45920. }
  45921. declare module "babylonjs/Cameras/Inputs/index" {
  45922. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  45923. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  45924. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  45925. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  45926. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  45927. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  45928. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  45929. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  45930. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  45931. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  45932. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45933. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  45934. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  45935. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  45936. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  45937. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  45938. }
  45939. declare module "babylonjs/Cameras/touchCamera" {
  45940. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45941. import { Scene } from "babylonjs/scene";
  45942. import { Vector3 } from "babylonjs/Maths/math.vector";
  45943. /**
  45944. * This represents a FPS type of camera controlled by touch.
  45945. * This is like a universal camera minus the Gamepad controls.
  45946. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45947. */
  45948. export class TouchCamera extends FreeCamera {
  45949. /**
  45950. * Defines the touch sensibility for rotation.
  45951. * The higher the faster.
  45952. */
  45953. get touchAngularSensibility(): number;
  45954. set touchAngularSensibility(value: number);
  45955. /**
  45956. * Defines the touch sensibility for move.
  45957. * The higher the faster.
  45958. */
  45959. get touchMoveSensibility(): number;
  45960. set touchMoveSensibility(value: number);
  45961. /**
  45962. * Instantiates a new touch camera.
  45963. * This represents a FPS type of camera controlled by touch.
  45964. * This is like a universal camera minus the Gamepad controls.
  45965. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  45966. * @param name Define the name of the camera in the scene
  45967. * @param position Define the start position of the camera in the scene
  45968. * @param scene Define the scene the camera belongs to
  45969. */
  45970. constructor(name: string, position: Vector3, scene: Scene);
  45971. /**
  45972. * Gets the current object class name.
  45973. * @return the class name
  45974. */
  45975. getClassName(): string;
  45976. /** @hidden */
  45977. _setupInputs(): void;
  45978. }
  45979. }
  45980. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  45981. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  45982. import { Scene } from "babylonjs/scene";
  45983. import { Vector3 } from "babylonjs/Maths/math.vector";
  45984. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  45985. import { Axis } from "babylonjs/Maths/math.axis";
  45986. /**
  45987. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  45988. * being tilted forward or back and left or right.
  45989. */
  45990. export class DeviceOrientationCamera extends FreeCamera {
  45991. private _initialQuaternion;
  45992. private _quaternionCache;
  45993. private _tmpDragQuaternion;
  45994. private _disablePointerInputWhenUsingDeviceOrientation;
  45995. /**
  45996. * Creates a new device orientation camera
  45997. * @param name The name of the camera
  45998. * @param position The start position camera
  45999. * @param scene The scene the camera belongs to
  46000. */
  46001. constructor(name: string, position: Vector3, scene: Scene);
  46002. /**
  46003. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  46004. */
  46005. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  46006. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  46007. private _dragFactor;
  46008. /**
  46009. * Enabled turning on the y axis when the orientation sensor is active
  46010. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  46011. */
  46012. enableHorizontalDragging(dragFactor?: number): void;
  46013. /**
  46014. * Gets the current instance class name ("DeviceOrientationCamera").
  46015. * This helps avoiding instanceof at run time.
  46016. * @returns the class name
  46017. */
  46018. getClassName(): string;
  46019. /**
  46020. * @hidden
  46021. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  46022. */
  46023. _checkInputs(): void;
  46024. /**
  46025. * Reset the camera to its default orientation on the specified axis only.
  46026. * @param axis The axis to reset
  46027. */
  46028. resetToCurrentRotation(axis?: Axis): void;
  46029. }
  46030. }
  46031. declare module "babylonjs/Gamepads/xboxGamepad" {
  46032. import { Observable } from "babylonjs/Misc/observable";
  46033. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46034. /**
  46035. * Defines supported buttons for XBox360 compatible gamepads
  46036. */
  46037. export enum Xbox360Button {
  46038. /** A */
  46039. A = 0,
  46040. /** B */
  46041. B = 1,
  46042. /** X */
  46043. X = 2,
  46044. /** Y */
  46045. Y = 3,
  46046. /** Left button */
  46047. LB = 4,
  46048. /** Right button */
  46049. RB = 5,
  46050. /** Back */
  46051. Back = 8,
  46052. /** Start */
  46053. Start = 9,
  46054. /** Left stick */
  46055. LeftStick = 10,
  46056. /** Right stick */
  46057. RightStick = 11
  46058. }
  46059. /** Defines values for XBox360 DPad */
  46060. export enum Xbox360Dpad {
  46061. /** Up */
  46062. Up = 12,
  46063. /** Down */
  46064. Down = 13,
  46065. /** Left */
  46066. Left = 14,
  46067. /** Right */
  46068. Right = 15
  46069. }
  46070. /**
  46071. * Defines a XBox360 gamepad
  46072. */
  46073. export class Xbox360Pad extends Gamepad {
  46074. private _leftTrigger;
  46075. private _rightTrigger;
  46076. private _onlefttriggerchanged;
  46077. private _onrighttriggerchanged;
  46078. private _onbuttondown;
  46079. private _onbuttonup;
  46080. private _ondpaddown;
  46081. private _ondpadup;
  46082. /** Observable raised when a button is pressed */
  46083. onButtonDownObservable: Observable<Xbox360Button>;
  46084. /** Observable raised when a button is released */
  46085. onButtonUpObservable: Observable<Xbox360Button>;
  46086. /** Observable raised when a pad is pressed */
  46087. onPadDownObservable: Observable<Xbox360Dpad>;
  46088. /** Observable raised when a pad is released */
  46089. onPadUpObservable: Observable<Xbox360Dpad>;
  46090. private _buttonA;
  46091. private _buttonB;
  46092. private _buttonX;
  46093. private _buttonY;
  46094. private _buttonBack;
  46095. private _buttonStart;
  46096. private _buttonLB;
  46097. private _buttonRB;
  46098. private _buttonLeftStick;
  46099. private _buttonRightStick;
  46100. private _dPadUp;
  46101. private _dPadDown;
  46102. private _dPadLeft;
  46103. private _dPadRight;
  46104. private _isXboxOnePad;
  46105. /**
  46106. * Creates a new XBox360 gamepad object
  46107. * @param id defines the id of this gamepad
  46108. * @param index defines its index
  46109. * @param gamepad defines the internal HTML gamepad object
  46110. * @param xboxOne defines if it is a XBox One gamepad
  46111. */
  46112. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  46113. /**
  46114. * Defines the callback to call when left trigger is pressed
  46115. * @param callback defines the callback to use
  46116. */
  46117. onlefttriggerchanged(callback: (value: number) => void): void;
  46118. /**
  46119. * Defines the callback to call when right trigger is pressed
  46120. * @param callback defines the callback to use
  46121. */
  46122. onrighttriggerchanged(callback: (value: number) => void): void;
  46123. /**
  46124. * Gets the left trigger value
  46125. */
  46126. get leftTrigger(): number;
  46127. /**
  46128. * Sets the left trigger value
  46129. */
  46130. set leftTrigger(newValue: number);
  46131. /**
  46132. * Gets the right trigger value
  46133. */
  46134. get rightTrigger(): number;
  46135. /**
  46136. * Sets the right trigger value
  46137. */
  46138. set rightTrigger(newValue: number);
  46139. /**
  46140. * Defines the callback to call when a button is pressed
  46141. * @param callback defines the callback to use
  46142. */
  46143. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  46144. /**
  46145. * Defines the callback to call when a button is released
  46146. * @param callback defines the callback to use
  46147. */
  46148. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  46149. /**
  46150. * Defines the callback to call when a pad is pressed
  46151. * @param callback defines the callback to use
  46152. */
  46153. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  46154. /**
  46155. * Defines the callback to call when a pad is released
  46156. * @param callback defines the callback to use
  46157. */
  46158. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  46159. private _setButtonValue;
  46160. private _setDPadValue;
  46161. /**
  46162. * Gets the value of the `A` button
  46163. */
  46164. get buttonA(): number;
  46165. /**
  46166. * Sets the value of the `A` button
  46167. */
  46168. set buttonA(value: number);
  46169. /**
  46170. * Gets the value of the `B` button
  46171. */
  46172. get buttonB(): number;
  46173. /**
  46174. * Sets the value of the `B` button
  46175. */
  46176. set buttonB(value: number);
  46177. /**
  46178. * Gets the value of the `X` button
  46179. */
  46180. get buttonX(): number;
  46181. /**
  46182. * Sets the value of the `X` button
  46183. */
  46184. set buttonX(value: number);
  46185. /**
  46186. * Gets the value of the `Y` button
  46187. */
  46188. get buttonY(): number;
  46189. /**
  46190. * Sets the value of the `Y` button
  46191. */
  46192. set buttonY(value: number);
  46193. /**
  46194. * Gets the value of the `Start` button
  46195. */
  46196. get buttonStart(): number;
  46197. /**
  46198. * Sets the value of the `Start` button
  46199. */
  46200. set buttonStart(value: number);
  46201. /**
  46202. * Gets the value of the `Back` button
  46203. */
  46204. get buttonBack(): number;
  46205. /**
  46206. * Sets the value of the `Back` button
  46207. */
  46208. set buttonBack(value: number);
  46209. /**
  46210. * Gets the value of the `Left` button
  46211. */
  46212. get buttonLB(): number;
  46213. /**
  46214. * Sets the value of the `Left` button
  46215. */
  46216. set buttonLB(value: number);
  46217. /**
  46218. * Gets the value of the `Right` button
  46219. */
  46220. get buttonRB(): number;
  46221. /**
  46222. * Sets the value of the `Right` button
  46223. */
  46224. set buttonRB(value: number);
  46225. /**
  46226. * Gets the value of the Left joystick
  46227. */
  46228. get buttonLeftStick(): number;
  46229. /**
  46230. * Sets the value of the Left joystick
  46231. */
  46232. set buttonLeftStick(value: number);
  46233. /**
  46234. * Gets the value of the Right joystick
  46235. */
  46236. get buttonRightStick(): number;
  46237. /**
  46238. * Sets the value of the Right joystick
  46239. */
  46240. set buttonRightStick(value: number);
  46241. /**
  46242. * Gets the value of D-pad up
  46243. */
  46244. get dPadUp(): number;
  46245. /**
  46246. * Sets the value of D-pad up
  46247. */
  46248. set dPadUp(value: number);
  46249. /**
  46250. * Gets the value of D-pad down
  46251. */
  46252. get dPadDown(): number;
  46253. /**
  46254. * Sets the value of D-pad down
  46255. */
  46256. set dPadDown(value: number);
  46257. /**
  46258. * Gets the value of D-pad left
  46259. */
  46260. get dPadLeft(): number;
  46261. /**
  46262. * Sets the value of D-pad left
  46263. */
  46264. set dPadLeft(value: number);
  46265. /**
  46266. * Gets the value of D-pad right
  46267. */
  46268. get dPadRight(): number;
  46269. /**
  46270. * Sets the value of D-pad right
  46271. */
  46272. set dPadRight(value: number);
  46273. /**
  46274. * Force the gamepad to synchronize with device values
  46275. */
  46276. update(): void;
  46277. /**
  46278. * Disposes the gamepad
  46279. */
  46280. dispose(): void;
  46281. }
  46282. }
  46283. declare module "babylonjs/Gamepads/dualShockGamepad" {
  46284. import { Observable } from "babylonjs/Misc/observable";
  46285. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46286. /**
  46287. * Defines supported buttons for DualShock compatible gamepads
  46288. */
  46289. export enum DualShockButton {
  46290. /** Cross */
  46291. Cross = 0,
  46292. /** Circle */
  46293. Circle = 1,
  46294. /** Square */
  46295. Square = 2,
  46296. /** Triangle */
  46297. Triangle = 3,
  46298. /** L1 */
  46299. L1 = 4,
  46300. /** R1 */
  46301. R1 = 5,
  46302. /** Share */
  46303. Share = 8,
  46304. /** Options */
  46305. Options = 9,
  46306. /** Left stick */
  46307. LeftStick = 10,
  46308. /** Right stick */
  46309. RightStick = 11
  46310. }
  46311. /** Defines values for DualShock DPad */
  46312. export enum DualShockDpad {
  46313. /** Up */
  46314. Up = 12,
  46315. /** Down */
  46316. Down = 13,
  46317. /** Left */
  46318. Left = 14,
  46319. /** Right */
  46320. Right = 15
  46321. }
  46322. /**
  46323. * Defines a DualShock gamepad
  46324. */
  46325. export class DualShockPad extends Gamepad {
  46326. private _leftTrigger;
  46327. private _rightTrigger;
  46328. private _onlefttriggerchanged;
  46329. private _onrighttriggerchanged;
  46330. private _onbuttondown;
  46331. private _onbuttonup;
  46332. private _ondpaddown;
  46333. private _ondpadup;
  46334. /** Observable raised when a button is pressed */
  46335. onButtonDownObservable: Observable<DualShockButton>;
  46336. /** Observable raised when a button is released */
  46337. onButtonUpObservable: Observable<DualShockButton>;
  46338. /** Observable raised when a pad is pressed */
  46339. onPadDownObservable: Observable<DualShockDpad>;
  46340. /** Observable raised when a pad is released */
  46341. onPadUpObservable: Observable<DualShockDpad>;
  46342. private _buttonCross;
  46343. private _buttonCircle;
  46344. private _buttonSquare;
  46345. private _buttonTriangle;
  46346. private _buttonShare;
  46347. private _buttonOptions;
  46348. private _buttonL1;
  46349. private _buttonR1;
  46350. private _buttonLeftStick;
  46351. private _buttonRightStick;
  46352. private _dPadUp;
  46353. private _dPadDown;
  46354. private _dPadLeft;
  46355. private _dPadRight;
  46356. /**
  46357. * Creates a new DualShock gamepad object
  46358. * @param id defines the id of this gamepad
  46359. * @param index defines its index
  46360. * @param gamepad defines the internal HTML gamepad object
  46361. */
  46362. constructor(id: string, index: number, gamepad: any);
  46363. /**
  46364. * Defines the callback to call when left trigger is pressed
  46365. * @param callback defines the callback to use
  46366. */
  46367. onlefttriggerchanged(callback: (value: number) => void): void;
  46368. /**
  46369. * Defines the callback to call when right trigger is pressed
  46370. * @param callback defines the callback to use
  46371. */
  46372. onrighttriggerchanged(callback: (value: number) => void): void;
  46373. /**
  46374. * Gets the left trigger value
  46375. */
  46376. get leftTrigger(): number;
  46377. /**
  46378. * Sets the left trigger value
  46379. */
  46380. set leftTrigger(newValue: number);
  46381. /**
  46382. * Gets the right trigger value
  46383. */
  46384. get rightTrigger(): number;
  46385. /**
  46386. * Sets the right trigger value
  46387. */
  46388. set rightTrigger(newValue: number);
  46389. /**
  46390. * Defines the callback to call when a button is pressed
  46391. * @param callback defines the callback to use
  46392. */
  46393. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  46394. /**
  46395. * Defines the callback to call when a button is released
  46396. * @param callback defines the callback to use
  46397. */
  46398. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  46399. /**
  46400. * Defines the callback to call when a pad is pressed
  46401. * @param callback defines the callback to use
  46402. */
  46403. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  46404. /**
  46405. * Defines the callback to call when a pad is released
  46406. * @param callback defines the callback to use
  46407. */
  46408. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  46409. private _setButtonValue;
  46410. private _setDPadValue;
  46411. /**
  46412. * Gets the value of the `Cross` button
  46413. */
  46414. get buttonCross(): number;
  46415. /**
  46416. * Sets the value of the `Cross` button
  46417. */
  46418. set buttonCross(value: number);
  46419. /**
  46420. * Gets the value of the `Circle` button
  46421. */
  46422. get buttonCircle(): number;
  46423. /**
  46424. * Sets the value of the `Circle` button
  46425. */
  46426. set buttonCircle(value: number);
  46427. /**
  46428. * Gets the value of the `Square` button
  46429. */
  46430. get buttonSquare(): number;
  46431. /**
  46432. * Sets the value of the `Square` button
  46433. */
  46434. set buttonSquare(value: number);
  46435. /**
  46436. * Gets the value of the `Triangle` button
  46437. */
  46438. get buttonTriangle(): number;
  46439. /**
  46440. * Sets the value of the `Triangle` button
  46441. */
  46442. set buttonTriangle(value: number);
  46443. /**
  46444. * Gets the value of the `Options` button
  46445. */
  46446. get buttonOptions(): number;
  46447. /**
  46448. * Sets the value of the `Options` button
  46449. */
  46450. set buttonOptions(value: number);
  46451. /**
  46452. * Gets the value of the `Share` button
  46453. */
  46454. get buttonShare(): number;
  46455. /**
  46456. * Sets the value of the `Share` button
  46457. */
  46458. set buttonShare(value: number);
  46459. /**
  46460. * Gets the value of the `L1` button
  46461. */
  46462. get buttonL1(): number;
  46463. /**
  46464. * Sets the value of the `L1` button
  46465. */
  46466. set buttonL1(value: number);
  46467. /**
  46468. * Gets the value of the `R1` button
  46469. */
  46470. get buttonR1(): number;
  46471. /**
  46472. * Sets the value of the `R1` button
  46473. */
  46474. set buttonR1(value: number);
  46475. /**
  46476. * Gets the value of the Left joystick
  46477. */
  46478. get buttonLeftStick(): number;
  46479. /**
  46480. * Sets the value of the Left joystick
  46481. */
  46482. set buttonLeftStick(value: number);
  46483. /**
  46484. * Gets the value of the Right joystick
  46485. */
  46486. get buttonRightStick(): number;
  46487. /**
  46488. * Sets the value of the Right joystick
  46489. */
  46490. set buttonRightStick(value: number);
  46491. /**
  46492. * Gets the value of D-pad up
  46493. */
  46494. get dPadUp(): number;
  46495. /**
  46496. * Sets the value of D-pad up
  46497. */
  46498. set dPadUp(value: number);
  46499. /**
  46500. * Gets the value of D-pad down
  46501. */
  46502. get dPadDown(): number;
  46503. /**
  46504. * Sets the value of D-pad down
  46505. */
  46506. set dPadDown(value: number);
  46507. /**
  46508. * Gets the value of D-pad left
  46509. */
  46510. get dPadLeft(): number;
  46511. /**
  46512. * Sets the value of D-pad left
  46513. */
  46514. set dPadLeft(value: number);
  46515. /**
  46516. * Gets the value of D-pad right
  46517. */
  46518. get dPadRight(): number;
  46519. /**
  46520. * Sets the value of D-pad right
  46521. */
  46522. set dPadRight(value: number);
  46523. /**
  46524. * Force the gamepad to synchronize with device values
  46525. */
  46526. update(): void;
  46527. /**
  46528. * Disposes the gamepad
  46529. */
  46530. dispose(): void;
  46531. }
  46532. }
  46533. declare module "babylonjs/Gamepads/gamepadManager" {
  46534. import { Observable } from "babylonjs/Misc/observable";
  46535. import { Nullable } from "babylonjs/types";
  46536. import { Scene } from "babylonjs/scene";
  46537. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46538. /**
  46539. * Manager for handling gamepads
  46540. */
  46541. export class GamepadManager {
  46542. private _scene?;
  46543. private _babylonGamepads;
  46544. private _oneGamepadConnected;
  46545. /** @hidden */
  46546. _isMonitoring: boolean;
  46547. private _gamepadEventSupported;
  46548. private _gamepadSupport?;
  46549. /**
  46550. * observable to be triggered when the gamepad controller has been connected
  46551. */
  46552. onGamepadConnectedObservable: Observable<Gamepad>;
  46553. /**
  46554. * observable to be triggered when the gamepad controller has been disconnected
  46555. */
  46556. onGamepadDisconnectedObservable: Observable<Gamepad>;
  46557. private _onGamepadConnectedEvent;
  46558. private _onGamepadDisconnectedEvent;
  46559. /**
  46560. * Initializes the gamepad manager
  46561. * @param _scene BabylonJS scene
  46562. */
  46563. constructor(_scene?: Scene | undefined);
  46564. /**
  46565. * The gamepads in the game pad manager
  46566. */
  46567. get gamepads(): Gamepad[];
  46568. /**
  46569. * Get the gamepad controllers based on type
  46570. * @param type The type of gamepad controller
  46571. * @returns Nullable gamepad
  46572. */
  46573. getGamepadByType(type?: number): Nullable<Gamepad>;
  46574. /**
  46575. * Disposes the gamepad manager
  46576. */
  46577. dispose(): void;
  46578. private _addNewGamepad;
  46579. private _startMonitoringGamepads;
  46580. private _stopMonitoringGamepads;
  46581. /** @hidden */
  46582. _checkGamepadsStatus(): void;
  46583. private _updateGamepadObjects;
  46584. }
  46585. }
  46586. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  46587. import { Nullable } from "babylonjs/types";
  46588. import { Scene } from "babylonjs/scene";
  46589. import { ISceneComponent } from "babylonjs/sceneComponent";
  46590. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  46591. module "babylonjs/scene" {
  46592. interface Scene {
  46593. /** @hidden */
  46594. _gamepadManager: Nullable<GamepadManager>;
  46595. /**
  46596. * Gets the gamepad manager associated with the scene
  46597. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  46598. */
  46599. gamepadManager: GamepadManager;
  46600. }
  46601. }
  46602. module "babylonjs/Cameras/freeCameraInputsManager" {
  46603. /**
  46604. * Interface representing a free camera inputs manager
  46605. */
  46606. interface FreeCameraInputsManager {
  46607. /**
  46608. * Adds gamepad input support to the FreeCameraInputsManager.
  46609. * @returns the FreeCameraInputsManager
  46610. */
  46611. addGamepad(): FreeCameraInputsManager;
  46612. }
  46613. }
  46614. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  46615. /**
  46616. * Interface representing an arc rotate camera inputs manager
  46617. */
  46618. interface ArcRotateCameraInputsManager {
  46619. /**
  46620. * Adds gamepad input support to the ArcRotateCamera InputManager.
  46621. * @returns the camera inputs manager
  46622. */
  46623. addGamepad(): ArcRotateCameraInputsManager;
  46624. }
  46625. }
  46626. /**
  46627. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  46628. */
  46629. export class GamepadSystemSceneComponent implements ISceneComponent {
  46630. /**
  46631. * The component name helpfull to identify the component in the list of scene components.
  46632. */
  46633. readonly name: string;
  46634. /**
  46635. * The scene the component belongs to.
  46636. */
  46637. scene: Scene;
  46638. /**
  46639. * Creates a new instance of the component for the given scene
  46640. * @param scene Defines the scene to register the component in
  46641. */
  46642. constructor(scene: Scene);
  46643. /**
  46644. * Registers the component in a given scene
  46645. */
  46646. register(): void;
  46647. /**
  46648. * Rebuilds the elements related to this component in case of
  46649. * context lost for instance.
  46650. */
  46651. rebuild(): void;
  46652. /**
  46653. * Disposes the component and the associated ressources
  46654. */
  46655. dispose(): void;
  46656. private _beforeCameraUpdate;
  46657. }
  46658. }
  46659. declare module "babylonjs/Cameras/universalCamera" {
  46660. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  46661. import { Scene } from "babylonjs/scene";
  46662. import { Vector3 } from "babylonjs/Maths/math.vector";
  46663. import "babylonjs/Gamepads/gamepadSceneComponent";
  46664. /**
  46665. * 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,
  46666. * which still works and will still be found in many Playgrounds.
  46667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46668. */
  46669. export class UniversalCamera extends TouchCamera {
  46670. /**
  46671. * Defines the gamepad rotation sensiblity.
  46672. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46673. */
  46674. get gamepadAngularSensibility(): number;
  46675. set gamepadAngularSensibility(value: number);
  46676. /**
  46677. * Defines the gamepad move sensiblity.
  46678. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46679. */
  46680. get gamepadMoveSensibility(): number;
  46681. set gamepadMoveSensibility(value: number);
  46682. /**
  46683. * 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,
  46684. * which still works and will still be found in many Playgrounds.
  46685. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46686. * @param name Define the name of the camera in the scene
  46687. * @param position Define the start position of the camera in the scene
  46688. * @param scene Define the scene the camera belongs to
  46689. */
  46690. constructor(name: string, position: Vector3, scene: Scene);
  46691. /**
  46692. * Gets the current object class name.
  46693. * @return the class name
  46694. */
  46695. getClassName(): string;
  46696. }
  46697. }
  46698. declare module "babylonjs/Cameras/gamepadCamera" {
  46699. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46700. import { Scene } from "babylonjs/scene";
  46701. import { Vector3 } from "babylonjs/Maths/math.vector";
  46702. /**
  46703. * This represents a FPS type of camera. This is only here for back compat purpose.
  46704. * Please use the UniversalCamera instead as both are identical.
  46705. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46706. */
  46707. export class GamepadCamera extends UniversalCamera {
  46708. /**
  46709. * Instantiates a new Gamepad Camera
  46710. * This represents a FPS type of camera. This is only here for back compat purpose.
  46711. * Please use the UniversalCamera instead as both are identical.
  46712. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  46713. * @param name Define the name of the camera in the scene
  46714. * @param position Define the start position of the camera in the scene
  46715. * @param scene Define the scene the camera belongs to
  46716. */
  46717. constructor(name: string, position: Vector3, scene: Scene);
  46718. /**
  46719. * Gets the current object class name.
  46720. * @return the class name
  46721. */
  46722. getClassName(): string;
  46723. }
  46724. }
  46725. declare module "babylonjs/Shaders/pass.fragment" {
  46726. /** @hidden */
  46727. export var passPixelShader: {
  46728. name: string;
  46729. shader: string;
  46730. };
  46731. }
  46732. declare module "babylonjs/Shaders/passCube.fragment" {
  46733. /** @hidden */
  46734. export var passCubePixelShader: {
  46735. name: string;
  46736. shader: string;
  46737. };
  46738. }
  46739. declare module "babylonjs/PostProcesses/passPostProcess" {
  46740. import { Nullable } from "babylonjs/types";
  46741. import { Camera } from "babylonjs/Cameras/camera";
  46742. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46743. import { Engine } from "babylonjs/Engines/engine";
  46744. import "babylonjs/Shaders/pass.fragment";
  46745. import "babylonjs/Shaders/passCube.fragment";
  46746. /**
  46747. * PassPostProcess which produces an output the same as it's input
  46748. */
  46749. export class PassPostProcess extends PostProcess {
  46750. /**
  46751. * Creates the PassPostProcess
  46752. * @param name The name of the effect.
  46753. * @param options The required width/height ratio to downsize to before computing the render pass.
  46754. * @param camera The camera to apply the render pass to.
  46755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46756. * @param engine The engine which the post process will be applied. (default: current engine)
  46757. * @param reusable If the post process can be reused on the same frame. (default: false)
  46758. * @param textureType The type of texture to be used when performing the post processing.
  46759. * @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)
  46760. */
  46761. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46762. }
  46763. /**
  46764. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  46765. */
  46766. export class PassCubePostProcess extends PostProcess {
  46767. private _face;
  46768. /**
  46769. * Gets or sets the cube face to display.
  46770. * * 0 is +X
  46771. * * 1 is -X
  46772. * * 2 is +Y
  46773. * * 3 is -Y
  46774. * * 4 is +Z
  46775. * * 5 is -Z
  46776. */
  46777. get face(): number;
  46778. set face(value: number);
  46779. /**
  46780. * Creates the PassCubePostProcess
  46781. * @param name The name of the effect.
  46782. * @param options The required width/height ratio to downsize to before computing the render pass.
  46783. * @param camera The camera to apply the render pass to.
  46784. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  46785. * @param engine The engine which the post process will be applied. (default: current engine)
  46786. * @param reusable If the post process can be reused on the same frame. (default: false)
  46787. * @param textureType The type of texture to be used when performing the post processing.
  46788. * @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)
  46789. */
  46790. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  46791. }
  46792. }
  46793. declare module "babylonjs/Shaders/anaglyph.fragment" {
  46794. /** @hidden */
  46795. export var anaglyphPixelShader: {
  46796. name: string;
  46797. shader: string;
  46798. };
  46799. }
  46800. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  46801. import { Engine } from "babylonjs/Engines/engine";
  46802. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  46803. import { Camera } from "babylonjs/Cameras/camera";
  46804. import "babylonjs/Shaders/anaglyph.fragment";
  46805. /**
  46806. * Postprocess used to generate anaglyphic rendering
  46807. */
  46808. export class AnaglyphPostProcess extends PostProcess {
  46809. private _passedProcess;
  46810. /**
  46811. * Creates a new AnaglyphPostProcess
  46812. * @param name defines postprocess name
  46813. * @param options defines creation options or target ratio scale
  46814. * @param rigCameras defines cameras using this postprocess
  46815. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  46816. * @param engine defines hosting engine
  46817. * @param reusable defines if the postprocess will be reused multiple times per frame
  46818. */
  46819. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  46820. }
  46821. }
  46822. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  46823. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  46824. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46825. import { Scene } from "babylonjs/scene";
  46826. import { Vector3 } from "babylonjs/Maths/math.vector";
  46827. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46828. /**
  46829. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  46830. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46831. */
  46832. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  46833. /**
  46834. * Creates a new AnaglyphArcRotateCamera
  46835. * @param name defines camera name
  46836. * @param alpha defines alpha angle (in radians)
  46837. * @param beta defines beta angle (in radians)
  46838. * @param radius defines radius
  46839. * @param target defines camera target
  46840. * @param interaxialDistance defines distance between each color axis
  46841. * @param scene defines the hosting scene
  46842. */
  46843. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  46844. /**
  46845. * Gets camera class name
  46846. * @returns AnaglyphArcRotateCamera
  46847. */
  46848. getClassName(): string;
  46849. }
  46850. }
  46851. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  46852. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46853. import { Scene } from "babylonjs/scene";
  46854. import { Vector3 } from "babylonjs/Maths/math.vector";
  46855. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46856. /**
  46857. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  46858. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46859. */
  46860. export class AnaglyphFreeCamera extends FreeCamera {
  46861. /**
  46862. * Creates a new AnaglyphFreeCamera
  46863. * @param name defines camera name
  46864. * @param position defines initial position
  46865. * @param interaxialDistance defines distance between each color axis
  46866. * @param scene defines the hosting scene
  46867. */
  46868. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46869. /**
  46870. * Gets camera class name
  46871. * @returns AnaglyphFreeCamera
  46872. */
  46873. getClassName(): string;
  46874. }
  46875. }
  46876. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  46877. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46878. import { Scene } from "babylonjs/scene";
  46879. import { Vector3 } from "babylonjs/Maths/math.vector";
  46880. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46881. /**
  46882. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  46883. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46884. */
  46885. export class AnaglyphGamepadCamera extends GamepadCamera {
  46886. /**
  46887. * Creates a new AnaglyphGamepadCamera
  46888. * @param name defines camera name
  46889. * @param position defines initial position
  46890. * @param interaxialDistance defines distance between each color axis
  46891. * @param scene defines the hosting scene
  46892. */
  46893. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46894. /**
  46895. * Gets camera class name
  46896. * @returns AnaglyphGamepadCamera
  46897. */
  46898. getClassName(): string;
  46899. }
  46900. }
  46901. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  46902. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  46903. import { Scene } from "babylonjs/scene";
  46904. import { Vector3 } from "babylonjs/Maths/math.vector";
  46905. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  46906. /**
  46907. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  46908. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  46909. */
  46910. export class AnaglyphUniversalCamera extends UniversalCamera {
  46911. /**
  46912. * Creates a new AnaglyphUniversalCamera
  46913. * @param name defines camera name
  46914. * @param position defines initial position
  46915. * @param interaxialDistance defines distance between each color axis
  46916. * @param scene defines the hosting scene
  46917. */
  46918. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  46919. /**
  46920. * Gets camera class name
  46921. * @returns AnaglyphUniversalCamera
  46922. */
  46923. getClassName(): string;
  46924. }
  46925. }
  46926. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  46927. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  46928. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  46929. import { Scene } from "babylonjs/scene";
  46930. import { Vector3 } from "babylonjs/Maths/math.vector";
  46931. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46932. /**
  46933. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  46934. * @see https://doc.babylonjs.com/features/cameras
  46935. */
  46936. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  46937. /**
  46938. * Creates a new StereoscopicArcRotateCamera
  46939. * @param name defines camera name
  46940. * @param alpha defines alpha angle (in radians)
  46941. * @param beta defines beta angle (in radians)
  46942. * @param radius defines radius
  46943. * @param target defines camera target
  46944. * @param interaxialDistance defines distance between each color axis
  46945. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46946. * @param scene defines the hosting scene
  46947. */
  46948. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46949. /**
  46950. * Gets camera class name
  46951. * @returns StereoscopicArcRotateCamera
  46952. */
  46953. getClassName(): string;
  46954. }
  46955. }
  46956. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  46957. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46958. import { Scene } from "babylonjs/scene";
  46959. import { Vector3 } from "babylonjs/Maths/math.vector";
  46960. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46961. /**
  46962. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  46963. * @see https://doc.babylonjs.com/features/cameras
  46964. */
  46965. export class StereoscopicFreeCamera extends FreeCamera {
  46966. /**
  46967. * Creates a new StereoscopicFreeCamera
  46968. * @param name defines camera name
  46969. * @param position defines initial position
  46970. * @param interaxialDistance defines distance between each color axis
  46971. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46972. * @param scene defines the hosting scene
  46973. */
  46974. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  46975. /**
  46976. * Gets camera class name
  46977. * @returns StereoscopicFreeCamera
  46978. */
  46979. getClassName(): string;
  46980. }
  46981. }
  46982. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  46983. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  46984. import { Scene } from "babylonjs/scene";
  46985. import { Vector3 } from "babylonjs/Maths/math.vector";
  46986. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  46987. /**
  46988. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  46989. * @see https://doc.babylonjs.com/features/cameras
  46990. */
  46991. export class StereoscopicGamepadCamera extends GamepadCamera {
  46992. /**
  46993. * Creates a new StereoscopicGamepadCamera
  46994. * @param name defines camera name
  46995. * @param position defines initial position
  46996. * @param interaxialDistance defines distance between each color axis
  46997. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  46998. * @param scene defines the hosting scene
  46999. */
  47000. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47001. /**
  47002. * Gets camera class name
  47003. * @returns StereoscopicGamepadCamera
  47004. */
  47005. getClassName(): string;
  47006. }
  47007. }
  47008. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  47009. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47010. import { Scene } from "babylonjs/scene";
  47011. import { Vector3 } from "babylonjs/Maths/math.vector";
  47012. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47013. /**
  47014. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  47015. * @see https://doc.babylonjs.com/features/cameras
  47016. */
  47017. export class StereoscopicUniversalCamera extends UniversalCamera {
  47018. /**
  47019. * Creates a new StereoscopicUniversalCamera
  47020. * @param name defines camera name
  47021. * @param position defines initial position
  47022. * @param interaxialDistance defines distance between each color axis
  47023. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  47024. * @param scene defines the hosting scene
  47025. */
  47026. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  47027. /**
  47028. * Gets camera class name
  47029. * @returns StereoscopicUniversalCamera
  47030. */
  47031. getClassName(): string;
  47032. }
  47033. }
  47034. declare module "babylonjs/Cameras/Stereoscopic/index" {
  47035. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  47036. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  47037. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  47038. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  47039. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  47040. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  47041. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  47042. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  47043. }
  47044. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  47045. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47046. import { Scene } from "babylonjs/scene";
  47047. import { Vector3 } from "babylonjs/Maths/math.vector";
  47048. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47049. /**
  47050. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  47051. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47052. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47053. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47054. */
  47055. export class VirtualJoysticksCamera extends FreeCamera {
  47056. /**
  47057. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  47058. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  47059. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  47060. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  47061. * @param name Define the name of the camera in the scene
  47062. * @param position Define the start position of the camera in the scene
  47063. * @param scene Define the scene the camera belongs to
  47064. */
  47065. constructor(name: string, position: Vector3, scene: Scene);
  47066. /**
  47067. * Gets the current object class name.
  47068. * @return the class name
  47069. */
  47070. getClassName(): string;
  47071. }
  47072. }
  47073. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  47074. import { Matrix } from "babylonjs/Maths/math.vector";
  47075. /**
  47076. * This represents all the required metrics to create a VR camera.
  47077. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  47078. */
  47079. export class VRCameraMetrics {
  47080. /**
  47081. * Define the horizontal resolution off the screen.
  47082. */
  47083. hResolution: number;
  47084. /**
  47085. * Define the vertical resolution off the screen.
  47086. */
  47087. vResolution: number;
  47088. /**
  47089. * Define the horizontal screen size.
  47090. */
  47091. hScreenSize: number;
  47092. /**
  47093. * Define the vertical screen size.
  47094. */
  47095. vScreenSize: number;
  47096. /**
  47097. * Define the vertical screen center position.
  47098. */
  47099. vScreenCenter: number;
  47100. /**
  47101. * Define the distance of the eyes to the screen.
  47102. */
  47103. eyeToScreenDistance: number;
  47104. /**
  47105. * Define the distance between both lenses
  47106. */
  47107. lensSeparationDistance: number;
  47108. /**
  47109. * Define the distance between both viewer's eyes.
  47110. */
  47111. interpupillaryDistance: number;
  47112. /**
  47113. * Define the distortion factor of the VR postprocess.
  47114. * Please, touch with care.
  47115. */
  47116. distortionK: number[];
  47117. /**
  47118. * Define the chromatic aberration correction factors for the VR post process.
  47119. */
  47120. chromaAbCorrection: number[];
  47121. /**
  47122. * Define the scale factor of the post process.
  47123. * The smaller the better but the slower.
  47124. */
  47125. postProcessScaleFactor: number;
  47126. /**
  47127. * Define an offset for the lens center.
  47128. */
  47129. lensCenterOffset: number;
  47130. /**
  47131. * Define if the current vr camera should compensate the distortion of the lense or not.
  47132. */
  47133. compensateDistortion: boolean;
  47134. /**
  47135. * Defines if multiview should be enabled when rendering (Default: false)
  47136. */
  47137. multiviewEnabled: boolean;
  47138. /**
  47139. * Gets the rendering aspect ratio based on the provided resolutions.
  47140. */
  47141. get aspectRatio(): number;
  47142. /**
  47143. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  47144. */
  47145. get aspectRatioFov(): number;
  47146. /**
  47147. * @hidden
  47148. */
  47149. get leftHMatrix(): Matrix;
  47150. /**
  47151. * @hidden
  47152. */
  47153. get rightHMatrix(): Matrix;
  47154. /**
  47155. * @hidden
  47156. */
  47157. get leftPreViewMatrix(): Matrix;
  47158. /**
  47159. * @hidden
  47160. */
  47161. get rightPreViewMatrix(): Matrix;
  47162. /**
  47163. * Get the default VRMetrics based on the most generic setup.
  47164. * @returns the default vr metrics
  47165. */
  47166. static GetDefault(): VRCameraMetrics;
  47167. }
  47168. }
  47169. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  47170. /** @hidden */
  47171. export var vrDistortionCorrectionPixelShader: {
  47172. name: string;
  47173. shader: string;
  47174. };
  47175. }
  47176. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  47177. import { Camera } from "babylonjs/Cameras/camera";
  47178. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47179. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  47180. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  47181. /**
  47182. * VRDistortionCorrectionPostProcess used for mobile VR
  47183. */
  47184. export class VRDistortionCorrectionPostProcess extends PostProcess {
  47185. private _isRightEye;
  47186. private _distortionFactors;
  47187. private _postProcessScaleFactor;
  47188. private _lensCenterOffset;
  47189. private _scaleIn;
  47190. private _scaleFactor;
  47191. private _lensCenter;
  47192. /**
  47193. * Initializes the VRDistortionCorrectionPostProcess
  47194. * @param name The name of the effect.
  47195. * @param camera The camera to apply the render pass to.
  47196. * @param isRightEye If this is for the right eye distortion
  47197. * @param vrMetrics All the required metrics for the VR camera
  47198. */
  47199. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  47200. }
  47201. }
  47202. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  47203. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  47204. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47205. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47206. import { Scene } from "babylonjs/scene";
  47207. import { Vector3 } from "babylonjs/Maths/math.vector";
  47208. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47209. import "babylonjs/Cameras/RigModes/vrRigMode";
  47210. /**
  47211. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  47212. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47213. */
  47214. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  47215. /**
  47216. * Creates a new VRDeviceOrientationArcRotateCamera
  47217. * @param name defines camera name
  47218. * @param alpha defines the camera rotation along the logitudinal axis
  47219. * @param beta defines the camera rotation along the latitudinal axis
  47220. * @param radius defines the camera distance from its target
  47221. * @param target defines the camera target
  47222. * @param scene defines the scene the camera belongs to
  47223. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47224. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47225. */
  47226. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47227. /**
  47228. * Gets camera class name
  47229. * @returns VRDeviceOrientationArcRotateCamera
  47230. */
  47231. getClassName(): string;
  47232. }
  47233. }
  47234. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  47235. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47236. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47237. import { Scene } from "babylonjs/scene";
  47238. import { Vector3 } from "babylonjs/Maths/math.vector";
  47239. import "babylonjs/Cameras/RigModes/vrRigMode";
  47240. /**
  47241. * Camera used to simulate VR rendering (based on FreeCamera)
  47242. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47243. */
  47244. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  47245. /**
  47246. * Creates a new VRDeviceOrientationFreeCamera
  47247. * @param name defines camera name
  47248. * @param position defines the start position of the camera
  47249. * @param scene defines the scene the camera belongs to
  47250. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47251. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47252. */
  47253. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47254. /**
  47255. * Gets camera class name
  47256. * @returns VRDeviceOrientationFreeCamera
  47257. */
  47258. getClassName(): string;
  47259. }
  47260. }
  47261. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  47262. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47263. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47264. import { Scene } from "babylonjs/scene";
  47265. import { Vector3 } from "babylonjs/Maths/math.vector";
  47266. import "babylonjs/Gamepads/gamepadSceneComponent";
  47267. /**
  47268. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  47269. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  47270. */
  47271. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  47272. /**
  47273. * Creates a new VRDeviceOrientationGamepadCamera
  47274. * @param name defines camera name
  47275. * @param position defines the start position of the camera
  47276. * @param scene defines the scene the camera belongs to
  47277. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  47278. * @param vrCameraMetrics defines the vr metrics associated to the camera
  47279. */
  47280. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  47281. /**
  47282. * Gets camera class name
  47283. * @returns VRDeviceOrientationGamepadCamera
  47284. */
  47285. getClassName(): string;
  47286. }
  47287. }
  47288. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  47289. import { Scene } from "babylonjs/scene";
  47290. import { Texture } from "babylonjs/Materials/Textures/texture";
  47291. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  47292. /**
  47293. * A class extending Texture allowing drawing on a texture
  47294. * @see https://doc.babylonjs.com/how_to/dynamictexture
  47295. */
  47296. export class DynamicTexture extends Texture {
  47297. private _generateMipMaps;
  47298. private _canvas;
  47299. private _context;
  47300. /**
  47301. * Creates a DynamicTexture
  47302. * @param name defines the name of the texture
  47303. * @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
  47304. * @param scene defines the scene where you want the texture
  47305. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  47306. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  47307. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  47308. */
  47309. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  47310. /**
  47311. * Get the current class name of the texture useful for serialization or dynamic coding.
  47312. * @returns "DynamicTexture"
  47313. */
  47314. getClassName(): string;
  47315. /**
  47316. * Gets the current state of canRescale
  47317. */
  47318. get canRescale(): boolean;
  47319. private _recreate;
  47320. /**
  47321. * Scales the texture
  47322. * @param ratio the scale factor to apply to both width and height
  47323. */
  47324. scale(ratio: number): void;
  47325. /**
  47326. * Resizes the texture
  47327. * @param width the new width
  47328. * @param height the new height
  47329. */
  47330. scaleTo(width: number, height: number): void;
  47331. /**
  47332. * Gets the context of the canvas used by the texture
  47333. * @returns the canvas context of the dynamic texture
  47334. */
  47335. getContext(): CanvasRenderingContext2D;
  47336. /**
  47337. * Clears the texture
  47338. */
  47339. clear(): void;
  47340. /**
  47341. * Updates the texture
  47342. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47343. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  47344. */
  47345. update(invertY?: boolean, premulAlpha?: boolean): void;
  47346. /**
  47347. * Draws text onto the texture
  47348. * @param text defines the text to be drawn
  47349. * @param x defines the placement of the text from the left
  47350. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  47351. * @param font defines the font to be used with font-style, font-size, font-name
  47352. * @param color defines the color used for the text
  47353. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  47354. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  47355. * @param update defines whether texture is immediately update (default is true)
  47356. */
  47357. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  47358. /**
  47359. * Clones the texture
  47360. * @returns the clone of the texture.
  47361. */
  47362. clone(): DynamicTexture;
  47363. /**
  47364. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  47365. * @returns a serialized dynamic texture object
  47366. */
  47367. serialize(): any;
  47368. private _IsCanvasElement;
  47369. /** @hidden */
  47370. _rebuild(): void;
  47371. }
  47372. }
  47373. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  47374. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47375. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47376. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47377. /** @hidden */
  47378. export var imageProcessingPixelShader: {
  47379. name: string;
  47380. shader: string;
  47381. };
  47382. }
  47383. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  47384. import { Nullable } from "babylonjs/types";
  47385. import { Color4 } from "babylonjs/Maths/math.color";
  47386. import { Camera } from "babylonjs/Cameras/camera";
  47387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47388. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47389. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47390. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47391. import { Engine } from "babylonjs/Engines/engine";
  47392. import "babylonjs/Shaders/imageProcessing.fragment";
  47393. import "babylonjs/Shaders/postprocess.vertex";
  47394. /**
  47395. * ImageProcessingPostProcess
  47396. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  47397. */
  47398. export class ImageProcessingPostProcess extends PostProcess {
  47399. /**
  47400. * Default configuration related to image processing available in the PBR Material.
  47401. */
  47402. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47403. /**
  47404. * Gets the image processing configuration used either in this material.
  47405. */
  47406. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  47407. /**
  47408. * Sets the Default image processing configuration used either in the this material.
  47409. *
  47410. * If sets to null, the scene one is in use.
  47411. */
  47412. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  47413. /**
  47414. * Keep track of the image processing observer to allow dispose and replace.
  47415. */
  47416. private _imageProcessingObserver;
  47417. /**
  47418. * Attaches a new image processing configuration to the PBR Material.
  47419. * @param configuration
  47420. */
  47421. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  47422. /**
  47423. * If the post process is supported.
  47424. */
  47425. get isSupported(): boolean;
  47426. /**
  47427. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47428. */
  47429. get colorCurves(): Nullable<ColorCurves>;
  47430. /**
  47431. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  47432. */
  47433. set colorCurves(value: Nullable<ColorCurves>);
  47434. /**
  47435. * Gets wether the color curves effect is enabled.
  47436. */
  47437. get colorCurvesEnabled(): boolean;
  47438. /**
  47439. * Sets wether the color curves effect is enabled.
  47440. */
  47441. set colorCurvesEnabled(value: boolean);
  47442. /**
  47443. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47444. */
  47445. get colorGradingTexture(): Nullable<BaseTexture>;
  47446. /**
  47447. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  47448. */
  47449. set colorGradingTexture(value: Nullable<BaseTexture>);
  47450. /**
  47451. * Gets wether the color grading effect is enabled.
  47452. */
  47453. get colorGradingEnabled(): boolean;
  47454. /**
  47455. * Gets wether the color grading effect is enabled.
  47456. */
  47457. set colorGradingEnabled(value: boolean);
  47458. /**
  47459. * Gets exposure used in the effect.
  47460. */
  47461. get exposure(): number;
  47462. /**
  47463. * Sets exposure used in the effect.
  47464. */
  47465. set exposure(value: number);
  47466. /**
  47467. * Gets wether tonemapping is enabled or not.
  47468. */
  47469. get toneMappingEnabled(): boolean;
  47470. /**
  47471. * Sets wether tonemapping is enabled or not
  47472. */
  47473. set toneMappingEnabled(value: boolean);
  47474. /**
  47475. * Gets the type of tone mapping effect.
  47476. */
  47477. get toneMappingType(): number;
  47478. /**
  47479. * Sets the type of tone mapping effect.
  47480. */
  47481. set toneMappingType(value: number);
  47482. /**
  47483. * Gets contrast used in the effect.
  47484. */
  47485. get contrast(): number;
  47486. /**
  47487. * Sets contrast used in the effect.
  47488. */
  47489. set contrast(value: number);
  47490. /**
  47491. * Gets Vignette stretch size.
  47492. */
  47493. get vignetteStretch(): number;
  47494. /**
  47495. * Sets Vignette stretch size.
  47496. */
  47497. set vignetteStretch(value: number);
  47498. /**
  47499. * Gets Vignette centre X Offset.
  47500. */
  47501. get vignetteCentreX(): number;
  47502. /**
  47503. * Sets Vignette centre X Offset.
  47504. */
  47505. set vignetteCentreX(value: number);
  47506. /**
  47507. * Gets Vignette centre Y Offset.
  47508. */
  47509. get vignetteCentreY(): number;
  47510. /**
  47511. * Sets Vignette centre Y Offset.
  47512. */
  47513. set vignetteCentreY(value: number);
  47514. /**
  47515. * Gets Vignette weight or intensity of the vignette effect.
  47516. */
  47517. get vignetteWeight(): number;
  47518. /**
  47519. * Sets Vignette weight or intensity of the vignette effect.
  47520. */
  47521. set vignetteWeight(value: number);
  47522. /**
  47523. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47524. * if vignetteEnabled is set to true.
  47525. */
  47526. get vignetteColor(): Color4;
  47527. /**
  47528. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  47529. * if vignetteEnabled is set to true.
  47530. */
  47531. set vignetteColor(value: Color4);
  47532. /**
  47533. * Gets Camera field of view used by the Vignette effect.
  47534. */
  47535. get vignetteCameraFov(): number;
  47536. /**
  47537. * Sets Camera field of view used by the Vignette effect.
  47538. */
  47539. set vignetteCameraFov(value: number);
  47540. /**
  47541. * Gets the vignette blend mode allowing different kind of effect.
  47542. */
  47543. get vignetteBlendMode(): number;
  47544. /**
  47545. * Sets the vignette blend mode allowing different kind of effect.
  47546. */
  47547. set vignetteBlendMode(value: number);
  47548. /**
  47549. * Gets wether the vignette effect is enabled.
  47550. */
  47551. get vignetteEnabled(): boolean;
  47552. /**
  47553. * Sets wether the vignette effect is enabled.
  47554. */
  47555. set vignetteEnabled(value: boolean);
  47556. private _fromLinearSpace;
  47557. /**
  47558. * Gets wether the input of the processing is in Gamma or Linear Space.
  47559. */
  47560. get fromLinearSpace(): boolean;
  47561. /**
  47562. * Sets wether the input of the processing is in Gamma or Linear Space.
  47563. */
  47564. set fromLinearSpace(value: boolean);
  47565. /**
  47566. * Defines cache preventing GC.
  47567. */
  47568. private _defines;
  47569. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  47570. /**
  47571. * "ImageProcessingPostProcess"
  47572. * @returns "ImageProcessingPostProcess"
  47573. */
  47574. getClassName(): string;
  47575. /**
  47576. * @hidden
  47577. */
  47578. _updateParameters(): void;
  47579. dispose(camera?: Camera): void;
  47580. }
  47581. }
  47582. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  47583. import { Scene } from "babylonjs/scene";
  47584. import { Color3 } from "babylonjs/Maths/math.color";
  47585. import { Mesh } from "babylonjs/Meshes/mesh";
  47586. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  47587. import { Nullable } from "babylonjs/types";
  47588. /**
  47589. * Class containing static functions to help procedurally build meshes
  47590. */
  47591. export class GroundBuilder {
  47592. /**
  47593. * Creates a ground mesh
  47594. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  47595. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  47596. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47597. * @param name defines the name of the mesh
  47598. * @param options defines the options used to create the mesh
  47599. * @param scene defines the hosting scene
  47600. * @returns the ground mesh
  47601. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  47602. */
  47603. static CreateGround(name: string, options: {
  47604. width?: number;
  47605. height?: number;
  47606. subdivisions?: number;
  47607. subdivisionsX?: number;
  47608. subdivisionsY?: number;
  47609. updatable?: boolean;
  47610. }, scene: any): Mesh;
  47611. /**
  47612. * Creates a tiled ground mesh
  47613. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  47614. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  47615. * * 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
  47616. * * 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
  47617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47618. * @param name defines the name of the mesh
  47619. * @param options defines the options used to create the mesh
  47620. * @param scene defines the hosting scene
  47621. * @returns the tiled ground mesh
  47622. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  47623. */
  47624. static CreateTiledGround(name: string, options: {
  47625. xmin: number;
  47626. zmin: number;
  47627. xmax: number;
  47628. zmax: number;
  47629. subdivisions?: {
  47630. w: number;
  47631. h: number;
  47632. };
  47633. precision?: {
  47634. w: number;
  47635. h: number;
  47636. };
  47637. updatable?: boolean;
  47638. }, scene?: Nullable<Scene>): Mesh;
  47639. /**
  47640. * Creates a ground mesh from a height map
  47641. * * The parameter `url` sets the URL of the height map image resource.
  47642. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  47643. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  47644. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  47645. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  47646. * * 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.
  47647. * * 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).
  47648. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  47649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47650. * @param name defines the name of the mesh
  47651. * @param url defines the url to the height map
  47652. * @param options defines the options used to create the mesh
  47653. * @param scene defines the hosting scene
  47654. * @returns the ground mesh
  47655. * @see https://doc.babylonjs.com/babylon101/height_map
  47656. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  47657. */
  47658. static CreateGroundFromHeightMap(name: string, url: string, options: {
  47659. width?: number;
  47660. height?: number;
  47661. subdivisions?: number;
  47662. minHeight?: number;
  47663. maxHeight?: number;
  47664. colorFilter?: Color3;
  47665. alphaFilter?: number;
  47666. updatable?: boolean;
  47667. onReady?: (mesh: GroundMesh) => void;
  47668. }, scene?: Nullable<Scene>): GroundMesh;
  47669. }
  47670. }
  47671. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  47672. import { Vector4 } from "babylonjs/Maths/math.vector";
  47673. import { Mesh } from "babylonjs/Meshes/mesh";
  47674. /**
  47675. * Class containing static functions to help procedurally build meshes
  47676. */
  47677. export class TorusBuilder {
  47678. /**
  47679. * Creates a torus mesh
  47680. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  47681. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  47682. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  47683. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47684. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47686. * @param name defines the name of the mesh
  47687. * @param options defines the options used to create the mesh
  47688. * @param scene defines the hosting scene
  47689. * @returns the torus mesh
  47690. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  47691. */
  47692. static CreateTorus(name: string, options: {
  47693. diameter?: number;
  47694. thickness?: number;
  47695. tessellation?: number;
  47696. updatable?: boolean;
  47697. sideOrientation?: number;
  47698. frontUVs?: Vector4;
  47699. backUVs?: Vector4;
  47700. }, scene: any): Mesh;
  47701. }
  47702. }
  47703. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  47704. import { Vector4 } from "babylonjs/Maths/math.vector";
  47705. import { Color4 } from "babylonjs/Maths/math.color";
  47706. import { Mesh } from "babylonjs/Meshes/mesh";
  47707. /**
  47708. * Class containing static functions to help procedurally build meshes
  47709. */
  47710. export class CylinderBuilder {
  47711. /**
  47712. * Creates a cylinder or a cone mesh
  47713. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  47714. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  47715. * * 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.
  47716. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  47717. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  47718. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  47719. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  47720. * * 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).
  47721. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  47722. * * 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).
  47723. * * 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
  47724. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  47725. * * 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
  47726. * * 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.
  47727. * * If `enclose` is false, a ring surface is one element.
  47728. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  47729. * * 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
  47730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  47733. * @param name defines the name of the mesh
  47734. * @param options defines the options used to create the mesh
  47735. * @param scene defines the hosting scene
  47736. * @returns the cylinder mesh
  47737. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  47738. */
  47739. static CreateCylinder(name: string, options: {
  47740. height?: number;
  47741. diameterTop?: number;
  47742. diameterBottom?: number;
  47743. diameter?: number;
  47744. tessellation?: number;
  47745. subdivisions?: number;
  47746. arc?: number;
  47747. faceColors?: Color4[];
  47748. faceUV?: Vector4[];
  47749. updatable?: boolean;
  47750. hasRings?: boolean;
  47751. enclose?: boolean;
  47752. cap?: number;
  47753. sideOrientation?: number;
  47754. frontUVs?: Vector4;
  47755. backUVs?: Vector4;
  47756. }, scene: any): Mesh;
  47757. }
  47758. }
  47759. declare module "babylonjs/XR/webXRTypes" {
  47760. import { Nullable } from "babylonjs/types";
  47761. import { IDisposable } from "babylonjs/scene";
  47762. /**
  47763. * States of the webXR experience
  47764. */
  47765. export enum WebXRState {
  47766. /**
  47767. * Transitioning to being in XR mode
  47768. */
  47769. ENTERING_XR = 0,
  47770. /**
  47771. * Transitioning to non XR mode
  47772. */
  47773. EXITING_XR = 1,
  47774. /**
  47775. * In XR mode and presenting
  47776. */
  47777. IN_XR = 2,
  47778. /**
  47779. * Not entered XR mode
  47780. */
  47781. NOT_IN_XR = 3
  47782. }
  47783. /**
  47784. * Abstraction of the XR render target
  47785. */
  47786. export interface WebXRRenderTarget extends IDisposable {
  47787. /**
  47788. * xrpresent context of the canvas which can be used to display/mirror xr content
  47789. */
  47790. canvasContext: WebGLRenderingContext;
  47791. /**
  47792. * xr layer for the canvas
  47793. */
  47794. xrLayer: Nullable<XRWebGLLayer>;
  47795. /**
  47796. * Initializes the xr layer for the session
  47797. * @param xrSession xr session
  47798. * @returns a promise that will resolve once the XR Layer has been created
  47799. */
  47800. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47801. }
  47802. }
  47803. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  47804. import { Nullable } from "babylonjs/types";
  47805. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47806. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  47807. import { Observable } from "babylonjs/Misc/observable";
  47808. /**
  47809. * COnfiguration object for WebXR output canvas
  47810. */
  47811. export class WebXRManagedOutputCanvasOptions {
  47812. /**
  47813. * An optional canvas in case you wish to create it yourself and provide it here.
  47814. * If not provided, a new canvas will be created
  47815. */
  47816. canvasElement?: HTMLCanvasElement;
  47817. /**
  47818. * Options for this XR Layer output
  47819. */
  47820. canvasOptions?: XRWebGLLayerOptions;
  47821. /**
  47822. * CSS styling for a newly created canvas (if not provided)
  47823. */
  47824. newCanvasCssStyle?: string;
  47825. /**
  47826. * Get the default values of the configuration object
  47827. * @returns default values of this configuration object
  47828. */
  47829. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  47830. }
  47831. /**
  47832. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  47833. */
  47834. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  47835. private _options;
  47836. private _canvas;
  47837. private _engine;
  47838. private _originalCanvasSize;
  47839. /**
  47840. * Rendering context of the canvas which can be used to display/mirror xr content
  47841. */
  47842. canvasContext: WebGLRenderingContext;
  47843. /**
  47844. * xr layer for the canvas
  47845. */
  47846. xrLayer: Nullable<XRWebGLLayer>;
  47847. /**
  47848. * Obseervers registered here will be triggered when the xr layer was initialized
  47849. */
  47850. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  47851. /**
  47852. * Initializes the canvas to be added/removed upon entering/exiting xr
  47853. * @param _xrSessionManager The XR Session manager
  47854. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  47855. */
  47856. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  47857. /**
  47858. * Disposes of the object
  47859. */
  47860. dispose(): void;
  47861. /**
  47862. * Initializes the xr layer for the session
  47863. * @param xrSession xr session
  47864. * @returns a promise that will resolve once the XR Layer has been created
  47865. */
  47866. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  47867. private _addCanvas;
  47868. private _removeCanvas;
  47869. private _setCanvasSize;
  47870. private _setManagedOutputCanvas;
  47871. }
  47872. }
  47873. declare module "babylonjs/XR/webXRSessionManager" {
  47874. import { Observable } from "babylonjs/Misc/observable";
  47875. import { Nullable } from "babylonjs/types";
  47876. import { IDisposable, Scene } from "babylonjs/scene";
  47877. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  47878. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  47879. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  47880. /**
  47881. * Manages an XRSession to work with Babylon's engine
  47882. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  47883. */
  47884. export class WebXRSessionManager implements IDisposable {
  47885. /** The scene which the session should be created for */
  47886. scene: Scene;
  47887. private _referenceSpace;
  47888. private _rttProvider;
  47889. private _sessionEnded;
  47890. private _xrNavigator;
  47891. private baseLayer;
  47892. /**
  47893. * The base reference space from which the session started. good if you want to reset your
  47894. * reference space
  47895. */
  47896. baseReferenceSpace: XRReferenceSpace;
  47897. /**
  47898. * Current XR frame
  47899. */
  47900. currentFrame: Nullable<XRFrame>;
  47901. /** WebXR timestamp updated every frame */
  47902. currentTimestamp: number;
  47903. /**
  47904. * Used just in case of a failure to initialize an immersive session.
  47905. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  47906. */
  47907. defaultHeightCompensation: number;
  47908. /**
  47909. * Fires every time a new xrFrame arrives which can be used to update the camera
  47910. */
  47911. onXRFrameObservable: Observable<XRFrame>;
  47912. /**
  47913. * Fires when the reference space changed
  47914. */
  47915. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  47916. /**
  47917. * Fires when the xr session is ended either by the device or manually done
  47918. */
  47919. onXRSessionEnded: Observable<any>;
  47920. /**
  47921. * Fires when the xr session is ended either by the device or manually done
  47922. */
  47923. onXRSessionInit: Observable<XRSession>;
  47924. /**
  47925. * Underlying xr session
  47926. */
  47927. session: XRSession;
  47928. /**
  47929. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  47930. * or get the offset the player is currently at.
  47931. */
  47932. viewerReferenceSpace: XRReferenceSpace;
  47933. /**
  47934. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  47935. * @param scene The scene which the session should be created for
  47936. */
  47937. constructor(
  47938. /** The scene which the session should be created for */
  47939. scene: Scene);
  47940. /**
  47941. * The current reference space used in this session. This reference space can constantly change!
  47942. * It is mainly used to offset the camera's position.
  47943. */
  47944. get referenceSpace(): XRReferenceSpace;
  47945. /**
  47946. * Set a new reference space and triggers the observable
  47947. */
  47948. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  47949. /**
  47950. * Disposes of the session manager
  47951. */
  47952. dispose(): void;
  47953. /**
  47954. * Stops the xrSession and restores the render loop
  47955. * @returns Promise which resolves after it exits XR
  47956. */
  47957. exitXRAsync(): Promise<void>;
  47958. /**
  47959. * Gets the correct render target texture to be rendered this frame for this eye
  47960. * @param eye the eye for which to get the render target
  47961. * @returns the render target for the specified eye
  47962. */
  47963. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  47964. /**
  47965. * Creates a WebXRRenderTarget object for the XR session
  47966. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  47967. * @param options optional options to provide when creating a new render target
  47968. * @returns a WebXR render target to which the session can render
  47969. */
  47970. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  47971. /**
  47972. * Initializes the manager
  47973. * After initialization enterXR can be called to start an XR session
  47974. * @returns Promise which resolves after it is initialized
  47975. */
  47976. initializeAsync(): Promise<void>;
  47977. /**
  47978. * Initializes an xr session
  47979. * @param xrSessionMode mode to initialize
  47980. * @param xrSessionInit defines optional and required values to pass to the session builder
  47981. * @returns a promise which will resolve once the session has been initialized
  47982. */
  47983. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  47984. /**
  47985. * Checks if a session would be supported for the creation options specified
  47986. * @param sessionMode session mode to check if supported eg. immersive-vr
  47987. * @returns A Promise that resolves to true if supported and false if not
  47988. */
  47989. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  47990. /**
  47991. * Resets the reference space to the one started the session
  47992. */
  47993. resetReferenceSpace(): void;
  47994. /**
  47995. * Starts rendering to the xr layer
  47996. */
  47997. runXRRenderLoop(): void;
  47998. /**
  47999. * Sets the reference space on the xr session
  48000. * @param referenceSpaceType space to set
  48001. * @returns a promise that will resolve once the reference space has been set
  48002. */
  48003. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48004. /**
  48005. * Updates the render state of the session
  48006. * @param state state to set
  48007. * @returns a promise that resolves once the render state has been updated
  48008. */
  48009. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48010. /**
  48011. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48012. * @param sessionMode defines the session to test
  48013. * @returns a promise with boolean as final value
  48014. */
  48015. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48016. private _createRenderTargetTexture;
  48017. }
  48018. }
  48019. declare module "babylonjs/XR/webXRCamera" {
  48020. import { Scene } from "babylonjs/scene";
  48021. import { Camera } from "babylonjs/Cameras/camera";
  48022. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48023. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48024. /**
  48025. * WebXR Camera which holds the views for the xrSession
  48026. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48027. */
  48028. export class WebXRCamera extends FreeCamera {
  48029. private _xrSessionManager;
  48030. private _firstFrame;
  48031. private _referenceQuaternion;
  48032. private _referencedPosition;
  48033. private _xrInvPositionCache;
  48034. private _xrInvQuaternionCache;
  48035. /**
  48036. * Should position compensation execute on first frame.
  48037. * This is used when copying the position from a native (non XR) camera
  48038. */
  48039. compensateOnFirstFrame: boolean;
  48040. /**
  48041. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48042. * @param name the name of the camera
  48043. * @param scene the scene to add the camera to
  48044. * @param _xrSessionManager a constructed xr session manager
  48045. */
  48046. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48047. /**
  48048. * Return the user's height, unrelated to the current ground.
  48049. * This will be the y position of this camera, when ground level is 0.
  48050. */
  48051. get realWorldHeight(): number;
  48052. /** @hidden */
  48053. _updateForDualEyeDebugging(): void;
  48054. /**
  48055. * Sets this camera's transformation based on a non-vr camera
  48056. * @param otherCamera the non-vr camera to copy the transformation from
  48057. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48058. */
  48059. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48060. /**
  48061. * Gets the current instance class name ("WebXRCamera").
  48062. * @returns the class name
  48063. */
  48064. getClassName(): string;
  48065. private _rotate180;
  48066. private _updateFromXRSession;
  48067. private _updateNumberOfRigCameras;
  48068. private _updateReferenceSpace;
  48069. private _updateReferenceSpaceOffset;
  48070. }
  48071. }
  48072. declare module "babylonjs/XR/webXRFeaturesManager" {
  48073. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48074. import { IDisposable } from "babylonjs/scene";
  48075. /**
  48076. * Defining the interface required for a (webxr) feature
  48077. */
  48078. export interface IWebXRFeature extends IDisposable {
  48079. /**
  48080. * Is this feature attached
  48081. */
  48082. attached: boolean;
  48083. /**
  48084. * Should auto-attach be disabled?
  48085. */
  48086. disableAutoAttach: boolean;
  48087. /**
  48088. * Attach the feature to the session
  48089. * Will usually be called by the features manager
  48090. *
  48091. * @param force should attachment be forced (even when already attached)
  48092. * @returns true if successful.
  48093. */
  48094. attach(force?: boolean): boolean;
  48095. /**
  48096. * Detach the feature from the session
  48097. * Will usually be called by the features manager
  48098. *
  48099. * @returns true if successful.
  48100. */
  48101. detach(): boolean;
  48102. }
  48103. /**
  48104. * A list of the currently available features without referencing them
  48105. */
  48106. export class WebXRFeatureName {
  48107. /**
  48108. * The name of the anchor system feature
  48109. */
  48110. static ANCHOR_SYSTEM: string;
  48111. /**
  48112. * The name of the background remover feature
  48113. */
  48114. static BACKGROUND_REMOVER: string;
  48115. /**
  48116. * The name of the hit test feature
  48117. */
  48118. static HIT_TEST: string;
  48119. /**
  48120. * physics impostors for xr controllers feature
  48121. */
  48122. static PHYSICS_CONTROLLERS: string;
  48123. /**
  48124. * The name of the plane detection feature
  48125. */
  48126. static PLANE_DETECTION: string;
  48127. /**
  48128. * The name of the pointer selection feature
  48129. */
  48130. static POINTER_SELECTION: string;
  48131. /**
  48132. * The name of the teleportation feature
  48133. */
  48134. static TELEPORTATION: string;
  48135. }
  48136. /**
  48137. * Defining the constructor of a feature. Used to register the modules.
  48138. */
  48139. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  48140. /**
  48141. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  48142. * It is mainly used in AR sessions.
  48143. *
  48144. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  48145. */
  48146. export class WebXRFeaturesManager implements IDisposable {
  48147. private _xrSessionManager;
  48148. private static readonly _AvailableFeatures;
  48149. private _features;
  48150. /**
  48151. * constructs a new features manages.
  48152. *
  48153. * @param _xrSessionManager an instance of WebXRSessionManager
  48154. */
  48155. constructor(_xrSessionManager: WebXRSessionManager);
  48156. /**
  48157. * Used to register a module. After calling this function a developer can use this feature in the scene.
  48158. * Mainly used internally.
  48159. *
  48160. * @param featureName the name of the feature to register
  48161. * @param constructorFunction the function used to construct the module
  48162. * @param version the (babylon) version of the module
  48163. * @param stable is that a stable version of this module
  48164. */
  48165. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  48166. /**
  48167. * Returns a constructor of a specific feature.
  48168. *
  48169. * @param featureName the name of the feature to construct
  48170. * @param version the version of the feature to load
  48171. * @param xrSessionManager the xrSessionManager. Used to construct the module
  48172. * @param options optional options provided to the module.
  48173. * @returns a function that, when called, will return a new instance of this feature
  48174. */
  48175. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  48176. /**
  48177. * Can be used to return the list of features currently registered
  48178. *
  48179. * @returns an Array of available features
  48180. */
  48181. static GetAvailableFeatures(): string[];
  48182. /**
  48183. * Gets the versions available for a specific feature
  48184. * @param featureName the name of the feature
  48185. * @returns an array with the available versions
  48186. */
  48187. static GetAvailableVersions(featureName: string): string[];
  48188. /**
  48189. * Return the latest unstable version of this feature
  48190. * @param featureName the name of the feature to search
  48191. * @returns the version number. if not found will return -1
  48192. */
  48193. static GetLatestVersionOfFeature(featureName: string): number;
  48194. /**
  48195. * Return the latest stable version of this feature
  48196. * @param featureName the name of the feature to search
  48197. * @returns the version number. if not found will return -1
  48198. */
  48199. static GetStableVersionOfFeature(featureName: string): number;
  48200. /**
  48201. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  48202. * Can be used during a session to start a feature
  48203. * @param featureName the name of feature to attach
  48204. */
  48205. attachFeature(featureName: string): void;
  48206. /**
  48207. * Can be used inside a session or when the session ends to detach a specific feature
  48208. * @param featureName the name of the feature to detach
  48209. */
  48210. detachFeature(featureName: string): void;
  48211. /**
  48212. * Used to disable an already-enabled feature
  48213. * The feature will be disposed and will be recreated once enabled.
  48214. * @param featureName the feature to disable
  48215. * @returns true if disable was successful
  48216. */
  48217. disableFeature(featureName: string | {
  48218. Name: string;
  48219. }): boolean;
  48220. /**
  48221. * dispose this features manager
  48222. */
  48223. dispose(): void;
  48224. /**
  48225. * 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.
  48226. * 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.
  48227. *
  48228. * @param featureName the name of the feature to load or the class of the feature
  48229. * @param version optional version to load. if not provided the latest version will be enabled
  48230. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  48231. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  48232. * @returns a new constructed feature or throws an error if feature not found.
  48233. */
  48234. enableFeature(featureName: string | {
  48235. Name: string;
  48236. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  48237. /**
  48238. * get the implementation of an enabled feature.
  48239. * @param featureName the name of the feature to load
  48240. * @returns the feature class, if found
  48241. */
  48242. getEnabledFeature(featureName: string): IWebXRFeature;
  48243. /**
  48244. * Get the list of enabled features
  48245. * @returns an array of enabled features
  48246. */
  48247. getEnabledFeatures(): string[];
  48248. }
  48249. }
  48250. declare module "babylonjs/XR/webXRExperienceHelper" {
  48251. import { Observable } from "babylonjs/Misc/observable";
  48252. import { IDisposable, Scene } from "babylonjs/scene";
  48253. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48254. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  48255. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48256. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  48257. /**
  48258. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  48259. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  48260. */
  48261. export class WebXRExperienceHelper implements IDisposable {
  48262. private scene;
  48263. private _nonVRCamera;
  48264. private _originalSceneAutoClear;
  48265. private _supported;
  48266. /**
  48267. * Camera used to render xr content
  48268. */
  48269. camera: WebXRCamera;
  48270. /** A features manager for this xr session */
  48271. featuresManager: WebXRFeaturesManager;
  48272. /**
  48273. * Observers registered here will be triggered after the camera's initial transformation is set
  48274. * This can be used to set a different ground level or an extra rotation.
  48275. *
  48276. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  48277. * to the position set after this observable is done executing.
  48278. */
  48279. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  48280. /**
  48281. * Fires when the state of the experience helper has changed
  48282. */
  48283. onStateChangedObservable: Observable<WebXRState>;
  48284. /** Session manager used to keep track of xr session */
  48285. sessionManager: WebXRSessionManager;
  48286. /**
  48287. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  48288. */
  48289. state: WebXRState;
  48290. /**
  48291. * Creates a WebXRExperienceHelper
  48292. * @param scene The scene the helper should be created in
  48293. */
  48294. private constructor();
  48295. /**
  48296. * Creates the experience helper
  48297. * @param scene the scene to attach the experience helper to
  48298. * @returns a promise for the experience helper
  48299. */
  48300. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  48301. /**
  48302. * Disposes of the experience helper
  48303. */
  48304. dispose(): void;
  48305. /**
  48306. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  48307. * @param sessionMode options for the XR session
  48308. * @param referenceSpaceType frame of reference of the XR session
  48309. * @param renderTarget the output canvas that will be used to enter XR mode
  48310. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  48311. * @returns promise that resolves after xr mode has entered
  48312. */
  48313. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  48314. /**
  48315. * Exits XR mode and returns the scene to its original state
  48316. * @returns promise that resolves after xr mode has exited
  48317. */
  48318. exitXRAsync(): Promise<void>;
  48319. private _nonXRToXRCamera;
  48320. private _setState;
  48321. }
  48322. }
  48323. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  48324. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  48325. import { Observable } from "babylonjs/Misc/observable";
  48326. import { IDisposable } from "babylonjs/scene";
  48327. /**
  48328. * X-Y values for axes in WebXR
  48329. */
  48330. export interface IWebXRMotionControllerAxesValue {
  48331. /**
  48332. * The value of the x axis
  48333. */
  48334. x: number;
  48335. /**
  48336. * The value of the y-axis
  48337. */
  48338. y: number;
  48339. }
  48340. /**
  48341. * changed / previous values for the values of this component
  48342. */
  48343. export interface IWebXRMotionControllerComponentChangesValues<T> {
  48344. /**
  48345. * current (this frame) value
  48346. */
  48347. current: T;
  48348. /**
  48349. * previous (last change) value
  48350. */
  48351. previous: T;
  48352. }
  48353. /**
  48354. * Represents changes in the component between current frame and last values recorded
  48355. */
  48356. export interface IWebXRMotionControllerComponentChanges {
  48357. /**
  48358. * will be populated with previous and current values if axes changed
  48359. */
  48360. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  48361. /**
  48362. * will be populated with previous and current values if pressed changed
  48363. */
  48364. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48365. /**
  48366. * will be populated with previous and current values if touched changed
  48367. */
  48368. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  48369. /**
  48370. * will be populated with previous and current values if value changed
  48371. */
  48372. value?: IWebXRMotionControllerComponentChangesValues<number>;
  48373. }
  48374. /**
  48375. * This class represents a single component (for example button or thumbstick) of a motion controller
  48376. */
  48377. export class WebXRControllerComponent implements IDisposable {
  48378. /**
  48379. * the id of this component
  48380. */
  48381. id: string;
  48382. /**
  48383. * the type of the component
  48384. */
  48385. type: MotionControllerComponentType;
  48386. private _buttonIndex;
  48387. private _axesIndices;
  48388. private _axes;
  48389. private _changes;
  48390. private _currentValue;
  48391. private _hasChanges;
  48392. private _pressed;
  48393. private _touched;
  48394. /**
  48395. * button component type
  48396. */
  48397. static BUTTON_TYPE: MotionControllerComponentType;
  48398. /**
  48399. * squeeze component type
  48400. */
  48401. static SQUEEZE_TYPE: MotionControllerComponentType;
  48402. /**
  48403. * Thumbstick component type
  48404. */
  48405. static THUMBSTICK_TYPE: MotionControllerComponentType;
  48406. /**
  48407. * Touchpad component type
  48408. */
  48409. static TOUCHPAD_TYPE: MotionControllerComponentType;
  48410. /**
  48411. * trigger component type
  48412. */
  48413. static TRIGGER_TYPE: MotionControllerComponentType;
  48414. /**
  48415. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  48416. * the axes data changes
  48417. */
  48418. onAxisValueChangedObservable: Observable<{
  48419. x: number;
  48420. y: number;
  48421. }>;
  48422. /**
  48423. * Observers registered here will be triggered when the state of a button changes
  48424. * State change is either pressed / touched / value
  48425. */
  48426. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  48427. /**
  48428. * Creates a new component for a motion controller.
  48429. * It is created by the motion controller itself
  48430. *
  48431. * @param id the id of this component
  48432. * @param type the type of the component
  48433. * @param _buttonIndex index in the buttons array of the gamepad
  48434. * @param _axesIndices indices of the values in the axes array of the gamepad
  48435. */
  48436. constructor(
  48437. /**
  48438. * the id of this component
  48439. */
  48440. id: string,
  48441. /**
  48442. * the type of the component
  48443. */
  48444. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  48445. /**
  48446. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  48447. */
  48448. get axes(): IWebXRMotionControllerAxesValue;
  48449. /**
  48450. * Get the changes. Elements will be populated only if they changed with their previous and current value
  48451. */
  48452. get changes(): IWebXRMotionControllerComponentChanges;
  48453. /**
  48454. * Return whether or not the component changed the last frame
  48455. */
  48456. get hasChanges(): boolean;
  48457. /**
  48458. * is the button currently pressed
  48459. */
  48460. get pressed(): boolean;
  48461. /**
  48462. * is the button currently touched
  48463. */
  48464. get touched(): boolean;
  48465. /**
  48466. * Get the current value of this component
  48467. */
  48468. get value(): number;
  48469. /**
  48470. * Dispose this component
  48471. */
  48472. dispose(): void;
  48473. /**
  48474. * Are there axes correlating to this component
  48475. * @return true is axes data is available
  48476. */
  48477. isAxes(): boolean;
  48478. /**
  48479. * Is this component a button (hence - pressable)
  48480. * @returns true if can be pressed
  48481. */
  48482. isButton(): boolean;
  48483. /**
  48484. * update this component using the gamepad object it is in. Called on every frame
  48485. * @param nativeController the native gamepad controller object
  48486. */
  48487. update(nativeController: IMinimalMotionControllerObject): void;
  48488. }
  48489. }
  48490. declare module "babylonjs/Loading/sceneLoader" {
  48491. import { Observable } from "babylonjs/Misc/observable";
  48492. import { Nullable } from "babylonjs/types";
  48493. import { Scene } from "babylonjs/scene";
  48494. import { Engine } from "babylonjs/Engines/engine";
  48495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48496. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  48497. import { AssetContainer } from "babylonjs/assetContainer";
  48498. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  48499. import { Skeleton } from "babylonjs/Bones/skeleton";
  48500. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  48501. import { WebRequest } from "babylonjs/Misc/webRequest";
  48502. /**
  48503. * Interface used to represent data loading progression
  48504. */
  48505. export interface ISceneLoaderProgressEvent {
  48506. /**
  48507. * Defines if data length to load can be evaluated
  48508. */
  48509. readonly lengthComputable: boolean;
  48510. /**
  48511. * Defines the loaded data length
  48512. */
  48513. readonly loaded: number;
  48514. /**
  48515. * Defines the data length to load
  48516. */
  48517. readonly total: number;
  48518. }
  48519. /**
  48520. * Interface used by SceneLoader plugins to define supported file extensions
  48521. */
  48522. export interface ISceneLoaderPluginExtensions {
  48523. /**
  48524. * Defines the list of supported extensions
  48525. */
  48526. [extension: string]: {
  48527. isBinary: boolean;
  48528. };
  48529. }
  48530. /**
  48531. * Interface used by SceneLoader plugin factory
  48532. */
  48533. export interface ISceneLoaderPluginFactory {
  48534. /**
  48535. * Defines the name of the factory
  48536. */
  48537. name: string;
  48538. /**
  48539. * Function called to create a new plugin
  48540. * @return the new plugin
  48541. */
  48542. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  48543. /**
  48544. * The callback that returns true if the data can be directly loaded.
  48545. * @param data string containing the file data
  48546. * @returns if the data can be loaded directly
  48547. */
  48548. canDirectLoad?(data: string): boolean;
  48549. }
  48550. /**
  48551. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  48552. */
  48553. export interface ISceneLoaderPluginBase {
  48554. /**
  48555. * The friendly name of this plugin.
  48556. */
  48557. name: string;
  48558. /**
  48559. * The file extensions supported by this plugin.
  48560. */
  48561. extensions: string | ISceneLoaderPluginExtensions;
  48562. /**
  48563. * The callback called when loading from a url.
  48564. * @param scene scene loading this url
  48565. * @param url url to load
  48566. * @param onSuccess callback called when the file successfully loads
  48567. * @param onProgress callback called while file is loading (if the server supports this mode)
  48568. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  48569. * @param onError callback called when the file fails to load
  48570. * @returns a file request object
  48571. */
  48572. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48573. /**
  48574. * The callback called when loading from a file object.
  48575. * @param scene scene loading this file
  48576. * @param file defines the file to load
  48577. * @param onSuccess defines the callback to call when data is loaded
  48578. * @param onProgress defines the callback to call during loading process
  48579. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  48580. * @param onError defines the callback to call when an error occurs
  48581. * @returns a file request object
  48582. */
  48583. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  48584. /**
  48585. * The callback that returns true if the data can be directly loaded.
  48586. * @param data string containing the file data
  48587. * @returns if the data can be loaded directly
  48588. */
  48589. canDirectLoad?(data: string): boolean;
  48590. /**
  48591. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  48592. * @param scene scene loading this data
  48593. * @param data string containing the data
  48594. * @returns data to pass to the plugin
  48595. */
  48596. directLoad?(scene: Scene, data: string): any;
  48597. /**
  48598. * The callback that allows custom handling of the root url based on the response url.
  48599. * @param rootUrl the original root url
  48600. * @param responseURL the response url if available
  48601. * @returns the new root url
  48602. */
  48603. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  48604. }
  48605. /**
  48606. * Interface used to define a SceneLoader plugin
  48607. */
  48608. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  48609. /**
  48610. * Import meshes into a scene.
  48611. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48612. * @param scene The scene to import into
  48613. * @param data The data to import
  48614. * @param rootUrl The root url for scene and resources
  48615. * @param meshes The meshes array to import into
  48616. * @param particleSystems The particle systems array to import into
  48617. * @param skeletons The skeletons array to import into
  48618. * @param onError The callback when import fails
  48619. * @returns True if successful or false otherwise
  48620. */
  48621. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  48622. /**
  48623. * Load into a scene.
  48624. * @param scene The scene to load into
  48625. * @param data The data to import
  48626. * @param rootUrl The root url for scene and resources
  48627. * @param onError The callback when import fails
  48628. * @returns True if successful or false otherwise
  48629. */
  48630. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  48631. /**
  48632. * Load into an asset container.
  48633. * @param scene The scene to load into
  48634. * @param data The data to import
  48635. * @param rootUrl The root url for scene and resources
  48636. * @param onError The callback when import fails
  48637. * @returns The loaded asset container
  48638. */
  48639. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  48640. }
  48641. /**
  48642. * Interface used to define an async SceneLoader plugin
  48643. */
  48644. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  48645. /**
  48646. * Import meshes into a scene.
  48647. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48648. * @param scene The scene to import into
  48649. * @param data The data to import
  48650. * @param rootUrl The root url for scene and resources
  48651. * @param onProgress The callback when the load progresses
  48652. * @param fileName Defines the name of the file to load
  48653. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  48654. */
  48655. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  48656. meshes: AbstractMesh[];
  48657. particleSystems: IParticleSystem[];
  48658. skeletons: Skeleton[];
  48659. animationGroups: AnimationGroup[];
  48660. }>;
  48661. /**
  48662. * Load into a scene.
  48663. * @param scene The scene to load into
  48664. * @param data The data to import
  48665. * @param rootUrl The root url for scene and resources
  48666. * @param onProgress The callback when the load progresses
  48667. * @param fileName Defines the name of the file to load
  48668. * @returns Nothing
  48669. */
  48670. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  48671. /**
  48672. * Load into an asset container.
  48673. * @param scene The scene to load into
  48674. * @param data The data to import
  48675. * @param rootUrl The root url for scene and resources
  48676. * @param onProgress The callback when the load progresses
  48677. * @param fileName Defines the name of the file to load
  48678. * @returns The loaded asset container
  48679. */
  48680. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  48681. }
  48682. /**
  48683. * Mode that determines how to handle old animation groups before loading new ones.
  48684. */
  48685. export enum SceneLoaderAnimationGroupLoadingMode {
  48686. /**
  48687. * Reset all old animations to initial state then dispose them.
  48688. */
  48689. Clean = 0,
  48690. /**
  48691. * Stop all old animations.
  48692. */
  48693. Stop = 1,
  48694. /**
  48695. * Restart old animations from first frame.
  48696. */
  48697. Sync = 2,
  48698. /**
  48699. * Old animations remains untouched.
  48700. */
  48701. NoSync = 3
  48702. }
  48703. /**
  48704. * Class used to load scene from various file formats using registered plugins
  48705. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  48706. */
  48707. export class SceneLoader {
  48708. /**
  48709. * No logging while loading
  48710. */
  48711. static readonly NO_LOGGING: number;
  48712. /**
  48713. * Minimal logging while loading
  48714. */
  48715. static readonly MINIMAL_LOGGING: number;
  48716. /**
  48717. * Summary logging while loading
  48718. */
  48719. static readonly SUMMARY_LOGGING: number;
  48720. /**
  48721. * Detailled logging while loading
  48722. */
  48723. static readonly DETAILED_LOGGING: number;
  48724. /**
  48725. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48726. */
  48727. static get ForceFullSceneLoadingForIncremental(): boolean;
  48728. static set ForceFullSceneLoadingForIncremental(value: boolean);
  48729. /**
  48730. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48731. */
  48732. static get ShowLoadingScreen(): boolean;
  48733. static set ShowLoadingScreen(value: boolean);
  48734. /**
  48735. * Defines the current logging level (while loading the scene)
  48736. * @ignorenaming
  48737. */
  48738. static get loggingLevel(): number;
  48739. static set loggingLevel(value: number);
  48740. /**
  48741. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48742. */
  48743. static get CleanBoneMatrixWeights(): boolean;
  48744. static set CleanBoneMatrixWeights(value: boolean);
  48745. /**
  48746. * Event raised when a plugin is used to load a scene
  48747. */
  48748. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  48749. private static _registeredPlugins;
  48750. private static _getDefaultPlugin;
  48751. private static _getPluginForExtension;
  48752. private static _getPluginForDirectLoad;
  48753. private static _getPluginForFilename;
  48754. private static _getDirectLoad;
  48755. private static _loadData;
  48756. private static _getFileInfo;
  48757. /**
  48758. * Gets a plugin that can load the given extension
  48759. * @param extension defines the extension to load
  48760. * @returns a plugin or null if none works
  48761. */
  48762. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  48763. /**
  48764. * Gets a boolean indicating that the given extension can be loaded
  48765. * @param extension defines the extension to load
  48766. * @returns true if the extension is supported
  48767. */
  48768. static IsPluginForExtensionAvailable(extension: string): boolean;
  48769. /**
  48770. * Adds a new plugin to the list of registered plugins
  48771. * @param plugin defines the plugin to add
  48772. */
  48773. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  48774. /**
  48775. * Import meshes into a scene
  48776. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48777. * @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)
  48778. * @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)
  48779. * @param scene the instance of BABYLON.Scene to append to
  48780. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48781. * @param onProgress a callback with a progress event for each file being loaded
  48782. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48783. * @param pluginExtension the extension used to determine the plugin
  48784. * @returns The loaded plugin
  48785. */
  48786. 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>;
  48787. /**
  48788. * Import meshes into a scene
  48789. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48790. * @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)
  48791. * @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)
  48792. * @param scene the instance of BABYLON.Scene to append to
  48793. * @param onProgress a callback with a progress event for each file being loaded
  48794. * @param pluginExtension the extension used to determine the plugin
  48795. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48796. */
  48797. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  48798. meshes: AbstractMesh[];
  48799. particleSystems: IParticleSystem[];
  48800. skeletons: Skeleton[];
  48801. animationGroups: AnimationGroup[];
  48802. }>;
  48803. /**
  48804. * Load a scene
  48805. * @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)
  48806. * @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)
  48807. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48808. * @param onSuccess a callback with the scene when import succeeds
  48809. * @param onProgress a callback with a progress event for each file being loaded
  48810. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48811. * @param pluginExtension the extension used to determine the plugin
  48812. * @returns The loaded plugin
  48813. */
  48814. 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>;
  48815. /**
  48816. * Load a scene
  48817. * @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)
  48818. * @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)
  48819. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48820. * @param onProgress a callback with a progress event for each file being loaded
  48821. * @param pluginExtension the extension used to determine the plugin
  48822. * @returns The loaded scene
  48823. */
  48824. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48825. /**
  48826. * Append a scene
  48827. * @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)
  48828. * @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)
  48829. * @param scene is the instance of BABYLON.Scene to append to
  48830. * @param onSuccess a callback with the scene when import succeeds
  48831. * @param onProgress a callback with a progress event for each file being loaded
  48832. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48833. * @param pluginExtension the extension used to determine the plugin
  48834. * @returns The loaded plugin
  48835. */
  48836. 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>;
  48837. /**
  48838. * Append a scene
  48839. * @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)
  48840. * @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)
  48841. * @param scene is the instance of BABYLON.Scene to append to
  48842. * @param onProgress a callback with a progress event for each file being loaded
  48843. * @param pluginExtension the extension used to determine the plugin
  48844. * @returns The given scene
  48845. */
  48846. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  48847. /**
  48848. * Load a scene into an asset container
  48849. * @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)
  48850. * @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)
  48851. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48852. * @param onSuccess a callback with the scene when import succeeds
  48853. * @param onProgress a callback with a progress event for each file being loaded
  48854. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48855. * @param pluginExtension the extension used to determine the plugin
  48856. * @returns The loaded plugin
  48857. */
  48858. 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>;
  48859. /**
  48860. * Load a scene into an asset container
  48861. * @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)
  48862. * @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)
  48863. * @param scene is the instance of Scene to append to
  48864. * @param onProgress a callback with a progress event for each file being loaded
  48865. * @param pluginExtension the extension used to determine the plugin
  48866. * @returns The loaded asset container
  48867. */
  48868. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  48869. /**
  48870. * Import animations from a file into a scene
  48871. * @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)
  48872. * @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)
  48873. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48874. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48875. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48876. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48877. * @param onSuccess a callback with the scene when import succeeds
  48878. * @param onProgress a callback with a progress event for each file being loaded
  48879. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48880. * @param pluginExtension the extension used to determine the plugin
  48881. */
  48882. 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;
  48883. /**
  48884. * Import animations from a file into a scene
  48885. * @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)
  48886. * @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)
  48887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  48888. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  48889. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  48890. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  48891. * @param onSuccess a callback with the scene when import succeeds
  48892. * @param onProgress a callback with a progress event for each file being loaded
  48893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48894. * @param pluginExtension the extension used to determine the plugin
  48895. * @returns the updated scene with imported animations
  48896. */
  48897. 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>;
  48898. }
  48899. }
  48900. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  48901. import { IDisposable, Scene } from "babylonjs/scene";
  48902. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  48903. import { Observable } from "babylonjs/Misc/observable";
  48904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48905. import { Nullable } from "babylonjs/types";
  48906. /**
  48907. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  48908. */
  48909. export type MotionControllerHandedness = "none" | "left" | "right";
  48910. /**
  48911. * The type of components available in motion controllers.
  48912. * This is not the name of the component.
  48913. */
  48914. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  48915. /**
  48916. * The state of a controller component
  48917. */
  48918. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  48919. /**
  48920. * The schema of motion controller layout.
  48921. * No object will be initialized using this interface
  48922. * This is used just to define the profile.
  48923. */
  48924. export interface IMotionControllerLayout {
  48925. /**
  48926. * Path to load the assets. Usually relative to the base path
  48927. */
  48928. assetPath: string;
  48929. /**
  48930. * Available components (unsorted)
  48931. */
  48932. components: {
  48933. /**
  48934. * A map of component Ids
  48935. */
  48936. [componentId: string]: {
  48937. /**
  48938. * The type of input the component outputs
  48939. */
  48940. type: MotionControllerComponentType;
  48941. /**
  48942. * The indices of this component in the gamepad object
  48943. */
  48944. gamepadIndices: {
  48945. /**
  48946. * Index of button
  48947. */
  48948. button?: number;
  48949. /**
  48950. * If available, index of x-axis
  48951. */
  48952. xAxis?: number;
  48953. /**
  48954. * If available, index of y-axis
  48955. */
  48956. yAxis?: number;
  48957. };
  48958. /**
  48959. * The mesh's root node name
  48960. */
  48961. rootNodeName: string;
  48962. /**
  48963. * Animation definitions for this model
  48964. */
  48965. visualResponses: {
  48966. [stateKey: string]: {
  48967. /**
  48968. * What property will be animated
  48969. */
  48970. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  48971. /**
  48972. * What states influence this visual response
  48973. */
  48974. states: MotionControllerComponentStateType[];
  48975. /**
  48976. * Type of animation - movement or visibility
  48977. */
  48978. valueNodeProperty: "transform" | "visibility";
  48979. /**
  48980. * Base node name to move. Its position will be calculated according to the min and max nodes
  48981. */
  48982. valueNodeName?: string;
  48983. /**
  48984. * Minimum movement node
  48985. */
  48986. minNodeName?: string;
  48987. /**
  48988. * Max movement node
  48989. */
  48990. maxNodeName?: string;
  48991. };
  48992. };
  48993. /**
  48994. * If touch enabled, what is the name of node to display user feedback
  48995. */
  48996. touchPointNodeName?: string;
  48997. };
  48998. };
  48999. /**
  49000. * Is it xr standard mapping or not
  49001. */
  49002. gamepadMapping: "" | "xr-standard";
  49003. /**
  49004. * Base root node of this entire model
  49005. */
  49006. rootNodeName: string;
  49007. /**
  49008. * Defines the main button component id
  49009. */
  49010. selectComponentId: string;
  49011. }
  49012. /**
  49013. * A definition for the layout map in the input profile
  49014. */
  49015. export interface IMotionControllerLayoutMap {
  49016. /**
  49017. * Layouts with handedness type as a key
  49018. */
  49019. [handedness: string]: IMotionControllerLayout;
  49020. }
  49021. /**
  49022. * The XR Input profile schema
  49023. * Profiles can be found here:
  49024. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49025. */
  49026. export interface IMotionControllerProfile {
  49027. /**
  49028. * fallback profiles for this profileId
  49029. */
  49030. fallbackProfileIds: string[];
  49031. /**
  49032. * The layout map, with handedness as key
  49033. */
  49034. layouts: IMotionControllerLayoutMap;
  49035. /**
  49036. * The id of this profile
  49037. * correlates to the profile(s) in the xrInput.profiles array
  49038. */
  49039. profileId: string;
  49040. }
  49041. /**
  49042. * A helper-interface for the 3 meshes needed for controller button animation
  49043. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  49044. */
  49045. export interface IMotionControllerButtonMeshMap {
  49046. /**
  49047. * the mesh that defines the pressed value mesh position.
  49048. * This is used to find the max-position of this button
  49049. */
  49050. pressedMesh: AbstractMesh;
  49051. /**
  49052. * the mesh that defines the unpressed value mesh position.
  49053. * This is used to find the min (or initial) position of this button
  49054. */
  49055. unpressedMesh: AbstractMesh;
  49056. /**
  49057. * The mesh that will be changed when value changes
  49058. */
  49059. valueMesh: AbstractMesh;
  49060. }
  49061. /**
  49062. * A helper-interface for the 3 meshes needed for controller axis animation.
  49063. * This will be expanded when touchpad animations are fully supported
  49064. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  49065. */
  49066. export interface IMotionControllerMeshMap {
  49067. /**
  49068. * the mesh that defines the maximum value mesh position.
  49069. */
  49070. maxMesh?: AbstractMesh;
  49071. /**
  49072. * the mesh that defines the minimum value mesh position.
  49073. */
  49074. minMesh?: AbstractMesh;
  49075. /**
  49076. * The mesh that will be changed when axis value changes
  49077. */
  49078. valueMesh: AbstractMesh;
  49079. }
  49080. /**
  49081. * The elements needed for change-detection of the gamepad objects in motion controllers
  49082. */
  49083. export interface IMinimalMotionControllerObject {
  49084. /**
  49085. * Available axes of this controller
  49086. */
  49087. axes: number[];
  49088. /**
  49089. * An array of available buttons
  49090. */
  49091. buttons: Array<{
  49092. /**
  49093. * Value of the button/trigger
  49094. */
  49095. value: number;
  49096. /**
  49097. * If the button/trigger is currently touched
  49098. */
  49099. touched: boolean;
  49100. /**
  49101. * If the button/trigger is currently pressed
  49102. */
  49103. pressed: boolean;
  49104. }>;
  49105. /**
  49106. * EXPERIMENTAL haptic support.
  49107. */
  49108. hapticActuators?: Array<{
  49109. pulse: (value: number, duration: number) => Promise<boolean>;
  49110. }>;
  49111. }
  49112. /**
  49113. * An Abstract Motion controller
  49114. * This class receives an xrInput and a profile layout and uses those to initialize the components
  49115. * Each component has an observable to check for changes in value and state
  49116. */
  49117. export abstract class WebXRAbstractMotionController implements IDisposable {
  49118. protected scene: Scene;
  49119. protected layout: IMotionControllerLayout;
  49120. /**
  49121. * The gamepad object correlating to this controller
  49122. */
  49123. gamepadObject: IMinimalMotionControllerObject;
  49124. /**
  49125. * handedness (left/right/none) of this controller
  49126. */
  49127. handedness: MotionControllerHandedness;
  49128. private _initComponent;
  49129. private _modelReady;
  49130. /**
  49131. * A map of components (WebXRControllerComponent) in this motion controller
  49132. * Components have a ComponentType and can also have both button and axis definitions
  49133. */
  49134. readonly components: {
  49135. [id: string]: WebXRControllerComponent;
  49136. };
  49137. /**
  49138. * Disable the model's animation. Can be set at any time.
  49139. */
  49140. disableAnimation: boolean;
  49141. /**
  49142. * Observers registered here will be triggered when the model of this controller is done loading
  49143. */
  49144. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  49145. /**
  49146. * The profile id of this motion controller
  49147. */
  49148. abstract profileId: string;
  49149. /**
  49150. * The root mesh of the model. It is null if the model was not yet initialized
  49151. */
  49152. rootMesh: Nullable<AbstractMesh>;
  49153. /**
  49154. * constructs a new abstract motion controller
  49155. * @param scene the scene to which the model of the controller will be added
  49156. * @param layout The profile layout to load
  49157. * @param gamepadObject The gamepad object correlating to this controller
  49158. * @param handedness handedness (left/right/none) of this controller
  49159. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  49160. */
  49161. constructor(scene: Scene, layout: IMotionControllerLayout,
  49162. /**
  49163. * The gamepad object correlating to this controller
  49164. */
  49165. gamepadObject: IMinimalMotionControllerObject,
  49166. /**
  49167. * handedness (left/right/none) of this controller
  49168. */
  49169. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  49170. /**
  49171. * Dispose this controller, the model mesh and all its components
  49172. */
  49173. dispose(): void;
  49174. /**
  49175. * Returns all components of specific type
  49176. * @param type the type to search for
  49177. * @return an array of components with this type
  49178. */
  49179. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  49180. /**
  49181. * get a component based an its component id as defined in layout.components
  49182. * @param id the id of the component
  49183. * @returns the component correlates to the id or undefined if not found
  49184. */
  49185. getComponent(id: string): WebXRControllerComponent;
  49186. /**
  49187. * Get the list of components available in this motion controller
  49188. * @returns an array of strings correlating to available components
  49189. */
  49190. getComponentIds(): string[];
  49191. /**
  49192. * Get the first component of specific type
  49193. * @param type type of component to find
  49194. * @return a controller component or null if not found
  49195. */
  49196. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  49197. /**
  49198. * Get the main (Select) component of this controller as defined in the layout
  49199. * @returns the main component of this controller
  49200. */
  49201. getMainComponent(): WebXRControllerComponent;
  49202. /**
  49203. * Loads the model correlating to this controller
  49204. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  49205. * @returns A promise fulfilled with the result of the model loading
  49206. */
  49207. loadModel(): Promise<boolean>;
  49208. /**
  49209. * Update this model using the current XRFrame
  49210. * @param xrFrame the current xr frame to use and update the model
  49211. */
  49212. updateFromXRFrame(xrFrame: XRFrame): void;
  49213. /**
  49214. * Backwards compatibility due to a deeply-integrated typo
  49215. */
  49216. get handness(): XREye;
  49217. /**
  49218. * Pulse (vibrate) this controller
  49219. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  49220. * Consecutive calls to this function will cancel the last pulse call
  49221. *
  49222. * @param value the strength of the pulse in 0.0...1.0 range
  49223. * @param duration Duration of the pulse in milliseconds
  49224. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  49225. * @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
  49226. */
  49227. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  49228. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49229. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  49230. /**
  49231. * Moves the axis on the controller mesh based on its current state
  49232. * @param axis the index of the axis
  49233. * @param axisValue the value of the axis which determines the meshes new position
  49234. * @hidden
  49235. */
  49236. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  49237. /**
  49238. * Update the model itself with the current frame data
  49239. * @param xrFrame the frame to use for updating the model mesh
  49240. */
  49241. protected updateModel(xrFrame: XRFrame): void;
  49242. /**
  49243. * Get the filename and path for this controller's model
  49244. * @returns a map of filename and path
  49245. */
  49246. protected abstract _getFilenameAndPath(): {
  49247. filename: string;
  49248. path: string;
  49249. };
  49250. /**
  49251. * This function is called before the mesh is loaded. It checks for loading constraints.
  49252. * For example, this function can check if the GLB loader is available
  49253. * If this function returns false, the generic controller will be loaded instead
  49254. * @returns Is the client ready to load the mesh
  49255. */
  49256. protected abstract _getModelLoadingConstraints(): boolean;
  49257. /**
  49258. * This function will be called after the model was successfully loaded and can be used
  49259. * for mesh transformations before it is available for the user
  49260. * @param meshes the loaded meshes
  49261. */
  49262. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  49263. /**
  49264. * Set the root mesh for this controller. Important for the WebXR controller class
  49265. * @param meshes the loaded meshes
  49266. */
  49267. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  49268. /**
  49269. * A function executed each frame that updates the mesh (if needed)
  49270. * @param xrFrame the current xrFrame
  49271. */
  49272. protected abstract _updateModel(xrFrame: XRFrame): void;
  49273. private _getGenericFilenameAndPath;
  49274. private _getGenericParentMesh;
  49275. }
  49276. }
  49277. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  49278. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49280. import { Scene } from "babylonjs/scene";
  49281. /**
  49282. * A generic trigger-only motion controller for WebXR
  49283. */
  49284. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  49285. /**
  49286. * Static version of the profile id of this controller
  49287. */
  49288. static ProfileId: string;
  49289. profileId: string;
  49290. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  49291. protected _getFilenameAndPath(): {
  49292. filename: string;
  49293. path: string;
  49294. };
  49295. protected _getModelLoadingConstraints(): boolean;
  49296. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  49297. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49298. protected _updateModel(): void;
  49299. }
  49300. }
  49301. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  49302. import { Vector4 } from "babylonjs/Maths/math.vector";
  49303. import { Mesh } from "babylonjs/Meshes/mesh";
  49304. import { Scene } from "babylonjs/scene";
  49305. import { Nullable } from "babylonjs/types";
  49306. /**
  49307. * Class containing static functions to help procedurally build meshes
  49308. */
  49309. export class SphereBuilder {
  49310. /**
  49311. * Creates a sphere mesh
  49312. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  49313. * * 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`)
  49314. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  49315. * * 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
  49316. * * 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)
  49317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  49319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49320. * @param name defines the name of the mesh
  49321. * @param options defines the options used to create the mesh
  49322. * @param scene defines the hosting scene
  49323. * @returns the sphere mesh
  49324. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  49325. */
  49326. static CreateSphere(name: string, options: {
  49327. segments?: number;
  49328. diameter?: number;
  49329. diameterX?: number;
  49330. diameterY?: number;
  49331. diameterZ?: number;
  49332. arc?: number;
  49333. slice?: number;
  49334. sideOrientation?: number;
  49335. frontUVs?: Vector4;
  49336. backUVs?: Vector4;
  49337. updatable?: boolean;
  49338. }, scene?: Nullable<Scene>): Mesh;
  49339. }
  49340. }
  49341. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  49342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49343. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49344. import { Scene } from "babylonjs/scene";
  49345. /**
  49346. * A profiled motion controller has its profile loaded from an online repository.
  49347. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  49348. */
  49349. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  49350. private _repositoryUrl;
  49351. private _buttonMeshMapping;
  49352. private _touchDots;
  49353. /**
  49354. * The profile ID of this controller. Will be populated when the controller initializes.
  49355. */
  49356. profileId: string;
  49357. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  49358. dispose(): void;
  49359. protected _getFilenameAndPath(): {
  49360. filename: string;
  49361. path: string;
  49362. };
  49363. protected _getModelLoadingConstraints(): boolean;
  49364. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  49365. protected _setRootMesh(meshes: AbstractMesh[]): void;
  49366. protected _updateModel(_xrFrame: XRFrame): void;
  49367. }
  49368. }
  49369. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  49370. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49371. import { Scene } from "babylonjs/scene";
  49372. /**
  49373. * A construction function type to create a new controller based on an xrInput object
  49374. */
  49375. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  49376. /**
  49377. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  49378. *
  49379. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  49380. * it should be replaced with auto-loaded controllers.
  49381. *
  49382. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  49383. */
  49384. export class WebXRMotionControllerManager {
  49385. private static _AvailableControllers;
  49386. private static _Fallbacks;
  49387. private static _ProfileLoadingPromises;
  49388. private static _ProfilesList;
  49389. /**
  49390. * The base URL of the online controller repository. Can be changed at any time.
  49391. */
  49392. static BaseRepositoryUrl: string;
  49393. /**
  49394. * Which repository gets priority - local or online
  49395. */
  49396. static PrioritizeOnlineRepository: boolean;
  49397. /**
  49398. * Use the online repository, or use only locally-defined controllers
  49399. */
  49400. static UseOnlineRepository: boolean;
  49401. /**
  49402. * Clear the cache used for profile loading and reload when requested again
  49403. */
  49404. static ClearProfilesCache(): void;
  49405. /**
  49406. * Register the default fallbacks.
  49407. * This function is called automatically when this file is imported.
  49408. */
  49409. static DefaultFallbacks(): void;
  49410. /**
  49411. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  49412. * @param profileId the profile to which a fallback needs to be found
  49413. * @return an array with corresponding fallback profiles
  49414. */
  49415. static FindFallbackWithProfileId(profileId: string): string[];
  49416. /**
  49417. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  49418. * The order of search:
  49419. *
  49420. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  49421. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  49422. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  49423. * 4) return the generic trigger controller if none were found
  49424. *
  49425. * @param xrInput the xrInput to which a new controller is initialized
  49426. * @param scene the scene to which the model will be added
  49427. * @param forceProfile force a certain profile for this controller
  49428. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  49429. */
  49430. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  49431. /**
  49432. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  49433. *
  49434. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  49435. *
  49436. * @param type the profile type to register
  49437. * @param constructFunction the function to be called when loading this profile
  49438. */
  49439. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  49440. /**
  49441. * Register a fallback to a specific profile.
  49442. * @param profileId the profileId that will receive the fallbacks
  49443. * @param fallbacks A list of fallback profiles
  49444. */
  49445. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  49446. /**
  49447. * Will update the list of profiles available in the repository
  49448. * @return a promise that resolves to a map of profiles available online
  49449. */
  49450. static UpdateProfilesList(): Promise<{
  49451. [profile: string]: string;
  49452. }>;
  49453. private static _LoadProfileFromRepository;
  49454. private static _LoadProfilesFromAvailableControllers;
  49455. }
  49456. }
  49457. declare module "babylonjs/XR/webXRInputSource" {
  49458. import { Observable } from "babylonjs/Misc/observable";
  49459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49460. import { Ray } from "babylonjs/Culling/ray";
  49461. import { Scene } from "babylonjs/scene";
  49462. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49463. /**
  49464. * Configuration options for the WebXR controller creation
  49465. */
  49466. export interface IWebXRControllerOptions {
  49467. /**
  49468. * Should the controller mesh be animated when a user interacts with it
  49469. * The pressed buttons / thumbstick and touchpad animations will be disabled
  49470. */
  49471. disableMotionControllerAnimation?: boolean;
  49472. /**
  49473. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  49474. */
  49475. doNotLoadControllerMesh?: boolean;
  49476. /**
  49477. * Force a specific controller type for this controller.
  49478. * This can be used when creating your own profile or when testing different controllers
  49479. */
  49480. forceControllerProfile?: string;
  49481. /**
  49482. * Defines a rendering group ID for meshes that will be loaded.
  49483. * This is for the default controllers only.
  49484. */
  49485. renderingGroupId?: number;
  49486. }
  49487. /**
  49488. * Represents an XR controller
  49489. */
  49490. export class WebXRInputSource {
  49491. private _scene;
  49492. /** The underlying input source for the controller */
  49493. inputSource: XRInputSource;
  49494. private _options;
  49495. private _tmpVector;
  49496. private _uniqueId;
  49497. /**
  49498. * 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
  49499. */
  49500. grip?: AbstractMesh;
  49501. /**
  49502. * If available, this is the gamepad object related to this controller.
  49503. * Using this object it is possible to get click events and trackpad changes of the
  49504. * webxr controller that is currently being used.
  49505. */
  49506. motionController?: WebXRAbstractMotionController;
  49507. /**
  49508. * Event that fires when the controller is removed/disposed.
  49509. * The object provided as event data is this controller, after associated assets were disposed.
  49510. * uniqueId is still available.
  49511. */
  49512. onDisposeObservable: Observable<WebXRInputSource>;
  49513. /**
  49514. * Will be triggered when the mesh associated with the motion controller is done loading.
  49515. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  49516. * A shortened version of controller -> motion controller -> on mesh loaded.
  49517. */
  49518. onMeshLoadedObservable: Observable<AbstractMesh>;
  49519. /**
  49520. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  49521. */
  49522. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  49523. /**
  49524. * Pointer which can be used to select objects or attach a visible laser to
  49525. */
  49526. pointer: AbstractMesh;
  49527. /**
  49528. * Creates the input source object
  49529. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  49530. * @param _scene the scene which the controller should be associated to
  49531. * @param inputSource the underlying input source for the controller
  49532. * @param _options options for this controller creation
  49533. */
  49534. constructor(_scene: Scene,
  49535. /** The underlying input source for the controller */
  49536. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  49537. /**
  49538. * Get this controllers unique id
  49539. */
  49540. get uniqueId(): string;
  49541. /**
  49542. * Disposes of the object
  49543. */
  49544. dispose(): void;
  49545. /**
  49546. * Gets a world space ray coming from the pointer or grip
  49547. * @param result the resulting ray
  49548. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  49549. */
  49550. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  49551. /**
  49552. * Updates the controller pose based on the given XRFrame
  49553. * @param xrFrame xr frame to update the pose with
  49554. * @param referenceSpace reference space to use
  49555. */
  49556. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  49557. }
  49558. }
  49559. declare module "babylonjs/XR/webXRInput" {
  49560. import { Observable } from "babylonjs/Misc/observable";
  49561. import { IDisposable } from "babylonjs/scene";
  49562. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  49563. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49564. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49565. /**
  49566. * The schema for initialization options of the XR Input class
  49567. */
  49568. export interface IWebXRInputOptions {
  49569. /**
  49570. * If set to true no model will be automatically loaded
  49571. */
  49572. doNotLoadControllerMeshes?: boolean;
  49573. /**
  49574. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  49575. * If not found, the xr input profile data will be used.
  49576. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  49577. */
  49578. forceInputProfile?: string;
  49579. /**
  49580. * Do not send a request to the controller repository to load the profile.
  49581. *
  49582. * Instead, use the controllers available in babylon itself.
  49583. */
  49584. disableOnlineControllerRepository?: boolean;
  49585. /**
  49586. * A custom URL for the controllers repository
  49587. */
  49588. customControllersRepositoryURL?: string;
  49589. /**
  49590. * Should the controller model's components not move according to the user input
  49591. */
  49592. disableControllerAnimation?: boolean;
  49593. /**
  49594. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  49595. */
  49596. controllerOptions?: IWebXRControllerOptions;
  49597. }
  49598. /**
  49599. * XR input used to track XR inputs such as controllers/rays
  49600. */
  49601. export class WebXRInput implements IDisposable {
  49602. /**
  49603. * the xr session manager for this session
  49604. */
  49605. xrSessionManager: WebXRSessionManager;
  49606. /**
  49607. * the WebXR camera for this session. Mainly used for teleportation
  49608. */
  49609. xrCamera: WebXRCamera;
  49610. private readonly options;
  49611. /**
  49612. * XR controllers being tracked
  49613. */
  49614. controllers: Array<WebXRInputSource>;
  49615. private _frameObserver;
  49616. private _sessionEndedObserver;
  49617. private _sessionInitObserver;
  49618. /**
  49619. * Event when a controller has been connected/added
  49620. */
  49621. onControllerAddedObservable: Observable<WebXRInputSource>;
  49622. /**
  49623. * Event when a controller has been removed/disconnected
  49624. */
  49625. onControllerRemovedObservable: Observable<WebXRInputSource>;
  49626. /**
  49627. * Initializes the WebXRInput
  49628. * @param xrSessionManager the xr session manager for this session
  49629. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  49630. * @param options = initialization options for this xr input
  49631. */
  49632. constructor(
  49633. /**
  49634. * the xr session manager for this session
  49635. */
  49636. xrSessionManager: WebXRSessionManager,
  49637. /**
  49638. * the WebXR camera for this session. Mainly used for teleportation
  49639. */
  49640. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  49641. private _onInputSourcesChange;
  49642. private _addAndRemoveControllers;
  49643. /**
  49644. * Disposes of the object
  49645. */
  49646. dispose(): void;
  49647. }
  49648. }
  49649. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  49650. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  49651. import { Observable, EventState } from "babylonjs/Misc/observable";
  49652. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49653. /**
  49654. * This is the base class for all WebXR features.
  49655. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  49656. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  49657. */
  49658. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  49659. protected _xrSessionManager: WebXRSessionManager;
  49660. private _attached;
  49661. private _removeOnDetach;
  49662. /**
  49663. * Should auto-attach be disabled?
  49664. */
  49665. disableAutoAttach: boolean;
  49666. /**
  49667. * Construct a new (abstract) WebXR feature
  49668. * @param _xrSessionManager the xr session manager for this feature
  49669. */
  49670. constructor(_xrSessionManager: WebXRSessionManager);
  49671. /**
  49672. * Is this feature attached
  49673. */
  49674. get attached(): boolean;
  49675. /**
  49676. * attach this feature
  49677. *
  49678. * @param force should attachment be forced (even when already attached)
  49679. * @returns true if successful, false is failed or already attached
  49680. */
  49681. attach(force?: boolean): boolean;
  49682. /**
  49683. * detach this feature.
  49684. *
  49685. * @returns true if successful, false if failed or already detached
  49686. */
  49687. detach(): boolean;
  49688. /**
  49689. * Dispose this feature and all of the resources attached
  49690. */
  49691. dispose(): void;
  49692. /**
  49693. * This is used to register callbacks that will automatically be removed when detach is called.
  49694. * @param observable the observable to which the observer will be attached
  49695. * @param callback the callback to register
  49696. */
  49697. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  49698. /**
  49699. * Code in this function will be executed on each xrFrame received from the browser.
  49700. * This function will not execute after the feature is detached.
  49701. * @param _xrFrame the current frame
  49702. */
  49703. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  49704. }
  49705. }
  49706. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  49707. import { IDisposable, Scene } from "babylonjs/scene";
  49708. import { Nullable } from "babylonjs/types";
  49709. import { Observable } from "babylonjs/Misc/observable";
  49710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49711. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  49712. import { Camera } from "babylonjs/Cameras/camera";
  49713. /**
  49714. * Renders a layer on top of an existing scene
  49715. */
  49716. export class UtilityLayerRenderer implements IDisposable {
  49717. /** the original scene that will be rendered on top of */
  49718. originalScene: Scene;
  49719. private _pointerCaptures;
  49720. private _lastPointerEvents;
  49721. private static _DefaultUtilityLayer;
  49722. private static _DefaultKeepDepthUtilityLayer;
  49723. private _sharedGizmoLight;
  49724. private _renderCamera;
  49725. /**
  49726. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  49727. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  49728. * @returns the camera that is used when rendering the utility layer
  49729. */
  49730. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  49731. /**
  49732. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  49733. * @param cam the camera that should be used when rendering the utility layer
  49734. */
  49735. setRenderCamera(cam: Nullable<Camera>): void;
  49736. /**
  49737. * @hidden
  49738. * Light which used by gizmos to get light shading
  49739. */
  49740. _getSharedGizmoLight(): HemisphericLight;
  49741. /**
  49742. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  49743. */
  49744. pickUtilitySceneFirst: boolean;
  49745. /**
  49746. * 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)
  49747. */
  49748. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  49749. /**
  49750. * 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)
  49751. */
  49752. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  49753. /**
  49754. * The scene that is rendered on top of the original scene
  49755. */
  49756. utilityLayerScene: Scene;
  49757. /**
  49758. * If the utility layer should automatically be rendered on top of existing scene
  49759. */
  49760. shouldRender: boolean;
  49761. /**
  49762. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  49763. */
  49764. onlyCheckPointerDownEvents: boolean;
  49765. /**
  49766. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  49767. */
  49768. processAllEvents: boolean;
  49769. /**
  49770. * Observable raised when the pointer move from the utility layer scene to the main scene
  49771. */
  49772. onPointerOutObservable: Observable<number>;
  49773. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  49774. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  49775. private _afterRenderObserver;
  49776. private _sceneDisposeObserver;
  49777. private _originalPointerObserver;
  49778. /**
  49779. * Instantiates a UtilityLayerRenderer
  49780. * @param originalScene the original scene that will be rendered on top of
  49781. * @param handleEvents boolean indicating if the utility layer should handle events
  49782. */
  49783. constructor(
  49784. /** the original scene that will be rendered on top of */
  49785. originalScene: Scene, handleEvents?: boolean);
  49786. private _notifyObservers;
  49787. /**
  49788. * Renders the utility layers scene on top of the original scene
  49789. */
  49790. render(): void;
  49791. /**
  49792. * Disposes of the renderer
  49793. */
  49794. dispose(): void;
  49795. private _updateCamera;
  49796. }
  49797. }
  49798. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  49799. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49801. import { WebXRInput } from "babylonjs/XR/webXRInput";
  49802. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  49803. import { Scene } from "babylonjs/scene";
  49804. import { Nullable } from "babylonjs/types";
  49805. import { Color3 } from "babylonjs/Maths/math.color";
  49806. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  49807. /**
  49808. * Options interface for the pointer selection module
  49809. */
  49810. export interface IWebXRControllerPointerSelectionOptions {
  49811. /**
  49812. * if provided, this scene will be used to render meshes.
  49813. */
  49814. customUtilityLayerScene?: Scene;
  49815. /**
  49816. * 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)
  49817. * If not disabled, the last picked point will be used to execute a pointer up event
  49818. * If disabled, pointer up event will be triggered right after the pointer down event.
  49819. * Used in screen and gaze target ray mode only
  49820. */
  49821. disablePointerUpOnTouchOut: boolean;
  49822. /**
  49823. * For gaze mode (time to select instead of press)
  49824. */
  49825. forceGazeMode: boolean;
  49826. /**
  49827. * 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
  49828. * to start a new countdown to the pointer down event.
  49829. * Defaults to 1.
  49830. */
  49831. gazeModePointerMovedFactor?: number;
  49832. /**
  49833. * Different button type to use instead of the main component
  49834. */
  49835. overrideButtonId?: string;
  49836. /**
  49837. * use this rendering group id for the meshes (optional)
  49838. */
  49839. renderingGroupId?: number;
  49840. /**
  49841. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  49842. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  49843. * 3000 means 3 seconds between pointing at something and selecting it
  49844. */
  49845. timeToSelect?: number;
  49846. /**
  49847. * Should meshes created here be added to a utility layer or the main scene
  49848. */
  49849. useUtilityLayer?: boolean;
  49850. /**
  49851. * the xr input to use with this pointer selection
  49852. */
  49853. xrInput: WebXRInput;
  49854. }
  49855. /**
  49856. * A module that will enable pointer selection for motion controllers of XR Input Sources
  49857. */
  49858. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  49859. private readonly _options;
  49860. private static _idCounter;
  49861. private _attachController;
  49862. private _controllers;
  49863. private _scene;
  49864. private _tmpVectorForPickCompare;
  49865. /**
  49866. * The module's name
  49867. */
  49868. static readonly Name: string;
  49869. /**
  49870. * The (Babylon) version of this module.
  49871. * This is an integer representing the implementation version.
  49872. * This number does not correspond to the WebXR specs version
  49873. */
  49874. static readonly Version: number;
  49875. /**
  49876. * Disable lighting on the laser pointer (so it will always be visible)
  49877. */
  49878. disablePointerLighting: boolean;
  49879. /**
  49880. * Disable lighting on the selection mesh (so it will always be visible)
  49881. */
  49882. disableSelectionMeshLighting: boolean;
  49883. /**
  49884. * Should the laser pointer be displayed
  49885. */
  49886. displayLaserPointer: boolean;
  49887. /**
  49888. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  49889. */
  49890. displaySelectionMesh: boolean;
  49891. /**
  49892. * This color will be set to the laser pointer when selection is triggered
  49893. */
  49894. laserPointerPickedColor: Color3;
  49895. /**
  49896. * Default color of the laser pointer
  49897. */
  49898. laserPointerDefaultColor: Color3;
  49899. /**
  49900. * default color of the selection ring
  49901. */
  49902. selectionMeshDefaultColor: Color3;
  49903. /**
  49904. * This color will be applied to the selection ring when selection is triggered
  49905. */
  49906. selectionMeshPickedColor: Color3;
  49907. /**
  49908. * Optional filter to be used for ray selection. This predicate shares behavior with
  49909. * scene.pointerMovePredicate which takes priority if it is also assigned.
  49910. */
  49911. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  49912. /**
  49913. * constructs a new background remover module
  49914. * @param _xrSessionManager the session manager for this module
  49915. * @param _options read-only options to be used in this module
  49916. */
  49917. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  49918. /**
  49919. * attach this feature
  49920. * Will usually be called by the features manager
  49921. *
  49922. * @returns true if successful.
  49923. */
  49924. attach(): boolean;
  49925. /**
  49926. * detach this feature.
  49927. * Will usually be called by the features manager
  49928. *
  49929. * @returns true if successful.
  49930. */
  49931. detach(): boolean;
  49932. /**
  49933. * Will get the mesh under a specific pointer.
  49934. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  49935. * @param controllerId the controllerId to check
  49936. * @returns The mesh under pointer or null if no mesh is under the pointer
  49937. */
  49938. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  49939. /**
  49940. * Get the xr controller that correlates to the pointer id in the pointer event
  49941. *
  49942. * @param id the pointer id to search for
  49943. * @returns the controller that correlates to this id or null if not found
  49944. */
  49945. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  49946. protected _onXRFrame(_xrFrame: XRFrame): void;
  49947. private _attachGazeMode;
  49948. private _attachScreenRayMode;
  49949. private _attachTrackedPointerRayMode;
  49950. private _convertNormalToDirectionOfRay;
  49951. private _detachController;
  49952. private _generateNewMeshPair;
  49953. private _pickingMoved;
  49954. private _updatePointerDistance;
  49955. /** @hidden */
  49956. get lasterPointerDefaultColor(): Color3;
  49957. }
  49958. }
  49959. declare module "babylonjs/XR/webXREnterExitUI" {
  49960. import { Nullable } from "babylonjs/types";
  49961. import { Observable } from "babylonjs/Misc/observable";
  49962. import { IDisposable, Scene } from "babylonjs/scene";
  49963. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  49964. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49965. /**
  49966. * Button which can be used to enter a different mode of XR
  49967. */
  49968. export class WebXREnterExitUIButton {
  49969. /** button element */
  49970. element: HTMLElement;
  49971. /** XR initialization options for the button */
  49972. sessionMode: XRSessionMode;
  49973. /** Reference space type */
  49974. referenceSpaceType: XRReferenceSpaceType;
  49975. /**
  49976. * Creates a WebXREnterExitUIButton
  49977. * @param element button element
  49978. * @param sessionMode XR initialization session mode
  49979. * @param referenceSpaceType the type of reference space to be used
  49980. */
  49981. constructor(
  49982. /** button element */
  49983. element: HTMLElement,
  49984. /** XR initialization options for the button */
  49985. sessionMode: XRSessionMode,
  49986. /** Reference space type */
  49987. referenceSpaceType: XRReferenceSpaceType);
  49988. /**
  49989. * Extendable function which can be used to update the button's visuals when the state changes
  49990. * @param activeButton the current active button in the UI
  49991. */
  49992. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  49993. }
  49994. /**
  49995. * Options to create the webXR UI
  49996. */
  49997. export class WebXREnterExitUIOptions {
  49998. /**
  49999. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50000. */
  50001. customButtons?: Array<WebXREnterExitUIButton>;
  50002. /**
  50003. * A reference space type to use when creating the default button.
  50004. * Default is local-floor
  50005. */
  50006. referenceSpaceType?: XRReferenceSpaceType;
  50007. /**
  50008. * Context to enter xr with
  50009. */
  50010. renderTarget?: Nullable<WebXRRenderTarget>;
  50011. /**
  50012. * A session mode to use when creating the default button.
  50013. * Default is immersive-vr
  50014. */
  50015. sessionMode?: XRSessionMode;
  50016. /**
  50017. * A list of optional features to init the session with
  50018. */
  50019. optionalFeatures?: string[];
  50020. /**
  50021. * A list of optional features to init the session with
  50022. */
  50023. requiredFeatures?: string[];
  50024. }
  50025. /**
  50026. * UI to allow the user to enter/exit XR mode
  50027. */
  50028. export class WebXREnterExitUI implements IDisposable {
  50029. private scene;
  50030. /** version of the options passed to this UI */
  50031. options: WebXREnterExitUIOptions;
  50032. private _activeButton;
  50033. private _buttons;
  50034. private _overlay;
  50035. /**
  50036. * Fired every time the active button is changed.
  50037. *
  50038. * When xr is entered via a button that launches xr that button will be the callback parameter
  50039. *
  50040. * When exiting xr the callback parameter will be null)
  50041. */
  50042. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  50043. /**
  50044. *
  50045. * @param scene babylon scene object to use
  50046. * @param options (read-only) version of the options passed to this UI
  50047. */
  50048. private constructor();
  50049. /**
  50050. * Creates UI to allow the user to enter/exit XR mode
  50051. * @param scene the scene to add the ui to
  50052. * @param helper the xr experience helper to enter/exit xr with
  50053. * @param options options to configure the UI
  50054. * @returns the created ui
  50055. */
  50056. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  50057. /**
  50058. * Disposes of the XR UI component
  50059. */
  50060. dispose(): void;
  50061. private _updateButtons;
  50062. }
  50063. }
  50064. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  50065. import { Vector3 } from "babylonjs/Maths/math.vector";
  50066. import { Color4 } from "babylonjs/Maths/math.color";
  50067. import { Nullable } from "babylonjs/types";
  50068. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  50069. import { Scene } from "babylonjs/scene";
  50070. /**
  50071. * Class containing static functions to help procedurally build meshes
  50072. */
  50073. export class LinesBuilder {
  50074. /**
  50075. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  50076. * * 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
  50077. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  50078. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  50079. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  50080. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  50081. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50082. * * 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
  50083. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  50084. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50085. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  50086. * @param name defines the name of the new line system
  50087. * @param options defines the options used to create the line system
  50088. * @param scene defines the hosting scene
  50089. * @returns a new line system mesh
  50090. */
  50091. static CreateLineSystem(name: string, options: {
  50092. lines: Vector3[][];
  50093. updatable?: boolean;
  50094. instance?: Nullable<LinesMesh>;
  50095. colors?: Nullable<Color4[][]>;
  50096. useVertexAlpha?: boolean;
  50097. }, scene: Nullable<Scene>): LinesMesh;
  50098. /**
  50099. * Creates a line mesh
  50100. * 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
  50101. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50102. * * The parameter `points` is an array successive Vector3
  50103. * * 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
  50104. * * The optional parameter `colors` is an array of successive Color4, one per line point
  50105. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  50106. * * When updating an instance, remember that only point positions can change, not the number of points
  50107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  50109. * @param name defines the name of the new line system
  50110. * @param options defines the options used to create the line system
  50111. * @param scene defines the hosting scene
  50112. * @returns a new line mesh
  50113. */
  50114. static CreateLines(name: string, options: {
  50115. points: Vector3[];
  50116. updatable?: boolean;
  50117. instance?: Nullable<LinesMesh>;
  50118. colors?: Color4[];
  50119. useVertexAlpha?: boolean;
  50120. }, scene?: Nullable<Scene>): LinesMesh;
  50121. /**
  50122. * Creates a dashed line mesh
  50123. * * 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
  50124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  50125. * * The parameter `points` is an array successive Vector3
  50126. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  50127. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  50128. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  50129. * * 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
  50130. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  50131. * * When updating an instance, remember that only point positions can change, not the number of points
  50132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50133. * @param name defines the name of the mesh
  50134. * @param options defines the options used to create the mesh
  50135. * @param scene defines the hosting scene
  50136. * @returns the dashed line mesh
  50137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  50138. */
  50139. static CreateDashedLines(name: string, options: {
  50140. points: Vector3[];
  50141. dashSize?: number;
  50142. gapSize?: number;
  50143. dashNb?: number;
  50144. updatable?: boolean;
  50145. instance?: LinesMesh;
  50146. useVertexAlpha?: boolean;
  50147. }, scene?: Nullable<Scene>): LinesMesh;
  50148. }
  50149. }
  50150. declare module "babylonjs/Misc/timer" {
  50151. import { Observable, Observer } from "babylonjs/Misc/observable";
  50152. import { Nullable } from "babylonjs/types";
  50153. import { IDisposable } from "babylonjs/scene";
  50154. /**
  50155. * Construction options for a timer
  50156. */
  50157. export interface ITimerOptions<T> {
  50158. /**
  50159. * Time-to-end
  50160. */
  50161. timeout: number;
  50162. /**
  50163. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  50164. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  50165. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  50166. */
  50167. contextObservable: Observable<T>;
  50168. /**
  50169. * Optional parameters when adding an observer to the observable
  50170. */
  50171. observableParameters?: {
  50172. mask?: number;
  50173. insertFirst?: boolean;
  50174. scope?: any;
  50175. };
  50176. /**
  50177. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  50178. */
  50179. breakCondition?: (data?: ITimerData<T>) => boolean;
  50180. /**
  50181. * Will be triggered when the time condition has met
  50182. */
  50183. onEnded?: (data: ITimerData<any>) => void;
  50184. /**
  50185. * Will be triggered when the break condition has met (prematurely ended)
  50186. */
  50187. onAborted?: (data: ITimerData<any>) => void;
  50188. /**
  50189. * Optional function to execute on each tick (or count)
  50190. */
  50191. onTick?: (data: ITimerData<any>) => void;
  50192. }
  50193. /**
  50194. * An interface defining the data sent by the timer
  50195. */
  50196. export interface ITimerData<T> {
  50197. /**
  50198. * When did it start
  50199. */
  50200. startTime: number;
  50201. /**
  50202. * Time now
  50203. */
  50204. currentTime: number;
  50205. /**
  50206. * Time passed since started
  50207. */
  50208. deltaTime: number;
  50209. /**
  50210. * How much is completed, in [0.0...1.0].
  50211. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  50212. */
  50213. completeRate: number;
  50214. /**
  50215. * What the registered observable sent in the last count
  50216. */
  50217. payload: T;
  50218. }
  50219. /**
  50220. * The current state of the timer
  50221. */
  50222. export enum TimerState {
  50223. /**
  50224. * Timer initialized, not yet started
  50225. */
  50226. INIT = 0,
  50227. /**
  50228. * Timer started and counting
  50229. */
  50230. STARTED = 1,
  50231. /**
  50232. * Timer ended (whether aborted or time reached)
  50233. */
  50234. ENDED = 2
  50235. }
  50236. /**
  50237. * A simple version of the timer. Will take options and start the timer immediately after calling it
  50238. *
  50239. * @param options options with which to initialize this timer
  50240. */
  50241. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  50242. /**
  50243. * An advanced implementation of a timer class
  50244. */
  50245. export class AdvancedTimer<T = any> implements IDisposable {
  50246. /**
  50247. * Will notify each time the timer calculates the remaining time
  50248. */
  50249. onEachCountObservable: Observable<ITimerData<T>>;
  50250. /**
  50251. * Will trigger when the timer was aborted due to the break condition
  50252. */
  50253. onTimerAbortedObservable: Observable<ITimerData<T>>;
  50254. /**
  50255. * Will trigger when the timer ended successfully
  50256. */
  50257. onTimerEndedObservable: Observable<ITimerData<T>>;
  50258. /**
  50259. * Will trigger when the timer state has changed
  50260. */
  50261. onStateChangedObservable: Observable<TimerState>;
  50262. private _observer;
  50263. private _contextObservable;
  50264. private _observableParameters;
  50265. private _startTime;
  50266. private _timer;
  50267. private _state;
  50268. private _breakCondition;
  50269. private _timeToEnd;
  50270. private _breakOnNextTick;
  50271. /**
  50272. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  50273. * @param options construction options for this advanced timer
  50274. */
  50275. constructor(options: ITimerOptions<T>);
  50276. /**
  50277. * set a breaking condition for this timer. Default is to never break during count
  50278. * @param predicate the new break condition. Returns true to break, false otherwise
  50279. */
  50280. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  50281. /**
  50282. * Reset ALL associated observables in this advanced timer
  50283. */
  50284. clearObservables(): void;
  50285. /**
  50286. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  50287. *
  50288. * @param timeToEnd how much time to measure until timer ended
  50289. */
  50290. start(timeToEnd?: number): void;
  50291. /**
  50292. * Will force a stop on the next tick.
  50293. */
  50294. stop(): void;
  50295. /**
  50296. * Dispose this timer, clearing all resources
  50297. */
  50298. dispose(): void;
  50299. private _setState;
  50300. private _tick;
  50301. private _stop;
  50302. }
  50303. }
  50304. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  50305. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50306. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50307. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50308. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50309. import { Vector3 } from "babylonjs/Maths/math.vector";
  50310. import { Material } from "babylonjs/Materials/material";
  50311. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50312. import { Scene } from "babylonjs/scene";
  50313. /**
  50314. * The options container for the teleportation module
  50315. */
  50316. export interface IWebXRTeleportationOptions {
  50317. /**
  50318. * if provided, this scene will be used to render meshes.
  50319. */
  50320. customUtilityLayerScene?: Scene;
  50321. /**
  50322. * Values to configure the default target mesh
  50323. */
  50324. defaultTargetMeshOptions?: {
  50325. /**
  50326. * Fill color of the teleportation area
  50327. */
  50328. teleportationFillColor?: string;
  50329. /**
  50330. * Border color for the teleportation area
  50331. */
  50332. teleportationBorderColor?: string;
  50333. /**
  50334. * Disable the mesh's animation sequence
  50335. */
  50336. disableAnimation?: boolean;
  50337. /**
  50338. * Disable lighting on the material or the ring and arrow
  50339. */
  50340. disableLighting?: boolean;
  50341. /**
  50342. * Override the default material of the torus and arrow
  50343. */
  50344. torusArrowMaterial?: Material;
  50345. };
  50346. /**
  50347. * A list of meshes to use as floor meshes.
  50348. * Meshes can be added and removed after initializing the feature using the
  50349. * addFloorMesh and removeFloorMesh functions
  50350. * If empty, rotation will still work
  50351. */
  50352. floorMeshes?: AbstractMesh[];
  50353. /**
  50354. * use this rendering group id for the meshes (optional)
  50355. */
  50356. renderingGroupId?: number;
  50357. /**
  50358. * Should teleportation move only to snap points
  50359. */
  50360. snapPointsOnly?: boolean;
  50361. /**
  50362. * An array of points to which the teleportation will snap to.
  50363. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  50364. */
  50365. snapPositions?: Vector3[];
  50366. /**
  50367. * How close should the teleportation ray be in order to snap to position.
  50368. * Default to 0.8 units (meters)
  50369. */
  50370. snapToPositionRadius?: number;
  50371. /**
  50372. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  50373. * If you want to support rotation, make sure your mesh has a direction indicator.
  50374. *
  50375. * When left untouched, the default mesh will be initialized.
  50376. */
  50377. teleportationTargetMesh?: AbstractMesh;
  50378. /**
  50379. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  50380. */
  50381. timeToTeleport?: number;
  50382. /**
  50383. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  50384. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  50385. */
  50386. useMainComponentOnly?: boolean;
  50387. /**
  50388. * Should meshes created here be added to a utility layer or the main scene
  50389. */
  50390. useUtilityLayer?: boolean;
  50391. /**
  50392. * Babylon XR Input class for controller
  50393. */
  50394. xrInput: WebXRInput;
  50395. }
  50396. /**
  50397. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  50398. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  50399. * the input of the attached controllers.
  50400. */
  50401. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  50402. private _options;
  50403. private _controllers;
  50404. private _currentTeleportationControllerId;
  50405. private _floorMeshes;
  50406. private _quadraticBezierCurve;
  50407. private _selectionFeature;
  50408. private _snapToPositions;
  50409. private _snappedToPoint;
  50410. private _teleportationRingMaterial?;
  50411. private _tmpRay;
  50412. private _tmpVector;
  50413. /**
  50414. * The module's name
  50415. */
  50416. static readonly Name: string;
  50417. /**
  50418. * The (Babylon) version of this module.
  50419. * This is an integer representing the implementation version.
  50420. * This number does not correspond to the webxr specs version
  50421. */
  50422. static readonly Version: number;
  50423. /**
  50424. * Is movement backwards enabled
  50425. */
  50426. backwardsMovementEnabled: boolean;
  50427. /**
  50428. * Distance to travel when moving backwards
  50429. */
  50430. backwardsTeleportationDistance: number;
  50431. /**
  50432. * The distance from the user to the inspection point in the direction of the controller
  50433. * A higher number will allow the user to move further
  50434. * defaults to 5 (meters, in xr units)
  50435. */
  50436. parabolicCheckRadius: number;
  50437. /**
  50438. * Should the module support parabolic ray on top of direct ray
  50439. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  50440. * Very helpful when moving between floors / different heights
  50441. */
  50442. parabolicRayEnabled: boolean;
  50443. /**
  50444. * How much rotation should be applied when rotating right and left
  50445. */
  50446. rotationAngle: number;
  50447. /**
  50448. * Is rotation enabled when moving forward?
  50449. * Disabling this feature will prevent the user from deciding the direction when teleporting
  50450. */
  50451. rotationEnabled: boolean;
  50452. /**
  50453. * constructs a new anchor system
  50454. * @param _xrSessionManager an instance of WebXRSessionManager
  50455. * @param _options configuration object for this feature
  50456. */
  50457. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  50458. /**
  50459. * Get the snapPointsOnly flag
  50460. */
  50461. get snapPointsOnly(): boolean;
  50462. /**
  50463. * Sets the snapPointsOnly flag
  50464. * @param snapToPoints should teleportation be exclusively to snap points
  50465. */
  50466. set snapPointsOnly(snapToPoints: boolean);
  50467. /**
  50468. * Add a new mesh to the floor meshes array
  50469. * @param mesh the mesh to use as floor mesh
  50470. */
  50471. addFloorMesh(mesh: AbstractMesh): void;
  50472. /**
  50473. * Add a new snap-to point to fix teleportation to this position
  50474. * @param newSnapPoint The new Snap-To point
  50475. */
  50476. addSnapPoint(newSnapPoint: Vector3): void;
  50477. attach(): boolean;
  50478. detach(): boolean;
  50479. dispose(): void;
  50480. /**
  50481. * Remove a mesh from the floor meshes array
  50482. * @param mesh the mesh to remove
  50483. */
  50484. removeFloorMesh(mesh: AbstractMesh): void;
  50485. /**
  50486. * Remove a mesh from the floor meshes array using its name
  50487. * @param name the mesh name to remove
  50488. */
  50489. removeFloorMeshByName(name: string): void;
  50490. /**
  50491. * 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
  50492. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  50493. * @returns was the point found and removed or not
  50494. */
  50495. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  50496. /**
  50497. * This function sets a selection feature that will be disabled when
  50498. * the forward ray is shown and will be reattached when hidden.
  50499. * This is used to remove the selection rays when moving.
  50500. * @param selectionFeature the feature to disable when forward movement is enabled
  50501. */
  50502. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  50503. protected _onXRFrame(_xrFrame: XRFrame): void;
  50504. private _attachController;
  50505. private _createDefaultTargetMesh;
  50506. private _detachController;
  50507. private _findClosestSnapPointWithRadius;
  50508. private _setTargetMeshPosition;
  50509. private _setTargetMeshVisibility;
  50510. private _showParabolicPath;
  50511. private _teleportForward;
  50512. }
  50513. }
  50514. declare module "babylonjs/XR/webXRDefaultExperience" {
  50515. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50516. import { Scene } from "babylonjs/scene";
  50517. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  50518. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  50519. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50520. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  50521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50522. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  50523. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  50524. /**
  50525. * Options for the default xr helper
  50526. */
  50527. export class WebXRDefaultExperienceOptions {
  50528. /**
  50529. * Enable or disable default UI to enter XR
  50530. */
  50531. disableDefaultUI?: boolean;
  50532. /**
  50533. * Should teleportation not initialize. defaults to false.
  50534. */
  50535. disableTeleportation?: boolean;
  50536. /**
  50537. * Floor meshes that will be used for teleport
  50538. */
  50539. floorMeshes?: Array<AbstractMesh>;
  50540. /**
  50541. * If set to true, the first frame will not be used to reset position
  50542. * The first frame is mainly used when copying transformation from the old camera
  50543. * Mainly used in AR
  50544. */
  50545. ignoreNativeCameraTransformation?: boolean;
  50546. /**
  50547. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  50548. */
  50549. inputOptions?: IWebXRInputOptions;
  50550. /**
  50551. * optional configuration for the output canvas
  50552. */
  50553. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  50554. /**
  50555. * optional UI options. This can be used among other to change session mode and reference space type
  50556. */
  50557. uiOptions?: WebXREnterExitUIOptions;
  50558. /**
  50559. * When loading teleportation and pointer select, use stable versions instead of latest.
  50560. */
  50561. useStablePlugins?: boolean;
  50562. /**
  50563. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  50564. */
  50565. renderingGroupId?: number;
  50566. /**
  50567. * A list of optional features to init the session with
  50568. * If set to true, all features we support will be added
  50569. */
  50570. optionalFeatures?: boolean | string[];
  50571. }
  50572. /**
  50573. * Default experience which provides a similar setup to the previous webVRExperience
  50574. */
  50575. export class WebXRDefaultExperience {
  50576. /**
  50577. * Base experience
  50578. */
  50579. baseExperience: WebXRExperienceHelper;
  50580. /**
  50581. * Enables ui for entering/exiting xr
  50582. */
  50583. enterExitUI: WebXREnterExitUI;
  50584. /**
  50585. * Input experience extension
  50586. */
  50587. input: WebXRInput;
  50588. /**
  50589. * Enables laser pointer and selection
  50590. */
  50591. pointerSelection: WebXRControllerPointerSelection;
  50592. /**
  50593. * Default target xr should render to
  50594. */
  50595. renderTarget: WebXRRenderTarget;
  50596. /**
  50597. * Enables teleportation
  50598. */
  50599. teleportation: WebXRMotionControllerTeleportation;
  50600. private constructor();
  50601. /**
  50602. * Creates the default xr experience
  50603. * @param scene scene
  50604. * @param options options for basic configuration
  50605. * @returns resulting WebXRDefaultExperience
  50606. */
  50607. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50608. /**
  50609. * DIsposes of the experience helper
  50610. */
  50611. dispose(): void;
  50612. }
  50613. }
  50614. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  50615. import { Observable } from "babylonjs/Misc/observable";
  50616. import { Nullable } from "babylonjs/types";
  50617. import { Camera } from "babylonjs/Cameras/camera";
  50618. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  50619. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  50620. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  50621. import { Scene } from "babylonjs/scene";
  50622. import { Vector3 } from "babylonjs/Maths/math.vector";
  50623. import { Color3 } from "babylonjs/Maths/math.color";
  50624. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50626. import { Mesh } from "babylonjs/Meshes/mesh";
  50627. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  50628. import { EasingFunction } from "babylonjs/Animations/easing";
  50629. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  50630. import "babylonjs/Meshes/Builders/groundBuilder";
  50631. import "babylonjs/Meshes/Builders/torusBuilder";
  50632. import "babylonjs/Meshes/Builders/cylinderBuilder";
  50633. import "babylonjs/Gamepads/gamepadSceneComponent";
  50634. import "babylonjs/Animations/animatable";
  50635. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  50636. /**
  50637. * Options to modify the vr teleportation behavior.
  50638. */
  50639. export interface VRTeleportationOptions {
  50640. /**
  50641. * The name of the mesh which should be used as the teleportation floor. (default: null)
  50642. */
  50643. floorMeshName?: string;
  50644. /**
  50645. * A list of meshes to be used as the teleportation floor. (default: empty)
  50646. */
  50647. floorMeshes?: Mesh[];
  50648. /**
  50649. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  50650. */
  50651. teleportationMode?: number;
  50652. /**
  50653. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  50654. */
  50655. teleportationTime?: number;
  50656. /**
  50657. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  50658. */
  50659. teleportationSpeed?: number;
  50660. /**
  50661. * The easing function used in the animation or null for Linear. (default CircleEase)
  50662. */
  50663. easingFunction?: EasingFunction;
  50664. }
  50665. /**
  50666. * Options to modify the vr experience helper's behavior.
  50667. */
  50668. export interface VRExperienceHelperOptions extends WebVROptions {
  50669. /**
  50670. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  50671. */
  50672. createDeviceOrientationCamera?: boolean;
  50673. /**
  50674. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  50675. */
  50676. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  50677. /**
  50678. * Uses the main button on the controller to toggle the laser casted. (default: true)
  50679. */
  50680. laserToggle?: boolean;
  50681. /**
  50682. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  50683. */
  50684. floorMeshes?: Mesh[];
  50685. /**
  50686. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  50687. */
  50688. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  50689. /**
  50690. * Defines if WebXR should be used instead of WebVR (if available)
  50691. */
  50692. useXR?: boolean;
  50693. }
  50694. /**
  50695. * Event containing information after VR has been entered
  50696. */
  50697. export class OnAfterEnteringVRObservableEvent {
  50698. /**
  50699. * If entering vr was successful
  50700. */
  50701. success: boolean;
  50702. }
  50703. /**
  50704. * Helps to quickly add VR support to an existing scene.
  50705. * See https://doc.babylonjs.com/how_to/webvr_helper
  50706. */
  50707. export class VRExperienceHelper {
  50708. /** Options to modify the vr experience helper's behavior. */
  50709. webVROptions: VRExperienceHelperOptions;
  50710. private _scene;
  50711. private _position;
  50712. private _btnVR;
  50713. private _btnVRDisplayed;
  50714. private _webVRsupported;
  50715. private _webVRready;
  50716. private _webVRrequesting;
  50717. private _webVRpresenting;
  50718. private _hasEnteredVR;
  50719. private _fullscreenVRpresenting;
  50720. private _inputElement;
  50721. private _webVRCamera;
  50722. private _vrDeviceOrientationCamera;
  50723. private _deviceOrientationCamera;
  50724. private _existingCamera;
  50725. private _onKeyDown;
  50726. private _onVrDisplayPresentChange;
  50727. private _onVRDisplayChanged;
  50728. private _onVRRequestPresentStart;
  50729. private _onVRRequestPresentComplete;
  50730. /**
  50731. * 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)
  50732. */
  50733. enableGazeEvenWhenNoPointerLock: boolean;
  50734. /**
  50735. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  50736. */
  50737. exitVROnDoubleTap: boolean;
  50738. /**
  50739. * Observable raised right before entering VR.
  50740. */
  50741. onEnteringVRObservable: Observable<VRExperienceHelper>;
  50742. /**
  50743. * Observable raised when entering VR has completed.
  50744. */
  50745. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  50746. /**
  50747. * Observable raised when exiting VR.
  50748. */
  50749. onExitingVRObservable: Observable<VRExperienceHelper>;
  50750. /**
  50751. * Observable raised when controller mesh is loaded.
  50752. */
  50753. onControllerMeshLoadedObservable: Observable<WebVRController>;
  50754. /** Return this.onEnteringVRObservable
  50755. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  50756. */
  50757. get onEnteringVR(): Observable<VRExperienceHelper>;
  50758. /** Return this.onExitingVRObservable
  50759. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  50760. */
  50761. get onExitingVR(): Observable<VRExperienceHelper>;
  50762. /** Return this.onControllerMeshLoadedObservable
  50763. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  50764. */
  50765. get onControllerMeshLoaded(): Observable<WebVRController>;
  50766. private _rayLength;
  50767. private _useCustomVRButton;
  50768. private _teleportationRequested;
  50769. private _teleportActive;
  50770. private _floorMeshName;
  50771. private _floorMeshesCollection;
  50772. private _teleportationMode;
  50773. private _teleportationTime;
  50774. private _teleportationSpeed;
  50775. private _teleportationEasing;
  50776. private _rotationAllowed;
  50777. private _teleportBackwardsVector;
  50778. private _teleportationTarget;
  50779. private _isDefaultTeleportationTarget;
  50780. private _postProcessMove;
  50781. private _teleportationFillColor;
  50782. private _teleportationBorderColor;
  50783. private _rotationAngle;
  50784. private _haloCenter;
  50785. private _cameraGazer;
  50786. private _padSensibilityUp;
  50787. private _padSensibilityDown;
  50788. private _leftController;
  50789. private _rightController;
  50790. private _gazeColor;
  50791. private _laserColor;
  50792. private _pickedLaserColor;
  50793. private _pickedGazeColor;
  50794. /**
  50795. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  50796. */
  50797. onNewMeshSelected: Observable<AbstractMesh>;
  50798. /**
  50799. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  50800. * This observable will provide the mesh and the controller used to select the mesh
  50801. */
  50802. onMeshSelectedWithController: Observable<{
  50803. mesh: AbstractMesh;
  50804. controller: WebVRController;
  50805. }>;
  50806. /**
  50807. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  50808. */
  50809. onNewMeshPicked: Observable<PickingInfo>;
  50810. private _circleEase;
  50811. /**
  50812. * Observable raised before camera teleportation
  50813. */
  50814. onBeforeCameraTeleport: Observable<Vector3>;
  50815. /**
  50816. * Observable raised after camera teleportation
  50817. */
  50818. onAfterCameraTeleport: Observable<Vector3>;
  50819. /**
  50820. * Observable raised when current selected mesh gets unselected
  50821. */
  50822. onSelectedMeshUnselected: Observable<AbstractMesh>;
  50823. private _raySelectionPredicate;
  50824. /**
  50825. * To be optionaly changed by user to define custom ray selection
  50826. */
  50827. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50828. /**
  50829. * To be optionaly changed by user to define custom selection logic (after ray selection)
  50830. */
  50831. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50832. /**
  50833. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  50834. */
  50835. teleportationEnabled: boolean;
  50836. private _defaultHeight;
  50837. private _teleportationInitialized;
  50838. private _interactionsEnabled;
  50839. private _interactionsRequested;
  50840. private _displayGaze;
  50841. private _displayLaserPointer;
  50842. /**
  50843. * The mesh used to display where the user is going to teleport.
  50844. */
  50845. get teleportationTarget(): Mesh;
  50846. /**
  50847. * Sets the mesh to be used to display where the user is going to teleport.
  50848. */
  50849. set teleportationTarget(value: Mesh);
  50850. /**
  50851. * 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
  50852. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  50853. * See https://doc.babylonjs.com/resources/baking_transformations
  50854. */
  50855. get gazeTrackerMesh(): Mesh;
  50856. set gazeTrackerMesh(value: Mesh);
  50857. /**
  50858. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  50859. */
  50860. updateGazeTrackerScale: boolean;
  50861. /**
  50862. * If the gaze trackers color should be updated when selecting meshes
  50863. */
  50864. updateGazeTrackerColor: boolean;
  50865. /**
  50866. * If the controller laser color should be updated when selecting meshes
  50867. */
  50868. updateControllerLaserColor: boolean;
  50869. /**
  50870. * The gaze tracking mesh corresponding to the left controller
  50871. */
  50872. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  50873. /**
  50874. * The gaze tracking mesh corresponding to the right controller
  50875. */
  50876. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  50877. /**
  50878. * If the ray of the gaze should be displayed.
  50879. */
  50880. get displayGaze(): boolean;
  50881. /**
  50882. * Sets if the ray of the gaze should be displayed.
  50883. */
  50884. set displayGaze(value: boolean);
  50885. /**
  50886. * If the ray of the LaserPointer should be displayed.
  50887. */
  50888. get displayLaserPointer(): boolean;
  50889. /**
  50890. * Sets if the ray of the LaserPointer should be displayed.
  50891. */
  50892. set displayLaserPointer(value: boolean);
  50893. /**
  50894. * The deviceOrientationCamera used as the camera when not in VR.
  50895. */
  50896. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  50897. /**
  50898. * Based on the current WebVR support, returns the current VR camera used.
  50899. */
  50900. get currentVRCamera(): Nullable<Camera>;
  50901. /**
  50902. * The webVRCamera which is used when in VR.
  50903. */
  50904. get webVRCamera(): WebVRFreeCamera;
  50905. /**
  50906. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  50907. */
  50908. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  50909. /**
  50910. * The html button that is used to trigger entering into VR.
  50911. */
  50912. get vrButton(): Nullable<HTMLButtonElement>;
  50913. private get _teleportationRequestInitiated();
  50914. /**
  50915. * Defines whether or not Pointer lock should be requested when switching to
  50916. * full screen.
  50917. */
  50918. requestPointerLockOnFullScreen: boolean;
  50919. /**
  50920. * If asking to force XR, this will be populated with the default xr experience
  50921. */
  50922. xr: WebXRDefaultExperience;
  50923. /**
  50924. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  50925. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  50926. */
  50927. xrTestDone: boolean;
  50928. /**
  50929. * Instantiates a VRExperienceHelper.
  50930. * Helps to quickly add VR support to an existing scene.
  50931. * @param scene The scene the VRExperienceHelper belongs to.
  50932. * @param webVROptions Options to modify the vr experience helper's behavior.
  50933. */
  50934. constructor(scene: Scene,
  50935. /** Options to modify the vr experience helper's behavior. */
  50936. webVROptions?: VRExperienceHelperOptions);
  50937. private completeVRInit;
  50938. private _onDefaultMeshLoaded;
  50939. private _onResize;
  50940. private _onFullscreenChange;
  50941. /**
  50942. * Gets a value indicating if we are currently in VR mode.
  50943. */
  50944. get isInVRMode(): boolean;
  50945. private onVrDisplayPresentChange;
  50946. private onVRDisplayChanged;
  50947. private moveButtonToBottomRight;
  50948. private displayVRButton;
  50949. private updateButtonVisibility;
  50950. private _cachedAngularSensibility;
  50951. /**
  50952. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  50953. * Otherwise, will use the fullscreen API.
  50954. */
  50955. enterVR(): void;
  50956. /**
  50957. * Attempt to exit VR, or fullscreen.
  50958. */
  50959. exitVR(): void;
  50960. /**
  50961. * The position of the vr experience helper.
  50962. */
  50963. get position(): Vector3;
  50964. /**
  50965. * Sets the position of the vr experience helper.
  50966. */
  50967. set position(value: Vector3);
  50968. /**
  50969. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  50970. */
  50971. enableInteractions(): void;
  50972. private get _noControllerIsActive();
  50973. private beforeRender;
  50974. private _isTeleportationFloor;
  50975. /**
  50976. * Adds a floor mesh to be used for teleportation.
  50977. * @param floorMesh the mesh to be used for teleportation.
  50978. */
  50979. addFloorMesh(floorMesh: Mesh): void;
  50980. /**
  50981. * Removes a floor mesh from being used for teleportation.
  50982. * @param floorMesh the mesh to be removed.
  50983. */
  50984. removeFloorMesh(floorMesh: Mesh): void;
  50985. /**
  50986. * Enables interactions and teleportation using the VR controllers and gaze.
  50987. * @param vrTeleportationOptions options to modify teleportation behavior.
  50988. */
  50989. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  50990. private _onNewGamepadConnected;
  50991. private _tryEnableInteractionOnController;
  50992. private _onNewGamepadDisconnected;
  50993. private _enableInteractionOnController;
  50994. private _checkTeleportWithRay;
  50995. private _checkRotate;
  50996. private _checkTeleportBackwards;
  50997. private _enableTeleportationOnController;
  50998. private _createTeleportationCircles;
  50999. private _displayTeleportationTarget;
  51000. private _hideTeleportationTarget;
  51001. private _rotateCamera;
  51002. private _moveTeleportationSelectorTo;
  51003. private _workingVector;
  51004. private _workingQuaternion;
  51005. private _workingMatrix;
  51006. /**
  51007. * Time Constant Teleportation Mode
  51008. */
  51009. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  51010. /**
  51011. * Speed Constant Teleportation Mode
  51012. */
  51013. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  51014. /**
  51015. * Teleports the users feet to the desired location
  51016. * @param location The location where the user's feet should be placed
  51017. */
  51018. teleportCamera(location: Vector3): void;
  51019. private _convertNormalToDirectionOfRay;
  51020. private _castRayAndSelectObject;
  51021. private _notifySelectedMeshUnselected;
  51022. /**
  51023. * Permanently set new colors for the laser pointer
  51024. * @param color the new laser color
  51025. * @param pickedColor the new laser color when picked mesh detected
  51026. */
  51027. setLaserColor(color: Color3, pickedColor?: Color3): void;
  51028. /**
  51029. * Set lighting enabled / disabled on the laser pointer of both controllers
  51030. * @param enabled should the lighting be enabled on the laser pointer
  51031. */
  51032. setLaserLightingState(enabled?: boolean): void;
  51033. /**
  51034. * Permanently set new colors for the gaze pointer
  51035. * @param color the new gaze color
  51036. * @param pickedColor the new gaze color when picked mesh detected
  51037. */
  51038. setGazeColor(color: Color3, pickedColor?: Color3): void;
  51039. /**
  51040. * Sets the color of the laser ray from the vr controllers.
  51041. * @param color new color for the ray.
  51042. */
  51043. changeLaserColor(color: Color3): void;
  51044. /**
  51045. * Sets the color of the ray from the vr headsets gaze.
  51046. * @param color new color for the ray.
  51047. */
  51048. changeGazeColor(color: Color3): void;
  51049. /**
  51050. * Exits VR and disposes of the vr experience helper
  51051. */
  51052. dispose(): void;
  51053. /**
  51054. * Gets the name of the VRExperienceHelper class
  51055. * @returns "VRExperienceHelper"
  51056. */
  51057. getClassName(): string;
  51058. }
  51059. }
  51060. declare module "babylonjs/Cameras/VR/index" {
  51061. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  51062. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  51063. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51064. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  51065. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  51066. export * from "babylonjs/Cameras/VR/webVRCamera";
  51067. }
  51068. declare module "babylonjs/Cameras/RigModes/index" {
  51069. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  51070. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  51071. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  51072. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  51073. }
  51074. declare module "babylonjs/Cameras/index" {
  51075. export * from "babylonjs/Cameras/Inputs/index";
  51076. export * from "babylonjs/Cameras/cameraInputsManager";
  51077. export * from "babylonjs/Cameras/camera";
  51078. export * from "babylonjs/Cameras/targetCamera";
  51079. export * from "babylonjs/Cameras/freeCamera";
  51080. export * from "babylonjs/Cameras/freeCameraInputsManager";
  51081. export * from "babylonjs/Cameras/touchCamera";
  51082. export * from "babylonjs/Cameras/arcRotateCamera";
  51083. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  51084. export * from "babylonjs/Cameras/deviceOrientationCamera";
  51085. export * from "babylonjs/Cameras/flyCamera";
  51086. export * from "babylonjs/Cameras/flyCameraInputsManager";
  51087. export * from "babylonjs/Cameras/followCamera";
  51088. export * from "babylonjs/Cameras/followCameraInputsManager";
  51089. export * from "babylonjs/Cameras/gamepadCamera";
  51090. export * from "babylonjs/Cameras/Stereoscopic/index";
  51091. export * from "babylonjs/Cameras/universalCamera";
  51092. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  51093. export * from "babylonjs/Cameras/VR/index";
  51094. export * from "babylonjs/Cameras/RigModes/index";
  51095. }
  51096. declare module "babylonjs/Collisions/index" {
  51097. export * from "babylonjs/Collisions/collider";
  51098. export * from "babylonjs/Collisions/collisionCoordinator";
  51099. export * from "babylonjs/Collisions/pickingInfo";
  51100. export * from "babylonjs/Collisions/intersectionInfo";
  51101. export * from "babylonjs/Collisions/meshCollisionData";
  51102. }
  51103. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  51104. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  51105. import { Vector3 } from "babylonjs/Maths/math.vector";
  51106. import { Ray } from "babylonjs/Culling/ray";
  51107. import { Plane } from "babylonjs/Maths/math.plane";
  51108. /**
  51109. * Contains an array of blocks representing the octree
  51110. */
  51111. export interface IOctreeContainer<T> {
  51112. /**
  51113. * Blocks within the octree
  51114. */
  51115. blocks: Array<OctreeBlock<T>>;
  51116. }
  51117. /**
  51118. * Class used to store a cell in an octree
  51119. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51120. */
  51121. export class OctreeBlock<T> {
  51122. /**
  51123. * Gets the content of the current block
  51124. */
  51125. entries: T[];
  51126. /**
  51127. * Gets the list of block children
  51128. */
  51129. blocks: Array<OctreeBlock<T>>;
  51130. private _depth;
  51131. private _maxDepth;
  51132. private _capacity;
  51133. private _minPoint;
  51134. private _maxPoint;
  51135. private _boundingVectors;
  51136. private _creationFunc;
  51137. /**
  51138. * Creates a new block
  51139. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  51140. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  51141. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51142. * @param depth defines the current depth of this block in the octree
  51143. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  51144. * @param creationFunc defines a callback to call when an element is added to the block
  51145. */
  51146. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  51147. /**
  51148. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  51149. */
  51150. get capacity(): number;
  51151. /**
  51152. * Gets the minimum vector (in world space) of the block's bounding box
  51153. */
  51154. get minPoint(): Vector3;
  51155. /**
  51156. * Gets the maximum vector (in world space) of the block's bounding box
  51157. */
  51158. get maxPoint(): Vector3;
  51159. /**
  51160. * Add a new element to this block
  51161. * @param entry defines the element to add
  51162. */
  51163. addEntry(entry: T): void;
  51164. /**
  51165. * Remove an element from this block
  51166. * @param entry defines the element to remove
  51167. */
  51168. removeEntry(entry: T): void;
  51169. /**
  51170. * Add an array of elements to this block
  51171. * @param entries defines the array of elements to add
  51172. */
  51173. addEntries(entries: T[]): void;
  51174. /**
  51175. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  51176. * @param frustumPlanes defines the frustum planes to test
  51177. * @param selection defines the array to store current content if selection is positive
  51178. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51179. */
  51180. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51181. /**
  51182. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  51183. * @param sphereCenter defines the bounding sphere center
  51184. * @param sphereRadius defines the bounding sphere radius
  51185. * @param selection defines the array to store current content if selection is positive
  51186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51187. */
  51188. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  51189. /**
  51190. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  51191. * @param ray defines the ray to test with
  51192. * @param selection defines the array to store current content if selection is positive
  51193. */
  51194. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  51195. /**
  51196. * Subdivide the content into child blocks (this block will then be empty)
  51197. */
  51198. createInnerBlocks(): void;
  51199. /**
  51200. * @hidden
  51201. */
  51202. 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;
  51203. }
  51204. }
  51205. declare module "babylonjs/Culling/Octrees/octree" {
  51206. import { SmartArray } from "babylonjs/Misc/smartArray";
  51207. import { Vector3 } from "babylonjs/Maths/math.vector";
  51208. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51210. import { Ray } from "babylonjs/Culling/ray";
  51211. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  51212. import { Plane } from "babylonjs/Maths/math.plane";
  51213. /**
  51214. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  51215. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51216. */
  51217. export class Octree<T> {
  51218. /** 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.) */
  51219. maxDepth: number;
  51220. /**
  51221. * Blocks within the octree containing objects
  51222. */
  51223. blocks: Array<OctreeBlock<T>>;
  51224. /**
  51225. * Content stored in the octree
  51226. */
  51227. dynamicContent: T[];
  51228. private _maxBlockCapacity;
  51229. private _selectionContent;
  51230. private _creationFunc;
  51231. /**
  51232. * Creates a octree
  51233. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51234. * @param creationFunc function to be used to instatiate the octree
  51235. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  51236. * @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.)
  51237. */
  51238. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  51239. /** 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.) */
  51240. maxDepth?: number);
  51241. /**
  51242. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  51243. * @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);
  51244. * @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);
  51245. * @param entries meshes to be added to the octree blocks
  51246. */
  51247. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  51248. /**
  51249. * Adds a mesh to the octree
  51250. * @param entry Mesh to add to the octree
  51251. */
  51252. addMesh(entry: T): void;
  51253. /**
  51254. * Remove an element from the octree
  51255. * @param entry defines the element to remove
  51256. */
  51257. removeMesh(entry: T): void;
  51258. /**
  51259. * Selects an array of meshes within the frustum
  51260. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  51261. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  51262. * @returns array of meshes within the frustum
  51263. */
  51264. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  51265. /**
  51266. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  51267. * @param sphereCenter defines the bounding sphere center
  51268. * @param sphereRadius defines the bounding sphere radius
  51269. * @param allowDuplicate defines if the selection array can contains duplicated entries
  51270. * @returns an array of objects that intersect the sphere
  51271. */
  51272. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  51273. /**
  51274. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  51275. * @param ray defines the ray to test with
  51276. * @returns array of intersected objects
  51277. */
  51278. intersectsRay(ray: Ray): SmartArray<T>;
  51279. /**
  51280. * Adds a mesh into the octree block if it intersects the block
  51281. */
  51282. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  51283. /**
  51284. * Adds a submesh into the octree block if it intersects the block
  51285. */
  51286. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  51287. }
  51288. }
  51289. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  51290. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  51291. import { Scene } from "babylonjs/scene";
  51292. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51293. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51294. import { Ray } from "babylonjs/Culling/ray";
  51295. import { Octree } from "babylonjs/Culling/Octrees/octree";
  51296. import { Collider } from "babylonjs/Collisions/collider";
  51297. module "babylonjs/scene" {
  51298. interface Scene {
  51299. /**
  51300. * @hidden
  51301. * Backing Filed
  51302. */
  51303. _selectionOctree: Octree<AbstractMesh>;
  51304. /**
  51305. * Gets the octree used to boost mesh selection (picking)
  51306. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51307. */
  51308. selectionOctree: Octree<AbstractMesh>;
  51309. /**
  51310. * Creates or updates the octree used to boost selection (picking)
  51311. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51312. * @param maxCapacity defines the maximum capacity per leaf
  51313. * @param maxDepth defines the maximum depth of the octree
  51314. * @returns an octree of AbstractMesh
  51315. */
  51316. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  51317. }
  51318. }
  51319. module "babylonjs/Meshes/abstractMesh" {
  51320. interface AbstractMesh {
  51321. /**
  51322. * @hidden
  51323. * Backing Field
  51324. */
  51325. _submeshesOctree: Octree<SubMesh>;
  51326. /**
  51327. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  51328. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  51329. * @param maxCapacity defines the maximum size of each block (64 by default)
  51330. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  51331. * @returns the new octree
  51332. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  51333. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  51334. */
  51335. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  51336. }
  51337. }
  51338. /**
  51339. * Defines the octree scene component responsible to manage any octrees
  51340. * in a given scene.
  51341. */
  51342. export class OctreeSceneComponent {
  51343. /**
  51344. * The component name help to identify the component in the list of scene components.
  51345. */
  51346. readonly name: string;
  51347. /**
  51348. * The scene the component belongs to.
  51349. */
  51350. scene: Scene;
  51351. /**
  51352. * Indicates if the meshes have been checked to make sure they are isEnabled()
  51353. */
  51354. readonly checksIsEnabled: boolean;
  51355. /**
  51356. * Creates a new instance of the component for the given scene
  51357. * @param scene Defines the scene to register the component in
  51358. */
  51359. constructor(scene: Scene);
  51360. /**
  51361. * Registers the component in a given scene
  51362. */
  51363. register(): void;
  51364. /**
  51365. * Return the list of active meshes
  51366. * @returns the list of active meshes
  51367. */
  51368. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  51369. /**
  51370. * Return the list of active sub meshes
  51371. * @param mesh The mesh to get the candidates sub meshes from
  51372. * @returns the list of active sub meshes
  51373. */
  51374. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  51375. private _tempRay;
  51376. /**
  51377. * Return the list of sub meshes intersecting with a given local ray
  51378. * @param mesh defines the mesh to find the submesh for
  51379. * @param localRay defines the ray in local space
  51380. * @returns the list of intersecting sub meshes
  51381. */
  51382. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  51383. /**
  51384. * Return the list of sub meshes colliding with a collider
  51385. * @param mesh defines the mesh to find the submesh for
  51386. * @param collider defines the collider to evaluate the collision against
  51387. * @returns the list of colliding sub meshes
  51388. */
  51389. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  51390. /**
  51391. * Rebuilds the elements related to this component in case of
  51392. * context lost for instance.
  51393. */
  51394. rebuild(): void;
  51395. /**
  51396. * Disposes the component and the associated ressources.
  51397. */
  51398. dispose(): void;
  51399. }
  51400. }
  51401. declare module "babylonjs/Culling/Octrees/index" {
  51402. export * from "babylonjs/Culling/Octrees/octree";
  51403. export * from "babylonjs/Culling/Octrees/octreeBlock";
  51404. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  51405. }
  51406. declare module "babylonjs/Culling/index" {
  51407. export * from "babylonjs/Culling/boundingBox";
  51408. export * from "babylonjs/Culling/boundingInfo";
  51409. export * from "babylonjs/Culling/boundingSphere";
  51410. export * from "babylonjs/Culling/Octrees/index";
  51411. export * from "babylonjs/Culling/ray";
  51412. }
  51413. declare module "babylonjs/Gizmos/gizmo" {
  51414. import { Nullable } from "babylonjs/types";
  51415. import { IDisposable } from "babylonjs/scene";
  51416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51417. import { Mesh } from "babylonjs/Meshes/mesh";
  51418. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51419. /**
  51420. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  51421. */
  51422. export class Gizmo implements IDisposable {
  51423. /** The utility layer the gizmo will be added to */
  51424. gizmoLayer: UtilityLayerRenderer;
  51425. /**
  51426. * The root mesh of the gizmo
  51427. */
  51428. _rootMesh: Mesh;
  51429. private _attachedMesh;
  51430. /**
  51431. * Ratio for the scale of the gizmo (Default: 1)
  51432. */
  51433. scaleRatio: number;
  51434. /**
  51435. * If a custom mesh has been set (Default: false)
  51436. */
  51437. protected _customMeshSet: boolean;
  51438. /**
  51439. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  51440. * * When set, interactions will be enabled
  51441. */
  51442. get attachedMesh(): Nullable<AbstractMesh>;
  51443. set attachedMesh(value: Nullable<AbstractMesh>);
  51444. /**
  51445. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  51446. * @param mesh The mesh to replace the default mesh of the gizmo
  51447. */
  51448. setCustomMesh(mesh: Mesh): void;
  51449. /**
  51450. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  51451. */
  51452. updateGizmoRotationToMatchAttachedMesh: boolean;
  51453. /**
  51454. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  51455. */
  51456. updateGizmoPositionToMatchAttachedMesh: boolean;
  51457. /**
  51458. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  51459. */
  51460. updateScale: boolean;
  51461. protected _interactionsEnabled: boolean;
  51462. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51463. private _beforeRenderObserver;
  51464. private _tempVector;
  51465. /**
  51466. * Creates a gizmo
  51467. * @param gizmoLayer The utility layer the gizmo will be added to
  51468. */
  51469. constructor(
  51470. /** The utility layer the gizmo will be added to */
  51471. gizmoLayer?: UtilityLayerRenderer);
  51472. /**
  51473. * Updates the gizmo to match the attached mesh's position/rotation
  51474. */
  51475. protected _update(): void;
  51476. /**
  51477. * Disposes of the gizmo
  51478. */
  51479. dispose(): void;
  51480. }
  51481. }
  51482. declare module "babylonjs/Gizmos/planeDragGizmo" {
  51483. import { Observable } from "babylonjs/Misc/observable";
  51484. import { Nullable } from "babylonjs/types";
  51485. import { Vector3 } from "babylonjs/Maths/math.vector";
  51486. import { Color3 } from "babylonjs/Maths/math.color";
  51487. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51489. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51490. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51491. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51492. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51493. import { Scene } from "babylonjs/scene";
  51494. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51495. /**
  51496. * Single plane drag gizmo
  51497. */
  51498. export class PlaneDragGizmo extends Gizmo {
  51499. /**
  51500. * Drag behavior responsible for the gizmos dragging interactions
  51501. */
  51502. dragBehavior: PointerDragBehavior;
  51503. private _pointerObserver;
  51504. /**
  51505. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51506. */
  51507. snapDistance: number;
  51508. /**
  51509. * Event that fires each time the gizmo snaps to a new location.
  51510. * * snapDistance is the the change in distance
  51511. */
  51512. onSnapObservable: Observable<{
  51513. snapDistance: number;
  51514. }>;
  51515. private _plane;
  51516. private _coloredMaterial;
  51517. private _hoverMaterial;
  51518. private _isEnabled;
  51519. private _parent;
  51520. /** @hidden */
  51521. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  51522. /** @hidden */
  51523. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51524. /**
  51525. * Creates a PlaneDragGizmo
  51526. * @param gizmoLayer The utility layer the gizmo will be added to
  51527. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  51528. * @param color The color of the gizmo
  51529. */
  51530. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51531. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51532. /**
  51533. * If the gizmo is enabled
  51534. */
  51535. set isEnabled(value: boolean);
  51536. get isEnabled(): boolean;
  51537. /**
  51538. * Disposes of the gizmo
  51539. */
  51540. dispose(): void;
  51541. }
  51542. }
  51543. declare module "babylonjs/Gizmos/positionGizmo" {
  51544. import { Observable } from "babylonjs/Misc/observable";
  51545. import { Nullable } from "babylonjs/types";
  51546. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51547. import { Mesh } from "babylonjs/Meshes/mesh";
  51548. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51549. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  51550. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  51551. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51552. /**
  51553. * Gizmo that enables dragging a mesh along 3 axis
  51554. */
  51555. export class PositionGizmo extends Gizmo {
  51556. /**
  51557. * Internal gizmo used for interactions on the x axis
  51558. */
  51559. xGizmo: AxisDragGizmo;
  51560. /**
  51561. * Internal gizmo used for interactions on the y axis
  51562. */
  51563. yGizmo: AxisDragGizmo;
  51564. /**
  51565. * Internal gizmo used for interactions on the z axis
  51566. */
  51567. zGizmo: AxisDragGizmo;
  51568. /**
  51569. * Internal gizmo used for interactions on the yz plane
  51570. */
  51571. xPlaneGizmo: PlaneDragGizmo;
  51572. /**
  51573. * Internal gizmo used for interactions on the xz plane
  51574. */
  51575. yPlaneGizmo: PlaneDragGizmo;
  51576. /**
  51577. * Internal gizmo used for interactions on the xy plane
  51578. */
  51579. zPlaneGizmo: PlaneDragGizmo;
  51580. /**
  51581. * private variables
  51582. */
  51583. private _meshAttached;
  51584. private _updateGizmoRotationToMatchAttachedMesh;
  51585. private _snapDistance;
  51586. private _scaleRatio;
  51587. /** Fires an event when any of it's sub gizmos are dragged */
  51588. onDragStartObservable: Observable<unknown>;
  51589. /** Fires an event when any of it's sub gizmos are released from dragging */
  51590. onDragEndObservable: Observable<unknown>;
  51591. /**
  51592. * If set to true, planar drag is enabled
  51593. */
  51594. private _planarGizmoEnabled;
  51595. get attachedMesh(): Nullable<AbstractMesh>;
  51596. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51597. /**
  51598. * Creates a PositionGizmo
  51599. * @param gizmoLayer The utility layer the gizmo will be added to
  51600. */
  51601. constructor(gizmoLayer?: UtilityLayerRenderer);
  51602. /**
  51603. * If the planar drag gizmo is enabled
  51604. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  51605. */
  51606. set planarGizmoEnabled(value: boolean);
  51607. get planarGizmoEnabled(): boolean;
  51608. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51609. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51610. /**
  51611. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51612. */
  51613. set snapDistance(value: number);
  51614. get snapDistance(): number;
  51615. /**
  51616. * Ratio for the scale of the gizmo (Default: 1)
  51617. */
  51618. set scaleRatio(value: number);
  51619. get scaleRatio(): number;
  51620. /**
  51621. * Disposes of the gizmo
  51622. */
  51623. dispose(): void;
  51624. /**
  51625. * CustomMeshes are not supported by this gizmo
  51626. * @param mesh The mesh to replace the default mesh of the gizmo
  51627. */
  51628. setCustomMesh(mesh: Mesh): void;
  51629. }
  51630. }
  51631. declare module "babylonjs/Gizmos/axisDragGizmo" {
  51632. import { Observable } from "babylonjs/Misc/observable";
  51633. import { Nullable } from "babylonjs/types";
  51634. import { Vector3 } from "babylonjs/Maths/math.vector";
  51635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51637. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  51638. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51639. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51640. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51641. import { Scene } from "babylonjs/scene";
  51642. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51643. import { Color3 } from "babylonjs/Maths/math.color";
  51644. /**
  51645. * Single axis drag gizmo
  51646. */
  51647. export class AxisDragGizmo extends Gizmo {
  51648. /**
  51649. * Drag behavior responsible for the gizmos dragging interactions
  51650. */
  51651. dragBehavior: PointerDragBehavior;
  51652. private _pointerObserver;
  51653. /**
  51654. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51655. */
  51656. snapDistance: number;
  51657. /**
  51658. * Event that fires each time the gizmo snaps to a new location.
  51659. * * snapDistance is the the change in distance
  51660. */
  51661. onSnapObservable: Observable<{
  51662. snapDistance: number;
  51663. }>;
  51664. private _isEnabled;
  51665. private _parent;
  51666. private _arrow;
  51667. private _coloredMaterial;
  51668. private _hoverMaterial;
  51669. /** @hidden */
  51670. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  51671. /** @hidden */
  51672. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  51673. /**
  51674. * Creates an AxisDragGizmo
  51675. * @param gizmoLayer The utility layer the gizmo will be added to
  51676. * @param dragAxis The axis which the gizmo will be able to drag on
  51677. * @param color The color of the gizmo
  51678. */
  51679. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  51680. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51681. /**
  51682. * If the gizmo is enabled
  51683. */
  51684. set isEnabled(value: boolean);
  51685. get isEnabled(): boolean;
  51686. /**
  51687. * Disposes of the gizmo
  51688. */
  51689. dispose(): void;
  51690. }
  51691. }
  51692. declare module "babylonjs/Debug/axesViewer" {
  51693. import { Vector3 } from "babylonjs/Maths/math.vector";
  51694. import { Nullable } from "babylonjs/types";
  51695. import { Scene } from "babylonjs/scene";
  51696. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51697. /**
  51698. * The Axes viewer will show 3 axes in a specific point in space
  51699. */
  51700. export class AxesViewer {
  51701. private _xAxis;
  51702. private _yAxis;
  51703. private _zAxis;
  51704. private _scaleLinesFactor;
  51705. private _instanced;
  51706. /**
  51707. * Gets the hosting scene
  51708. */
  51709. scene: Scene;
  51710. /**
  51711. * Gets or sets a number used to scale line length
  51712. */
  51713. scaleLines: number;
  51714. /** Gets the node hierarchy used to render x-axis */
  51715. get xAxis(): TransformNode;
  51716. /** Gets the node hierarchy used to render y-axis */
  51717. get yAxis(): TransformNode;
  51718. /** Gets the node hierarchy used to render z-axis */
  51719. get zAxis(): TransformNode;
  51720. /**
  51721. * Creates a new AxesViewer
  51722. * @param scene defines the hosting scene
  51723. * @param scaleLines defines a number used to scale line length (1 by default)
  51724. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  51725. * @param xAxis defines the node hierarchy used to render the x-axis
  51726. * @param yAxis defines the node hierarchy used to render the y-axis
  51727. * @param zAxis defines the node hierarchy used to render the z-axis
  51728. */
  51729. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  51730. /**
  51731. * Force the viewer to update
  51732. * @param position defines the position of the viewer
  51733. * @param xaxis defines the x axis of the viewer
  51734. * @param yaxis defines the y axis of the viewer
  51735. * @param zaxis defines the z axis of the viewer
  51736. */
  51737. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  51738. /**
  51739. * Creates an instance of this axes viewer.
  51740. * @returns a new axes viewer with instanced meshes
  51741. */
  51742. createInstance(): AxesViewer;
  51743. /** Releases resources */
  51744. dispose(): void;
  51745. private static _SetRenderingGroupId;
  51746. }
  51747. }
  51748. declare module "babylonjs/Debug/boneAxesViewer" {
  51749. import { Nullable } from "babylonjs/types";
  51750. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  51751. import { Vector3 } from "babylonjs/Maths/math.vector";
  51752. import { Mesh } from "babylonjs/Meshes/mesh";
  51753. import { Bone } from "babylonjs/Bones/bone";
  51754. import { Scene } from "babylonjs/scene";
  51755. /**
  51756. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  51757. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  51758. */
  51759. export class BoneAxesViewer extends AxesViewer {
  51760. /**
  51761. * Gets or sets the target mesh where to display the axes viewer
  51762. */
  51763. mesh: Nullable<Mesh>;
  51764. /**
  51765. * Gets or sets the target bone where to display the axes viewer
  51766. */
  51767. bone: Nullable<Bone>;
  51768. /** Gets current position */
  51769. pos: Vector3;
  51770. /** Gets direction of X axis */
  51771. xaxis: Vector3;
  51772. /** Gets direction of Y axis */
  51773. yaxis: Vector3;
  51774. /** Gets direction of Z axis */
  51775. zaxis: Vector3;
  51776. /**
  51777. * Creates a new BoneAxesViewer
  51778. * @param scene defines the hosting scene
  51779. * @param bone defines the target bone
  51780. * @param mesh defines the target mesh
  51781. * @param scaleLines defines a scaling factor for line length (1 by default)
  51782. */
  51783. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  51784. /**
  51785. * Force the viewer to update
  51786. */
  51787. update(): void;
  51788. /** Releases resources */
  51789. dispose(): void;
  51790. }
  51791. }
  51792. declare module "babylonjs/Debug/debugLayer" {
  51793. import { Scene } from "babylonjs/scene";
  51794. /**
  51795. * Interface used to define scene explorer extensibility option
  51796. */
  51797. export interface IExplorerExtensibilityOption {
  51798. /**
  51799. * Define the option label
  51800. */
  51801. label: string;
  51802. /**
  51803. * Defines the action to execute on click
  51804. */
  51805. action: (entity: any) => void;
  51806. }
  51807. /**
  51808. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  51809. */
  51810. export interface IExplorerExtensibilityGroup {
  51811. /**
  51812. * Defines a predicate to test if a given type mut be extended
  51813. */
  51814. predicate: (entity: any) => boolean;
  51815. /**
  51816. * Gets the list of options added to a type
  51817. */
  51818. entries: IExplorerExtensibilityOption[];
  51819. }
  51820. /**
  51821. * Interface used to define the options to use to create the Inspector
  51822. */
  51823. export interface IInspectorOptions {
  51824. /**
  51825. * Display in overlay mode (default: false)
  51826. */
  51827. overlay?: boolean;
  51828. /**
  51829. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  51830. */
  51831. globalRoot?: HTMLElement;
  51832. /**
  51833. * Display the Scene explorer
  51834. */
  51835. showExplorer?: boolean;
  51836. /**
  51837. * Display the property inspector
  51838. */
  51839. showInspector?: boolean;
  51840. /**
  51841. * Display in embed mode (both panes on the right)
  51842. */
  51843. embedMode?: boolean;
  51844. /**
  51845. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  51846. */
  51847. handleResize?: boolean;
  51848. /**
  51849. * Allow the panes to popup (default: true)
  51850. */
  51851. enablePopup?: boolean;
  51852. /**
  51853. * Allow the panes to be closed by users (default: true)
  51854. */
  51855. enableClose?: boolean;
  51856. /**
  51857. * Optional list of extensibility entries
  51858. */
  51859. explorerExtensibility?: IExplorerExtensibilityGroup[];
  51860. /**
  51861. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  51862. */
  51863. inspectorURL?: string;
  51864. /**
  51865. * Optional initial tab (default to DebugLayerTab.Properties)
  51866. */
  51867. initialTab?: DebugLayerTab;
  51868. }
  51869. module "babylonjs/scene" {
  51870. interface Scene {
  51871. /**
  51872. * @hidden
  51873. * Backing field
  51874. */
  51875. _debugLayer: DebugLayer;
  51876. /**
  51877. * Gets the debug layer (aka Inspector) associated with the scene
  51878. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51879. */
  51880. debugLayer: DebugLayer;
  51881. }
  51882. }
  51883. /**
  51884. * Enum of inspector action tab
  51885. */
  51886. export enum DebugLayerTab {
  51887. /**
  51888. * Properties tag (default)
  51889. */
  51890. Properties = 0,
  51891. /**
  51892. * Debug tab
  51893. */
  51894. Debug = 1,
  51895. /**
  51896. * Statistics tab
  51897. */
  51898. Statistics = 2,
  51899. /**
  51900. * Tools tab
  51901. */
  51902. Tools = 3,
  51903. /**
  51904. * Settings tab
  51905. */
  51906. Settings = 4
  51907. }
  51908. /**
  51909. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51910. * what is happening in your scene
  51911. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51912. */
  51913. export class DebugLayer {
  51914. /**
  51915. * Define the url to get the inspector script from.
  51916. * By default it uses the babylonjs CDN.
  51917. * @ignoreNaming
  51918. */
  51919. static InspectorURL: string;
  51920. private _scene;
  51921. private BJSINSPECTOR;
  51922. private _onPropertyChangedObservable?;
  51923. /**
  51924. * Observable triggered when a property is changed through the inspector.
  51925. */
  51926. get onPropertyChangedObservable(): any;
  51927. /**
  51928. * Instantiates a new debug layer.
  51929. * The debug layer (aka Inspector) is the go to tool in order to better understand
  51930. * what is happening in your scene
  51931. * @see https://doc.babylonjs.com/features/playground_debuglayer
  51932. * @param scene Defines the scene to inspect
  51933. */
  51934. constructor(scene: Scene);
  51935. /** Creates the inspector window. */
  51936. private _createInspector;
  51937. /**
  51938. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  51939. * @param entity defines the entity to select
  51940. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  51941. */
  51942. select(entity: any, lineContainerTitles?: string | string[]): void;
  51943. /** Get the inspector from bundle or global */
  51944. private _getGlobalInspector;
  51945. /**
  51946. * Get if the inspector is visible or not.
  51947. * @returns true if visible otherwise, false
  51948. */
  51949. isVisible(): boolean;
  51950. /**
  51951. * Hide the inspector and close its window.
  51952. */
  51953. hide(): void;
  51954. /**
  51955. * Update the scene in the inspector
  51956. */
  51957. setAsActiveScene(): void;
  51958. /**
  51959. * Launch the debugLayer.
  51960. * @param config Define the configuration of the inspector
  51961. * @return a promise fulfilled when the debug layer is visible
  51962. */
  51963. show(config?: IInspectorOptions): Promise<DebugLayer>;
  51964. }
  51965. }
  51966. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  51967. import { Nullable } from "babylonjs/types";
  51968. import { Scene } from "babylonjs/scene";
  51969. import { Vector4 } from "babylonjs/Maths/math.vector";
  51970. import { Color4 } from "babylonjs/Maths/math.color";
  51971. import { Mesh } from "babylonjs/Meshes/mesh";
  51972. /**
  51973. * Class containing static functions to help procedurally build meshes
  51974. */
  51975. export class BoxBuilder {
  51976. /**
  51977. * Creates a box mesh
  51978. * * The parameter `size` sets the size (float) of each box side (default 1)
  51979. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  51980. * * 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)
  51981. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  51982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51985. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  51986. * @param name defines the name of the mesh
  51987. * @param options defines the options used to create the mesh
  51988. * @param scene defines the hosting scene
  51989. * @returns the box mesh
  51990. */
  51991. static CreateBox(name: string, options: {
  51992. size?: number;
  51993. width?: number;
  51994. height?: number;
  51995. depth?: number;
  51996. faceUV?: Vector4[];
  51997. faceColors?: Color4[];
  51998. sideOrientation?: number;
  51999. frontUVs?: Vector4;
  52000. backUVs?: Vector4;
  52001. wrap?: boolean;
  52002. topBaseAt?: number;
  52003. bottomBaseAt?: number;
  52004. updatable?: boolean;
  52005. }, scene?: Nullable<Scene>): Mesh;
  52006. }
  52007. }
  52008. declare module "babylonjs/Debug/physicsViewer" {
  52009. import { Nullable } from "babylonjs/types";
  52010. import { Scene } from "babylonjs/scene";
  52011. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52012. import { Mesh } from "babylonjs/Meshes/mesh";
  52013. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  52014. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  52015. /**
  52016. * Used to show the physics impostor around the specific mesh
  52017. */
  52018. export class PhysicsViewer {
  52019. /** @hidden */
  52020. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  52021. /** @hidden */
  52022. protected _meshes: Array<Nullable<AbstractMesh>>;
  52023. /** @hidden */
  52024. protected _scene: Nullable<Scene>;
  52025. /** @hidden */
  52026. protected _numMeshes: number;
  52027. /** @hidden */
  52028. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  52029. private _renderFunction;
  52030. private _utilityLayer;
  52031. private _debugBoxMesh;
  52032. private _debugSphereMesh;
  52033. private _debugCylinderMesh;
  52034. private _debugMaterial;
  52035. private _debugMeshMeshes;
  52036. /**
  52037. * Creates a new PhysicsViewer
  52038. * @param scene defines the hosting scene
  52039. */
  52040. constructor(scene: Scene);
  52041. /** @hidden */
  52042. protected _updateDebugMeshes(): void;
  52043. /**
  52044. * Renders a specified physic impostor
  52045. * @param impostor defines the impostor to render
  52046. * @param targetMesh defines the mesh represented by the impostor
  52047. * @returns the new debug mesh used to render the impostor
  52048. */
  52049. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  52050. /**
  52051. * Hides a specified physic impostor
  52052. * @param impostor defines the impostor to hide
  52053. */
  52054. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  52055. private _getDebugMaterial;
  52056. private _getDebugBoxMesh;
  52057. private _getDebugSphereMesh;
  52058. private _getDebugCylinderMesh;
  52059. private _getDebugMeshMesh;
  52060. private _getDebugMesh;
  52061. /** Releases all resources */
  52062. dispose(): void;
  52063. }
  52064. }
  52065. declare module "babylonjs/Debug/rayHelper" {
  52066. import { Nullable } from "babylonjs/types";
  52067. import { Ray } from "babylonjs/Culling/ray";
  52068. import { Vector3 } from "babylonjs/Maths/math.vector";
  52069. import { Color3 } from "babylonjs/Maths/math.color";
  52070. import { Scene } from "babylonjs/scene";
  52071. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52072. import "babylonjs/Meshes/Builders/linesBuilder";
  52073. /**
  52074. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52075. * in order to better appreciate the issue one might have.
  52076. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52077. */
  52078. export class RayHelper {
  52079. /**
  52080. * Defines the ray we are currently tryin to visualize.
  52081. */
  52082. ray: Nullable<Ray>;
  52083. private _renderPoints;
  52084. private _renderLine;
  52085. private _renderFunction;
  52086. private _scene;
  52087. private _updateToMeshFunction;
  52088. private _attachedToMesh;
  52089. private _meshSpaceDirection;
  52090. private _meshSpaceOrigin;
  52091. /**
  52092. * Helper function to create a colored helper in a scene in one line.
  52093. * @param ray Defines the ray we are currently tryin to visualize
  52094. * @param scene Defines the scene the ray is used in
  52095. * @param color Defines the color we want to see the ray in
  52096. * @returns The newly created ray helper.
  52097. */
  52098. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  52099. /**
  52100. * Instantiate a new ray helper.
  52101. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  52102. * in order to better appreciate the issue one might have.
  52103. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  52104. * @param ray Defines the ray we are currently tryin to visualize
  52105. */
  52106. constructor(ray: Ray);
  52107. /**
  52108. * Shows the ray we are willing to debug.
  52109. * @param scene Defines the scene the ray needs to be rendered in
  52110. * @param color Defines the color the ray needs to be rendered in
  52111. */
  52112. show(scene: Scene, color?: Color3): void;
  52113. /**
  52114. * Hides the ray we are debugging.
  52115. */
  52116. hide(): void;
  52117. private _render;
  52118. /**
  52119. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  52120. * @param mesh Defines the mesh we want the helper attached to
  52121. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  52122. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  52123. * @param length Defines the length of the ray
  52124. */
  52125. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  52126. /**
  52127. * Detach the ray helper from the mesh it has previously been attached to.
  52128. */
  52129. detachFromMesh(): void;
  52130. private _updateToMesh;
  52131. /**
  52132. * Dispose the helper and release its associated resources.
  52133. */
  52134. dispose(): void;
  52135. }
  52136. }
  52137. declare module "babylonjs/Debug/skeletonViewer" {
  52138. import { Color3 } from "babylonjs/Maths/math.color";
  52139. import { Scene } from "babylonjs/scene";
  52140. import { Nullable } from "babylonjs/types";
  52141. import { Skeleton } from "babylonjs/Bones/skeleton";
  52142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52143. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52144. /**
  52145. * Class used to render a debug view of a given skeleton
  52146. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  52147. */
  52148. export class SkeletonViewer {
  52149. /** defines the skeleton to render */
  52150. skeleton: Skeleton;
  52151. /** defines the mesh attached to the skeleton */
  52152. mesh: AbstractMesh;
  52153. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52154. autoUpdateBonesMatrices: boolean;
  52155. /** defines the rendering group id to use with the viewer */
  52156. renderingGroupId: number;
  52157. /** Gets or sets the color used to render the skeleton */
  52158. color: Color3;
  52159. private _scene;
  52160. private _debugLines;
  52161. private _debugMesh;
  52162. private _isEnabled;
  52163. private _renderFunction;
  52164. private _utilityLayer;
  52165. /**
  52166. * Returns the mesh used to render the bones
  52167. */
  52168. get debugMesh(): Nullable<LinesMesh>;
  52169. /**
  52170. * Creates a new SkeletonViewer
  52171. * @param skeleton defines the skeleton to render
  52172. * @param mesh defines the mesh attached to the skeleton
  52173. * @param scene defines the hosting scene
  52174. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  52175. * @param renderingGroupId defines the rendering group id to use with the viewer
  52176. */
  52177. constructor(
  52178. /** defines the skeleton to render */
  52179. skeleton: Skeleton,
  52180. /** defines the mesh attached to the skeleton */
  52181. mesh: AbstractMesh, scene: Scene,
  52182. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  52183. autoUpdateBonesMatrices?: boolean,
  52184. /** defines the rendering group id to use with the viewer */
  52185. renderingGroupId?: number);
  52186. /** Gets or sets a boolean indicating if the viewer is enabled */
  52187. set isEnabled(value: boolean);
  52188. get isEnabled(): boolean;
  52189. private _getBonePosition;
  52190. private _getLinesForBonesWithLength;
  52191. private _getLinesForBonesNoLength;
  52192. /** Update the viewer to sync with current skeleton state */
  52193. update(): void;
  52194. /** Release associated resources */
  52195. dispose(): void;
  52196. }
  52197. }
  52198. declare module "babylonjs/Debug/index" {
  52199. export * from "babylonjs/Debug/axesViewer";
  52200. export * from "babylonjs/Debug/boneAxesViewer";
  52201. export * from "babylonjs/Debug/debugLayer";
  52202. export * from "babylonjs/Debug/physicsViewer";
  52203. export * from "babylonjs/Debug/rayHelper";
  52204. export * from "babylonjs/Debug/skeletonViewer";
  52205. }
  52206. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  52207. /**
  52208. * Enum for Device Types
  52209. */
  52210. export enum DeviceType {
  52211. /** Generic */
  52212. Generic = 0,
  52213. /** Keyboard */
  52214. Keyboard = 1,
  52215. /** Mouse */
  52216. Mouse = 2,
  52217. /** Touch Pointers */
  52218. Touch = 3,
  52219. /** PS4 Dual Shock */
  52220. DualShock = 4,
  52221. /** Xbox */
  52222. Xbox = 5,
  52223. /** Switch Controller */
  52224. Switch = 6
  52225. }
  52226. /**
  52227. * Enum for All Pointers (Touch/Mouse)
  52228. */
  52229. export enum PointerInput {
  52230. /** Horizontal Axis */
  52231. Horizontal = 0,
  52232. /** Vertical Axis */
  52233. Vertical = 1,
  52234. /** Left Click or Touch */
  52235. LeftClick = 2,
  52236. /** Middle Click */
  52237. MiddleClick = 3,
  52238. /** Right Click */
  52239. RightClick = 4,
  52240. /** Browser Back */
  52241. BrowserBack = 5,
  52242. /** Browser Forward */
  52243. BrowserForward = 6
  52244. }
  52245. /**
  52246. * Enum for Dual Shock Gamepad
  52247. */
  52248. export enum DualShockInput {
  52249. /** Cross */
  52250. Cross = 0,
  52251. /** Circle */
  52252. Circle = 1,
  52253. /** Square */
  52254. Square = 2,
  52255. /** Triangle */
  52256. Triangle = 3,
  52257. /** L1 */
  52258. L1 = 4,
  52259. /** R1 */
  52260. R1 = 5,
  52261. /** L2 */
  52262. L2 = 6,
  52263. /** R2 */
  52264. R2 = 7,
  52265. /** Share */
  52266. Share = 8,
  52267. /** Options */
  52268. Options = 9,
  52269. /** L3 */
  52270. L3 = 10,
  52271. /** R3 */
  52272. R3 = 11,
  52273. /** DPadUp */
  52274. DPadUp = 12,
  52275. /** DPadDown */
  52276. DPadDown = 13,
  52277. /** DPadLeft */
  52278. DPadLeft = 14,
  52279. /** DRight */
  52280. DPadRight = 15,
  52281. /** Home */
  52282. Home = 16,
  52283. /** TouchPad */
  52284. TouchPad = 17,
  52285. /** LStickXAxis */
  52286. LStickXAxis = 18,
  52287. /** LStickYAxis */
  52288. LStickYAxis = 19,
  52289. /** RStickXAxis */
  52290. RStickXAxis = 20,
  52291. /** RStickYAxis */
  52292. RStickYAxis = 21
  52293. }
  52294. /**
  52295. * Enum for Xbox Gamepad
  52296. */
  52297. export enum XboxInput {
  52298. /** A */
  52299. A = 0,
  52300. /** B */
  52301. B = 1,
  52302. /** X */
  52303. X = 2,
  52304. /** Y */
  52305. Y = 3,
  52306. /** LB */
  52307. LB = 4,
  52308. /** RB */
  52309. RB = 5,
  52310. /** LT */
  52311. LT = 6,
  52312. /** RT */
  52313. RT = 7,
  52314. /** Back */
  52315. Back = 8,
  52316. /** Start */
  52317. Start = 9,
  52318. /** LS */
  52319. LS = 10,
  52320. /** RS */
  52321. RS = 11,
  52322. /** DPadUp */
  52323. DPadUp = 12,
  52324. /** DPadDown */
  52325. DPadDown = 13,
  52326. /** DPadLeft */
  52327. DPadLeft = 14,
  52328. /** DRight */
  52329. DPadRight = 15,
  52330. /** Home */
  52331. Home = 16,
  52332. /** LStickXAxis */
  52333. LStickXAxis = 17,
  52334. /** LStickYAxis */
  52335. LStickYAxis = 18,
  52336. /** RStickXAxis */
  52337. RStickXAxis = 19,
  52338. /** RStickYAxis */
  52339. RStickYAxis = 20
  52340. }
  52341. /**
  52342. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  52343. */
  52344. export enum SwitchInput {
  52345. /** B */
  52346. B = 0,
  52347. /** A */
  52348. A = 1,
  52349. /** Y */
  52350. Y = 2,
  52351. /** X */
  52352. X = 3,
  52353. /** L */
  52354. L = 4,
  52355. /** R */
  52356. R = 5,
  52357. /** ZL */
  52358. ZL = 6,
  52359. /** ZR */
  52360. ZR = 7,
  52361. /** Minus */
  52362. Minus = 8,
  52363. /** Plus */
  52364. Plus = 9,
  52365. /** LS */
  52366. LS = 10,
  52367. /** RS */
  52368. RS = 11,
  52369. /** DPadUp */
  52370. DPadUp = 12,
  52371. /** DPadDown */
  52372. DPadDown = 13,
  52373. /** DPadLeft */
  52374. DPadLeft = 14,
  52375. /** DRight */
  52376. DPadRight = 15,
  52377. /** Home */
  52378. Home = 16,
  52379. /** Capture */
  52380. Capture = 17,
  52381. /** LStickXAxis */
  52382. LStickXAxis = 18,
  52383. /** LStickYAxis */
  52384. LStickYAxis = 19,
  52385. /** RStickXAxis */
  52386. RStickXAxis = 20,
  52387. /** RStickYAxis */
  52388. RStickYAxis = 21
  52389. }
  52390. }
  52391. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  52392. import { Engine } from "babylonjs/Engines/engine";
  52393. import { IDisposable } from "babylonjs/scene";
  52394. import { Nullable } from "babylonjs/types";
  52395. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52396. /**
  52397. * This class will take all inputs from Keyboard, Pointer, and
  52398. * any Gamepads and provide a polling system that all devices
  52399. * will use. This class assumes that there will only be one
  52400. * pointer device and one keyboard.
  52401. */
  52402. export class DeviceInputSystem implements IDisposable {
  52403. /**
  52404. * Callback to be triggered when a device is connected
  52405. */
  52406. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52407. /**
  52408. * Callback to be triggered when a device is disconnected
  52409. */
  52410. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  52411. /**
  52412. * Callback to be triggered when event driven input is updated
  52413. */
  52414. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  52415. private _inputs;
  52416. private _gamepads;
  52417. private _keyboardActive;
  52418. private _pointerActive;
  52419. private _elementToAttachTo;
  52420. private _keyboardDownEvent;
  52421. private _keyboardUpEvent;
  52422. private _pointerMoveEvent;
  52423. private _pointerDownEvent;
  52424. private _pointerUpEvent;
  52425. private _gamepadConnectedEvent;
  52426. private _gamepadDisconnectedEvent;
  52427. private static _MAX_KEYCODES;
  52428. private static _MAX_POINTER_INPUTS;
  52429. private constructor();
  52430. /**
  52431. * Creates a new DeviceInputSystem instance
  52432. * @param engine Engine to pull input element from
  52433. * @returns The new instance
  52434. */
  52435. static Create(engine: Engine): DeviceInputSystem;
  52436. /**
  52437. * Checks for current device input value, given an id and input index
  52438. * @param deviceName Id of connected device
  52439. * @param inputIndex Index of device input
  52440. * @returns Current value of input
  52441. */
  52442. /**
  52443. * Checks for current device input value, given an id and input index
  52444. * @param deviceType Enum specifiying device type
  52445. * @param deviceSlot "Slot" or index that device is referenced in
  52446. * @param inputIndex Id of input to be checked
  52447. * @returns Current value of input
  52448. */
  52449. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  52450. /**
  52451. * Dispose of all the eventlisteners
  52452. */
  52453. dispose(): void;
  52454. /**
  52455. * Add device and inputs to device array
  52456. * @param deviceType Enum specifiying device type
  52457. * @param deviceSlot "Slot" or index that device is referenced in
  52458. * @param numberOfInputs Number of input entries to create for given device
  52459. */
  52460. private _registerDevice;
  52461. /**
  52462. * Given a specific device name, remove that device from the device map
  52463. * @param deviceType Enum specifiying device type
  52464. * @param deviceSlot "Slot" or index that device is referenced in
  52465. */
  52466. private _unregisterDevice;
  52467. /**
  52468. * Handle all actions that come from keyboard interaction
  52469. */
  52470. private _handleKeyActions;
  52471. /**
  52472. * Handle all actions that come from pointer interaction
  52473. */
  52474. private _handlePointerActions;
  52475. /**
  52476. * Handle all actions that come from gamepad interaction
  52477. */
  52478. private _handleGamepadActions;
  52479. /**
  52480. * Update all non-event based devices with each frame
  52481. * @param deviceType Enum specifiying device type
  52482. * @param deviceSlot "Slot" or index that device is referenced in
  52483. * @param inputIndex Id of input to be checked
  52484. */
  52485. private _updateDevice;
  52486. /**
  52487. * Gets DeviceType from the device name
  52488. * @param deviceName Name of Device from DeviceInputSystem
  52489. * @returns DeviceType enum value
  52490. */
  52491. private _getGamepadDeviceType;
  52492. }
  52493. }
  52494. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  52495. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52496. /**
  52497. * Type to handle enforcement of inputs
  52498. */
  52499. 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;
  52500. }
  52501. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  52502. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  52503. import { Engine } from "babylonjs/Engines/engine";
  52504. import { IDisposable } from "babylonjs/scene";
  52505. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52506. import { Nullable } from "babylonjs/types";
  52507. import { Observable } from "babylonjs/Misc/observable";
  52508. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52509. /**
  52510. * Class that handles all input for a specific device
  52511. */
  52512. export class DeviceSource<T extends DeviceType> {
  52513. /** Type of device */
  52514. readonly deviceType: DeviceType;
  52515. /** "Slot" or index that device is referenced in */
  52516. readonly deviceSlot: number;
  52517. /**
  52518. * Observable to handle device input changes per device
  52519. */
  52520. readonly onInputChangedObservable: Observable<{
  52521. inputIndex: DeviceInput<T>;
  52522. previousState: Nullable<number>;
  52523. currentState: Nullable<number>;
  52524. }>;
  52525. private readonly _deviceInputSystem;
  52526. /**
  52527. * Default Constructor
  52528. * @param deviceInputSystem Reference to DeviceInputSystem
  52529. * @param deviceType Type of device
  52530. * @param deviceSlot "Slot" or index that device is referenced in
  52531. */
  52532. constructor(deviceInputSystem: DeviceInputSystem,
  52533. /** Type of device */
  52534. deviceType: DeviceType,
  52535. /** "Slot" or index that device is referenced in */
  52536. deviceSlot?: number);
  52537. /**
  52538. * Get input for specific input
  52539. * @param inputIndex index of specific input on device
  52540. * @returns Input value from DeviceInputSystem
  52541. */
  52542. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  52543. }
  52544. /**
  52545. * Class to keep track of devices
  52546. */
  52547. export class DeviceSourceManager implements IDisposable {
  52548. /**
  52549. * Observable to be triggered when before a device is connected
  52550. */
  52551. readonly onBeforeDeviceConnectedObservable: Observable<{
  52552. deviceType: DeviceType;
  52553. deviceSlot: number;
  52554. }>;
  52555. /**
  52556. * Observable to be triggered when before a device is disconnected
  52557. */
  52558. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  52559. deviceType: DeviceType;
  52560. deviceSlot: number;
  52561. }>;
  52562. /**
  52563. * Observable to be triggered when after a device is connected
  52564. */
  52565. readonly onAfterDeviceConnectedObservable: Observable<{
  52566. deviceType: DeviceType;
  52567. deviceSlot: number;
  52568. }>;
  52569. /**
  52570. * Observable to be triggered when after a device is disconnected
  52571. */
  52572. readonly onAfterDeviceDisconnectedObservable: Observable<{
  52573. deviceType: DeviceType;
  52574. deviceSlot: number;
  52575. }>;
  52576. private readonly _devices;
  52577. private readonly _firstDevice;
  52578. private readonly _deviceInputSystem;
  52579. /**
  52580. * Default Constructor
  52581. * @param engine engine to pull input element from
  52582. */
  52583. constructor(engine: Engine);
  52584. /**
  52585. * Gets a DeviceSource, given a type and slot
  52586. * @param deviceType Enum specifying device type
  52587. * @param deviceSlot "Slot" or index that device is referenced in
  52588. * @returns DeviceSource object
  52589. */
  52590. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  52591. /**
  52592. * Gets an array of DeviceSource objects for a given device type
  52593. * @param deviceType Enum specifying device type
  52594. * @returns Array of DeviceSource objects
  52595. */
  52596. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  52597. /**
  52598. * Dispose of DeviceInputSystem and other parts
  52599. */
  52600. dispose(): void;
  52601. /**
  52602. * Function to add device name to device list
  52603. * @param deviceType Enum specifying device type
  52604. * @param deviceSlot "Slot" or index that device is referenced in
  52605. */
  52606. private _addDevice;
  52607. /**
  52608. * Function to remove device name to device list
  52609. * @param deviceType Enum specifying device type
  52610. * @param deviceSlot "Slot" or index that device is referenced in
  52611. */
  52612. private _removeDevice;
  52613. /**
  52614. * Updates array storing first connected device of each type
  52615. * @param type Type of Device
  52616. */
  52617. private _updateFirstDevices;
  52618. }
  52619. }
  52620. declare module "babylonjs/DeviceInput/index" {
  52621. export * from "babylonjs/DeviceInput/deviceInputSystem";
  52622. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  52623. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  52624. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52625. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  52626. }
  52627. declare module "babylonjs/Engines/nullEngine" {
  52628. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  52629. import { Engine } from "babylonjs/Engines/engine";
  52630. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  52631. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  52632. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52633. import { Effect } from "babylonjs/Materials/effect";
  52634. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  52635. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  52636. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  52637. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  52638. /**
  52639. * Options to create the null engine
  52640. */
  52641. export class NullEngineOptions {
  52642. /**
  52643. * Render width (Default: 512)
  52644. */
  52645. renderWidth: number;
  52646. /**
  52647. * Render height (Default: 256)
  52648. */
  52649. renderHeight: number;
  52650. /**
  52651. * Texture size (Default: 512)
  52652. */
  52653. textureSize: number;
  52654. /**
  52655. * If delta time between frames should be constant
  52656. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52657. */
  52658. deterministicLockstep: boolean;
  52659. /**
  52660. * Maximum about of steps between frames (Default: 4)
  52661. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52662. */
  52663. lockstepMaxSteps: number;
  52664. }
  52665. /**
  52666. * The null engine class provides support for headless version of babylon.js.
  52667. * This can be used in server side scenario or for testing purposes
  52668. */
  52669. export class NullEngine extends Engine {
  52670. private _options;
  52671. /**
  52672. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  52673. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52674. * @returns true if engine is in deterministic lock step mode
  52675. */
  52676. isDeterministicLockStep(): boolean;
  52677. /**
  52678. * Gets the max steps when engine is running in deterministic lock step
  52679. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  52680. * @returns the max steps
  52681. */
  52682. getLockstepMaxSteps(): number;
  52683. /**
  52684. * Gets the current hardware scaling level.
  52685. * By default the hardware scaling level is computed from the window device ratio.
  52686. * 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.
  52687. * @returns a number indicating the current hardware scaling level
  52688. */
  52689. getHardwareScalingLevel(): number;
  52690. constructor(options?: NullEngineOptions);
  52691. /**
  52692. * Creates a vertex buffer
  52693. * @param vertices the data for the vertex buffer
  52694. * @returns the new WebGL static buffer
  52695. */
  52696. createVertexBuffer(vertices: FloatArray): DataBuffer;
  52697. /**
  52698. * Creates a new index buffer
  52699. * @param indices defines the content of the index buffer
  52700. * @param updatable defines if the index buffer must be updatable
  52701. * @returns a new webGL buffer
  52702. */
  52703. createIndexBuffer(indices: IndicesArray): DataBuffer;
  52704. /**
  52705. * Clear the current render buffer or the current render target (if any is set up)
  52706. * @param color defines the color to use
  52707. * @param backBuffer defines if the back buffer must be cleared
  52708. * @param depth defines if the depth buffer must be cleared
  52709. * @param stencil defines if the stencil buffer must be cleared
  52710. */
  52711. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  52712. /**
  52713. * Gets the current render width
  52714. * @param useScreen defines if screen size must be used (or the current render target if any)
  52715. * @returns a number defining the current render width
  52716. */
  52717. getRenderWidth(useScreen?: boolean): number;
  52718. /**
  52719. * Gets the current render height
  52720. * @param useScreen defines if screen size must be used (or the current render target if any)
  52721. * @returns a number defining the current render height
  52722. */
  52723. getRenderHeight(useScreen?: boolean): number;
  52724. /**
  52725. * Set the WebGL's viewport
  52726. * @param viewport defines the viewport element to be used
  52727. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  52728. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  52729. */
  52730. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  52731. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  52732. /**
  52733. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  52734. * @param pipelineContext defines the pipeline context to use
  52735. * @param uniformsNames defines the list of uniform names
  52736. * @returns an array of webGL uniform locations
  52737. */
  52738. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  52739. /**
  52740. * Gets the lsit of active attributes for a given webGL program
  52741. * @param pipelineContext defines the pipeline context to use
  52742. * @param attributesNames defines the list of attribute names to get
  52743. * @returns an array of indices indicating the offset of each attribute
  52744. */
  52745. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  52746. /**
  52747. * Binds an effect to the webGL context
  52748. * @param effect defines the effect to bind
  52749. */
  52750. bindSamplers(effect: Effect): void;
  52751. /**
  52752. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  52753. * @param effect defines the effect to activate
  52754. */
  52755. enableEffect(effect: Effect): void;
  52756. /**
  52757. * Set various states to the webGL context
  52758. * @param culling defines backface culling state
  52759. * @param zOffset defines the value to apply to zOffset (0 by default)
  52760. * @param force defines if states must be applied even if cache is up to date
  52761. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  52762. */
  52763. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  52764. /**
  52765. * Set the value of an uniform to an array of int32
  52766. * @param uniform defines the webGL uniform location where to store the value
  52767. * @param array defines the array of int32 to store
  52768. */
  52769. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  52770. /**
  52771. * Set the value of an uniform to an array of int32 (stored as vec2)
  52772. * @param uniform defines the webGL uniform location where to store the value
  52773. * @param array defines the array of int32 to store
  52774. */
  52775. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  52776. /**
  52777. * Set the value of an uniform to an array of int32 (stored as vec3)
  52778. * @param uniform defines the webGL uniform location where to store the value
  52779. * @param array defines the array of int32 to store
  52780. */
  52781. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  52782. /**
  52783. * Set the value of an uniform to an array of int32 (stored as vec4)
  52784. * @param uniform defines the webGL uniform location where to store the value
  52785. * @param array defines the array of int32 to store
  52786. */
  52787. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  52788. /**
  52789. * Set the value of an uniform to an array of float32
  52790. * @param uniform defines the webGL uniform location where to store the value
  52791. * @param array defines the array of float32 to store
  52792. */
  52793. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  52794. /**
  52795. * Set the value of an uniform to an array of float32 (stored as vec2)
  52796. * @param uniform defines the webGL uniform location where to store the value
  52797. * @param array defines the array of float32 to store
  52798. */
  52799. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  52800. /**
  52801. * Set the value of an uniform to an array of float32 (stored as vec3)
  52802. * @param uniform defines the webGL uniform location where to store the value
  52803. * @param array defines the array of float32 to store
  52804. */
  52805. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  52806. /**
  52807. * Set the value of an uniform to an array of float32 (stored as vec4)
  52808. * @param uniform defines the webGL uniform location where to store the value
  52809. * @param array defines the array of float32 to store
  52810. */
  52811. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  52812. /**
  52813. * Set the value of an uniform to an array of number
  52814. * @param uniform defines the webGL uniform location where to store the value
  52815. * @param array defines the array of number to store
  52816. */
  52817. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  52818. /**
  52819. * Set the value of an uniform to an array of number (stored as vec2)
  52820. * @param uniform defines the webGL uniform location where to store the value
  52821. * @param array defines the array of number to store
  52822. */
  52823. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  52824. /**
  52825. * Set the value of an uniform to an array of number (stored as vec3)
  52826. * @param uniform defines the webGL uniform location where to store the value
  52827. * @param array defines the array of number to store
  52828. */
  52829. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  52830. /**
  52831. * Set the value of an uniform to an array of number (stored as vec4)
  52832. * @param uniform defines the webGL uniform location where to store the value
  52833. * @param array defines the array of number to store
  52834. */
  52835. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  52836. /**
  52837. * Set the value of an uniform to an array of float32 (stored as matrices)
  52838. * @param uniform defines the webGL uniform location where to store the value
  52839. * @param matrices defines the array of float32 to store
  52840. */
  52841. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  52842. /**
  52843. * Set the value of an uniform to a matrix (3x3)
  52844. * @param uniform defines the webGL uniform location where to store the value
  52845. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  52846. */
  52847. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52848. /**
  52849. * Set the value of an uniform to a matrix (2x2)
  52850. * @param uniform defines the webGL uniform location where to store the value
  52851. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  52852. */
  52853. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  52854. /**
  52855. * Set the value of an uniform to a number (float)
  52856. * @param uniform defines the webGL uniform location where to store the value
  52857. * @param value defines the float number to store
  52858. */
  52859. setFloat(uniform: WebGLUniformLocation, value: number): void;
  52860. /**
  52861. * Set the value of an uniform to a vec2
  52862. * @param uniform defines the webGL uniform location where to store the value
  52863. * @param x defines the 1st component of the value
  52864. * @param y defines the 2nd component of the value
  52865. */
  52866. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  52867. /**
  52868. * Set the value of an uniform to a vec3
  52869. * @param uniform defines the webGL uniform location where to store the value
  52870. * @param x defines the 1st component of the value
  52871. * @param y defines the 2nd component of the value
  52872. * @param z defines the 3rd component of the value
  52873. */
  52874. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  52875. /**
  52876. * Set the value of an uniform to a boolean
  52877. * @param uniform defines the webGL uniform location where to store the value
  52878. * @param bool defines the boolean to store
  52879. */
  52880. setBool(uniform: WebGLUniformLocation, bool: number): void;
  52881. /**
  52882. * Set the value of an uniform to a vec4
  52883. * @param uniform defines the webGL uniform location where to store the value
  52884. * @param x defines the 1st component of the value
  52885. * @param y defines the 2nd component of the value
  52886. * @param z defines the 3rd component of the value
  52887. * @param w defines the 4th component of the value
  52888. */
  52889. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  52890. /**
  52891. * Sets the current alpha mode
  52892. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  52893. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  52894. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  52895. */
  52896. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  52897. /**
  52898. * Bind webGl buffers directly to the webGL context
  52899. * @param vertexBuffers defines the vertex buffer to bind
  52900. * @param indexBuffer defines the index buffer to bind
  52901. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  52902. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  52903. * @param effect defines the effect associated with the vertex buffer
  52904. */
  52905. bindBuffers(vertexBuffers: {
  52906. [key: string]: VertexBuffer;
  52907. }, indexBuffer: DataBuffer, effect: Effect): void;
  52908. /**
  52909. * Force the entire cache to be cleared
  52910. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  52911. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  52912. */
  52913. wipeCaches(bruteForce?: boolean): void;
  52914. /**
  52915. * Send a draw order
  52916. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  52917. * @param indexStart defines the starting index
  52918. * @param indexCount defines the number of index to draw
  52919. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52920. */
  52921. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  52922. /**
  52923. * Draw a list of indexed primitives
  52924. * @param fillMode defines the primitive to use
  52925. * @param indexStart defines the starting index
  52926. * @param indexCount defines the number of index to draw
  52927. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52928. */
  52929. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  52930. /**
  52931. * Draw a list of unindexed primitives
  52932. * @param fillMode defines the primitive to use
  52933. * @param verticesStart defines the index of first vertex to draw
  52934. * @param verticesCount defines the count of vertices to draw
  52935. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  52936. */
  52937. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  52938. /** @hidden */
  52939. _createTexture(): WebGLTexture;
  52940. /** @hidden */
  52941. _releaseTexture(texture: InternalTexture): void;
  52942. /**
  52943. * Usually called from Texture.ts.
  52944. * Passed information to create a WebGLTexture
  52945. * @param urlArg defines a value which contains one of the following:
  52946. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  52947. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  52948. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  52949. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  52950. * @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)
  52951. * @param scene needed for loading to the correct scene
  52952. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  52953. * @param onLoad optional callback to be called upon successful completion
  52954. * @param onError optional callback to be called upon failure
  52955. * @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
  52956. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  52957. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  52958. * @param forcedExtension defines the extension to use to pick the right loader
  52959. * @param mimeType defines an optional mime type
  52960. * @returns a InternalTexture for assignment back into BABYLON.Texture
  52961. */
  52962. 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;
  52963. /**
  52964. * Creates a new render target texture
  52965. * @param size defines the size of the texture
  52966. * @param options defines the options used to create the texture
  52967. * @returns a new render target texture stored in an InternalTexture
  52968. */
  52969. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  52970. /**
  52971. * Update the sampling mode of a given texture
  52972. * @param samplingMode defines the required sampling mode
  52973. * @param texture defines the texture to update
  52974. */
  52975. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  52976. /**
  52977. * Binds the frame buffer to the specified texture.
  52978. * @param texture The texture to render to or null for the default canvas
  52979. * @param faceIndex The face of the texture to render to in case of cube texture
  52980. * @param requiredWidth The width of the target to render to
  52981. * @param requiredHeight The height of the target to render to
  52982. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  52983. * @param lodLevel defines le lod level to bind to the frame buffer
  52984. */
  52985. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  52986. /**
  52987. * Unbind the current render target texture from the webGL context
  52988. * @param texture defines the render target texture to unbind
  52989. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  52990. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  52991. */
  52992. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  52993. /**
  52994. * Creates a dynamic vertex buffer
  52995. * @param vertices the data for the dynamic vertex buffer
  52996. * @returns the new WebGL dynamic buffer
  52997. */
  52998. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  52999. /**
  53000. * Update the content of a dynamic texture
  53001. * @param texture defines the texture to update
  53002. * @param canvas defines the canvas containing the source
  53003. * @param invertY defines if data must be stored with Y axis inverted
  53004. * @param premulAlpha defines if alpha is stored as premultiplied
  53005. * @param format defines the format of the data
  53006. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  53007. */
  53008. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  53009. /**
  53010. * Gets a boolean indicating if all created effects are ready
  53011. * @returns true if all effects are ready
  53012. */
  53013. areAllEffectsReady(): boolean;
  53014. /**
  53015. * @hidden
  53016. * Get the current error code of the webGL context
  53017. * @returns the error code
  53018. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  53019. */
  53020. getError(): number;
  53021. /** @hidden */
  53022. _getUnpackAlignement(): number;
  53023. /** @hidden */
  53024. _unpackFlipY(value: boolean): void;
  53025. /**
  53026. * Update a dynamic index buffer
  53027. * @param indexBuffer defines the target index buffer
  53028. * @param indices defines the data to update
  53029. * @param offset defines the offset in the target index buffer where update should start
  53030. */
  53031. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  53032. /**
  53033. * Updates a dynamic vertex buffer.
  53034. * @param vertexBuffer the vertex buffer to update
  53035. * @param vertices the data used to update the vertex buffer
  53036. * @param byteOffset the byte offset of the data (optional)
  53037. * @param byteLength the byte length of the data (optional)
  53038. */
  53039. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  53040. /** @hidden */
  53041. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  53042. /** @hidden */
  53043. _bindTexture(channel: number, texture: InternalTexture): void;
  53044. protected _deleteBuffer(buffer: WebGLBuffer): void;
  53045. /**
  53046. * 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
  53047. */
  53048. releaseEffects(): void;
  53049. displayLoadingUI(): void;
  53050. hideLoadingUI(): void;
  53051. /** @hidden */
  53052. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53053. /** @hidden */
  53054. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53055. /** @hidden */
  53056. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  53057. /** @hidden */
  53058. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  53059. }
  53060. }
  53061. declare module "babylonjs/Instrumentation/timeToken" {
  53062. import { Nullable } from "babylonjs/types";
  53063. /**
  53064. * @hidden
  53065. **/
  53066. export class _TimeToken {
  53067. _startTimeQuery: Nullable<WebGLQuery>;
  53068. _endTimeQuery: Nullable<WebGLQuery>;
  53069. _timeElapsedQuery: Nullable<WebGLQuery>;
  53070. _timeElapsedQueryEnded: boolean;
  53071. }
  53072. }
  53073. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  53074. import { Nullable, int } from "babylonjs/types";
  53075. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  53076. /** @hidden */
  53077. export class _OcclusionDataStorage {
  53078. /** @hidden */
  53079. occlusionInternalRetryCounter: number;
  53080. /** @hidden */
  53081. isOcclusionQueryInProgress: boolean;
  53082. /** @hidden */
  53083. isOccluded: boolean;
  53084. /** @hidden */
  53085. occlusionRetryCount: number;
  53086. /** @hidden */
  53087. occlusionType: number;
  53088. /** @hidden */
  53089. occlusionQueryAlgorithmType: number;
  53090. }
  53091. module "babylonjs/Engines/engine" {
  53092. interface Engine {
  53093. /**
  53094. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  53095. * @return the new query
  53096. */
  53097. createQuery(): WebGLQuery;
  53098. /**
  53099. * Delete and release a webGL query
  53100. * @param query defines the query to delete
  53101. * @return the current engine
  53102. */
  53103. deleteQuery(query: WebGLQuery): Engine;
  53104. /**
  53105. * Check if a given query has resolved and got its value
  53106. * @param query defines the query to check
  53107. * @returns true if the query got its value
  53108. */
  53109. isQueryResultAvailable(query: WebGLQuery): boolean;
  53110. /**
  53111. * Gets the value of a given query
  53112. * @param query defines the query to check
  53113. * @returns the value of the query
  53114. */
  53115. getQueryResult(query: WebGLQuery): number;
  53116. /**
  53117. * Initiates an occlusion query
  53118. * @param algorithmType defines the algorithm to use
  53119. * @param query defines the query to use
  53120. * @returns the current engine
  53121. * @see https://doc.babylonjs.com/features/occlusionquery
  53122. */
  53123. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  53124. /**
  53125. * Ends an occlusion query
  53126. * @see https://doc.babylonjs.com/features/occlusionquery
  53127. * @param algorithmType defines the algorithm to use
  53128. * @returns the current engine
  53129. */
  53130. endOcclusionQuery(algorithmType: number): Engine;
  53131. /**
  53132. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  53133. * Please note that only one query can be issued at a time
  53134. * @returns a time token used to track the time span
  53135. */
  53136. startTimeQuery(): Nullable<_TimeToken>;
  53137. /**
  53138. * Ends a time query
  53139. * @param token defines the token used to measure the time span
  53140. * @returns the time spent (in ns)
  53141. */
  53142. endTimeQuery(token: _TimeToken): int;
  53143. /** @hidden */
  53144. _currentNonTimestampToken: Nullable<_TimeToken>;
  53145. /** @hidden */
  53146. _createTimeQuery(): WebGLQuery;
  53147. /** @hidden */
  53148. _deleteTimeQuery(query: WebGLQuery): void;
  53149. /** @hidden */
  53150. _getGlAlgorithmType(algorithmType: number): number;
  53151. /** @hidden */
  53152. _getTimeQueryResult(query: WebGLQuery): any;
  53153. /** @hidden */
  53154. _getTimeQueryAvailability(query: WebGLQuery): any;
  53155. }
  53156. }
  53157. module "babylonjs/Meshes/abstractMesh" {
  53158. interface AbstractMesh {
  53159. /**
  53160. * Backing filed
  53161. * @hidden
  53162. */
  53163. __occlusionDataStorage: _OcclusionDataStorage;
  53164. /**
  53165. * Access property
  53166. * @hidden
  53167. */
  53168. _occlusionDataStorage: _OcclusionDataStorage;
  53169. /**
  53170. * 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.
  53171. * The default value is -1 which means don't break the query and wait till the result
  53172. * @see https://doc.babylonjs.com/features/occlusionquery
  53173. */
  53174. occlusionRetryCount: number;
  53175. /**
  53176. * 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:
  53177. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  53178. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  53179. * * 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.
  53180. * @see https://doc.babylonjs.com/features/occlusionquery
  53181. */
  53182. occlusionType: number;
  53183. /**
  53184. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  53185. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  53186. * * 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.
  53187. * @see https://doc.babylonjs.com/features/occlusionquery
  53188. */
  53189. occlusionQueryAlgorithmType: number;
  53190. /**
  53191. * 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
  53192. * @see https://doc.babylonjs.com/features/occlusionquery
  53193. */
  53194. isOccluded: boolean;
  53195. /**
  53196. * Flag to check the progress status of the query
  53197. * @see https://doc.babylonjs.com/features/occlusionquery
  53198. */
  53199. isOcclusionQueryInProgress: boolean;
  53200. }
  53201. }
  53202. }
  53203. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  53204. import { Nullable } from "babylonjs/types";
  53205. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53206. /** @hidden */
  53207. export var _forceTransformFeedbackToBundle: boolean;
  53208. module "babylonjs/Engines/engine" {
  53209. interface Engine {
  53210. /**
  53211. * Creates a webGL transform feedback object
  53212. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  53213. * @returns the webGL transform feedback object
  53214. */
  53215. createTransformFeedback(): WebGLTransformFeedback;
  53216. /**
  53217. * Delete a webGL transform feedback object
  53218. * @param value defines the webGL transform feedback object to delete
  53219. */
  53220. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  53221. /**
  53222. * Bind a webGL transform feedback object to the webgl context
  53223. * @param value defines the webGL transform feedback object to bind
  53224. */
  53225. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  53226. /**
  53227. * Begins a transform feedback operation
  53228. * @param usePoints defines if points or triangles must be used
  53229. */
  53230. beginTransformFeedback(usePoints: boolean): void;
  53231. /**
  53232. * Ends a transform feedback operation
  53233. */
  53234. endTransformFeedback(): void;
  53235. /**
  53236. * Specify the varyings to use with transform feedback
  53237. * @param program defines the associated webGL program
  53238. * @param value defines the list of strings representing the varying names
  53239. */
  53240. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  53241. /**
  53242. * Bind a webGL buffer for a transform feedback operation
  53243. * @param value defines the webGL buffer to bind
  53244. */
  53245. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  53246. }
  53247. }
  53248. }
  53249. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  53250. import { Scene } from "babylonjs/scene";
  53251. import { Engine } from "babylonjs/Engines/engine";
  53252. import { Texture } from "babylonjs/Materials/Textures/texture";
  53253. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53254. import "babylonjs/Engines/Extensions/engine.multiRender";
  53255. /**
  53256. * Creation options of the multi render target texture.
  53257. */
  53258. export interface IMultiRenderTargetOptions {
  53259. /**
  53260. * Define if the texture needs to create mip maps after render.
  53261. */
  53262. generateMipMaps?: boolean;
  53263. /**
  53264. * Define the types of all the draw buffers we want to create
  53265. */
  53266. types?: number[];
  53267. /**
  53268. * Define the sampling modes of all the draw buffers we want to create
  53269. */
  53270. samplingModes?: number[];
  53271. /**
  53272. * Define if a depth buffer is required
  53273. */
  53274. generateDepthBuffer?: boolean;
  53275. /**
  53276. * Define if a stencil buffer is required
  53277. */
  53278. generateStencilBuffer?: boolean;
  53279. /**
  53280. * Define if a depth texture is required instead of a depth buffer
  53281. */
  53282. generateDepthTexture?: boolean;
  53283. /**
  53284. * Define the number of desired draw buffers
  53285. */
  53286. textureCount?: number;
  53287. /**
  53288. * Define if aspect ratio should be adapted to the texture or stay the scene one
  53289. */
  53290. doNotChangeAspectRatio?: boolean;
  53291. /**
  53292. * Define the default type of the buffers we are creating
  53293. */
  53294. defaultType?: number;
  53295. }
  53296. /**
  53297. * A multi render target, like a render target provides the ability to render to a texture.
  53298. * Unlike the render target, it can render to several draw buffers in one draw.
  53299. * This is specially interesting in deferred rendering or for any effects requiring more than
  53300. * just one color from a single pass.
  53301. */
  53302. export class MultiRenderTarget extends RenderTargetTexture {
  53303. private _internalTextures;
  53304. private _textures;
  53305. private _multiRenderTargetOptions;
  53306. private _count;
  53307. /**
  53308. * Get if draw buffers are currently supported by the used hardware and browser.
  53309. */
  53310. get isSupported(): boolean;
  53311. /**
  53312. * Get the list of textures generated by the multi render target.
  53313. */
  53314. get textures(): Texture[];
  53315. /**
  53316. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  53317. */
  53318. get count(): number;
  53319. /**
  53320. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  53321. */
  53322. get depthTexture(): Texture;
  53323. /**
  53324. * Set the wrapping mode on U of all the textures we are rendering to.
  53325. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53326. */
  53327. set wrapU(wrap: number);
  53328. /**
  53329. * Set the wrapping mode on V of all the textures we are rendering to.
  53330. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  53331. */
  53332. set wrapV(wrap: number);
  53333. /**
  53334. * Instantiate a new multi render target texture.
  53335. * A multi render target, like a render target provides the ability to render to a texture.
  53336. * Unlike the render target, it can render to several draw buffers in one draw.
  53337. * This is specially interesting in deferred rendering or for any effects requiring more than
  53338. * just one color from a single pass.
  53339. * @param name Define the name of the texture
  53340. * @param size Define the size of the buffers to render to
  53341. * @param count Define the number of target we are rendering into
  53342. * @param scene Define the scene the texture belongs to
  53343. * @param options Define the options used to create the multi render target
  53344. */
  53345. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  53346. /** @hidden */
  53347. _rebuild(): void;
  53348. private _createInternalTextures;
  53349. private _createTextures;
  53350. /**
  53351. * Define the number of samples used if MSAA is enabled.
  53352. */
  53353. get samples(): number;
  53354. set samples(value: number);
  53355. /**
  53356. * Resize all the textures in the multi render target.
  53357. * Be carrefull as it will recreate all the data in the new texture.
  53358. * @param size Define the new size
  53359. */
  53360. resize(size: any): void;
  53361. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  53362. /**
  53363. * Dispose the render targets and their associated resources
  53364. */
  53365. dispose(): void;
  53366. /**
  53367. * Release all the underlying texture used as draw buffers.
  53368. */
  53369. releaseInternalTextures(): void;
  53370. }
  53371. }
  53372. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  53373. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53374. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  53375. import { Nullable } from "babylonjs/types";
  53376. module "babylonjs/Engines/thinEngine" {
  53377. interface ThinEngine {
  53378. /**
  53379. * Unbind a list of render target textures from the webGL context
  53380. * This is used only when drawBuffer extension or webGL2 are active
  53381. * @param textures defines the render target textures to unbind
  53382. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  53383. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  53384. */
  53385. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  53386. /**
  53387. * Create a multi render target texture
  53388. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  53389. * @param size defines the size of the texture
  53390. * @param options defines the creation options
  53391. * @returns the cube texture as an InternalTexture
  53392. */
  53393. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  53394. /**
  53395. * Update the sample count for a given multiple render target texture
  53396. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  53397. * @param textures defines the textures to update
  53398. * @param samples defines the sample count to set
  53399. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  53400. */
  53401. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  53402. /**
  53403. * Select a subsets of attachments to draw to.
  53404. * @param attachments gl attachments
  53405. */
  53406. bindAttachments(attachments: number[]): void;
  53407. }
  53408. }
  53409. }
  53410. declare module "babylonjs/Engines/Extensions/engine.views" {
  53411. import { Camera } from "babylonjs/Cameras/camera";
  53412. import { Nullable } from "babylonjs/types";
  53413. /**
  53414. * Class used to define an additional view for the engine
  53415. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53416. */
  53417. export class EngineView {
  53418. /** Defines the canvas where to render the view */
  53419. target: HTMLCanvasElement;
  53420. /** Defines an optional camera used to render the view (will use active camera else) */
  53421. camera?: Camera;
  53422. }
  53423. module "babylonjs/Engines/engine" {
  53424. interface Engine {
  53425. /**
  53426. * Gets or sets the HTML element to use for attaching events
  53427. */
  53428. inputElement: Nullable<HTMLElement>;
  53429. /**
  53430. * Gets the current engine view
  53431. * @see https://doc.babylonjs.com/how_to/multi_canvases
  53432. */
  53433. activeView: Nullable<EngineView>;
  53434. /** Gets or sets the list of views */
  53435. views: EngineView[];
  53436. /**
  53437. * Register a new child canvas
  53438. * @param canvas defines the canvas to register
  53439. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  53440. * @returns the associated view
  53441. */
  53442. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  53443. /**
  53444. * Remove a registered child canvas
  53445. * @param canvas defines the canvas to remove
  53446. * @returns the current engine
  53447. */
  53448. unRegisterView(canvas: HTMLCanvasElement): Engine;
  53449. }
  53450. }
  53451. }
  53452. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  53453. import { Nullable } from "babylonjs/types";
  53454. module "babylonjs/Engines/engine" {
  53455. interface Engine {
  53456. /** @hidden */
  53457. _excludedCompressedTextures: string[];
  53458. /** @hidden */
  53459. _textureFormatInUse: string;
  53460. /**
  53461. * Gets the list of texture formats supported
  53462. */
  53463. readonly texturesSupported: Array<string>;
  53464. /**
  53465. * Gets the texture format in use
  53466. */
  53467. readonly textureFormatInUse: Nullable<string>;
  53468. /**
  53469. * Set the compressed texture extensions or file names to skip.
  53470. *
  53471. * @param skippedFiles defines the list of those texture files you want to skip
  53472. * Example: [".dds", ".env", "myfile.png"]
  53473. */
  53474. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  53475. /**
  53476. * Set the compressed texture format to use, based on the formats you have, and the formats
  53477. * supported by the hardware / browser.
  53478. *
  53479. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  53480. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  53481. * to API arguments needed to compressed textures. This puts the burden on the container
  53482. * generator to house the arcane code for determining these for current & future formats.
  53483. *
  53484. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  53485. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  53486. *
  53487. * Note: The result of this call is not taken into account when a texture is base64.
  53488. *
  53489. * @param formatsAvailable defines the list of those format families you have created
  53490. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  53491. *
  53492. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  53493. * @returns The extension selected.
  53494. */
  53495. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  53496. }
  53497. }
  53498. }
  53499. declare module "babylonjs/Engines/Extensions/index" {
  53500. export * from "babylonjs/Engines/Extensions/engine.alpha";
  53501. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  53502. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  53503. export * from "babylonjs/Engines/Extensions/engine.multiview";
  53504. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  53505. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  53506. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  53507. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  53508. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  53509. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  53510. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53511. export * from "babylonjs/Engines/Extensions/engine.webVR";
  53512. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  53513. export * from "babylonjs/Engines/Extensions/engine.views";
  53514. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  53515. import "babylonjs/Engines/Extensions/engine.textureSelector";
  53516. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  53517. }
  53518. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  53519. import { Nullable } from "babylonjs/types";
  53520. /**
  53521. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  53522. */
  53523. export interface CubeMapInfo {
  53524. /**
  53525. * The pixel array for the front face.
  53526. * This is stored in format, left to right, up to down format.
  53527. */
  53528. front: Nullable<ArrayBufferView>;
  53529. /**
  53530. * The pixel array for the back face.
  53531. * This is stored in format, left to right, up to down format.
  53532. */
  53533. back: Nullable<ArrayBufferView>;
  53534. /**
  53535. * The pixel array for the left face.
  53536. * This is stored in format, left to right, up to down format.
  53537. */
  53538. left: Nullable<ArrayBufferView>;
  53539. /**
  53540. * The pixel array for the right face.
  53541. * This is stored in format, left to right, up to down format.
  53542. */
  53543. right: Nullable<ArrayBufferView>;
  53544. /**
  53545. * The pixel array for the up face.
  53546. * This is stored in format, left to right, up to down format.
  53547. */
  53548. up: Nullable<ArrayBufferView>;
  53549. /**
  53550. * The pixel array for the down face.
  53551. * This is stored in format, left to right, up to down format.
  53552. */
  53553. down: Nullable<ArrayBufferView>;
  53554. /**
  53555. * The size of the cubemap stored.
  53556. *
  53557. * Each faces will be size * size pixels.
  53558. */
  53559. size: number;
  53560. /**
  53561. * The format of the texture.
  53562. *
  53563. * RGBA, RGB.
  53564. */
  53565. format: number;
  53566. /**
  53567. * The type of the texture data.
  53568. *
  53569. * UNSIGNED_INT, FLOAT.
  53570. */
  53571. type: number;
  53572. /**
  53573. * Specifies whether the texture is in gamma space.
  53574. */
  53575. gammaSpace: boolean;
  53576. }
  53577. /**
  53578. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  53579. */
  53580. export class PanoramaToCubeMapTools {
  53581. private static FACE_LEFT;
  53582. private static FACE_RIGHT;
  53583. private static FACE_FRONT;
  53584. private static FACE_BACK;
  53585. private static FACE_DOWN;
  53586. private static FACE_UP;
  53587. /**
  53588. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  53589. *
  53590. * @param float32Array The source data.
  53591. * @param inputWidth The width of the input panorama.
  53592. * @param inputHeight The height of the input panorama.
  53593. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  53594. * @return The cubemap data
  53595. */
  53596. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  53597. private static CreateCubemapTexture;
  53598. private static CalcProjectionSpherical;
  53599. }
  53600. }
  53601. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  53602. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53603. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53604. import { Nullable } from "babylonjs/types";
  53605. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53606. /**
  53607. * Helper class dealing with the extraction of spherical polynomial dataArray
  53608. * from a cube map.
  53609. */
  53610. export class CubeMapToSphericalPolynomialTools {
  53611. private static FileFaces;
  53612. /**
  53613. * Converts a texture to the according Spherical Polynomial data.
  53614. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53615. *
  53616. * @param texture The texture to extract the information from.
  53617. * @return The Spherical Polynomial data.
  53618. */
  53619. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  53620. /**
  53621. * Converts a cubemap to the according Spherical Polynomial data.
  53622. * This extracts the first 3 orders only as they are the only one used in the lighting.
  53623. *
  53624. * @param cubeInfo The Cube map to extract the information from.
  53625. * @return The Spherical Polynomial data.
  53626. */
  53627. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  53628. }
  53629. }
  53630. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  53631. import { Nullable } from "babylonjs/types";
  53632. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53633. module "babylonjs/Materials/Textures/baseTexture" {
  53634. interface BaseTexture {
  53635. /**
  53636. * Get the polynomial representation of the texture data.
  53637. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  53638. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  53639. */
  53640. sphericalPolynomial: Nullable<SphericalPolynomial>;
  53641. }
  53642. }
  53643. }
  53644. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  53645. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53646. /** @hidden */
  53647. export var rgbdEncodePixelShader: {
  53648. name: string;
  53649. shader: string;
  53650. };
  53651. }
  53652. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  53653. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53654. /** @hidden */
  53655. export var rgbdDecodePixelShader: {
  53656. name: string;
  53657. shader: string;
  53658. };
  53659. }
  53660. declare module "babylonjs/Misc/environmentTextureTools" {
  53661. import { Nullable } from "babylonjs/types";
  53662. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  53663. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53664. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53665. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  53666. import "babylonjs/Engines/Extensions/engine.readTexture";
  53667. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53668. import "babylonjs/Shaders/rgbdEncode.fragment";
  53669. import "babylonjs/Shaders/rgbdDecode.fragment";
  53670. /**
  53671. * Raw texture data and descriptor sufficient for WebGL texture upload
  53672. */
  53673. export interface EnvironmentTextureInfo {
  53674. /**
  53675. * Version of the environment map
  53676. */
  53677. version: number;
  53678. /**
  53679. * Width of image
  53680. */
  53681. width: number;
  53682. /**
  53683. * Irradiance information stored in the file.
  53684. */
  53685. irradiance: any;
  53686. /**
  53687. * Specular information stored in the file.
  53688. */
  53689. specular: any;
  53690. }
  53691. /**
  53692. * Defines One Image in the file. It requires only the position in the file
  53693. * as well as the length.
  53694. */
  53695. interface BufferImageData {
  53696. /**
  53697. * Length of the image data.
  53698. */
  53699. length: number;
  53700. /**
  53701. * Position of the data from the null terminator delimiting the end of the JSON.
  53702. */
  53703. position: number;
  53704. }
  53705. /**
  53706. * Defines the specular data enclosed in the file.
  53707. * This corresponds to the version 1 of the data.
  53708. */
  53709. export interface EnvironmentTextureSpecularInfoV1 {
  53710. /**
  53711. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  53712. */
  53713. specularDataPosition?: number;
  53714. /**
  53715. * This contains all the images data needed to reconstruct the cubemap.
  53716. */
  53717. mipmaps: Array<BufferImageData>;
  53718. /**
  53719. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  53720. */
  53721. lodGenerationScale: number;
  53722. }
  53723. /**
  53724. * Sets of helpers addressing the serialization and deserialization of environment texture
  53725. * stored in a BabylonJS env file.
  53726. * Those files are usually stored as .env files.
  53727. */
  53728. export class EnvironmentTextureTools {
  53729. /**
  53730. * Magic number identifying the env file.
  53731. */
  53732. private static _MagicBytes;
  53733. /**
  53734. * Gets the environment info from an env file.
  53735. * @param data The array buffer containing the .env bytes.
  53736. * @returns the environment file info (the json header) if successfully parsed.
  53737. */
  53738. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  53739. /**
  53740. * Creates an environment texture from a loaded cube texture.
  53741. * @param texture defines the cube texture to convert in env file
  53742. * @return a promise containing the environment data if succesfull.
  53743. */
  53744. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  53745. /**
  53746. * Creates a JSON representation of the spherical data.
  53747. * @param texture defines the texture containing the polynomials
  53748. * @return the JSON representation of the spherical info
  53749. */
  53750. private static _CreateEnvTextureIrradiance;
  53751. /**
  53752. * Creates the ArrayBufferViews used for initializing environment texture image data.
  53753. * @param data the image data
  53754. * @param info parameters that determine what views will be created for accessing the underlying buffer
  53755. * @return the views described by info providing access to the underlying buffer
  53756. */
  53757. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  53758. /**
  53759. * Uploads the texture info contained in the env file to the GPU.
  53760. * @param texture defines the internal texture to upload to
  53761. * @param data defines the data to load
  53762. * @param info defines the texture info retrieved through the GetEnvInfo method
  53763. * @returns a promise
  53764. */
  53765. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  53766. private static _OnImageReadyAsync;
  53767. /**
  53768. * Uploads the levels of image data to the GPU.
  53769. * @param texture defines the internal texture to upload to
  53770. * @param imageData defines the array buffer views of image data [mipmap][face]
  53771. * @returns a promise
  53772. */
  53773. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  53774. /**
  53775. * Uploads spherical polynomials information to the texture.
  53776. * @param texture defines the texture we are trying to upload the information to
  53777. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  53778. */
  53779. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  53780. /** @hidden */
  53781. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  53782. }
  53783. }
  53784. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  53785. /**
  53786. * Class used to inline functions in shader code
  53787. */
  53788. export class ShaderCodeInliner {
  53789. private static readonly _RegexpFindFunctionNameAndType;
  53790. private _sourceCode;
  53791. private _functionDescr;
  53792. private _numMaxIterations;
  53793. /** Gets or sets the token used to mark the functions to inline */
  53794. inlineToken: string;
  53795. /** Gets or sets the debug mode */
  53796. debug: boolean;
  53797. /** Gets the code after the inlining process */
  53798. get code(): string;
  53799. /**
  53800. * Initializes the inliner
  53801. * @param sourceCode shader code source to inline
  53802. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  53803. */
  53804. constructor(sourceCode: string, numMaxIterations?: number);
  53805. /**
  53806. * Start the processing of the shader code
  53807. */
  53808. processCode(): void;
  53809. private _collectFunctions;
  53810. private _processInlining;
  53811. private _extractBetweenMarkers;
  53812. private _skipWhitespaces;
  53813. private _removeComments;
  53814. private _replaceFunctionCallsByCode;
  53815. private _findBackward;
  53816. private _escapeRegExp;
  53817. private _replaceNames;
  53818. }
  53819. }
  53820. declare module "babylonjs/Engines/nativeEngine" {
  53821. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  53822. import { Engine } from "babylonjs/Engines/engine";
  53823. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53824. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53825. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53826. import { Effect } from "babylonjs/Materials/effect";
  53827. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53828. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  53829. import { IColor4Like } from "babylonjs/Maths/math.like";
  53830. import { Scene } from "babylonjs/scene";
  53831. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53832. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53833. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53834. /**
  53835. * Container for accessors for natively-stored mesh data buffers.
  53836. */
  53837. class NativeDataBuffer extends DataBuffer {
  53838. /**
  53839. * Accessor value used to identify/retrieve a natively-stored index buffer.
  53840. */
  53841. nativeIndexBuffer?: any;
  53842. /**
  53843. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  53844. */
  53845. nativeVertexBuffer?: any;
  53846. }
  53847. /** @hidden */
  53848. class NativeTexture extends InternalTexture {
  53849. getInternalTexture(): InternalTexture;
  53850. getViewCount(): number;
  53851. }
  53852. /** @hidden */
  53853. export class NativeEngine extends Engine {
  53854. private readonly _native;
  53855. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  53856. private readonly INVALID_HANDLE;
  53857. getHardwareScalingLevel(): number;
  53858. constructor();
  53859. dispose(): void;
  53860. /**
  53861. * Can be used to override the current requestAnimationFrame requester.
  53862. * @hidden
  53863. */
  53864. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  53865. /**
  53866. * Override default engine behavior.
  53867. * @param color
  53868. * @param backBuffer
  53869. * @param depth
  53870. * @param stencil
  53871. */
  53872. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  53873. /**
  53874. * Gets host document
  53875. * @returns the host document object
  53876. */
  53877. getHostDocument(): Nullable<Document>;
  53878. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  53879. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  53880. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  53881. recordVertexArrayObject(vertexBuffers: {
  53882. [key: string]: VertexBuffer;
  53883. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  53884. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53885. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  53886. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  53887. /**
  53888. * Draw a list of indexed primitives
  53889. * @param fillMode defines the primitive to use
  53890. * @param indexStart defines the starting index
  53891. * @param indexCount defines the number of index to draw
  53892. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53893. */
  53894. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  53895. /**
  53896. * Draw a list of unindexed primitives
  53897. * @param fillMode defines the primitive to use
  53898. * @param verticesStart defines the index of first vertex to draw
  53899. * @param verticesCount defines the count of vertices to draw
  53900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  53901. */
  53902. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  53903. createPipelineContext(): IPipelineContext;
  53904. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  53905. /** @hidden */
  53906. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  53907. /** @hidden */
  53908. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  53909. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53910. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  53911. protected _setProgram(program: WebGLProgram): void;
  53912. _releaseEffect(effect: Effect): void;
  53913. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  53914. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  53915. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  53916. bindSamplers(effect: Effect): void;
  53917. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  53918. getRenderWidth(useScreen?: boolean): number;
  53919. getRenderHeight(useScreen?: boolean): number;
  53920. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  53921. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  53922. /**
  53923. * Set the z offset to apply to current rendering
  53924. * @param value defines the offset to apply
  53925. */
  53926. setZOffset(value: number): void;
  53927. /**
  53928. * Gets the current value of the zOffset
  53929. * @returns the current zOffset state
  53930. */
  53931. getZOffset(): number;
  53932. /**
  53933. * Enable or disable depth buffering
  53934. * @param enable defines the state to set
  53935. */
  53936. setDepthBuffer(enable: boolean): void;
  53937. /**
  53938. * Gets a boolean indicating if depth writing is enabled
  53939. * @returns the current depth writing state
  53940. */
  53941. getDepthWrite(): boolean;
  53942. /**
  53943. * Enable or disable depth writing
  53944. * @param enable defines the state to set
  53945. */
  53946. setDepthWrite(enable: boolean): void;
  53947. /**
  53948. * Enable or disable color writing
  53949. * @param enable defines the state to set
  53950. */
  53951. setColorWrite(enable: boolean): void;
  53952. /**
  53953. * Gets a boolean indicating if color writing is enabled
  53954. * @returns the current color writing state
  53955. */
  53956. getColorWrite(): boolean;
  53957. /**
  53958. * Sets alpha constants used by some alpha blending modes
  53959. * @param r defines the red component
  53960. * @param g defines the green component
  53961. * @param b defines the blue component
  53962. * @param a defines the alpha component
  53963. */
  53964. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  53965. /**
  53966. * Sets the current alpha mode
  53967. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  53968. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  53969. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53970. */
  53971. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  53972. /**
  53973. * Gets the current alpha mode
  53974. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  53975. * @returns the current alpha mode
  53976. */
  53977. getAlphaMode(): number;
  53978. setInt(uniform: WebGLUniformLocation, int: number): void;
  53979. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  53980. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  53981. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  53982. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  53983. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  53984. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  53985. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  53986. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  53987. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  53988. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  53989. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  53990. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  53991. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  53992. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53993. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  53994. setFloat(uniform: WebGLUniformLocation, value: number): void;
  53995. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  53996. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  53997. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  53998. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  53999. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  54000. wipeCaches(bruteForce?: boolean): void;
  54001. _createTexture(): WebGLTexture;
  54002. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  54003. /**
  54004. * Usually called from Texture.ts.
  54005. * Passed information to create a WebGLTexture
  54006. * @param url defines a value which contains one of the following:
  54007. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54008. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54009. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54010. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54011. * @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)
  54012. * @param scene needed for loading to the correct scene
  54013. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54014. * @param onLoad optional callback to be called upon successful completion
  54015. * @param onError optional callback to be called upon failure
  54016. * @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
  54017. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54018. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54019. * @param forcedExtension defines the extension to use to pick the right loader
  54020. * @param mimeType defines an optional mime type
  54021. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54022. */
  54023. 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;
  54024. /**
  54025. * Creates a cube texture
  54026. * @param rootUrl defines the url where the files to load is located
  54027. * @param scene defines the current scene
  54028. * @param files defines the list of files to load (1 per face)
  54029. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  54030. * @param onLoad defines an optional callback raised when the texture is loaded
  54031. * @param onError defines an optional callback raised if there is an issue to load the texture
  54032. * @param format defines the format of the data
  54033. * @param forcedExtension defines the extension to use to pick the right loader
  54034. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  54035. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54036. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54037. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  54038. * @returns the cube texture as an InternalTexture
  54039. */
  54040. 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;
  54041. private _getSamplingFilter;
  54042. private static _GetNativeTextureFormat;
  54043. createRenderTargetTexture(size: number | {
  54044. width: number;
  54045. height: number;
  54046. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  54047. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54048. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54049. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54050. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  54051. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  54052. /**
  54053. * Updates a dynamic vertex buffer.
  54054. * @param vertexBuffer the vertex buffer to update
  54055. * @param data the data used to update the vertex buffer
  54056. * @param byteOffset the byte offset of the data (optional)
  54057. * @param byteLength the byte length of the data (optional)
  54058. */
  54059. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  54060. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  54061. private _updateAnisotropicLevel;
  54062. private _getAddressMode;
  54063. /** @hidden */
  54064. _bindTexture(channel: number, texture: InternalTexture): void;
  54065. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  54066. releaseEffects(): void;
  54067. /** @hidden */
  54068. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54069. /** @hidden */
  54070. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54071. /** @hidden */
  54072. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54073. /** @hidden */
  54074. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54075. }
  54076. }
  54077. declare module "babylonjs/Engines/index" {
  54078. export * from "babylonjs/Engines/constants";
  54079. export * from "babylonjs/Engines/engineCapabilities";
  54080. export * from "babylonjs/Engines/instancingAttributeInfo";
  54081. export * from "babylonjs/Engines/thinEngine";
  54082. export * from "babylonjs/Engines/engine";
  54083. export * from "babylonjs/Engines/engineStore";
  54084. export * from "babylonjs/Engines/nullEngine";
  54085. export * from "babylonjs/Engines/Extensions/index";
  54086. export * from "babylonjs/Engines/IPipelineContext";
  54087. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  54088. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  54089. export * from "babylonjs/Engines/nativeEngine";
  54090. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  54091. }
  54092. declare module "babylonjs/Events/clipboardEvents" {
  54093. /**
  54094. * Gather the list of clipboard event types as constants.
  54095. */
  54096. export class ClipboardEventTypes {
  54097. /**
  54098. * The clipboard event is fired when a copy command is active (pressed).
  54099. */
  54100. static readonly COPY: number;
  54101. /**
  54102. * The clipboard event is fired when a cut command is active (pressed).
  54103. */
  54104. static readonly CUT: number;
  54105. /**
  54106. * The clipboard event is fired when a paste command is active (pressed).
  54107. */
  54108. static readonly PASTE: number;
  54109. }
  54110. /**
  54111. * This class is used to store clipboard related info for the onClipboardObservable event.
  54112. */
  54113. export class ClipboardInfo {
  54114. /**
  54115. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54116. */
  54117. type: number;
  54118. /**
  54119. * Defines the related dom event
  54120. */
  54121. event: ClipboardEvent;
  54122. /**
  54123. *Creates an instance of ClipboardInfo.
  54124. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  54125. * @param event Defines the related dom event
  54126. */
  54127. constructor(
  54128. /**
  54129. * Defines the type of event (BABYLON.ClipboardEventTypes)
  54130. */
  54131. type: number,
  54132. /**
  54133. * Defines the related dom event
  54134. */
  54135. event: ClipboardEvent);
  54136. /**
  54137. * Get the clipboard event's type from the keycode.
  54138. * @param keyCode Defines the keyCode for the current keyboard event.
  54139. * @return {number}
  54140. */
  54141. static GetTypeFromCharacter(keyCode: number): number;
  54142. }
  54143. }
  54144. declare module "babylonjs/Events/index" {
  54145. export * from "babylonjs/Events/keyboardEvents";
  54146. export * from "babylonjs/Events/pointerEvents";
  54147. export * from "babylonjs/Events/clipboardEvents";
  54148. }
  54149. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  54150. import { Scene } from "babylonjs/scene";
  54151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54152. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54153. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54154. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54155. /**
  54156. * Google Daydream controller
  54157. */
  54158. export class DaydreamController extends WebVRController {
  54159. /**
  54160. * Base Url for the controller model.
  54161. */
  54162. static MODEL_BASE_URL: string;
  54163. /**
  54164. * File name for the controller model.
  54165. */
  54166. static MODEL_FILENAME: string;
  54167. /**
  54168. * Gamepad Id prefix used to identify Daydream Controller.
  54169. */
  54170. static readonly GAMEPAD_ID_PREFIX: string;
  54171. /**
  54172. * Creates a new DaydreamController from a gamepad
  54173. * @param vrGamepad the gamepad that the controller should be created from
  54174. */
  54175. constructor(vrGamepad: any);
  54176. /**
  54177. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54178. * @param scene scene in which to add meshes
  54179. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54180. */
  54181. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54182. /**
  54183. * Called once for each button that changed state since the last frame
  54184. * @param buttonIdx Which button index changed
  54185. * @param state New state of the button
  54186. * @param changes Which properties on the state changed since last frame
  54187. */
  54188. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54189. }
  54190. }
  54191. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  54192. import { Scene } from "babylonjs/scene";
  54193. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54194. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54195. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54196. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54197. /**
  54198. * Gear VR Controller
  54199. */
  54200. export class GearVRController extends WebVRController {
  54201. /**
  54202. * Base Url for the controller model.
  54203. */
  54204. static MODEL_BASE_URL: string;
  54205. /**
  54206. * File name for the controller model.
  54207. */
  54208. static MODEL_FILENAME: string;
  54209. /**
  54210. * Gamepad Id prefix used to identify this controller.
  54211. */
  54212. static readonly GAMEPAD_ID_PREFIX: string;
  54213. private readonly _buttonIndexToObservableNameMap;
  54214. /**
  54215. * Creates a new GearVRController from a gamepad
  54216. * @param vrGamepad the gamepad that the controller should be created from
  54217. */
  54218. constructor(vrGamepad: any);
  54219. /**
  54220. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54221. * @param scene scene in which to add meshes
  54222. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54223. */
  54224. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54225. /**
  54226. * Called once for each button that changed state since the last frame
  54227. * @param buttonIdx Which button index changed
  54228. * @param state New state of the button
  54229. * @param changes Which properties on the state changed since last frame
  54230. */
  54231. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54232. }
  54233. }
  54234. declare module "babylonjs/Gamepads/Controllers/genericController" {
  54235. import { Scene } from "babylonjs/scene";
  54236. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54237. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54238. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54239. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54240. /**
  54241. * Generic Controller
  54242. */
  54243. export class GenericController extends WebVRController {
  54244. /**
  54245. * Base Url for the controller model.
  54246. */
  54247. static readonly MODEL_BASE_URL: string;
  54248. /**
  54249. * File name for the controller model.
  54250. */
  54251. static readonly MODEL_FILENAME: string;
  54252. /**
  54253. * Creates a new GenericController from a gamepad
  54254. * @param vrGamepad the gamepad that the controller should be created from
  54255. */
  54256. constructor(vrGamepad: any);
  54257. /**
  54258. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54259. * @param scene scene in which to add meshes
  54260. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54261. */
  54262. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54263. /**
  54264. * Called once for each button that changed state since the last frame
  54265. * @param buttonIdx Which button index changed
  54266. * @param state New state of the button
  54267. * @param changes Which properties on the state changed since last frame
  54268. */
  54269. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54270. }
  54271. }
  54272. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  54273. import { Observable } from "babylonjs/Misc/observable";
  54274. import { Scene } from "babylonjs/scene";
  54275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54276. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54277. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54278. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54279. /**
  54280. * Oculus Touch Controller
  54281. */
  54282. export class OculusTouchController extends WebVRController {
  54283. /**
  54284. * Base Url for the controller model.
  54285. */
  54286. static MODEL_BASE_URL: string;
  54287. /**
  54288. * File name for the left controller model.
  54289. */
  54290. static MODEL_LEFT_FILENAME: string;
  54291. /**
  54292. * File name for the right controller model.
  54293. */
  54294. static MODEL_RIGHT_FILENAME: string;
  54295. /**
  54296. * Base Url for the Quest controller model.
  54297. */
  54298. static QUEST_MODEL_BASE_URL: string;
  54299. /**
  54300. * @hidden
  54301. * If the controllers are running on a device that needs the updated Quest controller models
  54302. */
  54303. static _IsQuest: boolean;
  54304. /**
  54305. * Fired when the secondary trigger on this controller is modified
  54306. */
  54307. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  54308. /**
  54309. * Fired when the thumb rest on this controller is modified
  54310. */
  54311. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  54312. /**
  54313. * Creates a new OculusTouchController from a gamepad
  54314. * @param vrGamepad the gamepad that the controller should be created from
  54315. */
  54316. constructor(vrGamepad: any);
  54317. /**
  54318. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54319. * @param scene scene in which to add meshes
  54320. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54321. */
  54322. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54323. /**
  54324. * Fired when the A button on this controller is modified
  54325. */
  54326. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54327. /**
  54328. * Fired when the B button on this controller is modified
  54329. */
  54330. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54331. /**
  54332. * Fired when the X button on this controller is modified
  54333. */
  54334. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54335. /**
  54336. * Fired when the Y button on this controller is modified
  54337. */
  54338. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54339. /**
  54340. * Called once for each button that changed state since the last frame
  54341. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  54342. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  54343. * 2) secondary trigger (same)
  54344. * 3) A (right) X (left), touch, pressed = value
  54345. * 4) B / Y
  54346. * 5) thumb rest
  54347. * @param buttonIdx Which button index changed
  54348. * @param state New state of the button
  54349. * @param changes Which properties on the state changed since last frame
  54350. */
  54351. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54352. }
  54353. }
  54354. declare module "babylonjs/Gamepads/Controllers/viveController" {
  54355. import { Scene } from "babylonjs/scene";
  54356. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54357. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54358. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54359. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54360. import { Observable } from "babylonjs/Misc/observable";
  54361. /**
  54362. * Vive Controller
  54363. */
  54364. export class ViveController extends WebVRController {
  54365. /**
  54366. * Base Url for the controller model.
  54367. */
  54368. static MODEL_BASE_URL: string;
  54369. /**
  54370. * File name for the controller model.
  54371. */
  54372. static MODEL_FILENAME: string;
  54373. /**
  54374. * Creates a new ViveController from a gamepad
  54375. * @param vrGamepad the gamepad that the controller should be created from
  54376. */
  54377. constructor(vrGamepad: any);
  54378. /**
  54379. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54380. * @param scene scene in which to add meshes
  54381. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54382. */
  54383. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  54384. /**
  54385. * Fired when the left button on this controller is modified
  54386. */
  54387. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54388. /**
  54389. * Fired when the right button on this controller is modified
  54390. */
  54391. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54392. /**
  54393. * Fired when the menu button on this controller is modified
  54394. */
  54395. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54396. /**
  54397. * Called once for each button that changed state since the last frame
  54398. * Vive mapping:
  54399. * 0: touchpad
  54400. * 1: trigger
  54401. * 2: left AND right buttons
  54402. * 3: menu button
  54403. * @param buttonIdx Which button index changed
  54404. * @param state New state of the button
  54405. * @param changes Which properties on the state changed since last frame
  54406. */
  54407. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54408. }
  54409. }
  54410. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  54411. import { Observable } from "babylonjs/Misc/observable";
  54412. import { Scene } from "babylonjs/scene";
  54413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54414. import { Ray } from "babylonjs/Culling/ray";
  54415. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  54416. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54417. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  54418. /**
  54419. * Defines the WindowsMotionController object that the state of the windows motion controller
  54420. */
  54421. export class WindowsMotionController extends WebVRController {
  54422. /**
  54423. * The base url used to load the left and right controller models
  54424. */
  54425. static MODEL_BASE_URL: string;
  54426. /**
  54427. * The name of the left controller model file
  54428. */
  54429. static MODEL_LEFT_FILENAME: string;
  54430. /**
  54431. * The name of the right controller model file
  54432. */
  54433. static MODEL_RIGHT_FILENAME: string;
  54434. /**
  54435. * The controller name prefix for this controller type
  54436. */
  54437. static readonly GAMEPAD_ID_PREFIX: string;
  54438. /**
  54439. * The controller id pattern for this controller type
  54440. */
  54441. private static readonly GAMEPAD_ID_PATTERN;
  54442. private _loadedMeshInfo;
  54443. protected readonly _mapping: {
  54444. buttons: string[];
  54445. buttonMeshNames: {
  54446. trigger: string;
  54447. menu: string;
  54448. grip: string;
  54449. thumbstick: string;
  54450. trackpad: string;
  54451. };
  54452. buttonObservableNames: {
  54453. trigger: string;
  54454. menu: string;
  54455. grip: string;
  54456. thumbstick: string;
  54457. trackpad: string;
  54458. };
  54459. axisMeshNames: string[];
  54460. pointingPoseMeshName: string;
  54461. };
  54462. /**
  54463. * Fired when the trackpad on this controller is clicked
  54464. */
  54465. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54466. /**
  54467. * Fired when the trackpad on this controller is modified
  54468. */
  54469. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54470. /**
  54471. * The current x and y values of this controller's trackpad
  54472. */
  54473. trackpad: StickValues;
  54474. /**
  54475. * Creates a new WindowsMotionController from a gamepad
  54476. * @param vrGamepad the gamepad that the controller should be created from
  54477. */
  54478. constructor(vrGamepad: any);
  54479. /**
  54480. * Fired when the trigger on this controller is modified
  54481. */
  54482. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54483. /**
  54484. * Fired when the menu button on this controller is modified
  54485. */
  54486. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54487. /**
  54488. * Fired when the grip button on this controller is modified
  54489. */
  54490. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54491. /**
  54492. * Fired when the thumbstick button on this controller is modified
  54493. */
  54494. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54495. /**
  54496. * Fired when the touchpad button on this controller is modified
  54497. */
  54498. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54499. /**
  54500. * Fired when the touchpad values on this controller are modified
  54501. */
  54502. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  54503. protected _updateTrackpad(): void;
  54504. /**
  54505. * Called once per frame by the engine.
  54506. */
  54507. update(): void;
  54508. /**
  54509. * Called once for each button that changed state since the last frame
  54510. * @param buttonIdx Which button index changed
  54511. * @param state New state of the button
  54512. * @param changes Which properties on the state changed since last frame
  54513. */
  54514. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  54515. /**
  54516. * Moves the buttons on the controller mesh based on their current state
  54517. * @param buttonName the name of the button to move
  54518. * @param buttonValue the value of the button which determines the buttons new position
  54519. */
  54520. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  54521. /**
  54522. * Moves the axis on the controller mesh based on its current state
  54523. * @param axis the index of the axis
  54524. * @param axisValue the value of the axis which determines the meshes new position
  54525. * @hidden
  54526. */
  54527. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  54528. /**
  54529. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  54530. * @param scene scene in which to add meshes
  54531. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  54532. */
  54533. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  54534. /**
  54535. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  54536. * can be transformed by button presses and axes values, based on this._mapping.
  54537. *
  54538. * @param scene scene in which the meshes exist
  54539. * @param meshes list of meshes that make up the controller model to process
  54540. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  54541. */
  54542. private processModel;
  54543. private createMeshInfo;
  54544. /**
  54545. * Gets the ray of the controller in the direction the controller is pointing
  54546. * @param length the length the resulting ray should be
  54547. * @returns a ray in the direction the controller is pointing
  54548. */
  54549. getForwardRay(length?: number): Ray;
  54550. /**
  54551. * Disposes of the controller
  54552. */
  54553. dispose(): void;
  54554. }
  54555. /**
  54556. * This class represents a new windows motion controller in XR.
  54557. */
  54558. export class XRWindowsMotionController extends WindowsMotionController {
  54559. /**
  54560. * Changing the original WIndowsMotionController mapping to fir the new mapping
  54561. */
  54562. protected readonly _mapping: {
  54563. buttons: string[];
  54564. buttonMeshNames: {
  54565. trigger: string;
  54566. menu: string;
  54567. grip: string;
  54568. thumbstick: string;
  54569. trackpad: string;
  54570. };
  54571. buttonObservableNames: {
  54572. trigger: string;
  54573. menu: string;
  54574. grip: string;
  54575. thumbstick: string;
  54576. trackpad: string;
  54577. };
  54578. axisMeshNames: string[];
  54579. pointingPoseMeshName: string;
  54580. };
  54581. /**
  54582. * Construct a new XR-Based windows motion controller
  54583. *
  54584. * @param gamepadInfo the gamepad object from the browser
  54585. */
  54586. constructor(gamepadInfo: any);
  54587. /**
  54588. * holds the thumbstick values (X,Y)
  54589. */
  54590. thumbstickValues: StickValues;
  54591. /**
  54592. * Fired when the thumbstick on this controller is clicked
  54593. */
  54594. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  54595. /**
  54596. * Fired when the thumbstick on this controller is modified
  54597. */
  54598. onThumbstickValuesChangedObservable: Observable<StickValues>;
  54599. /**
  54600. * Fired when the touchpad button on this controller is modified
  54601. */
  54602. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  54603. /**
  54604. * Fired when the touchpad values on this controller are modified
  54605. */
  54606. onTrackpadValuesChangedObservable: Observable<StickValues>;
  54607. /**
  54608. * Fired when the thumbstick button on this controller is modified
  54609. * here to prevent breaking changes
  54610. */
  54611. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  54612. /**
  54613. * updating the thumbstick(!) and not the trackpad.
  54614. * This is named this way due to the difference between WebVR and XR and to avoid
  54615. * changing the parent class.
  54616. */
  54617. protected _updateTrackpad(): void;
  54618. /**
  54619. * Disposes the class with joy
  54620. */
  54621. dispose(): void;
  54622. }
  54623. }
  54624. declare module "babylonjs/Gamepads/Controllers/index" {
  54625. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  54626. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  54627. export * from "babylonjs/Gamepads/Controllers/genericController";
  54628. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  54629. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  54630. export * from "babylonjs/Gamepads/Controllers/viveController";
  54631. export * from "babylonjs/Gamepads/Controllers/webVRController";
  54632. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  54633. }
  54634. declare module "babylonjs/Gamepads/index" {
  54635. export * from "babylonjs/Gamepads/Controllers/index";
  54636. export * from "babylonjs/Gamepads/gamepad";
  54637. export * from "babylonjs/Gamepads/gamepadManager";
  54638. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  54639. export * from "babylonjs/Gamepads/xboxGamepad";
  54640. export * from "babylonjs/Gamepads/dualShockGamepad";
  54641. }
  54642. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  54643. import { Scene } from "babylonjs/scene";
  54644. import { Vector4 } from "babylonjs/Maths/math.vector";
  54645. import { Color4 } from "babylonjs/Maths/math.color";
  54646. import { Mesh } from "babylonjs/Meshes/mesh";
  54647. import { Nullable } from "babylonjs/types";
  54648. /**
  54649. * Class containing static functions to help procedurally build meshes
  54650. */
  54651. export class PolyhedronBuilder {
  54652. /**
  54653. * Creates a polyhedron mesh
  54654. * * 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
  54655. * * The parameter `size` (positive float, default 1) sets the polygon size
  54656. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54657. * * 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`
  54658. * * 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
  54659. * * 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)`)
  54660. * * 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
  54661. * * 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
  54662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54665. * @param name defines the name of the mesh
  54666. * @param options defines the options used to create the mesh
  54667. * @param scene defines the hosting scene
  54668. * @returns the polyhedron mesh
  54669. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54670. */
  54671. static CreatePolyhedron(name: string, options: {
  54672. type?: number;
  54673. size?: number;
  54674. sizeX?: number;
  54675. sizeY?: number;
  54676. sizeZ?: number;
  54677. custom?: any;
  54678. faceUV?: Vector4[];
  54679. faceColors?: Color4[];
  54680. flat?: boolean;
  54681. updatable?: boolean;
  54682. sideOrientation?: number;
  54683. frontUVs?: Vector4;
  54684. backUVs?: Vector4;
  54685. }, scene?: Nullable<Scene>): Mesh;
  54686. }
  54687. }
  54688. declare module "babylonjs/Gizmos/scaleGizmo" {
  54689. import { Observable } from "babylonjs/Misc/observable";
  54690. import { Nullable } from "babylonjs/types";
  54691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54692. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54693. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  54694. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54695. /**
  54696. * Gizmo that enables scaling a mesh along 3 axis
  54697. */
  54698. export class ScaleGizmo extends Gizmo {
  54699. /**
  54700. * Internal gizmo used for interactions on the x axis
  54701. */
  54702. xGizmo: AxisScaleGizmo;
  54703. /**
  54704. * Internal gizmo used for interactions on the y axis
  54705. */
  54706. yGizmo: AxisScaleGizmo;
  54707. /**
  54708. * Internal gizmo used for interactions on the z axis
  54709. */
  54710. zGizmo: AxisScaleGizmo;
  54711. /**
  54712. * Internal gizmo used to scale all axis equally
  54713. */
  54714. uniformScaleGizmo: AxisScaleGizmo;
  54715. private _meshAttached;
  54716. private _updateGizmoRotationToMatchAttachedMesh;
  54717. private _snapDistance;
  54718. private _scaleRatio;
  54719. private _uniformScalingMesh;
  54720. private _octahedron;
  54721. private _sensitivity;
  54722. /** Fires an event when any of it's sub gizmos are dragged */
  54723. onDragStartObservable: Observable<unknown>;
  54724. /** Fires an event when any of it's sub gizmos are released from dragging */
  54725. onDragEndObservable: Observable<unknown>;
  54726. get attachedMesh(): Nullable<AbstractMesh>;
  54727. set attachedMesh(mesh: Nullable<AbstractMesh>);
  54728. /**
  54729. * Creates a ScaleGizmo
  54730. * @param gizmoLayer The utility layer the gizmo will be added to
  54731. */
  54732. constructor(gizmoLayer?: UtilityLayerRenderer);
  54733. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  54734. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  54735. /**
  54736. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54737. */
  54738. set snapDistance(value: number);
  54739. get snapDistance(): number;
  54740. /**
  54741. * Ratio for the scale of the gizmo (Default: 1)
  54742. */
  54743. set scaleRatio(value: number);
  54744. get scaleRatio(): number;
  54745. /**
  54746. * Sensitivity factor for dragging (Default: 1)
  54747. */
  54748. set sensitivity(value: number);
  54749. get sensitivity(): number;
  54750. /**
  54751. * Disposes of the gizmo
  54752. */
  54753. dispose(): void;
  54754. }
  54755. }
  54756. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  54757. import { Observable } from "babylonjs/Misc/observable";
  54758. import { Nullable } from "babylonjs/types";
  54759. import { Vector3 } from "babylonjs/Maths/math.vector";
  54760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54761. import { Mesh } from "babylonjs/Meshes/mesh";
  54762. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54763. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54764. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54765. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  54766. import { Color3 } from "babylonjs/Maths/math.color";
  54767. /**
  54768. * Single axis scale gizmo
  54769. */
  54770. export class AxisScaleGizmo extends Gizmo {
  54771. /**
  54772. * Drag behavior responsible for the gizmos dragging interactions
  54773. */
  54774. dragBehavior: PointerDragBehavior;
  54775. private _pointerObserver;
  54776. /**
  54777. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  54778. */
  54779. snapDistance: number;
  54780. /**
  54781. * Event that fires each time the gizmo snaps to a new location.
  54782. * * snapDistance is the the change in distance
  54783. */
  54784. onSnapObservable: Observable<{
  54785. snapDistance: number;
  54786. }>;
  54787. /**
  54788. * If the scaling operation should be done on all axis (default: false)
  54789. */
  54790. uniformScaling: boolean;
  54791. /**
  54792. * Custom sensitivity value for the drag strength
  54793. */
  54794. sensitivity: number;
  54795. private _isEnabled;
  54796. private _parent;
  54797. private _arrow;
  54798. private _coloredMaterial;
  54799. private _hoverMaterial;
  54800. /**
  54801. * Creates an AxisScaleGizmo
  54802. * @param gizmoLayer The utility layer the gizmo will be added to
  54803. * @param dragAxis The axis which the gizmo will be able to scale on
  54804. * @param color The color of the gizmo
  54805. */
  54806. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  54807. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54808. /**
  54809. * If the gizmo is enabled
  54810. */
  54811. set isEnabled(value: boolean);
  54812. get isEnabled(): boolean;
  54813. /**
  54814. * Disposes of the gizmo
  54815. */
  54816. dispose(): void;
  54817. /**
  54818. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  54819. * @param mesh The mesh to replace the default mesh of the gizmo
  54820. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  54821. */
  54822. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  54823. }
  54824. }
  54825. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  54826. import { Observable } from "babylonjs/Misc/observable";
  54827. import { Nullable } from "babylonjs/types";
  54828. import { Vector3 } from "babylonjs/Maths/math.vector";
  54829. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54830. import { Mesh } from "babylonjs/Meshes/mesh";
  54831. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54832. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54833. import { Color3 } from "babylonjs/Maths/math.color";
  54834. import "babylonjs/Meshes/Builders/boxBuilder";
  54835. /**
  54836. * Bounding box gizmo
  54837. */
  54838. export class BoundingBoxGizmo extends Gizmo {
  54839. private _lineBoundingBox;
  54840. private _rotateSpheresParent;
  54841. private _scaleBoxesParent;
  54842. private _boundingDimensions;
  54843. private _renderObserver;
  54844. private _pointerObserver;
  54845. private _scaleDragSpeed;
  54846. private _tmpQuaternion;
  54847. private _tmpVector;
  54848. private _tmpRotationMatrix;
  54849. /**
  54850. * 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)
  54851. */
  54852. ignoreChildren: boolean;
  54853. /**
  54854. * 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)
  54855. */
  54856. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  54857. /**
  54858. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  54859. */
  54860. rotationSphereSize: number;
  54861. /**
  54862. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  54863. */
  54864. scaleBoxSize: number;
  54865. /**
  54866. * 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)
  54867. */
  54868. fixedDragMeshScreenSize: boolean;
  54869. /**
  54870. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  54871. */
  54872. fixedDragMeshScreenSizeDistanceFactor: number;
  54873. /**
  54874. * Fired when a rotation sphere or scale box is dragged
  54875. */
  54876. onDragStartObservable: Observable<{}>;
  54877. /**
  54878. * Fired when a scale box is dragged
  54879. */
  54880. onScaleBoxDragObservable: Observable<{}>;
  54881. /**
  54882. * Fired when a scale box drag is ended
  54883. */
  54884. onScaleBoxDragEndObservable: Observable<{}>;
  54885. /**
  54886. * Fired when a rotation sphere is dragged
  54887. */
  54888. onRotationSphereDragObservable: Observable<{}>;
  54889. /**
  54890. * Fired when a rotation sphere drag is ended
  54891. */
  54892. onRotationSphereDragEndObservable: Observable<{}>;
  54893. /**
  54894. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  54895. */
  54896. scalePivot: Nullable<Vector3>;
  54897. /**
  54898. * Mesh used as a pivot to rotate the attached mesh
  54899. */
  54900. private _anchorMesh;
  54901. private _existingMeshScale;
  54902. private _dragMesh;
  54903. private pointerDragBehavior;
  54904. private coloredMaterial;
  54905. private hoverColoredMaterial;
  54906. /**
  54907. * Sets the color of the bounding box gizmo
  54908. * @param color the color to set
  54909. */
  54910. setColor(color: Color3): void;
  54911. /**
  54912. * Creates an BoundingBoxGizmo
  54913. * @param gizmoLayer The utility layer the gizmo will be added to
  54914. * @param color The color of the gizmo
  54915. */
  54916. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  54917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  54918. private _selectNode;
  54919. /**
  54920. * Updates the bounding box information for the Gizmo
  54921. */
  54922. updateBoundingBox(): void;
  54923. private _updateRotationSpheres;
  54924. private _updateScaleBoxes;
  54925. /**
  54926. * Enables rotation on the specified axis and disables rotation on the others
  54927. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  54928. */
  54929. setEnabledRotationAxis(axis: string): void;
  54930. /**
  54931. * Enables/disables scaling
  54932. * @param enable if scaling should be enabled
  54933. * @param homogeneousScaling defines if scaling should only be homogeneous
  54934. */
  54935. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  54936. private _updateDummy;
  54937. /**
  54938. * Enables a pointer drag behavior on the bounding box of the gizmo
  54939. */
  54940. enableDragBehavior(): void;
  54941. /**
  54942. * Disposes of the gizmo
  54943. */
  54944. dispose(): void;
  54945. /**
  54946. * 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)
  54947. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  54948. * @returns the bounding box mesh with the passed in mesh as a child
  54949. */
  54950. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  54951. /**
  54952. * CustomMeshes are not supported by this gizmo
  54953. * @param mesh The mesh to replace the default mesh of the gizmo
  54954. */
  54955. setCustomMesh(mesh: Mesh): void;
  54956. }
  54957. }
  54958. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  54959. import { Observable } from "babylonjs/Misc/observable";
  54960. import { Nullable } from "babylonjs/types";
  54961. import { Vector3 } from "babylonjs/Maths/math.vector";
  54962. import { Color3 } from "babylonjs/Maths/math.color";
  54963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54964. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  54965. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  54966. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  54967. import "babylonjs/Meshes/Builders/linesBuilder";
  54968. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  54969. /**
  54970. * Single plane rotation gizmo
  54971. */
  54972. export class PlaneRotationGizmo extends Gizmo {
  54973. /**
  54974. * Drag behavior responsible for the gizmos dragging interactions
  54975. */
  54976. dragBehavior: PointerDragBehavior;
  54977. private _pointerObserver;
  54978. /**
  54979. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  54980. */
  54981. snapDistance: number;
  54982. /**
  54983. * Event that fires each time the gizmo snaps to a new location.
  54984. * * snapDistance is the the change in distance
  54985. */
  54986. onSnapObservable: Observable<{
  54987. snapDistance: number;
  54988. }>;
  54989. private _isEnabled;
  54990. private _parent;
  54991. /**
  54992. * Creates a PlaneRotationGizmo
  54993. * @param gizmoLayer The utility layer the gizmo will be added to
  54994. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  54995. * @param color The color of the gizmo
  54996. * @param tessellation Amount of tessellation to be used when creating rotation circles
  54997. * @param useEulerRotation Use and update Euler angle instead of quaternion
  54998. */
  54999. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  55000. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  55001. /**
  55002. * If the gizmo is enabled
  55003. */
  55004. set isEnabled(value: boolean);
  55005. get isEnabled(): boolean;
  55006. /**
  55007. * Disposes of the gizmo
  55008. */
  55009. dispose(): void;
  55010. }
  55011. }
  55012. declare module "babylonjs/Gizmos/rotationGizmo" {
  55013. import { Observable } from "babylonjs/Misc/observable";
  55014. import { Nullable } from "babylonjs/types";
  55015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55016. import { Mesh } from "babylonjs/Meshes/mesh";
  55017. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55018. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  55019. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55020. /**
  55021. * Gizmo that enables rotating a mesh along 3 axis
  55022. */
  55023. export class RotationGizmo extends Gizmo {
  55024. /**
  55025. * Internal gizmo used for interactions on the x axis
  55026. */
  55027. xGizmo: PlaneRotationGizmo;
  55028. /**
  55029. * Internal gizmo used for interactions on the y axis
  55030. */
  55031. yGizmo: PlaneRotationGizmo;
  55032. /**
  55033. * Internal gizmo used for interactions on the z axis
  55034. */
  55035. zGizmo: PlaneRotationGizmo;
  55036. /** Fires an event when any of it's sub gizmos are dragged */
  55037. onDragStartObservable: Observable<unknown>;
  55038. /** Fires an event when any of it's sub gizmos are released from dragging */
  55039. onDragEndObservable: Observable<unknown>;
  55040. private _meshAttached;
  55041. get attachedMesh(): Nullable<AbstractMesh>;
  55042. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55043. /**
  55044. * Creates a RotationGizmo
  55045. * @param gizmoLayer The utility layer the gizmo will be added to
  55046. * @param tessellation Amount of tessellation to be used when creating rotation circles
  55047. * @param useEulerRotation Use and update Euler angle instead of quaternion
  55048. */
  55049. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  55050. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55051. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55052. /**
  55053. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55054. */
  55055. set snapDistance(value: number);
  55056. get snapDistance(): number;
  55057. /**
  55058. * Ratio for the scale of the gizmo (Default: 1)
  55059. */
  55060. set scaleRatio(value: number);
  55061. get scaleRatio(): number;
  55062. /**
  55063. * Disposes of the gizmo
  55064. */
  55065. dispose(): void;
  55066. /**
  55067. * CustomMeshes are not supported by this gizmo
  55068. * @param mesh The mesh to replace the default mesh of the gizmo
  55069. */
  55070. setCustomMesh(mesh: Mesh): void;
  55071. }
  55072. }
  55073. declare module "babylonjs/Gizmos/gizmoManager" {
  55074. import { Observable } from "babylonjs/Misc/observable";
  55075. import { Nullable } from "babylonjs/types";
  55076. import { Scene, IDisposable } from "babylonjs/scene";
  55077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55078. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55079. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  55080. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  55081. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  55082. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55083. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  55084. /**
  55085. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  55086. */
  55087. export class GizmoManager implements IDisposable {
  55088. private scene;
  55089. /**
  55090. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  55091. */
  55092. gizmos: {
  55093. positionGizmo: Nullable<PositionGizmo>;
  55094. rotationGizmo: Nullable<RotationGizmo>;
  55095. scaleGizmo: Nullable<ScaleGizmo>;
  55096. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  55097. };
  55098. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  55099. clearGizmoOnEmptyPointerEvent: boolean;
  55100. /** Fires an event when the manager is attached to a mesh */
  55101. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  55102. private _gizmosEnabled;
  55103. private _pointerObserver;
  55104. private _attachedMesh;
  55105. private _boundingBoxColor;
  55106. private _defaultUtilityLayer;
  55107. private _defaultKeepDepthUtilityLayer;
  55108. /**
  55109. * When bounding box gizmo is enabled, this can be used to track drag/end events
  55110. */
  55111. boundingBoxDragBehavior: SixDofDragBehavior;
  55112. /**
  55113. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  55114. */
  55115. attachableMeshes: Nullable<Array<AbstractMesh>>;
  55116. /**
  55117. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  55118. */
  55119. usePointerToAttachGizmos: boolean;
  55120. /**
  55121. * Utility layer that the bounding box gizmo belongs to
  55122. */
  55123. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  55124. /**
  55125. * Utility layer that all gizmos besides bounding box belong to
  55126. */
  55127. get utilityLayer(): UtilityLayerRenderer;
  55128. /**
  55129. * Instatiates a gizmo manager
  55130. * @param scene the scene to overlay the gizmos on top of
  55131. */
  55132. constructor(scene: Scene);
  55133. /**
  55134. * Attaches a set of gizmos to the specified mesh
  55135. * @param mesh The mesh the gizmo's should be attached to
  55136. */
  55137. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  55138. /**
  55139. * If the position gizmo is enabled
  55140. */
  55141. set positionGizmoEnabled(value: boolean);
  55142. get positionGizmoEnabled(): boolean;
  55143. /**
  55144. * If the rotation gizmo is enabled
  55145. */
  55146. set rotationGizmoEnabled(value: boolean);
  55147. get rotationGizmoEnabled(): boolean;
  55148. /**
  55149. * If the scale gizmo is enabled
  55150. */
  55151. set scaleGizmoEnabled(value: boolean);
  55152. get scaleGizmoEnabled(): boolean;
  55153. /**
  55154. * If the boundingBox gizmo is enabled
  55155. */
  55156. set boundingBoxGizmoEnabled(value: boolean);
  55157. get boundingBoxGizmoEnabled(): boolean;
  55158. /**
  55159. * Disposes of the gizmo manager
  55160. */
  55161. dispose(): void;
  55162. }
  55163. }
  55164. declare module "babylonjs/Lights/directionalLight" {
  55165. import { Camera } from "babylonjs/Cameras/camera";
  55166. import { Scene } from "babylonjs/scene";
  55167. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55168. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55169. import { Light } from "babylonjs/Lights/light";
  55170. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55171. import { Effect } from "babylonjs/Materials/effect";
  55172. /**
  55173. * A directional light is defined by a direction (what a surprise!).
  55174. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  55175. * 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.
  55176. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55177. */
  55178. export class DirectionalLight extends ShadowLight {
  55179. private _shadowFrustumSize;
  55180. /**
  55181. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  55182. */
  55183. get shadowFrustumSize(): number;
  55184. /**
  55185. * Specifies a fix frustum size for the shadow generation.
  55186. */
  55187. set shadowFrustumSize(value: number);
  55188. private _shadowOrthoScale;
  55189. /**
  55190. * Gets the shadow projection scale against the optimal computed one.
  55191. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55192. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55193. */
  55194. get shadowOrthoScale(): number;
  55195. /**
  55196. * Sets the shadow projection scale against the optimal computed one.
  55197. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  55198. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  55199. */
  55200. set shadowOrthoScale(value: number);
  55201. /**
  55202. * Automatically compute the projection matrix to best fit (including all the casters)
  55203. * on each frame.
  55204. */
  55205. autoUpdateExtends: boolean;
  55206. /**
  55207. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  55208. * on each frame. autoUpdateExtends must be set to true for this to work
  55209. */
  55210. autoCalcShadowZBounds: boolean;
  55211. private _orthoLeft;
  55212. private _orthoRight;
  55213. private _orthoTop;
  55214. private _orthoBottom;
  55215. /**
  55216. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  55217. * The directional light is emitted from everywhere in the given direction.
  55218. * It can cast shadows.
  55219. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55220. * @param name The friendly name of the light
  55221. * @param direction The direction of the light
  55222. * @param scene The scene the light belongs to
  55223. */
  55224. constructor(name: string, direction: Vector3, scene: Scene);
  55225. /**
  55226. * Returns the string "DirectionalLight".
  55227. * @return The class name
  55228. */
  55229. getClassName(): string;
  55230. /**
  55231. * Returns the integer 1.
  55232. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55233. */
  55234. getTypeID(): number;
  55235. /**
  55236. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  55237. * Returns the DirectionalLight Shadow projection matrix.
  55238. */
  55239. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55240. /**
  55241. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  55242. * Returns the DirectionalLight Shadow projection matrix.
  55243. */
  55244. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  55245. /**
  55246. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  55247. * Returns the DirectionalLight Shadow projection matrix.
  55248. */
  55249. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55250. protected _buildUniformLayout(): void;
  55251. /**
  55252. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  55253. * @param effect The effect to update
  55254. * @param lightIndex The index of the light in the effect to update
  55255. * @returns The directional light
  55256. */
  55257. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  55258. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  55259. /**
  55260. * Gets the minZ used for shadow according to both the scene and the light.
  55261. *
  55262. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55263. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55264. * @param activeCamera The camera we are returning the min for
  55265. * @returns the depth min z
  55266. */
  55267. getDepthMinZ(activeCamera: Camera): number;
  55268. /**
  55269. * Gets the maxZ used for shadow according to both the scene and the light.
  55270. *
  55271. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  55272. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  55273. * @param activeCamera The camera we are returning the max for
  55274. * @returns the depth max z
  55275. */
  55276. getDepthMaxZ(activeCamera: Camera): number;
  55277. /**
  55278. * Prepares the list of defines specific to the light type.
  55279. * @param defines the list of defines
  55280. * @param lightIndex defines the index of the light for the effect
  55281. */
  55282. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55283. }
  55284. }
  55285. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  55286. import { Mesh } from "babylonjs/Meshes/mesh";
  55287. /**
  55288. * Class containing static functions to help procedurally build meshes
  55289. */
  55290. export class HemisphereBuilder {
  55291. /**
  55292. * Creates a hemisphere mesh
  55293. * @param name defines the name of the mesh
  55294. * @param options defines the options used to create the mesh
  55295. * @param scene defines the hosting scene
  55296. * @returns the hemisphere mesh
  55297. */
  55298. static CreateHemisphere(name: string, options: {
  55299. segments?: number;
  55300. diameter?: number;
  55301. sideOrientation?: number;
  55302. }, scene: any): Mesh;
  55303. }
  55304. }
  55305. declare module "babylonjs/Lights/spotLight" {
  55306. import { Nullable } from "babylonjs/types";
  55307. import { Scene } from "babylonjs/scene";
  55308. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55309. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55310. import { Effect } from "babylonjs/Materials/effect";
  55311. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55312. import { Light } from "babylonjs/Lights/light";
  55313. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  55314. /**
  55315. * A spot light is defined by a position, a direction, an angle, and an exponent.
  55316. * These values define a cone of light starting from the position, emitting toward the direction.
  55317. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  55318. * and the exponent defines the speed of the decay of the light with distance (reach).
  55319. * Documentation: https://doc.babylonjs.com/babylon101/lights
  55320. */
  55321. export class SpotLight extends ShadowLight {
  55322. private _angle;
  55323. private _innerAngle;
  55324. private _cosHalfAngle;
  55325. private _lightAngleScale;
  55326. private _lightAngleOffset;
  55327. /**
  55328. * Gets the cone angle of the spot light in Radians.
  55329. */
  55330. get angle(): number;
  55331. /**
  55332. * Sets the cone angle of the spot light in Radians.
  55333. */
  55334. set angle(value: number);
  55335. /**
  55336. * Only used in gltf falloff mode, this defines the angle where
  55337. * the directional falloff will start before cutting at angle which could be seen
  55338. * as outer angle.
  55339. */
  55340. get innerAngle(): number;
  55341. /**
  55342. * Only used in gltf falloff mode, this defines the angle where
  55343. * the directional falloff will start before cutting at angle which could be seen
  55344. * as outer angle.
  55345. */
  55346. set innerAngle(value: number);
  55347. private _shadowAngleScale;
  55348. /**
  55349. * Allows scaling the angle of the light for shadow generation only.
  55350. */
  55351. get shadowAngleScale(): number;
  55352. /**
  55353. * Allows scaling the angle of the light for shadow generation only.
  55354. */
  55355. set shadowAngleScale(value: number);
  55356. /**
  55357. * The light decay speed with the distance from the emission spot.
  55358. */
  55359. exponent: number;
  55360. private _projectionTextureMatrix;
  55361. /**
  55362. * Allows reading the projecton texture
  55363. */
  55364. get projectionTextureMatrix(): Matrix;
  55365. protected _projectionTextureLightNear: number;
  55366. /**
  55367. * Gets the near clip of the Spotlight for texture projection.
  55368. */
  55369. get projectionTextureLightNear(): number;
  55370. /**
  55371. * Sets the near clip of the Spotlight for texture projection.
  55372. */
  55373. set projectionTextureLightNear(value: number);
  55374. protected _projectionTextureLightFar: number;
  55375. /**
  55376. * Gets the far clip of the Spotlight for texture projection.
  55377. */
  55378. get projectionTextureLightFar(): number;
  55379. /**
  55380. * Sets the far clip of the Spotlight for texture projection.
  55381. */
  55382. set projectionTextureLightFar(value: number);
  55383. protected _projectionTextureUpDirection: Vector3;
  55384. /**
  55385. * Gets the Up vector of the Spotlight for texture projection.
  55386. */
  55387. get projectionTextureUpDirection(): Vector3;
  55388. /**
  55389. * Sets the Up vector of the Spotlight for texture projection.
  55390. */
  55391. set projectionTextureUpDirection(value: Vector3);
  55392. private _projectionTexture;
  55393. /**
  55394. * Gets the projection texture of the light.
  55395. */
  55396. get projectionTexture(): Nullable<BaseTexture>;
  55397. /**
  55398. * Sets the projection texture of the light.
  55399. */
  55400. set projectionTexture(value: Nullable<BaseTexture>);
  55401. private _projectionTextureViewLightDirty;
  55402. private _projectionTextureProjectionLightDirty;
  55403. private _projectionTextureDirty;
  55404. private _projectionTextureViewTargetVector;
  55405. private _projectionTextureViewLightMatrix;
  55406. private _projectionTextureProjectionLightMatrix;
  55407. private _projectionTextureScalingMatrix;
  55408. /**
  55409. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  55410. * It can cast shadows.
  55411. * Documentation : https://doc.babylonjs.com/babylon101/lights
  55412. * @param name The light friendly name
  55413. * @param position The position of the spot light in the scene
  55414. * @param direction The direction of the light in the scene
  55415. * @param angle The cone angle of the light in Radians
  55416. * @param exponent The light decay speed with the distance from the emission spot
  55417. * @param scene The scene the lights belongs to
  55418. */
  55419. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  55420. /**
  55421. * Returns the string "SpotLight".
  55422. * @returns the class name
  55423. */
  55424. getClassName(): string;
  55425. /**
  55426. * Returns the integer 2.
  55427. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  55428. */
  55429. getTypeID(): number;
  55430. /**
  55431. * Overrides the direction setter to recompute the projection texture view light Matrix.
  55432. */
  55433. protected _setDirection(value: Vector3): void;
  55434. /**
  55435. * Overrides the position setter to recompute the projection texture view light Matrix.
  55436. */
  55437. protected _setPosition(value: Vector3): void;
  55438. /**
  55439. * 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.
  55440. * Returns the SpotLight.
  55441. */
  55442. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  55443. protected _computeProjectionTextureViewLightMatrix(): void;
  55444. protected _computeProjectionTextureProjectionLightMatrix(): void;
  55445. /**
  55446. * Main function for light texture projection matrix computing.
  55447. */
  55448. protected _computeProjectionTextureMatrix(): void;
  55449. protected _buildUniformLayout(): void;
  55450. private _computeAngleValues;
  55451. /**
  55452. * Sets the passed Effect "effect" with the Light textures.
  55453. * @param effect The effect to update
  55454. * @param lightIndex The index of the light in the effect to update
  55455. * @returns The light
  55456. */
  55457. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  55458. /**
  55459. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  55460. * @param effect The effect to update
  55461. * @param lightIndex The index of the light in the effect to update
  55462. * @returns The spot light
  55463. */
  55464. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  55465. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  55466. /**
  55467. * Disposes the light and the associated resources.
  55468. */
  55469. dispose(): void;
  55470. /**
  55471. * Prepares the list of defines specific to the light type.
  55472. * @param defines the list of defines
  55473. * @param lightIndex defines the index of the light for the effect
  55474. */
  55475. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  55476. }
  55477. }
  55478. declare module "babylonjs/Gizmos/lightGizmo" {
  55479. import { Nullable } from "babylonjs/types";
  55480. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55481. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55482. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  55483. import { Light } from "babylonjs/Lights/light";
  55484. /**
  55485. * Gizmo that enables viewing a light
  55486. */
  55487. export class LightGizmo extends Gizmo {
  55488. private _lightMesh;
  55489. private _material;
  55490. private _cachedPosition;
  55491. private _cachedForward;
  55492. private _attachedMeshParent;
  55493. /**
  55494. * Creates a LightGizmo
  55495. * @param gizmoLayer The utility layer the gizmo will be added to
  55496. */
  55497. constructor(gizmoLayer?: UtilityLayerRenderer);
  55498. private _light;
  55499. /**
  55500. * The light that the gizmo is attached to
  55501. */
  55502. set light(light: Nullable<Light>);
  55503. get light(): Nullable<Light>;
  55504. /**
  55505. * Gets the material used to render the light gizmo
  55506. */
  55507. get material(): StandardMaterial;
  55508. /**
  55509. * @hidden
  55510. * Updates the gizmo to match the attached mesh's position/rotation
  55511. */
  55512. protected _update(): void;
  55513. private static _Scale;
  55514. /**
  55515. * Creates the lines for a light mesh
  55516. */
  55517. private static _CreateLightLines;
  55518. /**
  55519. * Disposes of the light gizmo
  55520. */
  55521. dispose(): void;
  55522. private static _CreateHemisphericLightMesh;
  55523. private static _CreatePointLightMesh;
  55524. private static _CreateSpotLightMesh;
  55525. private static _CreateDirectionalLightMesh;
  55526. }
  55527. }
  55528. declare module "babylonjs/Gizmos/index" {
  55529. export * from "babylonjs/Gizmos/axisDragGizmo";
  55530. export * from "babylonjs/Gizmos/axisScaleGizmo";
  55531. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  55532. export * from "babylonjs/Gizmos/gizmo";
  55533. export * from "babylonjs/Gizmos/gizmoManager";
  55534. export * from "babylonjs/Gizmos/planeRotationGizmo";
  55535. export * from "babylonjs/Gizmos/positionGizmo";
  55536. export * from "babylonjs/Gizmos/rotationGizmo";
  55537. export * from "babylonjs/Gizmos/scaleGizmo";
  55538. export * from "babylonjs/Gizmos/lightGizmo";
  55539. export * from "babylonjs/Gizmos/planeDragGizmo";
  55540. }
  55541. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  55542. /** @hidden */
  55543. export var backgroundFragmentDeclaration: {
  55544. name: string;
  55545. shader: string;
  55546. };
  55547. }
  55548. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  55549. /** @hidden */
  55550. export var backgroundUboDeclaration: {
  55551. name: string;
  55552. shader: string;
  55553. };
  55554. }
  55555. declare module "babylonjs/Shaders/background.fragment" {
  55556. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  55557. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55558. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55559. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55560. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55561. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55563. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  55564. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  55565. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55566. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  55567. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  55568. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55569. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  55570. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  55571. /** @hidden */
  55572. export var backgroundPixelShader: {
  55573. name: string;
  55574. shader: string;
  55575. };
  55576. }
  55577. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  55578. /** @hidden */
  55579. export var backgroundVertexDeclaration: {
  55580. name: string;
  55581. shader: string;
  55582. };
  55583. }
  55584. declare module "babylonjs/Shaders/background.vertex" {
  55585. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  55586. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  55587. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55588. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55589. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55590. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  55591. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  55592. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  55593. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  55594. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55595. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55596. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55597. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  55598. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  55599. /** @hidden */
  55600. export var backgroundVertexShader: {
  55601. name: string;
  55602. shader: string;
  55603. };
  55604. }
  55605. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  55606. import { Nullable, int, float } from "babylonjs/types";
  55607. import { Scene } from "babylonjs/scene";
  55608. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  55609. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55611. import { Mesh } from "babylonjs/Meshes/mesh";
  55612. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55613. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  55614. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  55615. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55616. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  55617. import { Color3 } from "babylonjs/Maths/math.color";
  55618. import "babylonjs/Shaders/background.fragment";
  55619. import "babylonjs/Shaders/background.vertex";
  55620. /**
  55621. * Background material used to create an efficient environement around your scene.
  55622. */
  55623. export class BackgroundMaterial extends PushMaterial {
  55624. /**
  55625. * Standard reflectance value at parallel view angle.
  55626. */
  55627. static StandardReflectance0: number;
  55628. /**
  55629. * Standard reflectance value at grazing angle.
  55630. */
  55631. static StandardReflectance90: number;
  55632. protected _primaryColor: Color3;
  55633. /**
  55634. * Key light Color (multiply against the environement texture)
  55635. */
  55636. primaryColor: Color3;
  55637. protected __perceptualColor: Nullable<Color3>;
  55638. /**
  55639. * Experimental Internal Use Only.
  55640. *
  55641. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  55642. * This acts as a helper to set the primary color to a more "human friendly" value.
  55643. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  55644. * output color as close as possible from the chosen value.
  55645. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  55646. * part of lighting setup.)
  55647. */
  55648. get _perceptualColor(): Nullable<Color3>;
  55649. set _perceptualColor(value: Nullable<Color3>);
  55650. protected _primaryColorShadowLevel: float;
  55651. /**
  55652. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  55653. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  55654. */
  55655. get primaryColorShadowLevel(): float;
  55656. set primaryColorShadowLevel(value: float);
  55657. protected _primaryColorHighlightLevel: float;
  55658. /**
  55659. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  55660. * The primary color is used at the level chosen to define what the white area would look.
  55661. */
  55662. get primaryColorHighlightLevel(): float;
  55663. set primaryColorHighlightLevel(value: float);
  55664. protected _reflectionTexture: Nullable<BaseTexture>;
  55665. /**
  55666. * Reflection Texture used in the material.
  55667. * Should be author in a specific way for the best result (refer to the documentation).
  55668. */
  55669. reflectionTexture: Nullable<BaseTexture>;
  55670. protected _reflectionBlur: float;
  55671. /**
  55672. * Reflection Texture level of blur.
  55673. *
  55674. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  55675. * texture twice.
  55676. */
  55677. reflectionBlur: float;
  55678. protected _diffuseTexture: Nullable<BaseTexture>;
  55679. /**
  55680. * Diffuse Texture used in the material.
  55681. * Should be author in a specific way for the best result (refer to the documentation).
  55682. */
  55683. diffuseTexture: Nullable<BaseTexture>;
  55684. protected _shadowLights: Nullable<IShadowLight[]>;
  55685. /**
  55686. * Specify the list of lights casting shadow on the material.
  55687. * All scene shadow lights will be included if null.
  55688. */
  55689. shadowLights: Nullable<IShadowLight[]>;
  55690. protected _shadowLevel: float;
  55691. /**
  55692. * Helps adjusting the shadow to a softer level if required.
  55693. * 0 means black shadows and 1 means no shadows.
  55694. */
  55695. shadowLevel: float;
  55696. protected _sceneCenter: Vector3;
  55697. /**
  55698. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  55699. * It is usually zero but might be interesting to modify according to your setup.
  55700. */
  55701. sceneCenter: Vector3;
  55702. protected _opacityFresnel: boolean;
  55703. /**
  55704. * This helps specifying that the material is falling off to the sky box at grazing angle.
  55705. * This helps ensuring a nice transition when the camera goes under the ground.
  55706. */
  55707. opacityFresnel: boolean;
  55708. protected _reflectionFresnel: boolean;
  55709. /**
  55710. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  55711. * This helps adding a mirror texture on the ground.
  55712. */
  55713. reflectionFresnel: boolean;
  55714. protected _reflectionFalloffDistance: number;
  55715. /**
  55716. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  55717. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  55718. */
  55719. reflectionFalloffDistance: number;
  55720. protected _reflectionAmount: number;
  55721. /**
  55722. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  55723. */
  55724. reflectionAmount: number;
  55725. protected _reflectionReflectance0: number;
  55726. /**
  55727. * This specifies the weight of the reflection at grazing angle.
  55728. */
  55729. reflectionReflectance0: number;
  55730. protected _reflectionReflectance90: number;
  55731. /**
  55732. * This specifies the weight of the reflection at a perpendicular point of view.
  55733. */
  55734. reflectionReflectance90: number;
  55735. /**
  55736. * Sets the reflection reflectance fresnel values according to the default standard
  55737. * empirically know to work well :-)
  55738. */
  55739. set reflectionStandardFresnelWeight(value: number);
  55740. protected _useRGBColor: boolean;
  55741. /**
  55742. * Helps to directly use the maps channels instead of their level.
  55743. */
  55744. useRGBColor: boolean;
  55745. protected _enableNoise: boolean;
  55746. /**
  55747. * This helps reducing the banding effect that could occur on the background.
  55748. */
  55749. enableNoise: boolean;
  55750. /**
  55751. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55752. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  55753. * Recommended to be keep at 1.0 except for special cases.
  55754. */
  55755. get fovMultiplier(): number;
  55756. set fovMultiplier(value: number);
  55757. private _fovMultiplier;
  55758. /**
  55759. * Enable the FOV adjustment feature controlled by fovMultiplier.
  55760. */
  55761. useEquirectangularFOV: boolean;
  55762. private _maxSimultaneousLights;
  55763. /**
  55764. * Number of Simultaneous lights allowed on the material.
  55765. */
  55766. maxSimultaneousLights: int;
  55767. private _shadowOnly;
  55768. /**
  55769. * Make the material only render shadows
  55770. */
  55771. shadowOnly: boolean;
  55772. /**
  55773. * Default configuration related to image processing available in the Background Material.
  55774. */
  55775. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55776. /**
  55777. * Keep track of the image processing observer to allow dispose and replace.
  55778. */
  55779. private _imageProcessingObserver;
  55780. /**
  55781. * Attaches a new image processing configuration to the PBR Material.
  55782. * @param configuration (if null the scene configuration will be use)
  55783. */
  55784. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55785. /**
  55786. * Gets the image processing configuration used either in this material.
  55787. */
  55788. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  55789. /**
  55790. * Sets the Default image processing configuration used either in the this material.
  55791. *
  55792. * If sets to null, the scene one is in use.
  55793. */
  55794. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  55795. /**
  55796. * Gets wether the color curves effect is enabled.
  55797. */
  55798. get cameraColorCurvesEnabled(): boolean;
  55799. /**
  55800. * Sets wether the color curves effect is enabled.
  55801. */
  55802. set cameraColorCurvesEnabled(value: boolean);
  55803. /**
  55804. * Gets wether the color grading effect is enabled.
  55805. */
  55806. get cameraColorGradingEnabled(): boolean;
  55807. /**
  55808. * Gets wether the color grading effect is enabled.
  55809. */
  55810. set cameraColorGradingEnabled(value: boolean);
  55811. /**
  55812. * Gets wether tonemapping is enabled or not.
  55813. */
  55814. get cameraToneMappingEnabled(): boolean;
  55815. /**
  55816. * Sets wether tonemapping is enabled or not
  55817. */
  55818. set cameraToneMappingEnabled(value: boolean);
  55819. /**
  55820. * The camera exposure used on this material.
  55821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55822. * This corresponds to a photographic exposure.
  55823. */
  55824. get cameraExposure(): float;
  55825. /**
  55826. * The camera exposure used on this material.
  55827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  55828. * This corresponds to a photographic exposure.
  55829. */
  55830. set cameraExposure(value: float);
  55831. /**
  55832. * Gets The camera contrast used on this material.
  55833. */
  55834. get cameraContrast(): float;
  55835. /**
  55836. * Sets The camera contrast used on this material.
  55837. */
  55838. set cameraContrast(value: float);
  55839. /**
  55840. * Gets the Color Grading 2D Lookup Texture.
  55841. */
  55842. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  55843. /**
  55844. * Sets the Color Grading 2D Lookup Texture.
  55845. */
  55846. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  55847. /**
  55848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55850. * 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;
  55851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55852. */
  55853. get cameraColorCurves(): Nullable<ColorCurves>;
  55854. /**
  55855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  55856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  55857. * 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;
  55858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  55859. */
  55860. set cameraColorCurves(value: Nullable<ColorCurves>);
  55861. /**
  55862. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  55863. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  55864. */
  55865. switchToBGR: boolean;
  55866. private _renderTargets;
  55867. private _reflectionControls;
  55868. private _white;
  55869. private _primaryShadowColor;
  55870. private _primaryHighlightColor;
  55871. /**
  55872. * Instantiates a Background Material in the given scene
  55873. * @param name The friendly name of the material
  55874. * @param scene The scene to add the material to
  55875. */
  55876. constructor(name: string, scene: Scene);
  55877. /**
  55878. * Gets a boolean indicating that current material needs to register RTT
  55879. */
  55880. get hasRenderTargetTextures(): boolean;
  55881. /**
  55882. * The entire material has been created in order to prevent overdraw.
  55883. * @returns false
  55884. */
  55885. needAlphaTesting(): boolean;
  55886. /**
  55887. * The entire material has been created in order to prevent overdraw.
  55888. * @returns true if blending is enable
  55889. */
  55890. needAlphaBlending(): boolean;
  55891. /**
  55892. * Checks wether the material is ready to be rendered for a given mesh.
  55893. * @param mesh The mesh to render
  55894. * @param subMesh The submesh to check against
  55895. * @param useInstances Specify wether or not the material is used with instances
  55896. * @returns true if all the dependencies are ready (Textures, Effects...)
  55897. */
  55898. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55899. /**
  55900. * Compute the primary color according to the chosen perceptual color.
  55901. */
  55902. private _computePrimaryColorFromPerceptualColor;
  55903. /**
  55904. * Compute the highlights and shadow colors according to their chosen levels.
  55905. */
  55906. private _computePrimaryColors;
  55907. /**
  55908. * Build the uniform buffer used in the material.
  55909. */
  55910. buildUniformLayout(): void;
  55911. /**
  55912. * Unbind the material.
  55913. */
  55914. unbind(): void;
  55915. /**
  55916. * Bind only the world matrix to the material.
  55917. * @param world The world matrix to bind.
  55918. */
  55919. bindOnlyWorldMatrix(world: Matrix): void;
  55920. /**
  55921. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  55922. * @param world The world matrix to bind.
  55923. * @param subMesh The submesh to bind for.
  55924. */
  55925. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55926. /**
  55927. * Checks to see if a texture is used in the material.
  55928. * @param texture - Base texture to use.
  55929. * @returns - Boolean specifying if a texture is used in the material.
  55930. */
  55931. hasTexture(texture: BaseTexture): boolean;
  55932. /**
  55933. * Dispose the material.
  55934. * @param forceDisposeEffect Force disposal of the associated effect.
  55935. * @param forceDisposeTextures Force disposal of the associated textures.
  55936. */
  55937. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  55938. /**
  55939. * Clones the material.
  55940. * @param name The cloned name.
  55941. * @returns The cloned material.
  55942. */
  55943. clone(name: string): BackgroundMaterial;
  55944. /**
  55945. * Serializes the current material to its JSON representation.
  55946. * @returns The JSON representation.
  55947. */
  55948. serialize(): any;
  55949. /**
  55950. * Gets the class name of the material
  55951. * @returns "BackgroundMaterial"
  55952. */
  55953. getClassName(): string;
  55954. /**
  55955. * Parse a JSON input to create back a background material.
  55956. * @param source The JSON data to parse
  55957. * @param scene The scene to create the parsed material in
  55958. * @param rootUrl The root url of the assets the material depends upon
  55959. * @returns the instantiated BackgroundMaterial.
  55960. */
  55961. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  55962. }
  55963. }
  55964. declare module "babylonjs/Helpers/environmentHelper" {
  55965. import { Observable } from "babylonjs/Misc/observable";
  55966. import { Nullable } from "babylonjs/types";
  55967. import { Scene } from "babylonjs/scene";
  55968. import { Vector3 } from "babylonjs/Maths/math.vector";
  55969. import { Color3 } from "babylonjs/Maths/math.color";
  55970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55971. import { Mesh } from "babylonjs/Meshes/mesh";
  55972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55973. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  55974. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55975. import "babylonjs/Meshes/Builders/planeBuilder";
  55976. import "babylonjs/Meshes/Builders/boxBuilder";
  55977. /**
  55978. * Represents the different options available during the creation of
  55979. * a Environment helper.
  55980. *
  55981. * This can control the default ground, skybox and image processing setup of your scene.
  55982. */
  55983. export interface IEnvironmentHelperOptions {
  55984. /**
  55985. * Specifies whether or not to create a ground.
  55986. * True by default.
  55987. */
  55988. createGround: boolean;
  55989. /**
  55990. * Specifies the ground size.
  55991. * 15 by default.
  55992. */
  55993. groundSize: number;
  55994. /**
  55995. * The texture used on the ground for the main color.
  55996. * Comes from the BabylonJS CDN by default.
  55997. *
  55998. * Remarks: Can be either a texture or a url.
  55999. */
  56000. groundTexture: string | BaseTexture;
  56001. /**
  56002. * The color mixed in the ground texture by default.
  56003. * BabylonJS clearColor by default.
  56004. */
  56005. groundColor: Color3;
  56006. /**
  56007. * Specifies the ground opacity.
  56008. * 1 by default.
  56009. */
  56010. groundOpacity: number;
  56011. /**
  56012. * Enables the ground to receive shadows.
  56013. * True by default.
  56014. */
  56015. enableGroundShadow: boolean;
  56016. /**
  56017. * Helps preventing the shadow to be fully black on the ground.
  56018. * 0.5 by default.
  56019. */
  56020. groundShadowLevel: number;
  56021. /**
  56022. * Creates a mirror texture attach to the ground.
  56023. * false by default.
  56024. */
  56025. enableGroundMirror: boolean;
  56026. /**
  56027. * Specifies the ground mirror size ratio.
  56028. * 0.3 by default as the default kernel is 64.
  56029. */
  56030. groundMirrorSizeRatio: number;
  56031. /**
  56032. * Specifies the ground mirror blur kernel size.
  56033. * 64 by default.
  56034. */
  56035. groundMirrorBlurKernel: number;
  56036. /**
  56037. * Specifies the ground mirror visibility amount.
  56038. * 1 by default
  56039. */
  56040. groundMirrorAmount: number;
  56041. /**
  56042. * Specifies the ground mirror reflectance weight.
  56043. * This uses the standard weight of the background material to setup the fresnel effect
  56044. * of the mirror.
  56045. * 1 by default.
  56046. */
  56047. groundMirrorFresnelWeight: number;
  56048. /**
  56049. * Specifies the ground mirror Falloff distance.
  56050. * This can helps reducing the size of the reflection.
  56051. * 0 by Default.
  56052. */
  56053. groundMirrorFallOffDistance: number;
  56054. /**
  56055. * Specifies the ground mirror texture type.
  56056. * Unsigned Int by Default.
  56057. */
  56058. groundMirrorTextureType: number;
  56059. /**
  56060. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  56061. * the shown objects.
  56062. */
  56063. groundYBias: number;
  56064. /**
  56065. * Specifies whether or not to create a skybox.
  56066. * True by default.
  56067. */
  56068. createSkybox: boolean;
  56069. /**
  56070. * Specifies the skybox size.
  56071. * 20 by default.
  56072. */
  56073. skyboxSize: number;
  56074. /**
  56075. * The texture used on the skybox for the main color.
  56076. * Comes from the BabylonJS CDN by default.
  56077. *
  56078. * Remarks: Can be either a texture or a url.
  56079. */
  56080. skyboxTexture: string | BaseTexture;
  56081. /**
  56082. * The color mixed in the skybox texture by default.
  56083. * BabylonJS clearColor by default.
  56084. */
  56085. skyboxColor: Color3;
  56086. /**
  56087. * The background rotation around the Y axis of the scene.
  56088. * This helps aligning the key lights of your scene with the background.
  56089. * 0 by default.
  56090. */
  56091. backgroundYRotation: number;
  56092. /**
  56093. * Compute automatically the size of the elements to best fit with the scene.
  56094. */
  56095. sizeAuto: boolean;
  56096. /**
  56097. * Default position of the rootMesh if autoSize is not true.
  56098. */
  56099. rootPosition: Vector3;
  56100. /**
  56101. * Sets up the image processing in the scene.
  56102. * true by default.
  56103. */
  56104. setupImageProcessing: boolean;
  56105. /**
  56106. * The texture used as your environment texture in the scene.
  56107. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  56108. *
  56109. * Remarks: Can be either a texture or a url.
  56110. */
  56111. environmentTexture: string | BaseTexture;
  56112. /**
  56113. * The value of the exposure to apply to the scene.
  56114. * 0.6 by default if setupImageProcessing is true.
  56115. */
  56116. cameraExposure: number;
  56117. /**
  56118. * The value of the contrast to apply to the scene.
  56119. * 1.6 by default if setupImageProcessing is true.
  56120. */
  56121. cameraContrast: number;
  56122. /**
  56123. * Specifies whether or not tonemapping should be enabled in the scene.
  56124. * true by default if setupImageProcessing is true.
  56125. */
  56126. toneMappingEnabled: boolean;
  56127. }
  56128. /**
  56129. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  56130. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  56131. * It also helps with the default setup of your imageProcessing configuration.
  56132. */
  56133. export class EnvironmentHelper {
  56134. /**
  56135. * Default ground texture URL.
  56136. */
  56137. private static _groundTextureCDNUrl;
  56138. /**
  56139. * Default skybox texture URL.
  56140. */
  56141. private static _skyboxTextureCDNUrl;
  56142. /**
  56143. * Default environment texture URL.
  56144. */
  56145. private static _environmentTextureCDNUrl;
  56146. /**
  56147. * Creates the default options for the helper.
  56148. */
  56149. private static _getDefaultOptions;
  56150. private _rootMesh;
  56151. /**
  56152. * Gets the root mesh created by the helper.
  56153. */
  56154. get rootMesh(): Mesh;
  56155. private _skybox;
  56156. /**
  56157. * Gets the skybox created by the helper.
  56158. */
  56159. get skybox(): Nullable<Mesh>;
  56160. private _skyboxTexture;
  56161. /**
  56162. * Gets the skybox texture created by the helper.
  56163. */
  56164. get skyboxTexture(): Nullable<BaseTexture>;
  56165. private _skyboxMaterial;
  56166. /**
  56167. * Gets the skybox material created by the helper.
  56168. */
  56169. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  56170. private _ground;
  56171. /**
  56172. * Gets the ground mesh created by the helper.
  56173. */
  56174. get ground(): Nullable<Mesh>;
  56175. private _groundTexture;
  56176. /**
  56177. * Gets the ground texture created by the helper.
  56178. */
  56179. get groundTexture(): Nullable<BaseTexture>;
  56180. private _groundMirror;
  56181. /**
  56182. * Gets the ground mirror created by the helper.
  56183. */
  56184. get groundMirror(): Nullable<MirrorTexture>;
  56185. /**
  56186. * Gets the ground mirror render list to helps pushing the meshes
  56187. * you wish in the ground reflection.
  56188. */
  56189. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  56190. private _groundMaterial;
  56191. /**
  56192. * Gets the ground material created by the helper.
  56193. */
  56194. get groundMaterial(): Nullable<BackgroundMaterial>;
  56195. /**
  56196. * Stores the creation options.
  56197. */
  56198. private readonly _scene;
  56199. private _options;
  56200. /**
  56201. * This observable will be notified with any error during the creation of the environment,
  56202. * mainly texture creation errors.
  56203. */
  56204. onErrorObservable: Observable<{
  56205. message?: string;
  56206. exception?: any;
  56207. }>;
  56208. /**
  56209. * constructor
  56210. * @param options Defines the options we want to customize the helper
  56211. * @param scene The scene to add the material to
  56212. */
  56213. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  56214. /**
  56215. * Updates the background according to the new options
  56216. * @param options
  56217. */
  56218. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  56219. /**
  56220. * Sets the primary color of all the available elements.
  56221. * @param color the main color to affect to the ground and the background
  56222. */
  56223. setMainColor(color: Color3): void;
  56224. /**
  56225. * Setup the image processing according to the specified options.
  56226. */
  56227. private _setupImageProcessing;
  56228. /**
  56229. * Setup the environment texture according to the specified options.
  56230. */
  56231. private _setupEnvironmentTexture;
  56232. /**
  56233. * Setup the background according to the specified options.
  56234. */
  56235. private _setupBackground;
  56236. /**
  56237. * Get the scene sizes according to the setup.
  56238. */
  56239. private _getSceneSize;
  56240. /**
  56241. * Setup the ground according to the specified options.
  56242. */
  56243. private _setupGround;
  56244. /**
  56245. * Setup the ground material according to the specified options.
  56246. */
  56247. private _setupGroundMaterial;
  56248. /**
  56249. * Setup the ground diffuse texture according to the specified options.
  56250. */
  56251. private _setupGroundDiffuseTexture;
  56252. /**
  56253. * Setup the ground mirror texture according to the specified options.
  56254. */
  56255. private _setupGroundMirrorTexture;
  56256. /**
  56257. * Setup the ground to receive the mirror texture.
  56258. */
  56259. private _setupMirrorInGroundMaterial;
  56260. /**
  56261. * Setup the skybox according to the specified options.
  56262. */
  56263. private _setupSkybox;
  56264. /**
  56265. * Setup the skybox material according to the specified options.
  56266. */
  56267. private _setupSkyboxMaterial;
  56268. /**
  56269. * Setup the skybox reflection texture according to the specified options.
  56270. */
  56271. private _setupSkyboxReflectionTexture;
  56272. private _errorHandler;
  56273. /**
  56274. * Dispose all the elements created by the Helper.
  56275. */
  56276. dispose(): void;
  56277. }
  56278. }
  56279. declare module "babylonjs/Helpers/photoDome" {
  56280. import { Observable } from "babylonjs/Misc/observable";
  56281. import { Nullable } from "babylonjs/types";
  56282. import { Scene } from "babylonjs/scene";
  56283. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56284. import { Mesh } from "babylonjs/Meshes/mesh";
  56285. import { Texture } from "babylonjs/Materials/Textures/texture";
  56286. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  56287. import "babylonjs/Meshes/Builders/sphereBuilder";
  56288. /**
  56289. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  56290. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  56291. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  56292. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  56293. */
  56294. export class PhotoDome extends TransformNode {
  56295. /**
  56296. * Define the image as a Monoscopic panoramic 360 image.
  56297. */
  56298. static readonly MODE_MONOSCOPIC: number;
  56299. /**
  56300. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56301. */
  56302. static readonly MODE_TOPBOTTOM: number;
  56303. /**
  56304. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56305. */
  56306. static readonly MODE_SIDEBYSIDE: number;
  56307. private _useDirectMapping;
  56308. /**
  56309. * The texture being displayed on the sphere
  56310. */
  56311. protected _photoTexture: Texture;
  56312. /**
  56313. * Gets or sets the texture being displayed on the sphere
  56314. */
  56315. get photoTexture(): Texture;
  56316. set photoTexture(value: Texture);
  56317. /**
  56318. * Observable raised when an error occured while loading the 360 image
  56319. */
  56320. onLoadErrorObservable: Observable<string>;
  56321. /**
  56322. * The skybox material
  56323. */
  56324. protected _material: BackgroundMaterial;
  56325. /**
  56326. * The surface used for the skybox
  56327. */
  56328. protected _mesh: Mesh;
  56329. /**
  56330. * Gets the mesh used for the skybox.
  56331. */
  56332. get mesh(): Mesh;
  56333. /**
  56334. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  56335. * Also see the options.resolution property.
  56336. */
  56337. get fovMultiplier(): number;
  56338. set fovMultiplier(value: number);
  56339. private _imageMode;
  56340. /**
  56341. * Gets or set the current video mode for the video. It can be:
  56342. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  56343. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  56344. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  56345. */
  56346. get imageMode(): number;
  56347. set imageMode(value: number);
  56348. /**
  56349. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  56350. * @param name Element's name, child elements will append suffixes for their own names.
  56351. * @param urlsOfPhoto defines the url of the photo to display
  56352. * @param options defines an object containing optional or exposed sub element properties
  56353. * @param onError defines a callback called when an error occured while loading the texture
  56354. */
  56355. constructor(name: string, urlOfPhoto: string, options: {
  56356. resolution?: number;
  56357. size?: number;
  56358. useDirectMapping?: boolean;
  56359. faceForward?: boolean;
  56360. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  56361. private _onBeforeCameraRenderObserver;
  56362. private _changeImageMode;
  56363. /**
  56364. * Releases resources associated with this node.
  56365. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  56366. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  56367. */
  56368. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  56369. }
  56370. }
  56371. declare module "babylonjs/Misc/rgbdTextureTools" {
  56372. import "babylonjs/Shaders/rgbdDecode.fragment";
  56373. import "babylonjs/Engines/Extensions/engine.renderTarget";
  56374. import { Texture } from "babylonjs/Materials/Textures/texture";
  56375. /**
  56376. * Class used to host RGBD texture specific utilities
  56377. */
  56378. export class RGBDTextureTools {
  56379. /**
  56380. * Expand the RGBD Texture from RGBD to Half Float if possible.
  56381. * @param texture the texture to expand.
  56382. */
  56383. static ExpandRGBDTexture(texture: Texture): void;
  56384. }
  56385. }
  56386. declare module "babylonjs/Misc/brdfTextureTools" {
  56387. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56388. import { Scene } from "babylonjs/scene";
  56389. /**
  56390. * Class used to host texture specific utilities
  56391. */
  56392. export class BRDFTextureTools {
  56393. /**
  56394. * Prevents texture cache collision
  56395. */
  56396. private static _instanceNumber;
  56397. /**
  56398. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  56399. * @param scene defines the hosting scene
  56400. * @returns the environment BRDF texture
  56401. */
  56402. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  56403. private static _environmentBRDFBase64Texture;
  56404. }
  56405. }
  56406. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  56407. import { Nullable } from "babylonjs/types";
  56408. import { Color3 } from "babylonjs/Maths/math.color";
  56409. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56410. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56411. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56412. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56413. import { Engine } from "babylonjs/Engines/engine";
  56414. import { Scene } from "babylonjs/scene";
  56415. /**
  56416. * @hidden
  56417. */
  56418. export interface IMaterialClearCoatDefines {
  56419. CLEARCOAT: boolean;
  56420. CLEARCOAT_DEFAULTIOR: boolean;
  56421. CLEARCOAT_TEXTURE: boolean;
  56422. CLEARCOAT_TEXTUREDIRECTUV: number;
  56423. CLEARCOAT_BUMP: boolean;
  56424. CLEARCOAT_BUMPDIRECTUV: number;
  56425. CLEARCOAT_TINT: boolean;
  56426. CLEARCOAT_TINT_TEXTURE: boolean;
  56427. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  56428. /** @hidden */
  56429. _areTexturesDirty: boolean;
  56430. }
  56431. /**
  56432. * Define the code related to the clear coat parameters of the pbr material.
  56433. */
  56434. export class PBRClearCoatConfiguration {
  56435. /**
  56436. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56437. * The default fits with a polyurethane material.
  56438. */
  56439. private static readonly _DefaultIndexOfRefraction;
  56440. private _isEnabled;
  56441. /**
  56442. * Defines if the clear coat is enabled in the material.
  56443. */
  56444. isEnabled: boolean;
  56445. /**
  56446. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  56447. */
  56448. intensity: number;
  56449. /**
  56450. * Defines the clear coat layer roughness.
  56451. */
  56452. roughness: number;
  56453. private _indexOfRefraction;
  56454. /**
  56455. * Defines the index of refraction of the clear coat.
  56456. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  56457. * The default fits with a polyurethane material.
  56458. * Changing the default value is more performance intensive.
  56459. */
  56460. indexOfRefraction: number;
  56461. private _texture;
  56462. /**
  56463. * Stores the clear coat values in a texture.
  56464. */
  56465. texture: Nullable<BaseTexture>;
  56466. private _bumpTexture;
  56467. /**
  56468. * Define the clear coat specific bump texture.
  56469. */
  56470. bumpTexture: Nullable<BaseTexture>;
  56471. private _isTintEnabled;
  56472. /**
  56473. * Defines if the clear coat tint is enabled in the material.
  56474. */
  56475. isTintEnabled: boolean;
  56476. /**
  56477. * Defines the clear coat tint of the material.
  56478. * This is only use if tint is enabled
  56479. */
  56480. tintColor: Color3;
  56481. /**
  56482. * Defines the distance at which the tint color should be found in the
  56483. * clear coat media.
  56484. * This is only use if tint is enabled
  56485. */
  56486. tintColorAtDistance: number;
  56487. /**
  56488. * Defines the clear coat layer thickness.
  56489. * This is only use if tint is enabled
  56490. */
  56491. tintThickness: number;
  56492. private _tintTexture;
  56493. /**
  56494. * Stores the clear tint values in a texture.
  56495. * rgb is tint
  56496. * a is a thickness factor
  56497. */
  56498. tintTexture: Nullable<BaseTexture>;
  56499. /** @hidden */
  56500. private _internalMarkAllSubMeshesAsTexturesDirty;
  56501. /** @hidden */
  56502. _markAllSubMeshesAsTexturesDirty(): void;
  56503. /**
  56504. * Instantiate a new istance of clear coat configuration.
  56505. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56506. */
  56507. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56508. /**
  56509. * Gets wehter the submesh is ready to be used or not.
  56510. * @param defines the list of "defines" to update.
  56511. * @param scene defines the scene the material belongs to.
  56512. * @param engine defines the engine the material belongs to.
  56513. * @param disableBumpMap defines wether the material disables bump or not.
  56514. * @returns - boolean indicating that the submesh is ready or not.
  56515. */
  56516. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  56517. /**
  56518. * Checks to see if a texture is used in the material.
  56519. * @param defines the list of "defines" to update.
  56520. * @param scene defines the scene to the material belongs to.
  56521. */
  56522. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  56523. /**
  56524. * Binds the material data.
  56525. * @param uniformBuffer defines the Uniform buffer to fill in.
  56526. * @param scene defines the scene the material belongs to.
  56527. * @param engine defines the engine the material belongs to.
  56528. * @param disableBumpMap defines wether the material disables bump or not.
  56529. * @param isFrozen defines wether the material is frozen or not.
  56530. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  56531. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  56532. */
  56533. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  56534. /**
  56535. * Checks to see if a texture is used in the material.
  56536. * @param texture - Base texture to use.
  56537. * @returns - Boolean specifying if a texture is used in the material.
  56538. */
  56539. hasTexture(texture: BaseTexture): boolean;
  56540. /**
  56541. * Returns an array of the actively used textures.
  56542. * @param activeTextures Array of BaseTextures
  56543. */
  56544. getActiveTextures(activeTextures: BaseTexture[]): void;
  56545. /**
  56546. * Returns the animatable textures.
  56547. * @param animatables Array of animatable textures.
  56548. */
  56549. getAnimatables(animatables: IAnimatable[]): void;
  56550. /**
  56551. * Disposes the resources of the material.
  56552. * @param forceDisposeTextures - Forces the disposal of all textures.
  56553. */
  56554. dispose(forceDisposeTextures?: boolean): void;
  56555. /**
  56556. * Get the current class name of the texture useful for serialization or dynamic coding.
  56557. * @returns "PBRClearCoatConfiguration"
  56558. */
  56559. getClassName(): string;
  56560. /**
  56561. * Add fallbacks to the effect fallbacks list.
  56562. * @param defines defines the Base texture to use.
  56563. * @param fallbacks defines the current fallback list.
  56564. * @param currentRank defines the current fallback rank.
  56565. * @returns the new fallback rank.
  56566. */
  56567. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56568. /**
  56569. * Add the required uniforms to the current list.
  56570. * @param uniforms defines the current uniform list.
  56571. */
  56572. static AddUniforms(uniforms: string[]): void;
  56573. /**
  56574. * Add the required samplers to the current list.
  56575. * @param samplers defines the current sampler list.
  56576. */
  56577. static AddSamplers(samplers: string[]): void;
  56578. /**
  56579. * Add the required uniforms to the current buffer.
  56580. * @param uniformBuffer defines the current uniform buffer.
  56581. */
  56582. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56583. /**
  56584. * Makes a duplicate of the current configuration into another one.
  56585. * @param clearCoatConfiguration define the config where to copy the info
  56586. */
  56587. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  56588. /**
  56589. * Serializes this clear coat configuration.
  56590. * @returns - An object with the serialized config.
  56591. */
  56592. serialize(): any;
  56593. /**
  56594. * Parses a anisotropy Configuration from a serialized object.
  56595. * @param source - Serialized object.
  56596. * @param scene Defines the scene we are parsing for
  56597. * @param rootUrl Defines the rootUrl to load from
  56598. */
  56599. parse(source: any, scene: Scene, rootUrl: string): void;
  56600. }
  56601. }
  56602. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  56603. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56605. import { Vector2 } from "babylonjs/Maths/math.vector";
  56606. import { Scene } from "babylonjs/scene";
  56607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56608. import { Nullable } from "babylonjs/types";
  56609. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56610. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56611. /**
  56612. * @hidden
  56613. */
  56614. export interface IMaterialAnisotropicDefines {
  56615. ANISOTROPIC: boolean;
  56616. ANISOTROPIC_TEXTURE: boolean;
  56617. ANISOTROPIC_TEXTUREDIRECTUV: number;
  56618. MAINUV1: boolean;
  56619. _areTexturesDirty: boolean;
  56620. _needUVs: boolean;
  56621. }
  56622. /**
  56623. * Define the code related to the anisotropic parameters of the pbr material.
  56624. */
  56625. export class PBRAnisotropicConfiguration {
  56626. private _isEnabled;
  56627. /**
  56628. * Defines if the anisotropy is enabled in the material.
  56629. */
  56630. isEnabled: boolean;
  56631. /**
  56632. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  56633. */
  56634. intensity: number;
  56635. /**
  56636. * Defines if the effect is along the tangents, bitangents or in between.
  56637. * By default, the effect is "strectching" the highlights along the tangents.
  56638. */
  56639. direction: Vector2;
  56640. private _texture;
  56641. /**
  56642. * Stores the anisotropy values in a texture.
  56643. * rg is direction (like normal from -1 to 1)
  56644. * b is a intensity
  56645. */
  56646. texture: Nullable<BaseTexture>;
  56647. /** @hidden */
  56648. private _internalMarkAllSubMeshesAsTexturesDirty;
  56649. /** @hidden */
  56650. _markAllSubMeshesAsTexturesDirty(): void;
  56651. /**
  56652. * Instantiate a new istance of anisotropy configuration.
  56653. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56654. */
  56655. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56656. /**
  56657. * Specifies that the submesh is ready to be used.
  56658. * @param defines the list of "defines" to update.
  56659. * @param scene defines the scene the material belongs to.
  56660. * @returns - boolean indicating that the submesh is ready or not.
  56661. */
  56662. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  56663. /**
  56664. * Checks to see if a texture is used in the material.
  56665. * @param defines the list of "defines" to update.
  56666. * @param mesh the mesh we are preparing the defines for.
  56667. * @param scene defines the scene the material belongs to.
  56668. */
  56669. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  56670. /**
  56671. * Binds the material data.
  56672. * @param uniformBuffer defines the Uniform buffer to fill in.
  56673. * @param scene defines the scene the material belongs to.
  56674. * @param isFrozen defines wether the material is frozen or not.
  56675. */
  56676. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56677. /**
  56678. * Checks to see if a texture is used in the material.
  56679. * @param texture - Base texture to use.
  56680. * @returns - Boolean specifying if a texture is used in the material.
  56681. */
  56682. hasTexture(texture: BaseTexture): boolean;
  56683. /**
  56684. * Returns an array of the actively used textures.
  56685. * @param activeTextures Array of BaseTextures
  56686. */
  56687. getActiveTextures(activeTextures: BaseTexture[]): void;
  56688. /**
  56689. * Returns the animatable textures.
  56690. * @param animatables Array of animatable textures.
  56691. */
  56692. getAnimatables(animatables: IAnimatable[]): void;
  56693. /**
  56694. * Disposes the resources of the material.
  56695. * @param forceDisposeTextures - Forces the disposal of all textures.
  56696. */
  56697. dispose(forceDisposeTextures?: boolean): void;
  56698. /**
  56699. * Get the current class name of the texture useful for serialization or dynamic coding.
  56700. * @returns "PBRAnisotropicConfiguration"
  56701. */
  56702. getClassName(): string;
  56703. /**
  56704. * Add fallbacks to the effect fallbacks list.
  56705. * @param defines defines the Base texture to use.
  56706. * @param fallbacks defines the current fallback list.
  56707. * @param currentRank defines the current fallback rank.
  56708. * @returns the new fallback rank.
  56709. */
  56710. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56711. /**
  56712. * Add the required uniforms to the current list.
  56713. * @param uniforms defines the current uniform list.
  56714. */
  56715. static AddUniforms(uniforms: string[]): void;
  56716. /**
  56717. * Add the required uniforms to the current buffer.
  56718. * @param uniformBuffer defines the current uniform buffer.
  56719. */
  56720. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56721. /**
  56722. * Add the required samplers to the current list.
  56723. * @param samplers defines the current sampler list.
  56724. */
  56725. static AddSamplers(samplers: string[]): void;
  56726. /**
  56727. * Makes a duplicate of the current configuration into another one.
  56728. * @param anisotropicConfiguration define the config where to copy the info
  56729. */
  56730. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  56731. /**
  56732. * Serializes this anisotropy configuration.
  56733. * @returns - An object with the serialized config.
  56734. */
  56735. serialize(): any;
  56736. /**
  56737. * Parses a anisotropy Configuration from a serialized object.
  56738. * @param source - Serialized object.
  56739. * @param scene Defines the scene we are parsing for
  56740. * @param rootUrl Defines the rootUrl to load from
  56741. */
  56742. parse(source: any, scene: Scene, rootUrl: string): void;
  56743. }
  56744. }
  56745. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  56746. import { Scene } from "babylonjs/scene";
  56747. /**
  56748. * @hidden
  56749. */
  56750. export interface IMaterialBRDFDefines {
  56751. BRDF_V_HEIGHT_CORRELATED: boolean;
  56752. MS_BRDF_ENERGY_CONSERVATION: boolean;
  56753. SPHERICAL_HARMONICS: boolean;
  56754. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  56755. /** @hidden */
  56756. _areMiscDirty: boolean;
  56757. }
  56758. /**
  56759. * Define the code related to the BRDF parameters of the pbr material.
  56760. */
  56761. export class PBRBRDFConfiguration {
  56762. /**
  56763. * Default value used for the energy conservation.
  56764. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56765. */
  56766. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  56767. /**
  56768. * Default value used for the Smith Visibility Height Correlated mode.
  56769. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  56770. */
  56771. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  56772. /**
  56773. * Default value used for the IBL diffuse part.
  56774. * This can help switching back to the polynomials mode globally which is a tiny bit
  56775. * less GPU intensive at the drawback of a lower quality.
  56776. */
  56777. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  56778. /**
  56779. * Default value used for activating energy conservation for the specular workflow.
  56780. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56781. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56782. */
  56783. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  56784. private _useEnergyConservation;
  56785. /**
  56786. * Defines if the material uses energy conservation.
  56787. */
  56788. useEnergyConservation: boolean;
  56789. private _useSmithVisibilityHeightCorrelated;
  56790. /**
  56791. * LEGACY Mode set to false
  56792. * Defines if the material uses height smith correlated visibility term.
  56793. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  56794. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  56795. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  56796. * Not relying on height correlated will also disable energy conservation.
  56797. */
  56798. useSmithVisibilityHeightCorrelated: boolean;
  56799. private _useSphericalHarmonics;
  56800. /**
  56801. * LEGACY Mode set to false
  56802. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  56803. * diffuse part of the IBL.
  56804. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  56805. * to the ground truth.
  56806. */
  56807. useSphericalHarmonics: boolean;
  56808. private _useSpecularGlossinessInputEnergyConservation;
  56809. /**
  56810. * Defines if the material uses energy conservation, when the specular workflow is active.
  56811. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  56812. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  56813. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  56814. */
  56815. useSpecularGlossinessInputEnergyConservation: boolean;
  56816. /** @hidden */
  56817. private _internalMarkAllSubMeshesAsMiscDirty;
  56818. /** @hidden */
  56819. _markAllSubMeshesAsMiscDirty(): void;
  56820. /**
  56821. * Instantiate a new istance of clear coat configuration.
  56822. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  56823. */
  56824. constructor(markAllSubMeshesAsMiscDirty: () => void);
  56825. /**
  56826. * Checks to see if a texture is used in the material.
  56827. * @param defines the list of "defines" to update.
  56828. */
  56829. prepareDefines(defines: IMaterialBRDFDefines): void;
  56830. /**
  56831. * Get the current class name of the texture useful for serialization or dynamic coding.
  56832. * @returns "PBRClearCoatConfiguration"
  56833. */
  56834. getClassName(): string;
  56835. /**
  56836. * Makes a duplicate of the current configuration into another one.
  56837. * @param brdfConfiguration define the config where to copy the info
  56838. */
  56839. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  56840. /**
  56841. * Serializes this BRDF configuration.
  56842. * @returns - An object with the serialized config.
  56843. */
  56844. serialize(): any;
  56845. /**
  56846. * Parses a anisotropy Configuration from a serialized object.
  56847. * @param source - Serialized object.
  56848. * @param scene Defines the scene we are parsing for
  56849. * @param rootUrl Defines the rootUrl to load from
  56850. */
  56851. parse(source: any, scene: Scene, rootUrl: string): void;
  56852. }
  56853. }
  56854. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  56855. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  56856. import { Color3 } from "babylonjs/Maths/math.color";
  56857. import { Scene } from "babylonjs/scene";
  56858. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56859. import { Nullable } from "babylonjs/types";
  56860. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  56861. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56862. /**
  56863. * @hidden
  56864. */
  56865. export interface IMaterialSheenDefines {
  56866. SHEEN: boolean;
  56867. SHEEN_TEXTURE: boolean;
  56868. SHEEN_TEXTUREDIRECTUV: number;
  56869. SHEEN_LINKWITHALBEDO: boolean;
  56870. SHEEN_ROUGHNESS: boolean;
  56871. SHEEN_ALBEDOSCALING: boolean;
  56872. /** @hidden */
  56873. _areTexturesDirty: boolean;
  56874. }
  56875. /**
  56876. * Define the code related to the Sheen parameters of the pbr material.
  56877. */
  56878. export class PBRSheenConfiguration {
  56879. private _isEnabled;
  56880. /**
  56881. * Defines if the material uses sheen.
  56882. */
  56883. isEnabled: boolean;
  56884. private _linkSheenWithAlbedo;
  56885. /**
  56886. * Defines if the sheen is linked to the sheen color.
  56887. */
  56888. linkSheenWithAlbedo: boolean;
  56889. /**
  56890. * Defines the sheen intensity.
  56891. */
  56892. intensity: number;
  56893. /**
  56894. * Defines the sheen color.
  56895. */
  56896. color: Color3;
  56897. private _texture;
  56898. /**
  56899. * Stores the sheen tint values in a texture.
  56900. * rgb is tint
  56901. * a is a intensity or roughness if roughness has been defined
  56902. */
  56903. texture: Nullable<BaseTexture>;
  56904. private _roughness;
  56905. /**
  56906. * Defines the sheen roughness.
  56907. * It is not taken into account if linkSheenWithAlbedo is true.
  56908. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  56909. */
  56910. roughness: Nullable<number>;
  56911. private _albedoScaling;
  56912. /**
  56913. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  56914. * It allows the strength of the sheen effect to not depend on the base color of the material,
  56915. * making it easier to setup and tweak the effect
  56916. */
  56917. albedoScaling: boolean;
  56918. /** @hidden */
  56919. private _internalMarkAllSubMeshesAsTexturesDirty;
  56920. /** @hidden */
  56921. _markAllSubMeshesAsTexturesDirty(): void;
  56922. /**
  56923. * Instantiate a new istance of clear coat configuration.
  56924. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  56925. */
  56926. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  56927. /**
  56928. * Specifies that the submesh is ready to be used.
  56929. * @param defines the list of "defines" to update.
  56930. * @param scene defines the scene the material belongs to.
  56931. * @returns - boolean indicating that the submesh is ready or not.
  56932. */
  56933. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  56934. /**
  56935. * Checks to see if a texture is used in the material.
  56936. * @param defines the list of "defines" to update.
  56937. * @param scene defines the scene the material belongs to.
  56938. */
  56939. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  56940. /**
  56941. * Binds the material data.
  56942. * @param uniformBuffer defines the Uniform buffer to fill in.
  56943. * @param scene defines the scene the material belongs to.
  56944. * @param isFrozen defines wether the material is frozen or not.
  56945. */
  56946. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  56947. /**
  56948. * Checks to see if a texture is used in the material.
  56949. * @param texture - Base texture to use.
  56950. * @returns - Boolean specifying if a texture is used in the material.
  56951. */
  56952. hasTexture(texture: BaseTexture): boolean;
  56953. /**
  56954. * Returns an array of the actively used textures.
  56955. * @param activeTextures Array of BaseTextures
  56956. */
  56957. getActiveTextures(activeTextures: BaseTexture[]): void;
  56958. /**
  56959. * Returns the animatable textures.
  56960. * @param animatables Array of animatable textures.
  56961. */
  56962. getAnimatables(animatables: IAnimatable[]): void;
  56963. /**
  56964. * Disposes the resources of the material.
  56965. * @param forceDisposeTextures - Forces the disposal of all textures.
  56966. */
  56967. dispose(forceDisposeTextures?: boolean): void;
  56968. /**
  56969. * Get the current class name of the texture useful for serialization or dynamic coding.
  56970. * @returns "PBRSheenConfiguration"
  56971. */
  56972. getClassName(): string;
  56973. /**
  56974. * Add fallbacks to the effect fallbacks list.
  56975. * @param defines defines the Base texture to use.
  56976. * @param fallbacks defines the current fallback list.
  56977. * @param currentRank defines the current fallback rank.
  56978. * @returns the new fallback rank.
  56979. */
  56980. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  56981. /**
  56982. * Add the required uniforms to the current list.
  56983. * @param uniforms defines the current uniform list.
  56984. */
  56985. static AddUniforms(uniforms: string[]): void;
  56986. /**
  56987. * Add the required uniforms to the current buffer.
  56988. * @param uniformBuffer defines the current uniform buffer.
  56989. */
  56990. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  56991. /**
  56992. * Add the required samplers to the current list.
  56993. * @param samplers defines the current sampler list.
  56994. */
  56995. static AddSamplers(samplers: string[]): void;
  56996. /**
  56997. * Makes a duplicate of the current configuration into another one.
  56998. * @param sheenConfiguration define the config where to copy the info
  56999. */
  57000. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  57001. /**
  57002. * Serializes this BRDF configuration.
  57003. * @returns - An object with the serialized config.
  57004. */
  57005. serialize(): any;
  57006. /**
  57007. * Parses a anisotropy Configuration from a serialized object.
  57008. * @param source - Serialized object.
  57009. * @param scene Defines the scene we are parsing for
  57010. * @param rootUrl Defines the rootUrl to load from
  57011. */
  57012. parse(source: any, scene: Scene, rootUrl: string): void;
  57013. }
  57014. }
  57015. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  57016. import { Nullable } from "babylonjs/types";
  57017. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57018. import { Color3 } from "babylonjs/Maths/math.color";
  57019. import { SmartArray } from "babylonjs/Misc/smartArray";
  57020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57022. import { Effect } from "babylonjs/Materials/effect";
  57023. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57024. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57025. import { Engine } from "babylonjs/Engines/engine";
  57026. import { Scene } from "babylonjs/scene";
  57027. /**
  57028. * @hidden
  57029. */
  57030. export interface IMaterialSubSurfaceDefines {
  57031. SUBSURFACE: boolean;
  57032. SS_REFRACTION: boolean;
  57033. SS_TRANSLUCENCY: boolean;
  57034. SS_SCATTERING: boolean;
  57035. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57036. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57037. SS_REFRACTIONMAP_3D: boolean;
  57038. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57039. SS_LODINREFRACTIONALPHA: boolean;
  57040. SS_GAMMAREFRACTION: boolean;
  57041. SS_RGBDREFRACTION: boolean;
  57042. SS_LINEARSPECULARREFRACTION: boolean;
  57043. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57044. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57045. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57046. /** @hidden */
  57047. _areTexturesDirty: boolean;
  57048. }
  57049. /**
  57050. * Define the code related to the sub surface parameters of the pbr material.
  57051. */
  57052. export class PBRSubSurfaceConfiguration {
  57053. private _isRefractionEnabled;
  57054. /**
  57055. * Defines if the refraction is enabled in the material.
  57056. */
  57057. isRefractionEnabled: boolean;
  57058. private _isTranslucencyEnabled;
  57059. /**
  57060. * Defines if the translucency is enabled in the material.
  57061. */
  57062. isTranslucencyEnabled: boolean;
  57063. private _isScatteringEnabled;
  57064. /**
  57065. * Defines if the sub surface scattering is enabled in the material.
  57066. */
  57067. isScatteringEnabled: boolean;
  57068. private _scatteringDiffusionProfileIndex;
  57069. /**
  57070. * Diffusion profile for subsurface scattering.
  57071. * Useful for better scattering in the skins or foliages.
  57072. */
  57073. get scatteringDiffusionProfile(): Nullable<Color3>;
  57074. set scatteringDiffusionProfile(c: Nullable<Color3>);
  57075. /**
  57076. * Defines the refraction intensity of the material.
  57077. * The refraction when enabled replaces the Diffuse part of the material.
  57078. * The intensity helps transitionning between diffuse and refraction.
  57079. */
  57080. refractionIntensity: number;
  57081. /**
  57082. * Defines the translucency intensity of the material.
  57083. * When translucency has been enabled, this defines how much of the "translucency"
  57084. * is addded to the diffuse part of the material.
  57085. */
  57086. translucencyIntensity: number;
  57087. /**
  57088. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  57089. */
  57090. useAlbedoToTintRefraction: boolean;
  57091. private _thicknessTexture;
  57092. /**
  57093. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  57094. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  57095. * 0 would mean minimumThickness
  57096. * 1 would mean maximumThickness
  57097. * The other channels might be use as a mask to vary the different effects intensity.
  57098. */
  57099. thicknessTexture: Nullable<BaseTexture>;
  57100. private _refractionTexture;
  57101. /**
  57102. * Defines the texture to use for refraction.
  57103. */
  57104. refractionTexture: Nullable<BaseTexture>;
  57105. private _indexOfRefraction;
  57106. /**
  57107. * Index of refraction of the material base layer.
  57108. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57109. *
  57110. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  57111. *
  57112. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  57113. */
  57114. indexOfRefraction: number;
  57115. private _volumeIndexOfRefraction;
  57116. /**
  57117. * Index of refraction of the material's volume.
  57118. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  57119. *
  57120. * This ONLY impacts refraction. If not provided or given a non-valid value,
  57121. * the volume will use the same IOR as the surface.
  57122. */
  57123. get volumeIndexOfRefraction(): number;
  57124. set volumeIndexOfRefraction(value: number);
  57125. private _invertRefractionY;
  57126. /**
  57127. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  57128. */
  57129. invertRefractionY: boolean;
  57130. private _linkRefractionWithTransparency;
  57131. /**
  57132. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  57133. * Materials half opaque for instance using refraction could benefit from this control.
  57134. */
  57135. linkRefractionWithTransparency: boolean;
  57136. /**
  57137. * Defines the minimum thickness stored in the thickness map.
  57138. * If no thickness map is defined, this value will be used to simulate thickness.
  57139. */
  57140. minimumThickness: number;
  57141. /**
  57142. * Defines the maximum thickness stored in the thickness map.
  57143. */
  57144. maximumThickness: number;
  57145. /**
  57146. * Defines the volume tint of the material.
  57147. * This is used for both translucency and scattering.
  57148. */
  57149. tintColor: Color3;
  57150. /**
  57151. * Defines the distance at which the tint color should be found in the media.
  57152. * This is used for refraction only.
  57153. */
  57154. tintColorAtDistance: number;
  57155. /**
  57156. * Defines how far each channel transmit through the media.
  57157. * It is defined as a color to simplify it selection.
  57158. */
  57159. diffusionDistance: Color3;
  57160. private _useMaskFromThicknessTexture;
  57161. /**
  57162. * Stores the intensity of the different subsurface effects in the thickness texture.
  57163. * * the green channel is the translucency intensity.
  57164. * * the blue channel is the scattering intensity.
  57165. * * the alpha channel is the refraction intensity.
  57166. */
  57167. useMaskFromThicknessTexture: boolean;
  57168. private _scene;
  57169. /** @hidden */
  57170. private _internalMarkAllSubMeshesAsTexturesDirty;
  57171. private _internalMarkScenePrePassDirty;
  57172. /** @hidden */
  57173. _markAllSubMeshesAsTexturesDirty(): void;
  57174. /** @hidden */
  57175. _markScenePrePassDirty(): void;
  57176. /**
  57177. * Instantiate a new istance of sub surface configuration.
  57178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57179. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  57180. * @param scene The scene
  57181. */
  57182. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  57183. /**
  57184. * Gets wehter the submesh is ready to be used or not.
  57185. * @param defines the list of "defines" to update.
  57186. * @param scene defines the scene the material belongs to.
  57187. * @returns - boolean indicating that the submesh is ready or not.
  57188. */
  57189. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  57190. /**
  57191. * Checks to see if a texture is used in the material.
  57192. * @param defines the list of "defines" to update.
  57193. * @param scene defines the scene to the material belongs to.
  57194. */
  57195. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  57196. /**
  57197. * Binds the material data.
  57198. * @param uniformBuffer defines the Uniform buffer to fill in.
  57199. * @param scene defines the scene the material belongs to.
  57200. * @param engine defines the engine the material belongs to.
  57201. * @param isFrozen defines whether the material is frozen or not.
  57202. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  57203. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  57204. */
  57205. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  57206. /**
  57207. * Unbinds the material from the mesh.
  57208. * @param activeEffect defines the effect that should be unbound from.
  57209. * @returns true if unbound, otherwise false
  57210. */
  57211. unbind(activeEffect: Effect): boolean;
  57212. /**
  57213. * Returns the texture used for refraction or null if none is used.
  57214. * @param scene defines the scene the material belongs to.
  57215. * @returns - Refraction texture if present. If no refraction texture and refraction
  57216. * is linked with transparency, returns environment texture. Otherwise, returns null.
  57217. */
  57218. private _getRefractionTexture;
  57219. /**
  57220. * Returns true if alpha blending should be disabled.
  57221. */
  57222. get disableAlphaBlending(): boolean;
  57223. /**
  57224. * Fills the list of render target textures.
  57225. * @param renderTargets the list of render targets to update
  57226. */
  57227. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  57228. /**
  57229. * Checks to see if a texture is used in the material.
  57230. * @param texture - Base texture to use.
  57231. * @returns - Boolean specifying if a texture is used in the material.
  57232. */
  57233. hasTexture(texture: BaseTexture): boolean;
  57234. /**
  57235. * Gets a boolean indicating that current material needs to register RTT
  57236. * @returns true if this uses a render target otherwise false.
  57237. */
  57238. hasRenderTargetTextures(): boolean;
  57239. /**
  57240. * Returns an array of the actively used textures.
  57241. * @param activeTextures Array of BaseTextures
  57242. */
  57243. getActiveTextures(activeTextures: BaseTexture[]): void;
  57244. /**
  57245. * Returns the animatable textures.
  57246. * @param animatables Array of animatable textures.
  57247. */
  57248. getAnimatables(animatables: IAnimatable[]): void;
  57249. /**
  57250. * Disposes the resources of the material.
  57251. * @param forceDisposeTextures - Forces the disposal of all textures.
  57252. */
  57253. dispose(forceDisposeTextures?: boolean): void;
  57254. /**
  57255. * Get the current class name of the texture useful for serialization or dynamic coding.
  57256. * @returns "PBRSubSurfaceConfiguration"
  57257. */
  57258. getClassName(): string;
  57259. /**
  57260. * Add fallbacks to the effect fallbacks list.
  57261. * @param defines defines the Base texture to use.
  57262. * @param fallbacks defines the current fallback list.
  57263. * @param currentRank defines the current fallback rank.
  57264. * @returns the new fallback rank.
  57265. */
  57266. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57267. /**
  57268. * Add the required uniforms to the current list.
  57269. * @param uniforms defines the current uniform list.
  57270. */
  57271. static AddUniforms(uniforms: string[]): void;
  57272. /**
  57273. * Add the required samplers to the current list.
  57274. * @param samplers defines the current sampler list.
  57275. */
  57276. static AddSamplers(samplers: string[]): void;
  57277. /**
  57278. * Add the required uniforms to the current buffer.
  57279. * @param uniformBuffer defines the current uniform buffer.
  57280. */
  57281. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57282. /**
  57283. * Makes a duplicate of the current configuration into another one.
  57284. * @param configuration define the config where to copy the info
  57285. */
  57286. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  57287. /**
  57288. * Serializes this Sub Surface configuration.
  57289. * @returns - An object with the serialized config.
  57290. */
  57291. serialize(): any;
  57292. /**
  57293. * Parses a anisotropy Configuration from a serialized object.
  57294. * @param source - Serialized object.
  57295. * @param scene Defines the scene we are parsing for
  57296. * @param rootUrl Defines the rootUrl to load from
  57297. */
  57298. parse(source: any, scene: Scene, rootUrl: string): void;
  57299. }
  57300. }
  57301. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  57302. /** @hidden */
  57303. export var pbrFragmentDeclaration: {
  57304. name: string;
  57305. shader: string;
  57306. };
  57307. }
  57308. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  57309. /** @hidden */
  57310. export var pbrUboDeclaration: {
  57311. name: string;
  57312. shader: string;
  57313. };
  57314. }
  57315. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  57316. /** @hidden */
  57317. export var pbrFragmentExtraDeclaration: {
  57318. name: string;
  57319. shader: string;
  57320. };
  57321. }
  57322. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  57323. /** @hidden */
  57324. export var pbrFragmentSamplersDeclaration: {
  57325. name: string;
  57326. shader: string;
  57327. };
  57328. }
  57329. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  57330. /** @hidden */
  57331. export var subSurfaceScatteringFunctions: {
  57332. name: string;
  57333. shader: string;
  57334. };
  57335. }
  57336. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  57337. /** @hidden */
  57338. export var importanceSampling: {
  57339. name: string;
  57340. shader: string;
  57341. };
  57342. }
  57343. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  57344. /** @hidden */
  57345. export var pbrHelperFunctions: {
  57346. name: string;
  57347. shader: string;
  57348. };
  57349. }
  57350. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  57351. /** @hidden */
  57352. export var harmonicsFunctions: {
  57353. name: string;
  57354. shader: string;
  57355. };
  57356. }
  57357. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  57358. /** @hidden */
  57359. export var pbrDirectLightingSetupFunctions: {
  57360. name: string;
  57361. shader: string;
  57362. };
  57363. }
  57364. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  57365. /** @hidden */
  57366. export var pbrDirectLightingFalloffFunctions: {
  57367. name: string;
  57368. shader: string;
  57369. };
  57370. }
  57371. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  57372. /** @hidden */
  57373. export var pbrBRDFFunctions: {
  57374. name: string;
  57375. shader: string;
  57376. };
  57377. }
  57378. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  57379. /** @hidden */
  57380. export var hdrFilteringFunctions: {
  57381. name: string;
  57382. shader: string;
  57383. };
  57384. }
  57385. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  57386. /** @hidden */
  57387. export var pbrDirectLightingFunctions: {
  57388. name: string;
  57389. shader: string;
  57390. };
  57391. }
  57392. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  57393. /** @hidden */
  57394. export var pbrIBLFunctions: {
  57395. name: string;
  57396. shader: string;
  57397. };
  57398. }
  57399. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  57400. /** @hidden */
  57401. export var pbrBlockAlbedoOpacity: {
  57402. name: string;
  57403. shader: string;
  57404. };
  57405. }
  57406. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  57407. /** @hidden */
  57408. export var pbrBlockReflectivity: {
  57409. name: string;
  57410. shader: string;
  57411. };
  57412. }
  57413. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  57414. /** @hidden */
  57415. export var pbrBlockAmbientOcclusion: {
  57416. name: string;
  57417. shader: string;
  57418. };
  57419. }
  57420. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  57421. /** @hidden */
  57422. export var pbrBlockAlphaFresnel: {
  57423. name: string;
  57424. shader: string;
  57425. };
  57426. }
  57427. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  57428. /** @hidden */
  57429. export var pbrBlockAnisotropic: {
  57430. name: string;
  57431. shader: string;
  57432. };
  57433. }
  57434. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  57435. /** @hidden */
  57436. export var pbrBlockReflection: {
  57437. name: string;
  57438. shader: string;
  57439. };
  57440. }
  57441. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  57442. /** @hidden */
  57443. export var pbrBlockSheen: {
  57444. name: string;
  57445. shader: string;
  57446. };
  57447. }
  57448. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  57449. /** @hidden */
  57450. export var pbrBlockClearcoat: {
  57451. name: string;
  57452. shader: string;
  57453. };
  57454. }
  57455. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  57456. /** @hidden */
  57457. export var pbrBlockSubSurface: {
  57458. name: string;
  57459. shader: string;
  57460. };
  57461. }
  57462. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  57463. /** @hidden */
  57464. export var pbrBlockNormalGeometric: {
  57465. name: string;
  57466. shader: string;
  57467. };
  57468. }
  57469. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  57470. /** @hidden */
  57471. export var pbrBlockNormalFinal: {
  57472. name: string;
  57473. shader: string;
  57474. };
  57475. }
  57476. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  57477. /** @hidden */
  57478. export var pbrBlockGeometryInfo: {
  57479. name: string;
  57480. shader: string;
  57481. };
  57482. }
  57483. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  57484. /** @hidden */
  57485. export var pbrBlockReflectance0: {
  57486. name: string;
  57487. shader: string;
  57488. };
  57489. }
  57490. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  57491. /** @hidden */
  57492. export var pbrBlockReflectance: {
  57493. name: string;
  57494. shader: string;
  57495. };
  57496. }
  57497. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  57498. /** @hidden */
  57499. export var pbrBlockDirectLighting: {
  57500. name: string;
  57501. shader: string;
  57502. };
  57503. }
  57504. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  57505. /** @hidden */
  57506. export var pbrBlockFinalLitComponents: {
  57507. name: string;
  57508. shader: string;
  57509. };
  57510. }
  57511. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  57512. /** @hidden */
  57513. export var pbrBlockFinalUnlitComponents: {
  57514. name: string;
  57515. shader: string;
  57516. };
  57517. }
  57518. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  57519. /** @hidden */
  57520. export var pbrBlockFinalColorComposition: {
  57521. name: string;
  57522. shader: string;
  57523. };
  57524. }
  57525. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  57526. /** @hidden */
  57527. export var pbrBlockImageProcessing: {
  57528. name: string;
  57529. shader: string;
  57530. };
  57531. }
  57532. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  57533. /** @hidden */
  57534. export var pbrDebug: {
  57535. name: string;
  57536. shader: string;
  57537. };
  57538. }
  57539. declare module "babylonjs/Shaders/pbr.fragment" {
  57540. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  57541. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  57542. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57543. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  57544. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57545. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57546. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  57547. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57548. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57549. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57550. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57551. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57552. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  57553. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  57554. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  57555. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57556. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57557. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57558. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  57559. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  57560. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  57561. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  57562. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  57563. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  57564. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  57565. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  57566. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  57567. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  57568. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  57569. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  57570. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  57571. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  57572. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  57573. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  57574. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  57575. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  57576. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57577. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  57578. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  57579. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  57580. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  57581. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  57582. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  57583. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  57584. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  57585. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57586. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  57587. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  57588. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  57589. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57590. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57591. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  57592. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  57593. /** @hidden */
  57594. export var pbrPixelShader: {
  57595. name: string;
  57596. shader: string;
  57597. };
  57598. }
  57599. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  57600. /** @hidden */
  57601. export var pbrVertexDeclaration: {
  57602. name: string;
  57603. shader: string;
  57604. };
  57605. }
  57606. declare module "babylonjs/Shaders/pbr.vertex" {
  57607. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  57608. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  57609. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57610. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57612. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  57613. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  57614. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57615. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57616. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57617. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57618. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  57619. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  57620. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57621. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  57622. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57623. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57624. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  57625. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57626. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57627. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57628. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57629. /** @hidden */
  57630. export var pbrVertexShader: {
  57631. name: string;
  57632. shader: string;
  57633. };
  57634. }
  57635. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  57636. import { Nullable } from "babylonjs/types";
  57637. import { Scene } from "babylonjs/scene";
  57638. import { Matrix } from "babylonjs/Maths/math.vector";
  57639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57641. import { Mesh } from "babylonjs/Meshes/mesh";
  57642. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  57643. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  57644. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  57645. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  57646. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  57647. import { Color3 } from "babylonjs/Maths/math.color";
  57648. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  57649. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  57650. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  57651. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57653. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57654. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57655. import "babylonjs/Shaders/pbr.fragment";
  57656. import "babylonjs/Shaders/pbr.vertex";
  57657. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  57658. /**
  57659. * Manages the defines for the PBR Material.
  57660. * @hidden
  57661. */
  57662. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  57663. PBR: boolean;
  57664. NUM_SAMPLES: string;
  57665. REALTIME_FILTERING: boolean;
  57666. MAINUV1: boolean;
  57667. MAINUV2: boolean;
  57668. UV1: boolean;
  57669. UV2: boolean;
  57670. ALBEDO: boolean;
  57671. GAMMAALBEDO: boolean;
  57672. ALBEDODIRECTUV: number;
  57673. VERTEXCOLOR: boolean;
  57674. DETAIL: boolean;
  57675. DETAILDIRECTUV: number;
  57676. DETAIL_NORMALBLENDMETHOD: number;
  57677. AMBIENT: boolean;
  57678. AMBIENTDIRECTUV: number;
  57679. AMBIENTINGRAYSCALE: boolean;
  57680. OPACITY: boolean;
  57681. VERTEXALPHA: boolean;
  57682. OPACITYDIRECTUV: number;
  57683. OPACITYRGB: boolean;
  57684. ALPHATEST: boolean;
  57685. DEPTHPREPASS: boolean;
  57686. ALPHABLEND: boolean;
  57687. ALPHAFROMALBEDO: boolean;
  57688. ALPHATESTVALUE: string;
  57689. SPECULAROVERALPHA: boolean;
  57690. RADIANCEOVERALPHA: boolean;
  57691. ALPHAFRESNEL: boolean;
  57692. LINEARALPHAFRESNEL: boolean;
  57693. PREMULTIPLYALPHA: boolean;
  57694. EMISSIVE: boolean;
  57695. EMISSIVEDIRECTUV: number;
  57696. REFLECTIVITY: boolean;
  57697. REFLECTIVITYDIRECTUV: number;
  57698. SPECULARTERM: boolean;
  57699. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  57700. MICROSURFACEAUTOMATIC: boolean;
  57701. LODBASEDMICROSFURACE: boolean;
  57702. MICROSURFACEMAP: boolean;
  57703. MICROSURFACEMAPDIRECTUV: number;
  57704. METALLICWORKFLOW: boolean;
  57705. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  57706. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  57707. METALLNESSSTOREINMETALMAPBLUE: boolean;
  57708. AOSTOREINMETALMAPRED: boolean;
  57709. METALLIC_REFLECTANCE: boolean;
  57710. METALLIC_REFLECTANCEDIRECTUV: number;
  57711. ENVIRONMENTBRDF: boolean;
  57712. ENVIRONMENTBRDF_RGBD: boolean;
  57713. NORMAL: boolean;
  57714. TANGENT: boolean;
  57715. BUMP: boolean;
  57716. BUMPDIRECTUV: number;
  57717. OBJECTSPACE_NORMALMAP: boolean;
  57718. PARALLAX: boolean;
  57719. PARALLAXOCCLUSION: boolean;
  57720. NORMALXYSCALE: boolean;
  57721. LIGHTMAP: boolean;
  57722. LIGHTMAPDIRECTUV: number;
  57723. USELIGHTMAPASSHADOWMAP: boolean;
  57724. GAMMALIGHTMAP: boolean;
  57725. RGBDLIGHTMAP: boolean;
  57726. REFLECTION: boolean;
  57727. REFLECTIONMAP_3D: boolean;
  57728. REFLECTIONMAP_SPHERICAL: boolean;
  57729. REFLECTIONMAP_PLANAR: boolean;
  57730. REFLECTIONMAP_CUBIC: boolean;
  57731. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  57732. REFLECTIONMAP_PROJECTION: boolean;
  57733. REFLECTIONMAP_SKYBOX: boolean;
  57734. REFLECTIONMAP_EXPLICIT: boolean;
  57735. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  57736. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  57737. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  57738. INVERTCUBICMAP: boolean;
  57739. USESPHERICALFROMREFLECTIONMAP: boolean;
  57740. USEIRRADIANCEMAP: boolean;
  57741. SPHERICAL_HARMONICS: boolean;
  57742. USESPHERICALINVERTEX: boolean;
  57743. REFLECTIONMAP_OPPOSITEZ: boolean;
  57744. LODINREFLECTIONALPHA: boolean;
  57745. GAMMAREFLECTION: boolean;
  57746. RGBDREFLECTION: boolean;
  57747. LINEARSPECULARREFLECTION: boolean;
  57748. RADIANCEOCCLUSION: boolean;
  57749. HORIZONOCCLUSION: boolean;
  57750. INSTANCES: boolean;
  57751. THIN_INSTANCES: boolean;
  57752. PREPASS: boolean;
  57753. SCENE_MRT_COUNT: number;
  57754. NUM_BONE_INFLUENCERS: number;
  57755. BonesPerMesh: number;
  57756. BONETEXTURE: boolean;
  57757. NONUNIFORMSCALING: boolean;
  57758. MORPHTARGETS: boolean;
  57759. MORPHTARGETS_NORMAL: boolean;
  57760. MORPHTARGETS_TANGENT: boolean;
  57761. MORPHTARGETS_UV: boolean;
  57762. NUM_MORPH_INFLUENCERS: number;
  57763. IMAGEPROCESSING: boolean;
  57764. VIGNETTE: boolean;
  57765. VIGNETTEBLENDMODEMULTIPLY: boolean;
  57766. VIGNETTEBLENDMODEOPAQUE: boolean;
  57767. TONEMAPPING: boolean;
  57768. TONEMAPPING_ACES: boolean;
  57769. CONTRAST: boolean;
  57770. COLORCURVES: boolean;
  57771. COLORGRADING: boolean;
  57772. COLORGRADING3D: boolean;
  57773. SAMPLER3DGREENDEPTH: boolean;
  57774. SAMPLER3DBGRMAP: boolean;
  57775. IMAGEPROCESSINGPOSTPROCESS: boolean;
  57776. EXPOSURE: boolean;
  57777. MULTIVIEW: boolean;
  57778. USEPHYSICALLIGHTFALLOFF: boolean;
  57779. USEGLTFLIGHTFALLOFF: boolean;
  57780. TWOSIDEDLIGHTING: boolean;
  57781. SHADOWFLOAT: boolean;
  57782. CLIPPLANE: boolean;
  57783. CLIPPLANE2: boolean;
  57784. CLIPPLANE3: boolean;
  57785. CLIPPLANE4: boolean;
  57786. CLIPPLANE5: boolean;
  57787. CLIPPLANE6: boolean;
  57788. POINTSIZE: boolean;
  57789. FOG: boolean;
  57790. LOGARITHMICDEPTH: boolean;
  57791. FORCENORMALFORWARD: boolean;
  57792. SPECULARAA: boolean;
  57793. CLEARCOAT: boolean;
  57794. CLEARCOAT_DEFAULTIOR: boolean;
  57795. CLEARCOAT_TEXTURE: boolean;
  57796. CLEARCOAT_TEXTUREDIRECTUV: number;
  57797. CLEARCOAT_BUMP: boolean;
  57798. CLEARCOAT_BUMPDIRECTUV: number;
  57799. CLEARCOAT_TINT: boolean;
  57800. CLEARCOAT_TINT_TEXTURE: boolean;
  57801. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57802. ANISOTROPIC: boolean;
  57803. ANISOTROPIC_TEXTURE: boolean;
  57804. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57805. BRDF_V_HEIGHT_CORRELATED: boolean;
  57806. MS_BRDF_ENERGY_CONSERVATION: boolean;
  57807. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  57808. SHEEN: boolean;
  57809. SHEEN_TEXTURE: boolean;
  57810. SHEEN_TEXTUREDIRECTUV: number;
  57811. SHEEN_LINKWITHALBEDO: boolean;
  57812. SHEEN_ROUGHNESS: boolean;
  57813. SHEEN_ALBEDOSCALING: boolean;
  57814. SUBSURFACE: boolean;
  57815. SS_REFRACTION: boolean;
  57816. SS_TRANSLUCENCY: boolean;
  57817. SS_SCATTERING: boolean;
  57818. SS_THICKNESSANDMASK_TEXTURE: boolean;
  57819. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  57820. SS_REFRACTIONMAP_3D: boolean;
  57821. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  57822. SS_LODINREFRACTIONALPHA: boolean;
  57823. SS_GAMMAREFRACTION: boolean;
  57824. SS_RGBDREFRACTION: boolean;
  57825. SS_LINEARSPECULARREFRACTION: boolean;
  57826. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  57827. SS_ALBEDOFORREFRACTIONTINT: boolean;
  57828. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  57829. UNLIT: boolean;
  57830. DEBUGMODE: number;
  57831. /**
  57832. * Initializes the PBR Material defines.
  57833. */
  57834. constructor();
  57835. /**
  57836. * Resets the PBR Material defines.
  57837. */
  57838. reset(): void;
  57839. }
  57840. /**
  57841. * The Physically based material base class of BJS.
  57842. *
  57843. * This offers the main features of a standard PBR material.
  57844. * For more information, please refer to the documentation :
  57845. * https://doc.babylonjs.com/how_to/physically_based_rendering
  57846. */
  57847. export abstract class PBRBaseMaterial extends PushMaterial {
  57848. /**
  57849. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  57850. */
  57851. static readonly PBRMATERIAL_OPAQUE: number;
  57852. /**
  57853. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  57854. */
  57855. static readonly PBRMATERIAL_ALPHATEST: number;
  57856. /**
  57857. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57858. */
  57859. static readonly PBRMATERIAL_ALPHABLEND: number;
  57860. /**
  57861. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  57862. * They are also discarded below the alpha cutoff threshold to improve performances.
  57863. */
  57864. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  57865. /**
  57866. * Defines the default value of how much AO map is occluding the analytical lights
  57867. * (point spot...).
  57868. */
  57869. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  57870. /**
  57871. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  57872. */
  57873. static readonly LIGHTFALLOFF_PHYSICAL: number;
  57874. /**
  57875. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  57876. * to enhance interoperability with other engines.
  57877. */
  57878. static readonly LIGHTFALLOFF_GLTF: number;
  57879. /**
  57880. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  57881. * to enhance interoperability with other materials.
  57882. */
  57883. static readonly LIGHTFALLOFF_STANDARD: number;
  57884. /**
  57885. * Intensity of the direct lights e.g. the four lights available in your scene.
  57886. * This impacts both the direct diffuse and specular highlights.
  57887. */
  57888. protected _directIntensity: number;
  57889. /**
  57890. * Intensity of the emissive part of the material.
  57891. * This helps controlling the emissive effect without modifying the emissive color.
  57892. */
  57893. protected _emissiveIntensity: number;
  57894. /**
  57895. * Intensity of the environment e.g. how much the environment will light the object
  57896. * either through harmonics for rough material or through the refelction for shiny ones.
  57897. */
  57898. protected _environmentIntensity: number;
  57899. /**
  57900. * This is a special control allowing the reduction of the specular highlights coming from the
  57901. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  57902. */
  57903. protected _specularIntensity: number;
  57904. /**
  57905. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  57906. */
  57907. private _lightingInfos;
  57908. /**
  57909. * Debug Control allowing disabling the bump map on this material.
  57910. */
  57911. protected _disableBumpMap: boolean;
  57912. /**
  57913. * AKA Diffuse Texture in standard nomenclature.
  57914. */
  57915. protected _albedoTexture: Nullable<BaseTexture>;
  57916. /**
  57917. * AKA Occlusion Texture in other nomenclature.
  57918. */
  57919. protected _ambientTexture: Nullable<BaseTexture>;
  57920. /**
  57921. * AKA Occlusion Texture Intensity in other nomenclature.
  57922. */
  57923. protected _ambientTextureStrength: number;
  57924. /**
  57925. * Defines how much the AO map is occluding the analytical lights (point spot...).
  57926. * 1 means it completely occludes it
  57927. * 0 mean it has no impact
  57928. */
  57929. protected _ambientTextureImpactOnAnalyticalLights: number;
  57930. /**
  57931. * Stores the alpha values in a texture.
  57932. */
  57933. protected _opacityTexture: Nullable<BaseTexture>;
  57934. /**
  57935. * Stores the reflection values in a texture.
  57936. */
  57937. protected _reflectionTexture: Nullable<BaseTexture>;
  57938. /**
  57939. * Stores the emissive values in a texture.
  57940. */
  57941. protected _emissiveTexture: Nullable<BaseTexture>;
  57942. /**
  57943. * AKA Specular texture in other nomenclature.
  57944. */
  57945. protected _reflectivityTexture: Nullable<BaseTexture>;
  57946. /**
  57947. * Used to switch from specular/glossiness to metallic/roughness workflow.
  57948. */
  57949. protected _metallicTexture: Nullable<BaseTexture>;
  57950. /**
  57951. * Specifies the metallic scalar of the metallic/roughness workflow.
  57952. * Can also be used to scale the metalness values of the metallic texture.
  57953. */
  57954. protected _metallic: Nullable<number>;
  57955. /**
  57956. * Specifies the roughness scalar of the metallic/roughness workflow.
  57957. * Can also be used to scale the roughness values of the metallic texture.
  57958. */
  57959. protected _roughness: Nullable<number>;
  57960. /**
  57961. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  57962. * By default the indexOfrefraction is used to compute F0;
  57963. *
  57964. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  57965. *
  57966. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  57967. * F90 = metallicReflectanceColor;
  57968. */
  57969. protected _metallicF0Factor: number;
  57970. /**
  57971. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  57972. * By default the F90 is always 1;
  57973. *
  57974. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  57975. *
  57976. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  57977. * F90 = metallicReflectanceColor;
  57978. */
  57979. protected _metallicReflectanceColor: Color3;
  57980. /**
  57981. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  57982. * This is multiply against the scalar values defined in the material.
  57983. */
  57984. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  57985. /**
  57986. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  57987. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  57988. */
  57989. protected _microSurfaceTexture: Nullable<BaseTexture>;
  57990. /**
  57991. * Stores surface normal data used to displace a mesh in a texture.
  57992. */
  57993. protected _bumpTexture: Nullable<BaseTexture>;
  57994. /**
  57995. * Stores the pre-calculated light information of a mesh in a texture.
  57996. */
  57997. protected _lightmapTexture: Nullable<BaseTexture>;
  57998. /**
  57999. * The color of a material in ambient lighting.
  58000. */
  58001. protected _ambientColor: Color3;
  58002. /**
  58003. * AKA Diffuse Color in other nomenclature.
  58004. */
  58005. protected _albedoColor: Color3;
  58006. /**
  58007. * AKA Specular Color in other nomenclature.
  58008. */
  58009. protected _reflectivityColor: Color3;
  58010. /**
  58011. * The color applied when light is reflected from a material.
  58012. */
  58013. protected _reflectionColor: Color3;
  58014. /**
  58015. * The color applied when light is emitted from a material.
  58016. */
  58017. protected _emissiveColor: Color3;
  58018. /**
  58019. * AKA Glossiness in other nomenclature.
  58020. */
  58021. protected _microSurface: number;
  58022. /**
  58023. * Specifies that the material will use the light map as a show map.
  58024. */
  58025. protected _useLightmapAsShadowmap: boolean;
  58026. /**
  58027. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58028. * makes the reflect vector face the model (under horizon).
  58029. */
  58030. protected _useHorizonOcclusion: boolean;
  58031. /**
  58032. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58033. * too much the area relying on ambient texture to define their ambient occlusion.
  58034. */
  58035. protected _useRadianceOcclusion: boolean;
  58036. /**
  58037. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58038. */
  58039. protected _useAlphaFromAlbedoTexture: boolean;
  58040. /**
  58041. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  58042. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58043. */
  58044. protected _useSpecularOverAlpha: boolean;
  58045. /**
  58046. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58047. */
  58048. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58049. /**
  58050. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58051. */
  58052. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  58053. /**
  58054. * Specifies if the metallic texture contains the roughness information in its green channel.
  58055. */
  58056. protected _useRoughnessFromMetallicTextureGreen: boolean;
  58057. /**
  58058. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58059. */
  58060. protected _useMetallnessFromMetallicTextureBlue: boolean;
  58061. /**
  58062. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58063. */
  58064. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  58065. /**
  58066. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58067. */
  58068. protected _useAmbientInGrayScale: boolean;
  58069. /**
  58070. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58071. * The material will try to infer what glossiness each pixel should be.
  58072. */
  58073. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  58074. /**
  58075. * Defines the falloff type used in this material.
  58076. * It by default is Physical.
  58077. */
  58078. protected _lightFalloff: number;
  58079. /**
  58080. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58081. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58082. */
  58083. protected _useRadianceOverAlpha: boolean;
  58084. /**
  58085. * Allows using an object space normal map (instead of tangent space).
  58086. */
  58087. protected _useObjectSpaceNormalMap: boolean;
  58088. /**
  58089. * Allows using the bump map in parallax mode.
  58090. */
  58091. protected _useParallax: boolean;
  58092. /**
  58093. * Allows using the bump map in parallax occlusion mode.
  58094. */
  58095. protected _useParallaxOcclusion: boolean;
  58096. /**
  58097. * Controls the scale bias of the parallax mode.
  58098. */
  58099. protected _parallaxScaleBias: number;
  58100. /**
  58101. * If sets to true, disables all the lights affecting the material.
  58102. */
  58103. protected _disableLighting: boolean;
  58104. /**
  58105. * Number of Simultaneous lights allowed on the material.
  58106. */
  58107. protected _maxSimultaneousLights: number;
  58108. /**
  58109. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58110. */
  58111. protected _invertNormalMapX: boolean;
  58112. /**
  58113. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58114. */
  58115. protected _invertNormalMapY: boolean;
  58116. /**
  58117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58118. */
  58119. protected _twoSidedLighting: boolean;
  58120. /**
  58121. * Defines the alpha limits in alpha test mode.
  58122. */
  58123. protected _alphaCutOff: number;
  58124. /**
  58125. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58126. */
  58127. protected _forceAlphaTest: boolean;
  58128. /**
  58129. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58130. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58131. */
  58132. protected _useAlphaFresnel: boolean;
  58133. /**
  58134. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58135. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58136. */
  58137. protected _useLinearAlphaFresnel: boolean;
  58138. /**
  58139. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  58140. * from cos thetav and roughness:
  58141. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  58142. */
  58143. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  58144. /**
  58145. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58146. */
  58147. protected _forceIrradianceInFragment: boolean;
  58148. private _realTimeFiltering;
  58149. /**
  58150. * Enables realtime filtering on the texture.
  58151. */
  58152. get realTimeFiltering(): boolean;
  58153. set realTimeFiltering(b: boolean);
  58154. private _realTimeFilteringQuality;
  58155. /**
  58156. * Quality switch for realtime filtering
  58157. */
  58158. get realTimeFilteringQuality(): number;
  58159. set realTimeFilteringQuality(n: number);
  58160. /**
  58161. * Should this material render to several textures at once
  58162. */
  58163. get shouldRenderToMRT(): boolean;
  58164. /**
  58165. * Force normal to face away from face.
  58166. */
  58167. protected _forceNormalForward: boolean;
  58168. /**
  58169. * Enables specular anti aliasing in the PBR shader.
  58170. * It will both interacts on the Geometry for analytical and IBL lighting.
  58171. * It also prefilter the roughness map based on the bump values.
  58172. */
  58173. protected _enableSpecularAntiAliasing: boolean;
  58174. /**
  58175. * Default configuration related to image processing available in the PBR Material.
  58176. */
  58177. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  58178. /**
  58179. * Keep track of the image processing observer to allow dispose and replace.
  58180. */
  58181. private _imageProcessingObserver;
  58182. /**
  58183. * Attaches a new image processing configuration to the PBR Material.
  58184. * @param configuration
  58185. */
  58186. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  58187. /**
  58188. * Stores the available render targets.
  58189. */
  58190. private _renderTargets;
  58191. /**
  58192. * Sets the global ambient color for the material used in lighting calculations.
  58193. */
  58194. private _globalAmbientColor;
  58195. /**
  58196. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  58197. */
  58198. private _useLogarithmicDepth;
  58199. /**
  58200. * If set to true, no lighting calculations will be applied.
  58201. */
  58202. private _unlit;
  58203. private _debugMode;
  58204. /**
  58205. * @hidden
  58206. * This is reserved for the inspector.
  58207. * Defines the material debug mode.
  58208. * It helps seeing only some components of the material while troubleshooting.
  58209. */
  58210. debugMode: number;
  58211. /**
  58212. * @hidden
  58213. * This is reserved for the inspector.
  58214. * Specify from where on screen the debug mode should start.
  58215. * The value goes from -1 (full screen) to 1 (not visible)
  58216. * It helps with side by side comparison against the final render
  58217. * This defaults to -1
  58218. */
  58219. private debugLimit;
  58220. /**
  58221. * @hidden
  58222. * This is reserved for the inspector.
  58223. * As the default viewing range might not be enough (if the ambient is really small for instance)
  58224. * You can use the factor to better multiply the final value.
  58225. */
  58226. private debugFactor;
  58227. /**
  58228. * Defines the clear coat layer parameters for the material.
  58229. */
  58230. readonly clearCoat: PBRClearCoatConfiguration;
  58231. /**
  58232. * Defines the anisotropic parameters for the material.
  58233. */
  58234. readonly anisotropy: PBRAnisotropicConfiguration;
  58235. /**
  58236. * Defines the BRDF parameters for the material.
  58237. */
  58238. readonly brdf: PBRBRDFConfiguration;
  58239. /**
  58240. * Defines the Sheen parameters for the material.
  58241. */
  58242. readonly sheen: PBRSheenConfiguration;
  58243. /**
  58244. * Defines the SubSurface parameters for the material.
  58245. */
  58246. readonly subSurface: PBRSubSurfaceConfiguration;
  58247. /**
  58248. * Defines the detail map parameters for the material.
  58249. */
  58250. readonly detailMap: DetailMapConfiguration;
  58251. protected _rebuildInParallel: boolean;
  58252. /**
  58253. * Instantiates a new PBRMaterial instance.
  58254. *
  58255. * @param name The material name
  58256. * @param scene The scene the material will be use in.
  58257. */
  58258. constructor(name: string, scene: Scene);
  58259. /**
  58260. * Gets a boolean indicating that current material needs to register RTT
  58261. */
  58262. get hasRenderTargetTextures(): boolean;
  58263. /**
  58264. * Gets the name of the material class.
  58265. */
  58266. getClassName(): string;
  58267. /**
  58268. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58269. */
  58270. get useLogarithmicDepth(): boolean;
  58271. /**
  58272. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  58273. */
  58274. set useLogarithmicDepth(value: boolean);
  58275. /**
  58276. * Returns true if alpha blending should be disabled.
  58277. */
  58278. protected get _disableAlphaBlending(): boolean;
  58279. /**
  58280. * Specifies whether or not this material should be rendered in alpha blend mode.
  58281. */
  58282. needAlphaBlending(): boolean;
  58283. /**
  58284. * Specifies whether or not this material should be rendered in alpha test mode.
  58285. */
  58286. needAlphaTesting(): boolean;
  58287. /**
  58288. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  58289. */
  58290. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  58291. /**
  58292. * Gets the texture used for the alpha test.
  58293. */
  58294. getAlphaTestTexture(): Nullable<BaseTexture>;
  58295. /**
  58296. * Specifies that the submesh is ready to be used.
  58297. * @param mesh - BJS mesh.
  58298. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  58299. * @param useInstances - Specifies that instances should be used.
  58300. * @returns - boolean indicating that the submesh is ready or not.
  58301. */
  58302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  58303. /**
  58304. * Specifies if the material uses metallic roughness workflow.
  58305. * @returns boolean specifiying if the material uses metallic roughness workflow.
  58306. */
  58307. isMetallicWorkflow(): boolean;
  58308. private _prepareEffect;
  58309. private _prepareDefines;
  58310. /**
  58311. * Force shader compilation
  58312. */
  58313. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  58314. /**
  58315. * Initializes the uniform buffer layout for the shader.
  58316. */
  58317. buildUniformLayout(): void;
  58318. /**
  58319. * Unbinds the material from the mesh
  58320. */
  58321. unbind(): void;
  58322. /**
  58323. * Binds the submesh data.
  58324. * @param world - The world matrix.
  58325. * @param mesh - The BJS mesh.
  58326. * @param subMesh - A submesh of the BJS mesh.
  58327. */
  58328. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  58329. /**
  58330. * Returns the animatable textures.
  58331. * @returns - Array of animatable textures.
  58332. */
  58333. getAnimatables(): IAnimatable[];
  58334. /**
  58335. * Returns the texture used for reflections.
  58336. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  58337. */
  58338. private _getReflectionTexture;
  58339. /**
  58340. * Returns an array of the actively used textures.
  58341. * @returns - Array of BaseTextures
  58342. */
  58343. getActiveTextures(): BaseTexture[];
  58344. /**
  58345. * Checks to see if a texture is used in the material.
  58346. * @param texture - Base texture to use.
  58347. * @returns - Boolean specifying if a texture is used in the material.
  58348. */
  58349. hasTexture(texture: BaseTexture): boolean;
  58350. /**
  58351. * Disposes the resources of the material.
  58352. * @param forceDisposeEffect - Forces the disposal of effects.
  58353. * @param forceDisposeTextures - Forces the disposal of all textures.
  58354. */
  58355. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  58356. }
  58357. }
  58358. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  58359. import { Nullable } from "babylonjs/types";
  58360. import { Scene } from "babylonjs/scene";
  58361. import { Color3 } from "babylonjs/Maths/math.color";
  58362. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  58363. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  58364. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58365. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58366. /**
  58367. * The Physically based material of BJS.
  58368. *
  58369. * This offers the main features of a standard PBR material.
  58370. * For more information, please refer to the documentation :
  58371. * https://doc.babylonjs.com/how_to/physically_based_rendering
  58372. */
  58373. export class PBRMaterial extends PBRBaseMaterial {
  58374. /**
  58375. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  58376. */
  58377. static readonly PBRMATERIAL_OPAQUE: number;
  58378. /**
  58379. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  58380. */
  58381. static readonly PBRMATERIAL_ALPHATEST: number;
  58382. /**
  58383. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58384. */
  58385. static readonly PBRMATERIAL_ALPHABLEND: number;
  58386. /**
  58387. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  58388. * They are also discarded below the alpha cutoff threshold to improve performances.
  58389. */
  58390. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  58391. /**
  58392. * Defines the default value of how much AO map is occluding the analytical lights
  58393. * (point spot...).
  58394. */
  58395. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  58396. /**
  58397. * Intensity of the direct lights e.g. the four lights available in your scene.
  58398. * This impacts both the direct diffuse and specular highlights.
  58399. */
  58400. directIntensity: number;
  58401. /**
  58402. * Intensity of the emissive part of the material.
  58403. * This helps controlling the emissive effect without modifying the emissive color.
  58404. */
  58405. emissiveIntensity: number;
  58406. /**
  58407. * Intensity of the environment e.g. how much the environment will light the object
  58408. * either through harmonics for rough material or through the refelction for shiny ones.
  58409. */
  58410. environmentIntensity: number;
  58411. /**
  58412. * This is a special control allowing the reduction of the specular highlights coming from the
  58413. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  58414. */
  58415. specularIntensity: number;
  58416. /**
  58417. * Debug Control allowing disabling the bump map on this material.
  58418. */
  58419. disableBumpMap: boolean;
  58420. /**
  58421. * AKA Diffuse Texture in standard nomenclature.
  58422. */
  58423. albedoTexture: BaseTexture;
  58424. /**
  58425. * AKA Occlusion Texture in other nomenclature.
  58426. */
  58427. ambientTexture: BaseTexture;
  58428. /**
  58429. * AKA Occlusion Texture Intensity in other nomenclature.
  58430. */
  58431. ambientTextureStrength: number;
  58432. /**
  58433. * Defines how much the AO map is occluding the analytical lights (point spot...).
  58434. * 1 means it completely occludes it
  58435. * 0 mean it has no impact
  58436. */
  58437. ambientTextureImpactOnAnalyticalLights: number;
  58438. /**
  58439. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  58440. */
  58441. opacityTexture: BaseTexture;
  58442. /**
  58443. * Stores the reflection values in a texture.
  58444. */
  58445. reflectionTexture: Nullable<BaseTexture>;
  58446. /**
  58447. * Stores the emissive values in a texture.
  58448. */
  58449. emissiveTexture: BaseTexture;
  58450. /**
  58451. * AKA Specular texture in other nomenclature.
  58452. */
  58453. reflectivityTexture: BaseTexture;
  58454. /**
  58455. * Used to switch from specular/glossiness to metallic/roughness workflow.
  58456. */
  58457. metallicTexture: BaseTexture;
  58458. /**
  58459. * Specifies the metallic scalar of the metallic/roughness workflow.
  58460. * Can also be used to scale the metalness values of the metallic texture.
  58461. */
  58462. metallic: Nullable<number>;
  58463. /**
  58464. * Specifies the roughness scalar of the metallic/roughness workflow.
  58465. * Can also be used to scale the roughness values of the metallic texture.
  58466. */
  58467. roughness: Nullable<number>;
  58468. /**
  58469. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  58470. * By default the indexOfrefraction is used to compute F0;
  58471. *
  58472. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  58473. *
  58474. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  58475. * F90 = metallicReflectanceColor;
  58476. */
  58477. metallicF0Factor: number;
  58478. /**
  58479. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  58480. * By default the F90 is always 1;
  58481. *
  58482. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  58483. *
  58484. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  58485. * F90 = metallicReflectanceColor;
  58486. */
  58487. metallicReflectanceColor: Color3;
  58488. /**
  58489. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  58490. * This is multiply against the scalar values defined in the material.
  58491. */
  58492. metallicReflectanceTexture: Nullable<BaseTexture>;
  58493. /**
  58494. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  58495. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  58496. */
  58497. microSurfaceTexture: BaseTexture;
  58498. /**
  58499. * Stores surface normal data used to displace a mesh in a texture.
  58500. */
  58501. bumpTexture: BaseTexture;
  58502. /**
  58503. * Stores the pre-calculated light information of a mesh in a texture.
  58504. */
  58505. lightmapTexture: BaseTexture;
  58506. /**
  58507. * Stores the refracted light information in a texture.
  58508. */
  58509. get refractionTexture(): Nullable<BaseTexture>;
  58510. set refractionTexture(value: Nullable<BaseTexture>);
  58511. /**
  58512. * The color of a material in ambient lighting.
  58513. */
  58514. ambientColor: Color3;
  58515. /**
  58516. * AKA Diffuse Color in other nomenclature.
  58517. */
  58518. albedoColor: Color3;
  58519. /**
  58520. * AKA Specular Color in other nomenclature.
  58521. */
  58522. reflectivityColor: Color3;
  58523. /**
  58524. * The color reflected from the material.
  58525. */
  58526. reflectionColor: Color3;
  58527. /**
  58528. * The color emitted from the material.
  58529. */
  58530. emissiveColor: Color3;
  58531. /**
  58532. * AKA Glossiness in other nomenclature.
  58533. */
  58534. microSurface: number;
  58535. /**
  58536. * Index of refraction of the material base layer.
  58537. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58538. *
  58539. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58540. *
  58541. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58542. */
  58543. get indexOfRefraction(): number;
  58544. set indexOfRefraction(value: number);
  58545. /**
  58546. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58547. */
  58548. get invertRefractionY(): boolean;
  58549. set invertRefractionY(value: boolean);
  58550. /**
  58551. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58552. * Materials half opaque for instance using refraction could benefit from this control.
  58553. */
  58554. get linkRefractionWithTransparency(): boolean;
  58555. set linkRefractionWithTransparency(value: boolean);
  58556. /**
  58557. * If true, the light map contains occlusion information instead of lighting info.
  58558. */
  58559. useLightmapAsShadowmap: boolean;
  58560. /**
  58561. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  58562. */
  58563. useAlphaFromAlbedoTexture: boolean;
  58564. /**
  58565. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  58566. */
  58567. forceAlphaTest: boolean;
  58568. /**
  58569. * Defines the alpha limits in alpha test mode.
  58570. */
  58571. alphaCutOff: number;
  58572. /**
  58573. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  58574. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  58575. */
  58576. useSpecularOverAlpha: boolean;
  58577. /**
  58578. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  58579. */
  58580. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  58581. /**
  58582. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  58583. */
  58584. useRoughnessFromMetallicTextureAlpha: boolean;
  58585. /**
  58586. * Specifies if the metallic texture contains the roughness information in its green channel.
  58587. */
  58588. useRoughnessFromMetallicTextureGreen: boolean;
  58589. /**
  58590. * Specifies if the metallic texture contains the metallness information in its blue channel.
  58591. */
  58592. useMetallnessFromMetallicTextureBlue: boolean;
  58593. /**
  58594. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  58595. */
  58596. useAmbientOcclusionFromMetallicTextureRed: boolean;
  58597. /**
  58598. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  58599. */
  58600. useAmbientInGrayScale: boolean;
  58601. /**
  58602. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  58603. * The material will try to infer what glossiness each pixel should be.
  58604. */
  58605. useAutoMicroSurfaceFromReflectivityMap: boolean;
  58606. /**
  58607. * BJS is using an harcoded light falloff based on a manually sets up range.
  58608. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58609. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58610. */
  58611. get usePhysicalLightFalloff(): boolean;
  58612. /**
  58613. * BJS is using an harcoded light falloff based on a manually sets up range.
  58614. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  58615. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  58616. */
  58617. set usePhysicalLightFalloff(value: boolean);
  58618. /**
  58619. * In order to support the falloff compatibility with gltf, a special mode has been added
  58620. * to reproduce the gltf light falloff.
  58621. */
  58622. get useGLTFLightFalloff(): boolean;
  58623. /**
  58624. * In order to support the falloff compatibility with gltf, a special mode has been added
  58625. * to reproduce the gltf light falloff.
  58626. */
  58627. set useGLTFLightFalloff(value: boolean);
  58628. /**
  58629. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  58630. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  58631. */
  58632. useRadianceOverAlpha: boolean;
  58633. /**
  58634. * Allows using an object space normal map (instead of tangent space).
  58635. */
  58636. useObjectSpaceNormalMap: boolean;
  58637. /**
  58638. * Allows using the bump map in parallax mode.
  58639. */
  58640. useParallax: boolean;
  58641. /**
  58642. * Allows using the bump map in parallax occlusion mode.
  58643. */
  58644. useParallaxOcclusion: boolean;
  58645. /**
  58646. * Controls the scale bias of the parallax mode.
  58647. */
  58648. parallaxScaleBias: number;
  58649. /**
  58650. * If sets to true, disables all the lights affecting the material.
  58651. */
  58652. disableLighting: boolean;
  58653. /**
  58654. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  58655. */
  58656. forceIrradianceInFragment: boolean;
  58657. /**
  58658. * Number of Simultaneous lights allowed on the material.
  58659. */
  58660. maxSimultaneousLights: number;
  58661. /**
  58662. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58663. */
  58664. invertNormalMapX: boolean;
  58665. /**
  58666. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58667. */
  58668. invertNormalMapY: boolean;
  58669. /**
  58670. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58671. */
  58672. twoSidedLighting: boolean;
  58673. /**
  58674. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58675. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  58676. */
  58677. useAlphaFresnel: boolean;
  58678. /**
  58679. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  58680. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  58681. */
  58682. useLinearAlphaFresnel: boolean;
  58683. /**
  58684. * Let user defines the brdf lookup texture used for IBL.
  58685. * A default 8bit version is embedded but you could point at :
  58686. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  58687. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  58688. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  58689. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  58690. */
  58691. environmentBRDFTexture: Nullable<BaseTexture>;
  58692. /**
  58693. * Force normal to face away from face.
  58694. */
  58695. forceNormalForward: boolean;
  58696. /**
  58697. * Enables specular anti aliasing in the PBR shader.
  58698. * It will both interacts on the Geometry for analytical and IBL lighting.
  58699. * It also prefilter the roughness map based on the bump values.
  58700. */
  58701. enableSpecularAntiAliasing: boolean;
  58702. /**
  58703. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  58704. * makes the reflect vector face the model (under horizon).
  58705. */
  58706. useHorizonOcclusion: boolean;
  58707. /**
  58708. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  58709. * too much the area relying on ambient texture to define their ambient occlusion.
  58710. */
  58711. useRadianceOcclusion: boolean;
  58712. /**
  58713. * If set to true, no lighting calculations will be applied.
  58714. */
  58715. unlit: boolean;
  58716. /**
  58717. * Gets the image processing configuration used either in this material.
  58718. */
  58719. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  58720. /**
  58721. * Sets the Default image processing configuration used either in the this material.
  58722. *
  58723. * If sets to null, the scene one is in use.
  58724. */
  58725. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  58726. /**
  58727. * Gets wether the color curves effect is enabled.
  58728. */
  58729. get cameraColorCurvesEnabled(): boolean;
  58730. /**
  58731. * Sets wether the color curves effect is enabled.
  58732. */
  58733. set cameraColorCurvesEnabled(value: boolean);
  58734. /**
  58735. * Gets wether the color grading effect is enabled.
  58736. */
  58737. get cameraColorGradingEnabled(): boolean;
  58738. /**
  58739. * Gets wether the color grading effect is enabled.
  58740. */
  58741. set cameraColorGradingEnabled(value: boolean);
  58742. /**
  58743. * Gets wether tonemapping is enabled or not.
  58744. */
  58745. get cameraToneMappingEnabled(): boolean;
  58746. /**
  58747. * Sets wether tonemapping is enabled or not
  58748. */
  58749. set cameraToneMappingEnabled(value: boolean);
  58750. /**
  58751. * The camera exposure used on this material.
  58752. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58753. * This corresponds to a photographic exposure.
  58754. */
  58755. get cameraExposure(): number;
  58756. /**
  58757. * The camera exposure used on this material.
  58758. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  58759. * This corresponds to a photographic exposure.
  58760. */
  58761. set cameraExposure(value: number);
  58762. /**
  58763. * Gets The camera contrast used on this material.
  58764. */
  58765. get cameraContrast(): number;
  58766. /**
  58767. * Sets The camera contrast used on this material.
  58768. */
  58769. set cameraContrast(value: number);
  58770. /**
  58771. * Gets the Color Grading 2D Lookup Texture.
  58772. */
  58773. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  58774. /**
  58775. * Sets the Color Grading 2D Lookup Texture.
  58776. */
  58777. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  58778. /**
  58779. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58780. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58781. * 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;
  58782. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58783. */
  58784. get cameraColorCurves(): Nullable<ColorCurves>;
  58785. /**
  58786. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  58787. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  58788. * 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;
  58789. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  58790. */
  58791. set cameraColorCurves(value: Nullable<ColorCurves>);
  58792. /**
  58793. * Instantiates a new PBRMaterial instance.
  58794. *
  58795. * @param name The material name
  58796. * @param scene The scene the material will be use in.
  58797. */
  58798. constructor(name: string, scene: Scene);
  58799. /**
  58800. * Returns the name of this material class.
  58801. */
  58802. getClassName(): string;
  58803. /**
  58804. * Makes a duplicate of the current material.
  58805. * @param name - name to use for the new material.
  58806. */
  58807. clone(name: string): PBRMaterial;
  58808. /**
  58809. * Serializes this PBR Material.
  58810. * @returns - An object with the serialized material.
  58811. */
  58812. serialize(): any;
  58813. /**
  58814. * Parses a PBR Material from a serialized object.
  58815. * @param source - Serialized object.
  58816. * @param scene - BJS scene instance.
  58817. * @param rootUrl - url for the scene object
  58818. * @returns - PBRMaterial
  58819. */
  58820. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  58821. }
  58822. }
  58823. declare module "babylonjs/Misc/dds" {
  58824. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58825. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58826. import { Nullable } from "babylonjs/types";
  58827. import { Scene } from "babylonjs/scene";
  58828. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  58829. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58830. /**
  58831. * Direct draw surface info
  58832. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58833. */
  58834. export interface DDSInfo {
  58835. /**
  58836. * Width of the texture
  58837. */
  58838. width: number;
  58839. /**
  58840. * Width of the texture
  58841. */
  58842. height: number;
  58843. /**
  58844. * Number of Mipmaps for the texture
  58845. * @see https://en.wikipedia.org/wiki/Mipmap
  58846. */
  58847. mipmapCount: number;
  58848. /**
  58849. * If the textures format is a known fourCC format
  58850. * @see https://www.fourcc.org/
  58851. */
  58852. isFourCC: boolean;
  58853. /**
  58854. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58855. */
  58856. isRGB: boolean;
  58857. /**
  58858. * If the texture is a lumincance format
  58859. */
  58860. isLuminance: boolean;
  58861. /**
  58862. * If this is a cube texture
  58863. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58864. */
  58865. isCube: boolean;
  58866. /**
  58867. * If the texture is a compressed format eg. FOURCC_DXT1
  58868. */
  58869. isCompressed: boolean;
  58870. /**
  58871. * The dxgiFormat of the texture
  58872. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58873. */
  58874. dxgiFormat: number;
  58875. /**
  58876. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58877. */
  58878. textureType: number;
  58879. /**
  58880. * Sphericle polynomial created for the dds texture
  58881. */
  58882. sphericalPolynomial?: SphericalPolynomial;
  58883. }
  58884. /**
  58885. * Class used to provide DDS decompression tools
  58886. */
  58887. export class DDSTools {
  58888. /**
  58889. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58890. */
  58891. static StoreLODInAlphaChannel: boolean;
  58892. /**
  58893. * Gets DDS information from an array buffer
  58894. * @param data defines the array buffer view to read data from
  58895. * @returns the DDS information
  58896. */
  58897. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58898. private static _FloatView;
  58899. private static _Int32View;
  58900. private static _ToHalfFloat;
  58901. private static _FromHalfFloat;
  58902. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58903. private static _GetHalfFloatRGBAArrayBuffer;
  58904. private static _GetFloatRGBAArrayBuffer;
  58905. private static _GetFloatAsUIntRGBAArrayBuffer;
  58906. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58907. private static _GetRGBAArrayBuffer;
  58908. private static _ExtractLongWordOrder;
  58909. private static _GetRGBArrayBuffer;
  58910. private static _GetLuminanceArrayBuffer;
  58911. /**
  58912. * Uploads DDS Levels to a Babylon Texture
  58913. * @hidden
  58914. */
  58915. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58916. }
  58917. module "babylonjs/Engines/thinEngine" {
  58918. interface ThinEngine {
  58919. /**
  58920. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58921. * @param rootUrl defines the url where the file to load is located
  58922. * @param scene defines the current scene
  58923. * @param lodScale defines scale to apply to the mip map selection
  58924. * @param lodOffset defines offset to apply to the mip map selection
  58925. * @param onLoad defines an optional callback raised when the texture is loaded
  58926. * @param onError defines an optional callback raised if there is an issue to load the texture
  58927. * @param format defines the format of the data
  58928. * @param forcedExtension defines the extension to use to pick the right loader
  58929. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58930. * @returns the cube texture as an InternalTexture
  58931. */
  58932. 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;
  58933. }
  58934. }
  58935. }
  58936. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  58937. import { Nullable } from "babylonjs/types";
  58938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58939. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58940. /**
  58941. * Implementation of the DDS Texture Loader.
  58942. * @hidden
  58943. */
  58944. export class _DDSTextureLoader implements IInternalTextureLoader {
  58945. /**
  58946. * Defines wether the loader supports cascade loading the different faces.
  58947. */
  58948. readonly supportCascades: boolean;
  58949. /**
  58950. * This returns if the loader support the current file information.
  58951. * @param extension defines the file extension of the file being loaded
  58952. * @returns true if the loader can load the specified file
  58953. */
  58954. canLoad(extension: string): boolean;
  58955. /**
  58956. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58957. * @param data contains the texture data
  58958. * @param texture defines the BabylonJS internal texture
  58959. * @param createPolynomials will be true if polynomials have been requested
  58960. * @param onLoad defines the callback to trigger once the texture is ready
  58961. * @param onError defines the callback to trigger in case of error
  58962. */
  58963. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58964. /**
  58965. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58966. * @param data contains the texture data
  58967. * @param texture defines the BabylonJS internal texture
  58968. * @param callback defines the method to call once ready to upload
  58969. */
  58970. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58971. }
  58972. }
  58973. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  58974. import { Nullable } from "babylonjs/types";
  58975. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58976. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58977. /**
  58978. * Implementation of the ENV Texture Loader.
  58979. * @hidden
  58980. */
  58981. export class _ENVTextureLoader implements IInternalTextureLoader {
  58982. /**
  58983. * Defines wether the loader supports cascade loading the different faces.
  58984. */
  58985. readonly supportCascades: boolean;
  58986. /**
  58987. * This returns if the loader support the current file information.
  58988. * @param extension defines the file extension of the file being loaded
  58989. * @returns true if the loader can load the specified file
  58990. */
  58991. canLoad(extension: string): boolean;
  58992. /**
  58993. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58994. * @param data contains the texture data
  58995. * @param texture defines the BabylonJS internal texture
  58996. * @param createPolynomials will be true if polynomials have been requested
  58997. * @param onLoad defines the callback to trigger once the texture is ready
  58998. * @param onError defines the callback to trigger in case of error
  58999. */
  59000. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59001. /**
  59002. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59003. * @param data contains the texture data
  59004. * @param texture defines the BabylonJS internal texture
  59005. * @param callback defines the method to call once ready to upload
  59006. */
  59007. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59008. }
  59009. }
  59010. declare module "babylonjs/Misc/khronosTextureContainer" {
  59011. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59012. /**
  59013. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  59014. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  59015. */
  59016. export class KhronosTextureContainer {
  59017. /** contents of the KTX container file */
  59018. data: ArrayBufferView;
  59019. private static HEADER_LEN;
  59020. private static COMPRESSED_2D;
  59021. private static COMPRESSED_3D;
  59022. private static TEX_2D;
  59023. private static TEX_3D;
  59024. /**
  59025. * Gets the openGL type
  59026. */
  59027. glType: number;
  59028. /**
  59029. * Gets the openGL type size
  59030. */
  59031. glTypeSize: number;
  59032. /**
  59033. * Gets the openGL format
  59034. */
  59035. glFormat: number;
  59036. /**
  59037. * Gets the openGL internal format
  59038. */
  59039. glInternalFormat: number;
  59040. /**
  59041. * Gets the base internal format
  59042. */
  59043. glBaseInternalFormat: number;
  59044. /**
  59045. * Gets image width in pixel
  59046. */
  59047. pixelWidth: number;
  59048. /**
  59049. * Gets image height in pixel
  59050. */
  59051. pixelHeight: number;
  59052. /**
  59053. * Gets image depth in pixels
  59054. */
  59055. pixelDepth: number;
  59056. /**
  59057. * Gets the number of array elements
  59058. */
  59059. numberOfArrayElements: number;
  59060. /**
  59061. * Gets the number of faces
  59062. */
  59063. numberOfFaces: number;
  59064. /**
  59065. * Gets the number of mipmap levels
  59066. */
  59067. numberOfMipmapLevels: number;
  59068. /**
  59069. * Gets the bytes of key value data
  59070. */
  59071. bytesOfKeyValueData: number;
  59072. /**
  59073. * Gets the load type
  59074. */
  59075. loadType: number;
  59076. /**
  59077. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  59078. */
  59079. isInvalid: boolean;
  59080. /**
  59081. * Creates a new KhronosTextureContainer
  59082. * @param data contents of the KTX container file
  59083. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  59084. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  59085. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  59086. */
  59087. constructor(
  59088. /** contents of the KTX container file */
  59089. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  59090. /**
  59091. * Uploads KTX content to a Babylon Texture.
  59092. * It is assumed that the texture has already been created & is currently bound
  59093. * @hidden
  59094. */
  59095. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  59096. private _upload2DCompressedLevels;
  59097. /**
  59098. * Checks if the given data starts with a KTX file identifier.
  59099. * @param data the data to check
  59100. * @returns true if the data is a KTX file or false otherwise
  59101. */
  59102. static IsValid(data: ArrayBufferView): boolean;
  59103. }
  59104. }
  59105. declare module "babylonjs/Misc/khronosTextureContainer2" {
  59106. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59107. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59108. /**
  59109. * Class for loading KTX2 files
  59110. * !!! Experimental Extension Subject to Changes !!!
  59111. * @hidden
  59112. */
  59113. export class KhronosTextureContainer2 {
  59114. private static _ModulePromise;
  59115. private static _TranscodeFormat;
  59116. constructor(engine: ThinEngine);
  59117. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  59118. private _determineTranscodeFormat;
  59119. /**
  59120. * Checks if the given data starts with a KTX2 file identifier.
  59121. * @param data the data to check
  59122. * @returns true if the data is a KTX2 file or false otherwise
  59123. */
  59124. static IsValid(data: ArrayBufferView): boolean;
  59125. }
  59126. }
  59127. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  59128. import { Nullable } from "babylonjs/types";
  59129. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59130. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59131. /**
  59132. * Implementation of the KTX Texture Loader.
  59133. * @hidden
  59134. */
  59135. export class _KTXTextureLoader implements IInternalTextureLoader {
  59136. /**
  59137. * Defines wether the loader supports cascade loading the different faces.
  59138. */
  59139. readonly supportCascades: boolean;
  59140. /**
  59141. * This returns if the loader support the current file information.
  59142. * @param extension defines the file extension of the file being loaded
  59143. * @param mimeType defines the optional mime type of the file being loaded
  59144. * @returns true if the loader can load the specified file
  59145. */
  59146. canLoad(extension: string, mimeType?: string): boolean;
  59147. /**
  59148. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59149. * @param data contains the texture data
  59150. * @param texture defines the BabylonJS internal texture
  59151. * @param createPolynomials will be true if polynomials have been requested
  59152. * @param onLoad defines the callback to trigger once the texture is ready
  59153. * @param onError defines the callback to trigger in case of error
  59154. */
  59155. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59156. /**
  59157. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59158. * @param data contains the texture data
  59159. * @param texture defines the BabylonJS internal texture
  59160. * @param callback defines the method to call once ready to upload
  59161. */
  59162. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  59163. }
  59164. }
  59165. declare module "babylonjs/Helpers/sceneHelpers" {
  59166. import { Nullable } from "babylonjs/types";
  59167. import { Mesh } from "babylonjs/Meshes/mesh";
  59168. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59169. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  59170. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  59171. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59172. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59173. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59174. import "babylonjs/Meshes/Builders/boxBuilder";
  59175. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  59176. /** @hidden */
  59177. export var _forceSceneHelpersToBundle: boolean;
  59178. module "babylonjs/scene" {
  59179. interface Scene {
  59180. /**
  59181. * Creates a default light for the scene.
  59182. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  59183. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  59184. */
  59185. createDefaultLight(replace?: boolean): void;
  59186. /**
  59187. * Creates a default camera for the scene.
  59188. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  59189. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59190. * @param replace has default false, when true replaces the active camera in the scene
  59191. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  59192. */
  59193. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59194. /**
  59195. * Creates a default camera and a default light.
  59196. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  59197. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  59198. * @param replace has the default false, when true replaces the active camera/light in the scene
  59199. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  59200. */
  59201. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  59202. /**
  59203. * Creates a new sky box
  59204. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  59205. * @param environmentTexture defines the texture to use as environment texture
  59206. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  59207. * @param scale defines the overall scale of the skybox
  59208. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  59209. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  59210. * @returns a new mesh holding the sky box
  59211. */
  59212. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  59213. /**
  59214. * Creates a new environment
  59215. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  59216. * @param options defines the options you can use to configure the environment
  59217. * @returns the new EnvironmentHelper
  59218. */
  59219. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  59220. /**
  59221. * Creates a new VREXperienceHelper
  59222. * @see https://doc.babylonjs.com/how_to/webvr_helper
  59223. * @param webVROptions defines the options used to create the new VREXperienceHelper
  59224. * @returns a new VREXperienceHelper
  59225. */
  59226. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  59227. /**
  59228. * Creates a new WebXRDefaultExperience
  59229. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  59230. * @param options experience options
  59231. * @returns a promise for a new WebXRDefaultExperience
  59232. */
  59233. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  59234. }
  59235. }
  59236. }
  59237. declare module "babylonjs/Helpers/videoDome" {
  59238. import { Scene } from "babylonjs/scene";
  59239. import { TransformNode } from "babylonjs/Meshes/transformNode";
  59240. import { Mesh } from "babylonjs/Meshes/mesh";
  59241. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  59242. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  59243. import "babylonjs/Meshes/Builders/sphereBuilder";
  59244. /**
  59245. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  59246. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  59247. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  59248. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  59249. */
  59250. export class VideoDome extends TransformNode {
  59251. /**
  59252. * Define the video source as a Monoscopic panoramic 360 video.
  59253. */
  59254. static readonly MODE_MONOSCOPIC: number;
  59255. /**
  59256. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59257. */
  59258. static readonly MODE_TOPBOTTOM: number;
  59259. /**
  59260. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59261. */
  59262. static readonly MODE_SIDEBYSIDE: number;
  59263. private _halfDome;
  59264. private _useDirectMapping;
  59265. /**
  59266. * The video texture being displayed on the sphere
  59267. */
  59268. protected _videoTexture: VideoTexture;
  59269. /**
  59270. * Gets the video texture being displayed on the sphere
  59271. */
  59272. get videoTexture(): VideoTexture;
  59273. /**
  59274. * The skybox material
  59275. */
  59276. protected _material: BackgroundMaterial;
  59277. /**
  59278. * The surface used for the video dome
  59279. */
  59280. protected _mesh: Mesh;
  59281. /**
  59282. * Gets the mesh used for the video dome.
  59283. */
  59284. get mesh(): Mesh;
  59285. /**
  59286. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  59287. */
  59288. private _halfDomeMask;
  59289. /**
  59290. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  59291. * Also see the options.resolution property.
  59292. */
  59293. get fovMultiplier(): number;
  59294. set fovMultiplier(value: number);
  59295. private _videoMode;
  59296. /**
  59297. * Gets or set the current video mode for the video. It can be:
  59298. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  59299. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  59300. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  59301. */
  59302. get videoMode(): number;
  59303. set videoMode(value: number);
  59304. /**
  59305. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  59306. *
  59307. */
  59308. get halfDome(): boolean;
  59309. /**
  59310. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  59311. */
  59312. set halfDome(enabled: boolean);
  59313. /**
  59314. * Oberserver used in Stereoscopic VR Mode.
  59315. */
  59316. private _onBeforeCameraRenderObserver;
  59317. /**
  59318. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  59319. * @param name Element's name, child elements will append suffixes for their own names.
  59320. * @param urlsOrVideo defines the url(s) or the video element to use
  59321. * @param options An object containing optional or exposed sub element properties
  59322. */
  59323. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  59324. resolution?: number;
  59325. clickToPlay?: boolean;
  59326. autoPlay?: boolean;
  59327. loop?: boolean;
  59328. size?: number;
  59329. poster?: string;
  59330. faceForward?: boolean;
  59331. useDirectMapping?: boolean;
  59332. halfDomeMode?: boolean;
  59333. }, scene: Scene);
  59334. private _changeVideoMode;
  59335. /**
  59336. * Releases resources associated with this node.
  59337. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  59338. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  59339. */
  59340. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  59341. }
  59342. }
  59343. declare module "babylonjs/Helpers/index" {
  59344. export * from "babylonjs/Helpers/environmentHelper";
  59345. export * from "babylonjs/Helpers/photoDome";
  59346. export * from "babylonjs/Helpers/sceneHelpers";
  59347. export * from "babylonjs/Helpers/videoDome";
  59348. }
  59349. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  59350. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59351. import { IDisposable } from "babylonjs/scene";
  59352. import { Engine } from "babylonjs/Engines/engine";
  59353. /**
  59354. * This class can be used to get instrumentation data from a Babylon engine
  59355. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59356. */
  59357. export class EngineInstrumentation implements IDisposable {
  59358. /**
  59359. * Define the instrumented engine.
  59360. */
  59361. engine: Engine;
  59362. private _captureGPUFrameTime;
  59363. private _gpuFrameTimeToken;
  59364. private _gpuFrameTime;
  59365. private _captureShaderCompilationTime;
  59366. private _shaderCompilationTime;
  59367. private _onBeginFrameObserver;
  59368. private _onEndFrameObserver;
  59369. private _onBeforeShaderCompilationObserver;
  59370. private _onAfterShaderCompilationObserver;
  59371. /**
  59372. * Gets the perf counter used for GPU frame time
  59373. */
  59374. get gpuFrameTimeCounter(): PerfCounter;
  59375. /**
  59376. * Gets the GPU frame time capture status
  59377. */
  59378. get captureGPUFrameTime(): boolean;
  59379. /**
  59380. * Enable or disable the GPU frame time capture
  59381. */
  59382. set captureGPUFrameTime(value: boolean);
  59383. /**
  59384. * Gets the perf counter used for shader compilation time
  59385. */
  59386. get shaderCompilationTimeCounter(): PerfCounter;
  59387. /**
  59388. * Gets the shader compilation time capture status
  59389. */
  59390. get captureShaderCompilationTime(): boolean;
  59391. /**
  59392. * Enable or disable the shader compilation time capture
  59393. */
  59394. set captureShaderCompilationTime(value: boolean);
  59395. /**
  59396. * Instantiates a new engine instrumentation.
  59397. * This class can be used to get instrumentation data from a Babylon engine
  59398. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  59399. * @param engine Defines the engine to instrument
  59400. */
  59401. constructor(
  59402. /**
  59403. * Define the instrumented engine.
  59404. */
  59405. engine: Engine);
  59406. /**
  59407. * Dispose and release associated resources.
  59408. */
  59409. dispose(): void;
  59410. }
  59411. }
  59412. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  59413. import { Scene, IDisposable } from "babylonjs/scene";
  59414. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  59415. /**
  59416. * This class can be used to get instrumentation data from a Babylon engine
  59417. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59418. */
  59419. export class SceneInstrumentation implements IDisposable {
  59420. /**
  59421. * Defines the scene to instrument
  59422. */
  59423. scene: Scene;
  59424. private _captureActiveMeshesEvaluationTime;
  59425. private _activeMeshesEvaluationTime;
  59426. private _captureRenderTargetsRenderTime;
  59427. private _renderTargetsRenderTime;
  59428. private _captureFrameTime;
  59429. private _frameTime;
  59430. private _captureRenderTime;
  59431. private _renderTime;
  59432. private _captureInterFrameTime;
  59433. private _interFrameTime;
  59434. private _captureParticlesRenderTime;
  59435. private _particlesRenderTime;
  59436. private _captureSpritesRenderTime;
  59437. private _spritesRenderTime;
  59438. private _capturePhysicsTime;
  59439. private _physicsTime;
  59440. private _captureAnimationsTime;
  59441. private _animationsTime;
  59442. private _captureCameraRenderTime;
  59443. private _cameraRenderTime;
  59444. private _onBeforeActiveMeshesEvaluationObserver;
  59445. private _onAfterActiveMeshesEvaluationObserver;
  59446. private _onBeforeRenderTargetsRenderObserver;
  59447. private _onAfterRenderTargetsRenderObserver;
  59448. private _onAfterRenderObserver;
  59449. private _onBeforeDrawPhaseObserver;
  59450. private _onAfterDrawPhaseObserver;
  59451. private _onBeforeAnimationsObserver;
  59452. private _onBeforeParticlesRenderingObserver;
  59453. private _onAfterParticlesRenderingObserver;
  59454. private _onBeforeSpritesRenderingObserver;
  59455. private _onAfterSpritesRenderingObserver;
  59456. private _onBeforePhysicsObserver;
  59457. private _onAfterPhysicsObserver;
  59458. private _onAfterAnimationsObserver;
  59459. private _onBeforeCameraRenderObserver;
  59460. private _onAfterCameraRenderObserver;
  59461. /**
  59462. * Gets the perf counter used for active meshes evaluation time
  59463. */
  59464. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  59465. /**
  59466. * Gets the active meshes evaluation time capture status
  59467. */
  59468. get captureActiveMeshesEvaluationTime(): boolean;
  59469. /**
  59470. * Enable or disable the active meshes evaluation time capture
  59471. */
  59472. set captureActiveMeshesEvaluationTime(value: boolean);
  59473. /**
  59474. * Gets the perf counter used for render targets render time
  59475. */
  59476. get renderTargetsRenderTimeCounter(): PerfCounter;
  59477. /**
  59478. * Gets the render targets render time capture status
  59479. */
  59480. get captureRenderTargetsRenderTime(): boolean;
  59481. /**
  59482. * Enable or disable the render targets render time capture
  59483. */
  59484. set captureRenderTargetsRenderTime(value: boolean);
  59485. /**
  59486. * Gets the perf counter used for particles render time
  59487. */
  59488. get particlesRenderTimeCounter(): PerfCounter;
  59489. /**
  59490. * Gets the particles render time capture status
  59491. */
  59492. get captureParticlesRenderTime(): boolean;
  59493. /**
  59494. * Enable or disable the particles render time capture
  59495. */
  59496. set captureParticlesRenderTime(value: boolean);
  59497. /**
  59498. * Gets the perf counter used for sprites render time
  59499. */
  59500. get spritesRenderTimeCounter(): PerfCounter;
  59501. /**
  59502. * Gets the sprites render time capture status
  59503. */
  59504. get captureSpritesRenderTime(): boolean;
  59505. /**
  59506. * Enable or disable the sprites render time capture
  59507. */
  59508. set captureSpritesRenderTime(value: boolean);
  59509. /**
  59510. * Gets the perf counter used for physics time
  59511. */
  59512. get physicsTimeCounter(): PerfCounter;
  59513. /**
  59514. * Gets the physics time capture status
  59515. */
  59516. get capturePhysicsTime(): boolean;
  59517. /**
  59518. * Enable or disable the physics time capture
  59519. */
  59520. set capturePhysicsTime(value: boolean);
  59521. /**
  59522. * Gets the perf counter used for animations time
  59523. */
  59524. get animationsTimeCounter(): PerfCounter;
  59525. /**
  59526. * Gets the animations time capture status
  59527. */
  59528. get captureAnimationsTime(): boolean;
  59529. /**
  59530. * Enable or disable the animations time capture
  59531. */
  59532. set captureAnimationsTime(value: boolean);
  59533. /**
  59534. * Gets the perf counter used for frame time capture
  59535. */
  59536. get frameTimeCounter(): PerfCounter;
  59537. /**
  59538. * Gets the frame time capture status
  59539. */
  59540. get captureFrameTime(): boolean;
  59541. /**
  59542. * Enable or disable the frame time capture
  59543. */
  59544. set captureFrameTime(value: boolean);
  59545. /**
  59546. * Gets the perf counter used for inter-frames time capture
  59547. */
  59548. get interFrameTimeCounter(): PerfCounter;
  59549. /**
  59550. * Gets the inter-frames time capture status
  59551. */
  59552. get captureInterFrameTime(): boolean;
  59553. /**
  59554. * Enable or disable the inter-frames time capture
  59555. */
  59556. set captureInterFrameTime(value: boolean);
  59557. /**
  59558. * Gets the perf counter used for render time capture
  59559. */
  59560. get renderTimeCounter(): PerfCounter;
  59561. /**
  59562. * Gets the render time capture status
  59563. */
  59564. get captureRenderTime(): boolean;
  59565. /**
  59566. * Enable or disable the render time capture
  59567. */
  59568. set captureRenderTime(value: boolean);
  59569. /**
  59570. * Gets the perf counter used for camera render time capture
  59571. */
  59572. get cameraRenderTimeCounter(): PerfCounter;
  59573. /**
  59574. * Gets the camera render time capture status
  59575. */
  59576. get captureCameraRenderTime(): boolean;
  59577. /**
  59578. * Enable or disable the camera render time capture
  59579. */
  59580. set captureCameraRenderTime(value: boolean);
  59581. /**
  59582. * Gets the perf counter used for draw calls
  59583. */
  59584. get drawCallsCounter(): PerfCounter;
  59585. /**
  59586. * Instantiates a new scene instrumentation.
  59587. * This class can be used to get instrumentation data from a Babylon engine
  59588. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  59589. * @param scene Defines the scene to instrument
  59590. */
  59591. constructor(
  59592. /**
  59593. * Defines the scene to instrument
  59594. */
  59595. scene: Scene);
  59596. /**
  59597. * Dispose and release associated resources.
  59598. */
  59599. dispose(): void;
  59600. }
  59601. }
  59602. declare module "babylonjs/Instrumentation/index" {
  59603. export * from "babylonjs/Instrumentation/engineInstrumentation";
  59604. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  59605. export * from "babylonjs/Instrumentation/timeToken";
  59606. }
  59607. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  59608. /** @hidden */
  59609. export var glowMapGenerationPixelShader: {
  59610. name: string;
  59611. shader: string;
  59612. };
  59613. }
  59614. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  59615. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59616. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59617. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59618. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59619. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59620. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59621. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59622. /** @hidden */
  59623. export var glowMapGenerationVertexShader: {
  59624. name: string;
  59625. shader: string;
  59626. };
  59627. }
  59628. declare module "babylonjs/Layers/effectLayer" {
  59629. import { Observable } from "babylonjs/Misc/observable";
  59630. import { Nullable } from "babylonjs/types";
  59631. import { Camera } from "babylonjs/Cameras/camera";
  59632. import { Scene } from "babylonjs/scene";
  59633. import { ISize } from "babylonjs/Maths/math.size";
  59634. import { Color4 } from "babylonjs/Maths/math.color";
  59635. import { Engine } from "babylonjs/Engines/engine";
  59636. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59638. import { Mesh } from "babylonjs/Meshes/mesh";
  59639. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59640. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59641. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59642. import { Effect } from "babylonjs/Materials/effect";
  59643. import { Material } from "babylonjs/Materials/material";
  59644. import "babylonjs/Shaders/glowMapGeneration.fragment";
  59645. import "babylonjs/Shaders/glowMapGeneration.vertex";
  59646. /**
  59647. * Effect layer options. This helps customizing the behaviour
  59648. * of the effect layer.
  59649. */
  59650. export interface IEffectLayerOptions {
  59651. /**
  59652. * Multiplication factor apply to the canvas size to compute the render target size
  59653. * used to generated the objects (the smaller the faster).
  59654. */
  59655. mainTextureRatio: number;
  59656. /**
  59657. * Enforces a fixed size texture to ensure effect stability across devices.
  59658. */
  59659. mainTextureFixedSize?: number;
  59660. /**
  59661. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  59662. */
  59663. alphaBlendingMode: number;
  59664. /**
  59665. * The camera attached to the layer.
  59666. */
  59667. camera: Nullable<Camera>;
  59668. /**
  59669. * The rendering group to draw the layer in.
  59670. */
  59671. renderingGroupId: number;
  59672. }
  59673. /**
  59674. * The effect layer Helps adding post process effect blended with the main pass.
  59675. *
  59676. * This can be for instance use to generate glow or higlight effects on the scene.
  59677. *
  59678. * The effect layer class can not be used directly and is intented to inherited from to be
  59679. * customized per effects.
  59680. */
  59681. export abstract class EffectLayer {
  59682. private _vertexBuffers;
  59683. private _indexBuffer;
  59684. private _cachedDefines;
  59685. private _effectLayerMapGenerationEffect;
  59686. private _effectLayerOptions;
  59687. private _mergeEffect;
  59688. protected _scene: Scene;
  59689. protected _engine: Engine;
  59690. protected _maxSize: number;
  59691. protected _mainTextureDesiredSize: ISize;
  59692. protected _mainTexture: RenderTargetTexture;
  59693. protected _shouldRender: boolean;
  59694. protected _postProcesses: PostProcess[];
  59695. protected _textures: BaseTexture[];
  59696. protected _emissiveTextureAndColor: {
  59697. texture: Nullable<BaseTexture>;
  59698. color: Color4;
  59699. };
  59700. /**
  59701. * The name of the layer
  59702. */
  59703. name: string;
  59704. /**
  59705. * The clear color of the texture used to generate the glow map.
  59706. */
  59707. neutralColor: Color4;
  59708. /**
  59709. * Specifies whether the highlight layer is enabled or not.
  59710. */
  59711. isEnabled: boolean;
  59712. /**
  59713. * Gets the camera attached to the layer.
  59714. */
  59715. get camera(): Nullable<Camera>;
  59716. /**
  59717. * Gets the rendering group id the layer should render in.
  59718. */
  59719. get renderingGroupId(): number;
  59720. set renderingGroupId(renderingGroupId: number);
  59721. /**
  59722. * An event triggered when the effect layer has been disposed.
  59723. */
  59724. onDisposeObservable: Observable<EffectLayer>;
  59725. /**
  59726. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  59727. */
  59728. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  59729. /**
  59730. * An event triggered when the generated texture is being merged in the scene.
  59731. */
  59732. onBeforeComposeObservable: Observable<EffectLayer>;
  59733. /**
  59734. * An event triggered when the mesh is rendered into the effect render target.
  59735. */
  59736. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  59737. /**
  59738. * An event triggered after the mesh has been rendered into the effect render target.
  59739. */
  59740. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  59741. /**
  59742. * An event triggered when the generated texture has been merged in the scene.
  59743. */
  59744. onAfterComposeObservable: Observable<EffectLayer>;
  59745. /**
  59746. * An event triggered when the efffect layer changes its size.
  59747. */
  59748. onSizeChangedObservable: Observable<EffectLayer>;
  59749. /** @hidden */
  59750. static _SceneComponentInitialization: (scene: Scene) => void;
  59751. /**
  59752. * Instantiates a new effect Layer and references it in the scene.
  59753. * @param name The name of the layer
  59754. * @param scene The scene to use the layer in
  59755. */
  59756. constructor(
  59757. /** The Friendly of the effect in the scene */
  59758. name: string, scene: Scene);
  59759. /**
  59760. * Get the effect name of the layer.
  59761. * @return The effect name
  59762. */
  59763. abstract getEffectName(): string;
  59764. /**
  59765. * Checks for the readiness of the element composing the layer.
  59766. * @param subMesh the mesh to check for
  59767. * @param useInstances specify whether or not to use instances to render the mesh
  59768. * @return true if ready otherwise, false
  59769. */
  59770. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59771. /**
  59772. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59773. * @returns true if the effect requires stencil during the main canvas render pass.
  59774. */
  59775. abstract needStencil(): boolean;
  59776. /**
  59777. * Create the merge effect. This is the shader use to blit the information back
  59778. * to the main canvas at the end of the scene rendering.
  59779. * @returns The effect containing the shader used to merge the effect on the main canvas
  59780. */
  59781. protected abstract _createMergeEffect(): Effect;
  59782. /**
  59783. * Creates the render target textures and post processes used in the effect layer.
  59784. */
  59785. protected abstract _createTextureAndPostProcesses(): void;
  59786. /**
  59787. * Implementation specific of rendering the generating effect on the main canvas.
  59788. * @param effect The effect used to render through
  59789. */
  59790. protected abstract _internalRender(effect: Effect): void;
  59791. /**
  59792. * Sets the required values for both the emissive texture and and the main color.
  59793. */
  59794. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59795. /**
  59796. * Free any resources and references associated to a mesh.
  59797. * Internal use
  59798. * @param mesh The mesh to free.
  59799. */
  59800. abstract _disposeMesh(mesh: Mesh): void;
  59801. /**
  59802. * Serializes this layer (Glow or Highlight for example)
  59803. * @returns a serialized layer object
  59804. */
  59805. abstract serialize?(): any;
  59806. /**
  59807. * Initializes the effect layer with the required options.
  59808. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59809. */
  59810. protected _init(options: Partial<IEffectLayerOptions>): void;
  59811. /**
  59812. * Generates the index buffer of the full screen quad blending to the main canvas.
  59813. */
  59814. private _generateIndexBuffer;
  59815. /**
  59816. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59817. */
  59818. private _generateVertexBuffer;
  59819. /**
  59820. * Sets the main texture desired size which is the closest power of two
  59821. * of the engine canvas size.
  59822. */
  59823. private _setMainTextureSize;
  59824. /**
  59825. * Creates the main texture for the effect layer.
  59826. */
  59827. protected _createMainTexture(): void;
  59828. /**
  59829. * Adds specific effects defines.
  59830. * @param defines The defines to add specifics to.
  59831. */
  59832. protected _addCustomEffectDefines(defines: string[]): void;
  59833. /**
  59834. * Checks for the readiness of the element composing the layer.
  59835. * @param subMesh the mesh to check for
  59836. * @param useInstances specify whether or not to use instances to render the mesh
  59837. * @param emissiveTexture the associated emissive texture used to generate the glow
  59838. * @return true if ready otherwise, false
  59839. */
  59840. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59841. /**
  59842. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59843. */
  59844. render(): void;
  59845. /**
  59846. * Determine if a given mesh will be used in the current effect.
  59847. * @param mesh mesh to test
  59848. * @returns true if the mesh will be used
  59849. */
  59850. hasMesh(mesh: AbstractMesh): boolean;
  59851. /**
  59852. * Returns true if the layer contains information to display, otherwise false.
  59853. * @returns true if the glow layer should be rendered
  59854. */
  59855. shouldRender(): boolean;
  59856. /**
  59857. * Returns true if the mesh should render, otherwise false.
  59858. * @param mesh The mesh to render
  59859. * @returns true if it should render otherwise false
  59860. */
  59861. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59862. /**
  59863. * Returns true if the mesh can be rendered, otherwise false.
  59864. * @param mesh The mesh to render
  59865. * @param material The material used on the mesh
  59866. * @returns true if it can be rendered otherwise false
  59867. */
  59868. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59869. /**
  59870. * Returns true if the mesh should render, otherwise false.
  59871. * @param mesh The mesh to render
  59872. * @returns true if it should render otherwise false
  59873. */
  59874. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59875. /**
  59876. * Renders the submesh passed in parameter to the generation map.
  59877. */
  59878. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59879. /**
  59880. * Defines whether the current material of the mesh should be use to render the effect.
  59881. * @param mesh defines the current mesh to render
  59882. */
  59883. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59884. /**
  59885. * Rebuild the required buffers.
  59886. * @hidden Internal use only.
  59887. */
  59888. _rebuild(): void;
  59889. /**
  59890. * Dispose only the render target textures and post process.
  59891. */
  59892. private _disposeTextureAndPostProcesses;
  59893. /**
  59894. * Dispose the highlight layer and free resources.
  59895. */
  59896. dispose(): void;
  59897. /**
  59898. * Gets the class name of the effect layer
  59899. * @returns the string with the class name of the effect layer
  59900. */
  59901. getClassName(): string;
  59902. /**
  59903. * Creates an effect layer from parsed effect layer data
  59904. * @param parsedEffectLayer defines effect layer data
  59905. * @param scene defines the current scene
  59906. * @param rootUrl defines the root URL containing the effect layer information
  59907. * @returns a parsed effect Layer
  59908. */
  59909. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59910. }
  59911. }
  59912. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  59913. import { Scene } from "babylonjs/scene";
  59914. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  59915. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  59916. import { AbstractScene } from "babylonjs/abstractScene";
  59917. module "babylonjs/abstractScene" {
  59918. interface AbstractScene {
  59919. /**
  59920. * The list of effect layers (highlights/glow) added to the scene
  59921. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59922. * @see https://doc.babylonjs.com/how_to/glow_layer
  59923. */
  59924. effectLayers: Array<EffectLayer>;
  59925. /**
  59926. * Removes the given effect layer from this scene.
  59927. * @param toRemove defines the effect layer to remove
  59928. * @returns the index of the removed effect layer
  59929. */
  59930. removeEffectLayer(toRemove: EffectLayer): number;
  59931. /**
  59932. * Adds the given effect layer to this scene
  59933. * @param newEffectLayer defines the effect layer to add
  59934. */
  59935. addEffectLayer(newEffectLayer: EffectLayer): void;
  59936. }
  59937. }
  59938. /**
  59939. * Defines the layer scene component responsible to manage any effect layers
  59940. * in a given scene.
  59941. */
  59942. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59943. /**
  59944. * The component name helpfull to identify the component in the list of scene components.
  59945. */
  59946. readonly name: string;
  59947. /**
  59948. * The scene the component belongs to.
  59949. */
  59950. scene: Scene;
  59951. private _engine;
  59952. private _renderEffects;
  59953. private _needStencil;
  59954. private _previousStencilState;
  59955. /**
  59956. * Creates a new instance of the component for the given scene
  59957. * @param scene Defines the scene to register the component in
  59958. */
  59959. constructor(scene: Scene);
  59960. /**
  59961. * Registers the component in a given scene
  59962. */
  59963. register(): void;
  59964. /**
  59965. * Rebuilds the elements related to this component in case of
  59966. * context lost for instance.
  59967. */
  59968. rebuild(): void;
  59969. /**
  59970. * Serializes the component data to the specified json object
  59971. * @param serializationObject The object to serialize to
  59972. */
  59973. serialize(serializationObject: any): void;
  59974. /**
  59975. * Adds all the elements from the container to the scene
  59976. * @param container the container holding the elements
  59977. */
  59978. addFromContainer(container: AbstractScene): void;
  59979. /**
  59980. * Removes all the elements in the container from the scene
  59981. * @param container contains the elements to remove
  59982. * @param dispose if the removed element should be disposed (default: false)
  59983. */
  59984. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59985. /**
  59986. * Disposes the component and the associated ressources.
  59987. */
  59988. dispose(): void;
  59989. private _isReadyForMesh;
  59990. private _renderMainTexture;
  59991. private _setStencil;
  59992. private _setStencilBack;
  59993. private _draw;
  59994. private _drawCamera;
  59995. private _drawRenderingGroup;
  59996. }
  59997. }
  59998. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  59999. /** @hidden */
  60000. export var glowMapMergePixelShader: {
  60001. name: string;
  60002. shader: string;
  60003. };
  60004. }
  60005. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  60006. /** @hidden */
  60007. export var glowMapMergeVertexShader: {
  60008. name: string;
  60009. shader: string;
  60010. };
  60011. }
  60012. declare module "babylonjs/Layers/glowLayer" {
  60013. import { Nullable } from "babylonjs/types";
  60014. import { Camera } from "babylonjs/Cameras/camera";
  60015. import { Scene } from "babylonjs/scene";
  60016. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60018. import { Mesh } from "babylonjs/Meshes/mesh";
  60019. import { Texture } from "babylonjs/Materials/Textures/texture";
  60020. import { Effect } from "babylonjs/Materials/effect";
  60021. import { Material } from "babylonjs/Materials/material";
  60022. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60023. import { Color4 } from "babylonjs/Maths/math.color";
  60024. import "babylonjs/Shaders/glowMapMerge.fragment";
  60025. import "babylonjs/Shaders/glowMapMerge.vertex";
  60026. import "babylonjs/Layers/effectLayerSceneComponent";
  60027. module "babylonjs/abstractScene" {
  60028. interface AbstractScene {
  60029. /**
  60030. * Return a the first highlight layer of the scene with a given name.
  60031. * @param name The name of the highlight layer to look for.
  60032. * @return The highlight layer if found otherwise null.
  60033. */
  60034. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  60035. }
  60036. }
  60037. /**
  60038. * Glow layer options. This helps customizing the behaviour
  60039. * of the glow layer.
  60040. */
  60041. export interface IGlowLayerOptions {
  60042. /**
  60043. * Multiplication factor apply to the canvas size to compute the render target size
  60044. * used to generated the glowing objects (the smaller the faster).
  60045. */
  60046. mainTextureRatio: number;
  60047. /**
  60048. * Enforces a fixed size texture to ensure resize independant blur.
  60049. */
  60050. mainTextureFixedSize?: number;
  60051. /**
  60052. * How big is the kernel of the blur texture.
  60053. */
  60054. blurKernelSize: number;
  60055. /**
  60056. * The camera attached to the layer.
  60057. */
  60058. camera: Nullable<Camera>;
  60059. /**
  60060. * Enable MSAA by chosing the number of samples.
  60061. */
  60062. mainTextureSamples?: number;
  60063. /**
  60064. * The rendering group to draw the layer in.
  60065. */
  60066. renderingGroupId: number;
  60067. }
  60068. /**
  60069. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  60070. *
  60071. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  60072. *
  60073. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  60074. */
  60075. export class GlowLayer extends EffectLayer {
  60076. /**
  60077. * Effect Name of the layer.
  60078. */
  60079. static readonly EffectName: string;
  60080. /**
  60081. * The default blur kernel size used for the glow.
  60082. */
  60083. static DefaultBlurKernelSize: number;
  60084. /**
  60085. * The default texture size ratio used for the glow.
  60086. */
  60087. static DefaultTextureRatio: number;
  60088. /**
  60089. * Sets the kernel size of the blur.
  60090. */
  60091. set blurKernelSize(value: number);
  60092. /**
  60093. * Gets the kernel size of the blur.
  60094. */
  60095. get blurKernelSize(): number;
  60096. /**
  60097. * Sets the glow intensity.
  60098. */
  60099. set intensity(value: number);
  60100. /**
  60101. * Gets the glow intensity.
  60102. */
  60103. get intensity(): number;
  60104. private _options;
  60105. private _intensity;
  60106. private _horizontalBlurPostprocess1;
  60107. private _verticalBlurPostprocess1;
  60108. private _horizontalBlurPostprocess2;
  60109. private _verticalBlurPostprocess2;
  60110. private _blurTexture1;
  60111. private _blurTexture2;
  60112. private _postProcesses1;
  60113. private _postProcesses2;
  60114. private _includedOnlyMeshes;
  60115. private _excludedMeshes;
  60116. private _meshesUsingTheirOwnMaterials;
  60117. /**
  60118. * Callback used to let the user override the color selection on a per mesh basis
  60119. */
  60120. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  60121. /**
  60122. * Callback used to let the user override the texture selection on a per mesh basis
  60123. */
  60124. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  60125. /**
  60126. * Instantiates a new glow Layer and references it to the scene.
  60127. * @param name The name of the layer
  60128. * @param scene The scene to use the layer in
  60129. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  60130. */
  60131. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  60132. /**
  60133. * Get the effect name of the layer.
  60134. * @return The effect name
  60135. */
  60136. getEffectName(): string;
  60137. /**
  60138. * Create the merge effect. This is the shader use to blit the information back
  60139. * to the main canvas at the end of the scene rendering.
  60140. */
  60141. protected _createMergeEffect(): Effect;
  60142. /**
  60143. * Creates the render target textures and post processes used in the glow layer.
  60144. */
  60145. protected _createTextureAndPostProcesses(): void;
  60146. /**
  60147. * Checks for the readiness of the element composing the layer.
  60148. * @param subMesh the mesh to check for
  60149. * @param useInstances specify wether or not to use instances to render the mesh
  60150. * @param emissiveTexture the associated emissive texture used to generate the glow
  60151. * @return true if ready otherwise, false
  60152. */
  60153. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60154. /**
  60155. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  60156. */
  60157. needStencil(): boolean;
  60158. /**
  60159. * Returns true if the mesh can be rendered, otherwise false.
  60160. * @param mesh The mesh to render
  60161. * @param material The material used on the mesh
  60162. * @returns true if it can be rendered otherwise false
  60163. */
  60164. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60165. /**
  60166. * Implementation specific of rendering the generating effect on the main canvas.
  60167. * @param effect The effect used to render through
  60168. */
  60169. protected _internalRender(effect: Effect): void;
  60170. /**
  60171. * Sets the required values for both the emissive texture and and the main color.
  60172. */
  60173. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60174. /**
  60175. * Returns true if the mesh should render, otherwise false.
  60176. * @param mesh The mesh to render
  60177. * @returns true if it should render otherwise false
  60178. */
  60179. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60180. /**
  60181. * Adds specific effects defines.
  60182. * @param defines The defines to add specifics to.
  60183. */
  60184. protected _addCustomEffectDefines(defines: string[]): void;
  60185. /**
  60186. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  60187. * @param mesh The mesh to exclude from the glow layer
  60188. */
  60189. addExcludedMesh(mesh: Mesh): void;
  60190. /**
  60191. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  60192. * @param mesh The mesh to remove
  60193. */
  60194. removeExcludedMesh(mesh: Mesh): void;
  60195. /**
  60196. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  60197. * @param mesh The mesh to include in the glow layer
  60198. */
  60199. addIncludedOnlyMesh(mesh: Mesh): void;
  60200. /**
  60201. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  60202. * @param mesh The mesh to remove
  60203. */
  60204. removeIncludedOnlyMesh(mesh: Mesh): void;
  60205. /**
  60206. * Determine if a given mesh will be used in the glow layer
  60207. * @param mesh The mesh to test
  60208. * @returns true if the mesh will be highlighted by the current glow layer
  60209. */
  60210. hasMesh(mesh: AbstractMesh): boolean;
  60211. /**
  60212. * Defines whether the current material of the mesh should be use to render the effect.
  60213. * @param mesh defines the current mesh to render
  60214. */
  60215. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  60216. /**
  60217. * Add a mesh to be rendered through its own material and not with emissive only.
  60218. * @param mesh The mesh for which we need to use its material
  60219. */
  60220. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  60221. /**
  60222. * Remove a mesh from being rendered through its own material and not with emissive only.
  60223. * @param mesh The mesh for which we need to not use its material
  60224. */
  60225. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  60226. /**
  60227. * Free any resources and references associated to a mesh.
  60228. * Internal use
  60229. * @param mesh The mesh to free.
  60230. * @hidden
  60231. */
  60232. _disposeMesh(mesh: Mesh): void;
  60233. /**
  60234. * Gets the class name of the effect layer
  60235. * @returns the string with the class name of the effect layer
  60236. */
  60237. getClassName(): string;
  60238. /**
  60239. * Serializes this glow layer
  60240. * @returns a serialized glow layer object
  60241. */
  60242. serialize(): any;
  60243. /**
  60244. * Creates a Glow Layer from parsed glow layer data
  60245. * @param parsedGlowLayer defines glow layer data
  60246. * @param scene defines the current scene
  60247. * @param rootUrl defines the root URL containing the glow layer information
  60248. * @returns a parsed Glow Layer
  60249. */
  60250. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  60251. }
  60252. }
  60253. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  60254. /** @hidden */
  60255. export var glowBlurPostProcessPixelShader: {
  60256. name: string;
  60257. shader: string;
  60258. };
  60259. }
  60260. declare module "babylonjs/Layers/highlightLayer" {
  60261. import { Observable } from "babylonjs/Misc/observable";
  60262. import { Nullable } from "babylonjs/types";
  60263. import { Camera } from "babylonjs/Cameras/camera";
  60264. import { Scene } from "babylonjs/scene";
  60265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60267. import { Mesh } from "babylonjs/Meshes/mesh";
  60268. import { Effect } from "babylonjs/Materials/effect";
  60269. import { Material } from "babylonjs/Materials/material";
  60270. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  60271. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60272. import "babylonjs/Shaders/glowMapMerge.fragment";
  60273. import "babylonjs/Shaders/glowMapMerge.vertex";
  60274. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  60275. module "babylonjs/abstractScene" {
  60276. interface AbstractScene {
  60277. /**
  60278. * Return a the first highlight layer of the scene with a given name.
  60279. * @param name The name of the highlight layer to look for.
  60280. * @return The highlight layer if found otherwise null.
  60281. */
  60282. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  60283. }
  60284. }
  60285. /**
  60286. * Highlight layer options. This helps customizing the behaviour
  60287. * of the highlight layer.
  60288. */
  60289. export interface IHighlightLayerOptions {
  60290. /**
  60291. * Multiplication factor apply to the canvas size to compute the render target size
  60292. * used to generated the glowing objects (the smaller the faster).
  60293. */
  60294. mainTextureRatio: number;
  60295. /**
  60296. * Enforces a fixed size texture to ensure resize independant blur.
  60297. */
  60298. mainTextureFixedSize?: number;
  60299. /**
  60300. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  60301. * of the picture to blur (the smaller the faster).
  60302. */
  60303. blurTextureSizeRatio: number;
  60304. /**
  60305. * How big in texel of the blur texture is the vertical blur.
  60306. */
  60307. blurVerticalSize: number;
  60308. /**
  60309. * How big in texel of the blur texture is the horizontal blur.
  60310. */
  60311. blurHorizontalSize: number;
  60312. /**
  60313. * Alpha blending mode used to apply the blur. Default is combine.
  60314. */
  60315. alphaBlendingMode: number;
  60316. /**
  60317. * The camera attached to the layer.
  60318. */
  60319. camera: Nullable<Camera>;
  60320. /**
  60321. * Should we display highlight as a solid stroke?
  60322. */
  60323. isStroke?: boolean;
  60324. /**
  60325. * The rendering group to draw the layer in.
  60326. */
  60327. renderingGroupId: number;
  60328. }
  60329. /**
  60330. * The highlight layer Helps adding a glow effect around a mesh.
  60331. *
  60332. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  60333. * glowy meshes to your scene.
  60334. *
  60335. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  60336. */
  60337. export class HighlightLayer extends EffectLayer {
  60338. name: string;
  60339. /**
  60340. * Effect Name of the highlight layer.
  60341. */
  60342. static readonly EffectName: string;
  60343. /**
  60344. * The neutral color used during the preparation of the glow effect.
  60345. * This is black by default as the blend operation is a blend operation.
  60346. */
  60347. static NeutralColor: Color4;
  60348. /**
  60349. * Stencil value used for glowing meshes.
  60350. */
  60351. static GlowingMeshStencilReference: number;
  60352. /**
  60353. * Stencil value used for the other meshes in the scene.
  60354. */
  60355. static NormalMeshStencilReference: number;
  60356. /**
  60357. * Specifies whether or not the inner glow is ACTIVE in the layer.
  60358. */
  60359. innerGlow: boolean;
  60360. /**
  60361. * Specifies whether or not the outer glow is ACTIVE in the layer.
  60362. */
  60363. outerGlow: boolean;
  60364. /**
  60365. * Specifies the horizontal size of the blur.
  60366. */
  60367. set blurHorizontalSize(value: number);
  60368. /**
  60369. * Specifies the vertical size of the blur.
  60370. */
  60371. set blurVerticalSize(value: number);
  60372. /**
  60373. * Gets the horizontal size of the blur.
  60374. */
  60375. get blurHorizontalSize(): number;
  60376. /**
  60377. * Gets the vertical size of the blur.
  60378. */
  60379. get blurVerticalSize(): number;
  60380. /**
  60381. * An event triggered when the highlight layer is being blurred.
  60382. */
  60383. onBeforeBlurObservable: Observable<HighlightLayer>;
  60384. /**
  60385. * An event triggered when the highlight layer has been blurred.
  60386. */
  60387. onAfterBlurObservable: Observable<HighlightLayer>;
  60388. private _instanceGlowingMeshStencilReference;
  60389. private _options;
  60390. private _downSamplePostprocess;
  60391. private _horizontalBlurPostprocess;
  60392. private _verticalBlurPostprocess;
  60393. private _blurTexture;
  60394. private _meshes;
  60395. private _excludedMeshes;
  60396. /**
  60397. * Instantiates a new highlight Layer and references it to the scene..
  60398. * @param name The name of the layer
  60399. * @param scene The scene to use the layer in
  60400. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  60401. */
  60402. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  60403. /**
  60404. * Get the effect name of the layer.
  60405. * @return The effect name
  60406. */
  60407. getEffectName(): string;
  60408. /**
  60409. * Create the merge effect. This is the shader use to blit the information back
  60410. * to the main canvas at the end of the scene rendering.
  60411. */
  60412. protected _createMergeEffect(): Effect;
  60413. /**
  60414. * Creates the render target textures and post processes used in the highlight layer.
  60415. */
  60416. protected _createTextureAndPostProcesses(): void;
  60417. /**
  60418. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  60419. */
  60420. needStencil(): boolean;
  60421. /**
  60422. * Checks for the readiness of the element composing the layer.
  60423. * @param subMesh the mesh to check for
  60424. * @param useInstances specify wether or not to use instances to render the mesh
  60425. * @param emissiveTexture the associated emissive texture used to generate the glow
  60426. * @return true if ready otherwise, false
  60427. */
  60428. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60429. /**
  60430. * Implementation specific of rendering the generating effect on the main canvas.
  60431. * @param effect The effect used to render through
  60432. */
  60433. protected _internalRender(effect: Effect): void;
  60434. /**
  60435. * Returns true if the layer contains information to display, otherwise false.
  60436. */
  60437. shouldRender(): boolean;
  60438. /**
  60439. * Returns true if the mesh should render, otherwise false.
  60440. * @param mesh The mesh to render
  60441. * @returns true if it should render otherwise false
  60442. */
  60443. protected _shouldRenderMesh(mesh: Mesh): boolean;
  60444. /**
  60445. * Returns true if the mesh can be rendered, otherwise false.
  60446. * @param mesh The mesh to render
  60447. * @param material The material used on the mesh
  60448. * @returns true if it can be rendered otherwise false
  60449. */
  60450. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  60451. /**
  60452. * Adds specific effects defines.
  60453. * @param defines The defines to add specifics to.
  60454. */
  60455. protected _addCustomEffectDefines(defines: string[]): void;
  60456. /**
  60457. * Sets the required values for both the emissive texture and and the main color.
  60458. */
  60459. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  60460. /**
  60461. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  60462. * @param mesh The mesh to exclude from the highlight layer
  60463. */
  60464. addExcludedMesh(mesh: Mesh): void;
  60465. /**
  60466. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  60467. * @param mesh The mesh to highlight
  60468. */
  60469. removeExcludedMesh(mesh: Mesh): void;
  60470. /**
  60471. * Determine if a given mesh will be highlighted by the current HighlightLayer
  60472. * @param mesh mesh to test
  60473. * @returns true if the mesh will be highlighted by the current HighlightLayer
  60474. */
  60475. hasMesh(mesh: AbstractMesh): boolean;
  60476. /**
  60477. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  60478. * @param mesh The mesh to highlight
  60479. * @param color The color of the highlight
  60480. * @param glowEmissiveOnly Extract the glow from the emissive texture
  60481. */
  60482. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  60483. /**
  60484. * Remove a mesh from the highlight layer in order to make it stop glowing.
  60485. * @param mesh The mesh to highlight
  60486. */
  60487. removeMesh(mesh: Mesh): void;
  60488. /**
  60489. * Remove all the meshes currently referenced in the highlight layer
  60490. */
  60491. removeAllMeshes(): void;
  60492. /**
  60493. * Force the stencil to the normal expected value for none glowing parts
  60494. */
  60495. private _defaultStencilReference;
  60496. /**
  60497. * Free any resources and references associated to a mesh.
  60498. * Internal use
  60499. * @param mesh The mesh to free.
  60500. * @hidden
  60501. */
  60502. _disposeMesh(mesh: Mesh): void;
  60503. /**
  60504. * Dispose the highlight layer and free resources.
  60505. */
  60506. dispose(): void;
  60507. /**
  60508. * Gets the class name of the effect layer
  60509. * @returns the string with the class name of the effect layer
  60510. */
  60511. getClassName(): string;
  60512. /**
  60513. * Serializes this Highlight layer
  60514. * @returns a serialized Highlight layer object
  60515. */
  60516. serialize(): any;
  60517. /**
  60518. * Creates a Highlight layer from parsed Highlight layer data
  60519. * @param parsedHightlightLayer defines the Highlight layer data
  60520. * @param scene defines the current scene
  60521. * @param rootUrl defines the root URL containing the Highlight layer information
  60522. * @returns a parsed Highlight layer
  60523. */
  60524. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  60525. }
  60526. }
  60527. declare module "babylonjs/Layers/layerSceneComponent" {
  60528. import { Scene } from "babylonjs/scene";
  60529. import { ISceneComponent } from "babylonjs/sceneComponent";
  60530. import { Layer } from "babylonjs/Layers/layer";
  60531. import { AbstractScene } from "babylonjs/abstractScene";
  60532. module "babylonjs/abstractScene" {
  60533. interface AbstractScene {
  60534. /**
  60535. * The list of layers (background and foreground) of the scene
  60536. */
  60537. layers: Array<Layer>;
  60538. }
  60539. }
  60540. /**
  60541. * Defines the layer scene component responsible to manage any layers
  60542. * in a given scene.
  60543. */
  60544. export class LayerSceneComponent implements ISceneComponent {
  60545. /**
  60546. * The component name helpfull to identify the component in the list of scene components.
  60547. */
  60548. readonly name: string;
  60549. /**
  60550. * The scene the component belongs to.
  60551. */
  60552. scene: Scene;
  60553. private _engine;
  60554. /**
  60555. * Creates a new instance of the component for the given scene
  60556. * @param scene Defines the scene to register the component in
  60557. */
  60558. constructor(scene: Scene);
  60559. /**
  60560. * Registers the component in a given scene
  60561. */
  60562. register(): void;
  60563. /**
  60564. * Rebuilds the elements related to this component in case of
  60565. * context lost for instance.
  60566. */
  60567. rebuild(): void;
  60568. /**
  60569. * Disposes the component and the associated ressources.
  60570. */
  60571. dispose(): void;
  60572. private _draw;
  60573. private _drawCameraPredicate;
  60574. private _drawCameraBackground;
  60575. private _drawCameraForeground;
  60576. private _drawRenderTargetPredicate;
  60577. private _drawRenderTargetBackground;
  60578. private _drawRenderTargetForeground;
  60579. /**
  60580. * Adds all the elements from the container to the scene
  60581. * @param container the container holding the elements
  60582. */
  60583. addFromContainer(container: AbstractScene): void;
  60584. /**
  60585. * Removes all the elements in the container from the scene
  60586. * @param container contains the elements to remove
  60587. * @param dispose if the removed element should be disposed (default: false)
  60588. */
  60589. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60590. }
  60591. }
  60592. declare module "babylonjs/Shaders/layer.fragment" {
  60593. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60594. /** @hidden */
  60595. export var layerPixelShader: {
  60596. name: string;
  60597. shader: string;
  60598. };
  60599. }
  60600. declare module "babylonjs/Shaders/layer.vertex" {
  60601. /** @hidden */
  60602. export var layerVertexShader: {
  60603. name: string;
  60604. shader: string;
  60605. };
  60606. }
  60607. declare module "babylonjs/Layers/layer" {
  60608. import { Observable } from "babylonjs/Misc/observable";
  60609. import { Nullable } from "babylonjs/types";
  60610. import { Scene } from "babylonjs/scene";
  60611. import { Vector2 } from "babylonjs/Maths/math.vector";
  60612. import { Color4 } from "babylonjs/Maths/math.color";
  60613. import { Texture } from "babylonjs/Materials/Textures/texture";
  60614. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60615. import "babylonjs/Shaders/layer.fragment";
  60616. import "babylonjs/Shaders/layer.vertex";
  60617. /**
  60618. * This represents a full screen 2d layer.
  60619. * This can be useful to display a picture in the background of your scene for instance.
  60620. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60621. */
  60622. export class Layer {
  60623. /**
  60624. * Define the name of the layer.
  60625. */
  60626. name: string;
  60627. /**
  60628. * Define the texture the layer should display.
  60629. */
  60630. texture: Nullable<Texture>;
  60631. /**
  60632. * Is the layer in background or foreground.
  60633. */
  60634. isBackground: boolean;
  60635. /**
  60636. * Define the color of the layer (instead of texture).
  60637. */
  60638. color: Color4;
  60639. /**
  60640. * Define the scale of the layer in order to zoom in out of the texture.
  60641. */
  60642. scale: Vector2;
  60643. /**
  60644. * Define an offset for the layer in order to shift the texture.
  60645. */
  60646. offset: Vector2;
  60647. /**
  60648. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  60649. */
  60650. alphaBlendingMode: number;
  60651. /**
  60652. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  60653. * Alpha test will not mix with the background color in case of transparency.
  60654. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  60655. */
  60656. alphaTest: boolean;
  60657. /**
  60658. * Define a mask to restrict the layer to only some of the scene cameras.
  60659. */
  60660. layerMask: number;
  60661. /**
  60662. * Define the list of render target the layer is visible into.
  60663. */
  60664. renderTargetTextures: RenderTargetTexture[];
  60665. /**
  60666. * Define if the layer is only used in renderTarget or if it also
  60667. * renders in the main frame buffer of the canvas.
  60668. */
  60669. renderOnlyInRenderTargetTextures: boolean;
  60670. private _scene;
  60671. private _vertexBuffers;
  60672. private _indexBuffer;
  60673. private _effect;
  60674. private _previousDefines;
  60675. /**
  60676. * An event triggered when the layer is disposed.
  60677. */
  60678. onDisposeObservable: Observable<Layer>;
  60679. private _onDisposeObserver;
  60680. /**
  60681. * Back compatibility with callback before the onDisposeObservable existed.
  60682. * The set callback will be triggered when the layer has been disposed.
  60683. */
  60684. set onDispose(callback: () => void);
  60685. /**
  60686. * An event triggered before rendering the scene
  60687. */
  60688. onBeforeRenderObservable: Observable<Layer>;
  60689. private _onBeforeRenderObserver;
  60690. /**
  60691. * Back compatibility with callback before the onBeforeRenderObservable existed.
  60692. * The set callback will be triggered just before rendering the layer.
  60693. */
  60694. set onBeforeRender(callback: () => void);
  60695. /**
  60696. * An event triggered after rendering the scene
  60697. */
  60698. onAfterRenderObservable: Observable<Layer>;
  60699. private _onAfterRenderObserver;
  60700. /**
  60701. * Back compatibility with callback before the onAfterRenderObservable existed.
  60702. * The set callback will be triggered just after rendering the layer.
  60703. */
  60704. set onAfterRender(callback: () => void);
  60705. /**
  60706. * Instantiates a new layer.
  60707. * This represents a full screen 2d layer.
  60708. * This can be useful to display a picture in the background of your scene for instance.
  60709. * @see https://www.babylonjs-playground.com/#08A2BS#1
  60710. * @param name Define the name of the layer in the scene
  60711. * @param imgUrl Define the url of the texture to display in the layer
  60712. * @param scene Define the scene the layer belongs to
  60713. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  60714. * @param color Defines a color for the layer
  60715. */
  60716. constructor(
  60717. /**
  60718. * Define the name of the layer.
  60719. */
  60720. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  60721. private _createIndexBuffer;
  60722. /** @hidden */
  60723. _rebuild(): void;
  60724. /**
  60725. * Renders the layer in the scene.
  60726. */
  60727. render(): void;
  60728. /**
  60729. * Disposes and releases the associated ressources.
  60730. */
  60731. dispose(): void;
  60732. }
  60733. }
  60734. declare module "babylonjs/Layers/index" {
  60735. export * from "babylonjs/Layers/effectLayer";
  60736. export * from "babylonjs/Layers/effectLayerSceneComponent";
  60737. export * from "babylonjs/Layers/glowLayer";
  60738. export * from "babylonjs/Layers/highlightLayer";
  60739. export * from "babylonjs/Layers/layer";
  60740. export * from "babylonjs/Layers/layerSceneComponent";
  60741. }
  60742. declare module "babylonjs/Shaders/lensFlare.fragment" {
  60743. /** @hidden */
  60744. export var lensFlarePixelShader: {
  60745. name: string;
  60746. shader: string;
  60747. };
  60748. }
  60749. declare module "babylonjs/Shaders/lensFlare.vertex" {
  60750. /** @hidden */
  60751. export var lensFlareVertexShader: {
  60752. name: string;
  60753. shader: string;
  60754. };
  60755. }
  60756. declare module "babylonjs/LensFlares/lensFlareSystem" {
  60757. import { Scene } from "babylonjs/scene";
  60758. import { Vector3 } from "babylonjs/Maths/math.vector";
  60759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60760. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  60761. import "babylonjs/Shaders/lensFlare.fragment";
  60762. import "babylonjs/Shaders/lensFlare.vertex";
  60763. import { Viewport } from "babylonjs/Maths/math.viewport";
  60764. /**
  60765. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60766. * It is usually composed of several `lensFlare`.
  60767. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60768. */
  60769. export class LensFlareSystem {
  60770. /**
  60771. * Define the name of the lens flare system
  60772. */
  60773. name: string;
  60774. /**
  60775. * List of lens flares used in this system.
  60776. */
  60777. lensFlares: LensFlare[];
  60778. /**
  60779. * Define a limit from the border the lens flare can be visible.
  60780. */
  60781. borderLimit: number;
  60782. /**
  60783. * Define a viewport border we do not want to see the lens flare in.
  60784. */
  60785. viewportBorder: number;
  60786. /**
  60787. * Define a predicate which could limit the list of meshes able to occlude the effect.
  60788. */
  60789. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  60790. /**
  60791. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  60792. */
  60793. layerMask: number;
  60794. /**
  60795. * Define the id of the lens flare system in the scene.
  60796. * (equal to name by default)
  60797. */
  60798. id: string;
  60799. private _scene;
  60800. private _emitter;
  60801. private _vertexBuffers;
  60802. private _indexBuffer;
  60803. private _effect;
  60804. private _positionX;
  60805. private _positionY;
  60806. private _isEnabled;
  60807. /** @hidden */
  60808. static _SceneComponentInitialization: (scene: Scene) => void;
  60809. /**
  60810. * Instantiates a lens flare system.
  60811. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  60812. * It is usually composed of several `lensFlare`.
  60813. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60814. * @param name Define the name of the lens flare system in the scene
  60815. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  60816. * @param scene Define the scene the lens flare system belongs to
  60817. */
  60818. constructor(
  60819. /**
  60820. * Define the name of the lens flare system
  60821. */
  60822. name: string, emitter: any, scene: Scene);
  60823. /**
  60824. * Define if the lens flare system is enabled.
  60825. */
  60826. get isEnabled(): boolean;
  60827. set isEnabled(value: boolean);
  60828. /**
  60829. * Get the scene the effects belongs to.
  60830. * @returns the scene holding the lens flare system
  60831. */
  60832. getScene(): Scene;
  60833. /**
  60834. * Get the emitter of the lens flare system.
  60835. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60836. * @returns the emitter of the lens flare system
  60837. */
  60838. getEmitter(): any;
  60839. /**
  60840. * Set the emitter of the lens flare system.
  60841. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  60842. * @param newEmitter Define the new emitter of the system
  60843. */
  60844. setEmitter(newEmitter: any): void;
  60845. /**
  60846. * Get the lens flare system emitter position.
  60847. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  60848. * @returns the position
  60849. */
  60850. getEmitterPosition(): Vector3;
  60851. /**
  60852. * @hidden
  60853. */
  60854. computeEffectivePosition(globalViewport: Viewport): boolean;
  60855. /** @hidden */
  60856. _isVisible(): boolean;
  60857. /**
  60858. * @hidden
  60859. */
  60860. render(): boolean;
  60861. /**
  60862. * Dispose and release the lens flare with its associated resources.
  60863. */
  60864. dispose(): void;
  60865. /**
  60866. * Parse a lens flare system from a JSON repressentation
  60867. * @param parsedLensFlareSystem Define the JSON to parse
  60868. * @param scene Define the scene the parsed system should be instantiated in
  60869. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60870. * @returns the parsed system
  60871. */
  60872. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60873. /**
  60874. * Serialize the current Lens Flare System into a JSON representation.
  60875. * @returns the serialized JSON
  60876. */
  60877. serialize(): any;
  60878. }
  60879. }
  60880. declare module "babylonjs/LensFlares/lensFlare" {
  60881. import { Nullable } from "babylonjs/types";
  60882. import { Color3 } from "babylonjs/Maths/math.color";
  60883. import { Texture } from "babylonjs/Materials/Textures/texture";
  60884. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60885. /**
  60886. * This represents one of the lens effect in a `lensFlareSystem`.
  60887. * It controls one of the indiviual texture used in the effect.
  60888. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60889. */
  60890. export class LensFlare {
  60891. /**
  60892. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60893. */
  60894. size: number;
  60895. /**
  60896. * 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.
  60897. */
  60898. position: number;
  60899. /**
  60900. * Define the lens color.
  60901. */
  60902. color: Color3;
  60903. /**
  60904. * Define the lens texture.
  60905. */
  60906. texture: Nullable<Texture>;
  60907. /**
  60908. * Define the alpha mode to render this particular lens.
  60909. */
  60910. alphaMode: number;
  60911. private _system;
  60912. /**
  60913. * Creates a new Lens Flare.
  60914. * This represents one of the lens effect in a `lensFlareSystem`.
  60915. * It controls one of the indiviual texture used in the effect.
  60916. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60917. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60918. * @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.
  60919. * @param color Define the lens color
  60920. * @param imgUrl Define the lens texture url
  60921. * @param system Define the `lensFlareSystem` this flare is part of
  60922. * @returns The newly created Lens Flare
  60923. */
  60924. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60925. /**
  60926. * Instantiates a new Lens Flare.
  60927. * This represents one of the lens effect in a `lensFlareSystem`.
  60928. * It controls one of the indiviual texture used in the effect.
  60929. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60930. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60931. * @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.
  60932. * @param color Define the lens color
  60933. * @param imgUrl Define the lens texture url
  60934. * @param system Define the `lensFlareSystem` this flare is part of
  60935. */
  60936. constructor(
  60937. /**
  60938. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60939. */
  60940. size: number,
  60941. /**
  60942. * 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.
  60943. */
  60944. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60945. /**
  60946. * Dispose and release the lens flare with its associated resources.
  60947. */
  60948. dispose(): void;
  60949. }
  60950. }
  60951. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  60952. import { Nullable } from "babylonjs/types";
  60953. import { Scene } from "babylonjs/scene";
  60954. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  60955. import { AbstractScene } from "babylonjs/abstractScene";
  60956. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  60957. module "babylonjs/abstractScene" {
  60958. interface AbstractScene {
  60959. /**
  60960. * The list of lens flare system added to the scene
  60961. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60962. */
  60963. lensFlareSystems: Array<LensFlareSystem>;
  60964. /**
  60965. * Removes the given lens flare system from this scene.
  60966. * @param toRemove The lens flare system to remove
  60967. * @returns The index of the removed lens flare system
  60968. */
  60969. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60970. /**
  60971. * Adds the given lens flare system to this scene
  60972. * @param newLensFlareSystem The lens flare system to add
  60973. */
  60974. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60975. /**
  60976. * Gets a lens flare system using its name
  60977. * @param name defines the name to look for
  60978. * @returns the lens flare system or null if not found
  60979. */
  60980. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60981. /**
  60982. * Gets a lens flare system using its id
  60983. * @param id defines the id to look for
  60984. * @returns the lens flare system or null if not found
  60985. */
  60986. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60987. }
  60988. }
  60989. /**
  60990. * Defines the lens flare scene component responsible to manage any lens flares
  60991. * in a given scene.
  60992. */
  60993. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60994. /**
  60995. * The component name helpfull to identify the component in the list of scene components.
  60996. */
  60997. readonly name: string;
  60998. /**
  60999. * The scene the component belongs to.
  61000. */
  61001. scene: Scene;
  61002. /**
  61003. * Creates a new instance of the component for the given scene
  61004. * @param scene Defines the scene to register the component in
  61005. */
  61006. constructor(scene: Scene);
  61007. /**
  61008. * Registers the component in a given scene
  61009. */
  61010. register(): void;
  61011. /**
  61012. * Rebuilds the elements related to this component in case of
  61013. * context lost for instance.
  61014. */
  61015. rebuild(): void;
  61016. /**
  61017. * Adds all the elements from the container to the scene
  61018. * @param container the container holding the elements
  61019. */
  61020. addFromContainer(container: AbstractScene): void;
  61021. /**
  61022. * Removes all the elements in the container from the scene
  61023. * @param container contains the elements to remove
  61024. * @param dispose if the removed element should be disposed (default: false)
  61025. */
  61026. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61027. /**
  61028. * Serializes the component data to the specified json object
  61029. * @param serializationObject The object to serialize to
  61030. */
  61031. serialize(serializationObject: any): void;
  61032. /**
  61033. * Disposes the component and the associated ressources.
  61034. */
  61035. dispose(): void;
  61036. private _draw;
  61037. }
  61038. }
  61039. declare module "babylonjs/LensFlares/index" {
  61040. export * from "babylonjs/LensFlares/lensFlare";
  61041. export * from "babylonjs/LensFlares/lensFlareSystem";
  61042. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  61043. }
  61044. declare module "babylonjs/Shaders/depth.fragment" {
  61045. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  61046. /** @hidden */
  61047. export var depthPixelShader: {
  61048. name: string;
  61049. shader: string;
  61050. };
  61051. }
  61052. declare module "babylonjs/Shaders/depth.vertex" {
  61053. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61054. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61055. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61056. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61057. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61058. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61059. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61060. /** @hidden */
  61061. export var depthVertexShader: {
  61062. name: string;
  61063. shader: string;
  61064. };
  61065. }
  61066. declare module "babylonjs/Rendering/depthRenderer" {
  61067. import { Nullable } from "babylonjs/types";
  61068. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61069. import { Scene } from "babylonjs/scene";
  61070. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61071. import { Camera } from "babylonjs/Cameras/camera";
  61072. import "babylonjs/Shaders/depth.fragment";
  61073. import "babylonjs/Shaders/depth.vertex";
  61074. /**
  61075. * This represents a depth renderer in Babylon.
  61076. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  61077. */
  61078. export class DepthRenderer {
  61079. private _scene;
  61080. private _depthMap;
  61081. private _effect;
  61082. private readonly _storeNonLinearDepth;
  61083. private readonly _clearColor;
  61084. /** Get if the depth renderer is using packed depth or not */
  61085. readonly isPacked: boolean;
  61086. private _cachedDefines;
  61087. private _camera;
  61088. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  61089. enabled: boolean;
  61090. /**
  61091. * Specifiess that the depth renderer will only be used within
  61092. * the camera it is created for.
  61093. * This can help forcing its rendering during the camera processing.
  61094. */
  61095. useOnlyInActiveCamera: boolean;
  61096. /** @hidden */
  61097. static _SceneComponentInitialization: (scene: Scene) => void;
  61098. /**
  61099. * Instantiates a depth renderer
  61100. * @param scene The scene the renderer belongs to
  61101. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  61102. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  61103. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  61104. */
  61105. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  61106. /**
  61107. * Creates the depth rendering effect and checks if the effect is ready.
  61108. * @param subMesh The submesh to be used to render the depth map of
  61109. * @param useInstances If multiple world instances should be used
  61110. * @returns if the depth renderer is ready to render the depth map
  61111. */
  61112. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61113. /**
  61114. * Gets the texture which the depth map will be written to.
  61115. * @returns The depth map texture
  61116. */
  61117. getDepthMap(): RenderTargetTexture;
  61118. /**
  61119. * Disposes of the depth renderer.
  61120. */
  61121. dispose(): void;
  61122. }
  61123. }
  61124. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  61125. /** @hidden */
  61126. export var minmaxReduxPixelShader: {
  61127. name: string;
  61128. shader: string;
  61129. };
  61130. }
  61131. declare module "babylonjs/Misc/minMaxReducer" {
  61132. import { Nullable } from "babylonjs/types";
  61133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61134. import { Camera } from "babylonjs/Cameras/camera";
  61135. import { Observer } from "babylonjs/Misc/observable";
  61136. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61137. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  61138. import { Observable } from "babylonjs/Misc/observable";
  61139. import "babylonjs/Shaders/minmaxRedux.fragment";
  61140. /**
  61141. * This class computes a min/max reduction from a texture: it means it computes the minimum
  61142. * and maximum values from all values of the texture.
  61143. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  61144. * The source values are read from the red channel of the texture.
  61145. */
  61146. export class MinMaxReducer {
  61147. /**
  61148. * Observable triggered when the computation has been performed
  61149. */
  61150. onAfterReductionPerformed: Observable<{
  61151. min: number;
  61152. max: number;
  61153. }>;
  61154. protected _camera: Camera;
  61155. protected _sourceTexture: Nullable<RenderTargetTexture>;
  61156. protected _reductionSteps: Nullable<Array<PostProcess>>;
  61157. protected _postProcessManager: PostProcessManager;
  61158. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  61159. protected _forceFullscreenViewport: boolean;
  61160. /**
  61161. * Creates a min/max reducer
  61162. * @param camera The camera to use for the post processes
  61163. */
  61164. constructor(camera: Camera);
  61165. /**
  61166. * Gets the texture used to read the values from.
  61167. */
  61168. get sourceTexture(): Nullable<RenderTargetTexture>;
  61169. /**
  61170. * Sets the source texture to read the values from.
  61171. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  61172. * because in such textures '1' value must not be taken into account to compute the maximum
  61173. * as this value is used to clear the texture.
  61174. * Note that the computation is not activated by calling this function, you must call activate() for that!
  61175. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  61176. * @param depthRedux Indicates if the texture is a depth texture or not
  61177. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  61178. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61179. */
  61180. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61181. /**
  61182. * Defines the refresh rate of the computation.
  61183. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61184. */
  61185. get refreshRate(): number;
  61186. set refreshRate(value: number);
  61187. protected _activated: boolean;
  61188. /**
  61189. * Gets the activation status of the reducer
  61190. */
  61191. get activated(): boolean;
  61192. /**
  61193. * Activates the reduction computation.
  61194. * When activated, the observers registered in onAfterReductionPerformed are
  61195. * called after the compuation is performed
  61196. */
  61197. activate(): void;
  61198. /**
  61199. * Deactivates the reduction computation.
  61200. */
  61201. deactivate(): void;
  61202. /**
  61203. * Disposes the min/max reducer
  61204. * @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.
  61205. */
  61206. dispose(disposeAll?: boolean): void;
  61207. }
  61208. }
  61209. declare module "babylonjs/Misc/depthReducer" {
  61210. import { Nullable } from "babylonjs/types";
  61211. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61212. import { Camera } from "babylonjs/Cameras/camera";
  61213. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61214. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  61215. /**
  61216. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  61217. */
  61218. export class DepthReducer extends MinMaxReducer {
  61219. private _depthRenderer;
  61220. private _depthRendererId;
  61221. /**
  61222. * Gets the depth renderer used for the computation.
  61223. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  61224. */
  61225. get depthRenderer(): Nullable<DepthRenderer>;
  61226. /**
  61227. * Creates a depth reducer
  61228. * @param camera The camera used to render the depth texture
  61229. */
  61230. constructor(camera: Camera);
  61231. /**
  61232. * Sets the depth renderer to use to generate the depth map
  61233. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  61234. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  61235. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  61236. */
  61237. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  61238. /** @hidden */
  61239. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  61240. /**
  61241. * Activates the reduction computation.
  61242. * When activated, the observers registered in onAfterReductionPerformed are
  61243. * called after the compuation is performed
  61244. */
  61245. activate(): void;
  61246. /**
  61247. * Deactivates the reduction computation.
  61248. */
  61249. deactivate(): void;
  61250. /**
  61251. * Disposes the depth reducer
  61252. * @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.
  61253. */
  61254. dispose(disposeAll?: boolean): void;
  61255. }
  61256. }
  61257. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  61258. import { Nullable } from "babylonjs/types";
  61259. import { Scene } from "babylonjs/scene";
  61260. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61261. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61262. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61263. import { Effect } from "babylonjs/Materials/effect";
  61264. import "babylonjs/Shaders/shadowMap.fragment";
  61265. import "babylonjs/Shaders/shadowMap.vertex";
  61266. import "babylonjs/Shaders/depthBoxBlur.fragment";
  61267. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  61268. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  61269. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  61270. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  61271. /**
  61272. * A CSM implementation allowing casting shadows on large scenes.
  61273. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61274. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  61275. */
  61276. export class CascadedShadowGenerator extends ShadowGenerator {
  61277. private static readonly frustumCornersNDCSpace;
  61278. /**
  61279. * Name of the CSM class
  61280. */
  61281. static CLASSNAME: string;
  61282. /**
  61283. * Defines the default number of cascades used by the CSM.
  61284. */
  61285. static readonly DEFAULT_CASCADES_COUNT: number;
  61286. /**
  61287. * Defines the minimum number of cascades used by the CSM.
  61288. */
  61289. static readonly MIN_CASCADES_COUNT: number;
  61290. /**
  61291. * Defines the maximum number of cascades used by the CSM.
  61292. */
  61293. static readonly MAX_CASCADES_COUNT: number;
  61294. protected _validateFilter(filter: number): number;
  61295. /**
  61296. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  61297. */
  61298. penumbraDarkness: number;
  61299. private _numCascades;
  61300. /**
  61301. * Gets or set the number of cascades used by the CSM.
  61302. */
  61303. get numCascades(): number;
  61304. set numCascades(value: number);
  61305. /**
  61306. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  61307. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  61308. */
  61309. stabilizeCascades: boolean;
  61310. private _freezeShadowCastersBoundingInfo;
  61311. private _freezeShadowCastersBoundingInfoObservable;
  61312. /**
  61313. * Enables or disables the shadow casters bounding info computation.
  61314. * If your shadow casters don't move, you can disable this feature.
  61315. * If it is enabled, the bounding box computation is done every frame.
  61316. */
  61317. get freezeShadowCastersBoundingInfo(): boolean;
  61318. set freezeShadowCastersBoundingInfo(freeze: boolean);
  61319. private _scbiMin;
  61320. private _scbiMax;
  61321. protected _computeShadowCastersBoundingInfo(): void;
  61322. protected _shadowCastersBoundingInfo: BoundingInfo;
  61323. /**
  61324. * Gets or sets the shadow casters bounding info.
  61325. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  61326. * so that the system won't overwrite the bounds you provide
  61327. */
  61328. get shadowCastersBoundingInfo(): BoundingInfo;
  61329. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  61330. protected _breaksAreDirty: boolean;
  61331. protected _minDistance: number;
  61332. protected _maxDistance: number;
  61333. /**
  61334. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  61335. *
  61336. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  61337. * If you don't know these values, simply leave them to their defaults and don't call this function.
  61338. * @param min minimal distance for the breaks (default to 0.)
  61339. * @param max maximal distance for the breaks (default to 1.)
  61340. */
  61341. setMinMaxDistance(min: number, max: number): void;
  61342. /** Gets the minimal distance used in the cascade break computation */
  61343. get minDistance(): number;
  61344. /** Gets the maximal distance used in the cascade break computation */
  61345. get maxDistance(): number;
  61346. /**
  61347. * Gets the class name of that object
  61348. * @returns "CascadedShadowGenerator"
  61349. */
  61350. getClassName(): string;
  61351. private _cascadeMinExtents;
  61352. private _cascadeMaxExtents;
  61353. /**
  61354. * Gets a cascade minimum extents
  61355. * @param cascadeIndex index of the cascade
  61356. * @returns the minimum cascade extents
  61357. */
  61358. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  61359. /**
  61360. * Gets a cascade maximum extents
  61361. * @param cascadeIndex index of the cascade
  61362. * @returns the maximum cascade extents
  61363. */
  61364. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  61365. private _cascades;
  61366. private _currentLayer;
  61367. private _viewSpaceFrustumsZ;
  61368. private _viewMatrices;
  61369. private _projectionMatrices;
  61370. private _transformMatrices;
  61371. private _transformMatricesAsArray;
  61372. private _frustumLengths;
  61373. private _lightSizeUVCorrection;
  61374. private _depthCorrection;
  61375. private _frustumCornersWorldSpace;
  61376. private _frustumCenter;
  61377. private _shadowCameraPos;
  61378. private _shadowMaxZ;
  61379. /**
  61380. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  61381. * It defaults to camera.maxZ
  61382. */
  61383. get shadowMaxZ(): number;
  61384. /**
  61385. * Sets the shadow max z distance.
  61386. */
  61387. set shadowMaxZ(value: number);
  61388. protected _debug: boolean;
  61389. /**
  61390. * Gets or sets the debug flag.
  61391. * When enabled, the cascades are materialized by different colors on the screen.
  61392. */
  61393. get debug(): boolean;
  61394. set debug(dbg: boolean);
  61395. private _depthClamp;
  61396. /**
  61397. * Gets or sets the depth clamping value.
  61398. *
  61399. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  61400. * to account for the shadow casters far away.
  61401. *
  61402. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  61403. */
  61404. get depthClamp(): boolean;
  61405. set depthClamp(value: boolean);
  61406. private _cascadeBlendPercentage;
  61407. /**
  61408. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  61409. * It defaults to 0.1 (10% blending).
  61410. */
  61411. get cascadeBlendPercentage(): number;
  61412. set cascadeBlendPercentage(value: number);
  61413. private _lambda;
  61414. /**
  61415. * Gets or set the lambda parameter.
  61416. * This parameter is used to split the camera frustum and create the cascades.
  61417. * 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.
  61418. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  61419. */
  61420. get lambda(): number;
  61421. set lambda(value: number);
  61422. /**
  61423. * Gets the view matrix corresponding to a given cascade
  61424. * @param cascadeNum cascade to retrieve the view matrix from
  61425. * @returns the cascade view matrix
  61426. */
  61427. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  61428. /**
  61429. * Gets the projection matrix corresponding to a given cascade
  61430. * @param cascadeNum cascade to retrieve the projection matrix from
  61431. * @returns the cascade projection matrix
  61432. */
  61433. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  61434. /**
  61435. * Gets the transformation matrix corresponding to a given cascade
  61436. * @param cascadeNum cascade to retrieve the transformation matrix from
  61437. * @returns the cascade transformation matrix
  61438. */
  61439. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  61440. private _depthRenderer;
  61441. /**
  61442. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  61443. *
  61444. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  61445. *
  61446. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  61447. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  61448. * @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
  61449. */
  61450. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  61451. private _depthReducer;
  61452. private _autoCalcDepthBounds;
  61453. /**
  61454. * Gets or sets the autoCalcDepthBounds property.
  61455. *
  61456. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  61457. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  61458. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  61459. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  61460. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  61461. */
  61462. get autoCalcDepthBounds(): boolean;
  61463. set autoCalcDepthBounds(value: boolean);
  61464. /**
  61465. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  61466. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  61467. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  61468. * for setting the refresh rate on the renderer yourself!
  61469. */
  61470. get autoCalcDepthBoundsRefreshRate(): number;
  61471. set autoCalcDepthBoundsRefreshRate(value: number);
  61472. /**
  61473. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  61474. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  61475. * you change the camera near/far planes!
  61476. */
  61477. splitFrustum(): void;
  61478. private _splitFrustum;
  61479. private _computeMatrices;
  61480. private _computeFrustumInWorldSpace;
  61481. private _computeCascadeFrustum;
  61482. /**
  61483. * Support test.
  61484. */
  61485. static get IsSupported(): boolean;
  61486. /** @hidden */
  61487. static _SceneComponentInitialization: (scene: Scene) => void;
  61488. /**
  61489. * Creates a Cascaded Shadow Generator object.
  61490. * A ShadowGenerator is the required tool to use the shadows.
  61491. * Each directional light casting shadows needs to use its own ShadowGenerator.
  61492. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  61493. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  61494. * @param light The directional light object generating the shadows.
  61495. * @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.
  61496. */
  61497. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  61498. protected _initializeGenerator(): void;
  61499. protected _createTargetRenderTexture(): void;
  61500. protected _initializeShadowMap(): void;
  61501. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  61502. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  61503. /**
  61504. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  61505. * @param defines Defines of the material we want to update
  61506. * @param lightIndex Index of the light in the enabled light list of the material
  61507. */
  61508. prepareDefines(defines: any, lightIndex: number): void;
  61509. /**
  61510. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  61511. * defined in the generator but impacting the effect).
  61512. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  61513. * @param effect The effect we are binfing the information for
  61514. */
  61515. bindShadowLight(lightIndex: string, effect: Effect): void;
  61516. /**
  61517. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  61518. * (eq to view projection * shadow projection matrices)
  61519. * @returns The transform matrix used to create the shadow map
  61520. */
  61521. getTransformMatrix(): Matrix;
  61522. /**
  61523. * Disposes the ShadowGenerator.
  61524. * Returns nothing.
  61525. */
  61526. dispose(): void;
  61527. /**
  61528. * Serializes the shadow generator setup to a json object.
  61529. * @returns The serialized JSON object
  61530. */
  61531. serialize(): any;
  61532. /**
  61533. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  61534. * @param parsedShadowGenerator The JSON object to parse
  61535. * @param scene The scene to create the shadow map for
  61536. * @returns The parsed shadow generator
  61537. */
  61538. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  61539. }
  61540. }
  61541. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  61542. import { Scene } from "babylonjs/scene";
  61543. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61544. import { AbstractScene } from "babylonjs/abstractScene";
  61545. /**
  61546. * Defines the shadow generator component responsible to manage any shadow generators
  61547. * in a given scene.
  61548. */
  61549. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  61550. /**
  61551. * The component name helpfull to identify the component in the list of scene components.
  61552. */
  61553. readonly name: string;
  61554. /**
  61555. * The scene the component belongs to.
  61556. */
  61557. scene: Scene;
  61558. /**
  61559. * Creates a new instance of the component for the given scene
  61560. * @param scene Defines the scene to register the component in
  61561. */
  61562. constructor(scene: Scene);
  61563. /**
  61564. * Registers the component in a given scene
  61565. */
  61566. register(): void;
  61567. /**
  61568. * Rebuilds the elements related to this component in case of
  61569. * context lost for instance.
  61570. */
  61571. rebuild(): void;
  61572. /**
  61573. * Serializes the component data to the specified json object
  61574. * @param serializationObject The object to serialize to
  61575. */
  61576. serialize(serializationObject: any): void;
  61577. /**
  61578. * Adds all the elements from the container to the scene
  61579. * @param container the container holding the elements
  61580. */
  61581. addFromContainer(container: AbstractScene): void;
  61582. /**
  61583. * Removes all the elements in the container from the scene
  61584. * @param container contains the elements to remove
  61585. * @param dispose if the removed element should be disposed (default: false)
  61586. */
  61587. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61588. /**
  61589. * Rebuilds the elements related to this component in case of
  61590. * context lost for instance.
  61591. */
  61592. dispose(): void;
  61593. private _gatherRenderTargets;
  61594. }
  61595. }
  61596. declare module "babylonjs/Lights/Shadows/index" {
  61597. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  61598. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  61599. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  61600. }
  61601. declare module "babylonjs/Lights/pointLight" {
  61602. import { Scene } from "babylonjs/scene";
  61603. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61605. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  61606. import { Effect } from "babylonjs/Materials/effect";
  61607. /**
  61608. * A point light is a light defined by an unique point in world space.
  61609. * The light is emitted in every direction from this point.
  61610. * A good example of a point light is a standard light bulb.
  61611. * Documentation: https://doc.babylonjs.com/babylon101/lights
  61612. */
  61613. export class PointLight extends ShadowLight {
  61614. private _shadowAngle;
  61615. /**
  61616. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61617. * This specifies what angle the shadow will use to be created.
  61618. *
  61619. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61620. */
  61621. get shadowAngle(): number;
  61622. /**
  61623. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61624. * This specifies what angle the shadow will use to be created.
  61625. *
  61626. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  61627. */
  61628. set shadowAngle(value: number);
  61629. /**
  61630. * Gets the direction if it has been set.
  61631. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61632. */
  61633. get direction(): Vector3;
  61634. /**
  61635. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  61636. */
  61637. set direction(value: Vector3);
  61638. /**
  61639. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  61640. * A PointLight emits the light in every direction.
  61641. * It can cast shadows.
  61642. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  61643. * ```javascript
  61644. * var pointLight = new PointLight("pl", camera.position, scene);
  61645. * ```
  61646. * Documentation : https://doc.babylonjs.com/babylon101/lights
  61647. * @param name The light friendly name
  61648. * @param position The position of the point light in the scene
  61649. * @param scene The scene the lights belongs to
  61650. */
  61651. constructor(name: string, position: Vector3, scene: Scene);
  61652. /**
  61653. * Returns the string "PointLight"
  61654. * @returns the class name
  61655. */
  61656. getClassName(): string;
  61657. /**
  61658. * Returns the integer 0.
  61659. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  61660. */
  61661. getTypeID(): number;
  61662. /**
  61663. * Specifies wether or not the shadowmap should be a cube texture.
  61664. * @returns true if the shadowmap needs to be a cube texture.
  61665. */
  61666. needCube(): boolean;
  61667. /**
  61668. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  61669. * @param faceIndex The index of the face we are computed the direction to generate shadow
  61670. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  61671. */
  61672. getShadowDirection(faceIndex?: number): Vector3;
  61673. /**
  61674. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  61675. * - fov = PI / 2
  61676. * - aspect ratio : 1.0
  61677. * - z-near and far equal to the active camera minZ and maxZ.
  61678. * Returns the PointLight.
  61679. */
  61680. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  61681. protected _buildUniformLayout(): void;
  61682. /**
  61683. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  61684. * @param effect The effect to update
  61685. * @param lightIndex The index of the light in the effect to update
  61686. * @returns The point light
  61687. */
  61688. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  61689. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  61690. /**
  61691. * Prepares the list of defines specific to the light type.
  61692. * @param defines the list of defines
  61693. * @param lightIndex defines the index of the light for the effect
  61694. */
  61695. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  61696. }
  61697. }
  61698. declare module "babylonjs/Lights/index" {
  61699. export * from "babylonjs/Lights/light";
  61700. export * from "babylonjs/Lights/shadowLight";
  61701. export * from "babylonjs/Lights/Shadows/index";
  61702. export * from "babylonjs/Lights/directionalLight";
  61703. export * from "babylonjs/Lights/hemisphericLight";
  61704. export * from "babylonjs/Lights/pointLight";
  61705. export * from "babylonjs/Lights/spotLight";
  61706. }
  61707. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  61708. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  61709. /**
  61710. * Header information of HDR texture files.
  61711. */
  61712. export interface HDRInfo {
  61713. /**
  61714. * The height of the texture in pixels.
  61715. */
  61716. height: number;
  61717. /**
  61718. * The width of the texture in pixels.
  61719. */
  61720. width: number;
  61721. /**
  61722. * The index of the beginning of the data in the binary file.
  61723. */
  61724. dataPosition: number;
  61725. }
  61726. /**
  61727. * This groups tools to convert HDR texture to native colors array.
  61728. */
  61729. export class HDRTools {
  61730. private static Ldexp;
  61731. private static Rgbe2float;
  61732. private static readStringLine;
  61733. /**
  61734. * Reads header information from an RGBE texture stored in a native array.
  61735. * More information on this format are available here:
  61736. * https://en.wikipedia.org/wiki/RGBE_image_format
  61737. *
  61738. * @param uint8array The binary file stored in native array.
  61739. * @return The header information.
  61740. */
  61741. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  61742. /**
  61743. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  61744. * This RGBE texture needs to store the information as a panorama.
  61745. *
  61746. * More information on this format are available here:
  61747. * https://en.wikipedia.org/wiki/RGBE_image_format
  61748. *
  61749. * @param buffer The binary file stored in an array buffer.
  61750. * @param size The expected size of the extracted cubemap.
  61751. * @return The Cube Map information.
  61752. */
  61753. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  61754. /**
  61755. * Returns the pixels data extracted from an RGBE texture.
  61756. * This pixels will be stored left to right up to down in the R G B order in one array.
  61757. *
  61758. * More information on this format are available here:
  61759. * https://en.wikipedia.org/wiki/RGBE_image_format
  61760. *
  61761. * @param uint8array The binary file stored in an array buffer.
  61762. * @param hdrInfo The header information of the file.
  61763. * @return The pixels data in RGB right to left up to down order.
  61764. */
  61765. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  61766. private static RGBE_ReadPixels_RLE;
  61767. }
  61768. }
  61769. declare module "babylonjs/Materials/effectRenderer" {
  61770. import { Nullable } from "babylonjs/types";
  61771. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  61772. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61773. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61774. import { Viewport } from "babylonjs/Maths/math.viewport";
  61775. import { Observable } from "babylonjs/Misc/observable";
  61776. import { Effect } from "babylonjs/Materials/effect";
  61777. import "babylonjs/Shaders/postprocess.vertex";
  61778. /**
  61779. * Effect Render Options
  61780. */
  61781. export interface IEffectRendererOptions {
  61782. /**
  61783. * Defines the vertices positions.
  61784. */
  61785. positions?: number[];
  61786. /**
  61787. * Defines the indices.
  61788. */
  61789. indices?: number[];
  61790. }
  61791. /**
  61792. * Helper class to render one or more effects.
  61793. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  61794. */
  61795. export class EffectRenderer {
  61796. private engine;
  61797. private static _DefaultOptions;
  61798. private _vertexBuffers;
  61799. private _indexBuffer;
  61800. private _fullscreenViewport;
  61801. /**
  61802. * Creates an effect renderer
  61803. * @param engine the engine to use for rendering
  61804. * @param options defines the options of the effect renderer
  61805. */
  61806. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  61807. /**
  61808. * Sets the current viewport in normalized coordinates 0-1
  61809. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  61810. */
  61811. setViewport(viewport?: Viewport): void;
  61812. /**
  61813. * Binds the embedded attributes buffer to the effect.
  61814. * @param effect Defines the effect to bind the attributes for
  61815. */
  61816. bindBuffers(effect: Effect): void;
  61817. /**
  61818. * Sets the current effect wrapper to use during draw.
  61819. * The effect needs to be ready before calling this api.
  61820. * This also sets the default full screen position attribute.
  61821. * @param effectWrapper Defines the effect to draw with
  61822. */
  61823. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  61824. /**
  61825. * Restores engine states
  61826. */
  61827. restoreStates(): void;
  61828. /**
  61829. * Draws a full screen quad.
  61830. */
  61831. draw(): void;
  61832. private isRenderTargetTexture;
  61833. /**
  61834. * renders one or more effects to a specified texture
  61835. * @param effectWrapper the effect to renderer
  61836. * @param outputTexture texture to draw to, if null it will render to the screen.
  61837. */
  61838. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  61839. /**
  61840. * Disposes of the effect renderer
  61841. */
  61842. dispose(): void;
  61843. }
  61844. /**
  61845. * Options to create an EffectWrapper
  61846. */
  61847. interface EffectWrapperCreationOptions {
  61848. /**
  61849. * Engine to use to create the effect
  61850. */
  61851. engine: ThinEngine;
  61852. /**
  61853. * Fragment shader for the effect
  61854. */
  61855. fragmentShader: string;
  61856. /**
  61857. * Use the shader store instead of direct source code
  61858. */
  61859. useShaderStore?: boolean;
  61860. /**
  61861. * Vertex shader for the effect
  61862. */
  61863. vertexShader?: string;
  61864. /**
  61865. * Attributes to use in the shader
  61866. */
  61867. attributeNames?: Array<string>;
  61868. /**
  61869. * Uniforms to use in the shader
  61870. */
  61871. uniformNames?: Array<string>;
  61872. /**
  61873. * Texture sampler names to use in the shader
  61874. */
  61875. samplerNames?: Array<string>;
  61876. /**
  61877. * Defines to use in the shader
  61878. */
  61879. defines?: Array<string>;
  61880. /**
  61881. * Callback when effect is compiled
  61882. */
  61883. onCompiled?: Nullable<(effect: Effect) => void>;
  61884. /**
  61885. * The friendly name of the effect displayed in Spector.
  61886. */
  61887. name?: string;
  61888. }
  61889. /**
  61890. * Wraps an effect to be used for rendering
  61891. */
  61892. export class EffectWrapper {
  61893. /**
  61894. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  61895. */
  61896. onApplyObservable: Observable<{}>;
  61897. /**
  61898. * The underlying effect
  61899. */
  61900. effect: Effect;
  61901. /**
  61902. * Creates an effect to be renderer
  61903. * @param creationOptions options to create the effect
  61904. */
  61905. constructor(creationOptions: EffectWrapperCreationOptions);
  61906. /**
  61907. * Disposes of the effect wrapper
  61908. */
  61909. dispose(): void;
  61910. }
  61911. }
  61912. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  61913. /** @hidden */
  61914. export var hdrFilteringVertexShader: {
  61915. name: string;
  61916. shader: string;
  61917. };
  61918. }
  61919. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  61920. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61921. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  61922. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  61923. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  61924. /** @hidden */
  61925. export var hdrFilteringPixelShader: {
  61926. name: string;
  61927. shader: string;
  61928. };
  61929. }
  61930. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  61931. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61932. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  61933. import { Nullable } from "babylonjs/types";
  61934. import "babylonjs/Shaders/hdrFiltering.vertex";
  61935. import "babylonjs/Shaders/hdrFiltering.fragment";
  61936. /**
  61937. * Options for texture filtering
  61938. */
  61939. interface IHDRFilteringOptions {
  61940. /**
  61941. * Scales pixel intensity for the input HDR map.
  61942. */
  61943. hdrScale?: number;
  61944. /**
  61945. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  61946. */
  61947. quality?: number;
  61948. }
  61949. /**
  61950. * Filters HDR maps to get correct renderings of PBR reflections
  61951. */
  61952. export class HDRFiltering {
  61953. private _engine;
  61954. private _effectRenderer;
  61955. private _effectWrapper;
  61956. private _lodGenerationOffset;
  61957. private _lodGenerationScale;
  61958. /**
  61959. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61960. * you care about baking speed.
  61961. */
  61962. quality: number;
  61963. /**
  61964. * Scales pixel intensity for the input HDR map.
  61965. */
  61966. hdrScale: number;
  61967. /**
  61968. * Instantiates HDR filter for reflection maps
  61969. *
  61970. * @param engine Thin engine
  61971. * @param options Options
  61972. */
  61973. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61974. private _createRenderTarget;
  61975. private _prefilterInternal;
  61976. private _createEffect;
  61977. /**
  61978. * Get a value indicating if the filter is ready to be used
  61979. * @param texture Texture to filter
  61980. * @returns true if the filter is ready
  61981. */
  61982. isReady(texture: BaseTexture): boolean;
  61983. /**
  61984. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61985. * Prefiltering will be invoked at the end of next rendering pass.
  61986. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61987. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61988. * @param texture Texture to filter
  61989. * @param onFinished Callback when filtering is done
  61990. * @return Promise called when prefiltering is done
  61991. */
  61992. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61993. }
  61994. }
  61995. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  61996. import { Nullable } from "babylonjs/types";
  61997. import { Scene } from "babylonjs/scene";
  61998. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  61999. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  62000. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  62001. import "babylonjs/Engines/Extensions/engine.rawTexture";
  62002. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  62003. /**
  62004. * This represents a texture coming from an HDR input.
  62005. *
  62006. * The only supported format is currently panorama picture stored in RGBE format.
  62007. * Example of such files can be found on HDRLib: http://hdrlib.com/
  62008. */
  62009. export class HDRCubeTexture extends BaseTexture {
  62010. private static _facesMapping;
  62011. private _generateHarmonics;
  62012. private _noMipmap;
  62013. private _prefilterOnLoad;
  62014. private _textureMatrix;
  62015. private _size;
  62016. private _onLoad;
  62017. private _onError;
  62018. /**
  62019. * The texture URL.
  62020. */
  62021. url: string;
  62022. /**
  62023. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  62024. */
  62025. coordinatesMode: number;
  62026. protected _isBlocking: boolean;
  62027. /**
  62028. * Sets wether or not the texture is blocking during loading.
  62029. */
  62030. set isBlocking(value: boolean);
  62031. /**
  62032. * Gets wether or not the texture is blocking during loading.
  62033. */
  62034. get isBlocking(): boolean;
  62035. protected _rotationY: number;
  62036. /**
  62037. * Sets texture matrix rotation angle around Y axis in radians.
  62038. */
  62039. set rotationY(value: number);
  62040. /**
  62041. * Gets texture matrix rotation angle around Y axis radians.
  62042. */
  62043. get rotationY(): number;
  62044. /**
  62045. * Gets or sets the center of the bounding box associated with the cube texture
  62046. * It must define where the camera used to render the texture was set
  62047. */
  62048. boundingBoxPosition: Vector3;
  62049. private _boundingBoxSize;
  62050. /**
  62051. * Gets or sets the size of the bounding box associated with the cube texture
  62052. * When defined, the cubemap will switch to local mode
  62053. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  62054. * @example https://www.babylonjs-playground.com/#RNASML
  62055. */
  62056. set boundingBoxSize(value: Vector3);
  62057. get boundingBoxSize(): Vector3;
  62058. /**
  62059. * Instantiates an HDRTexture from the following parameters.
  62060. *
  62061. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  62062. * @param sceneOrEngine The scene or engine the texture will be used in
  62063. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62064. * @param noMipmap Forces to not generate the mipmap if true
  62065. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  62066. * @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)
  62067. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  62068. */
  62069. 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>);
  62070. /**
  62071. * Get the current class name of the texture useful for serialization or dynamic coding.
  62072. * @returns "HDRCubeTexture"
  62073. */
  62074. getClassName(): string;
  62075. /**
  62076. * Occurs when the file is raw .hdr file.
  62077. */
  62078. private loadTexture;
  62079. clone(): HDRCubeTexture;
  62080. delayLoad(): void;
  62081. /**
  62082. * Get the texture reflection matrix used to rotate/transform the reflection.
  62083. * @returns the reflection matrix
  62084. */
  62085. getReflectionTextureMatrix(): Matrix;
  62086. /**
  62087. * Set the texture reflection matrix used to rotate/transform the reflection.
  62088. * @param value Define the reflection matrix to set
  62089. */
  62090. setReflectionTextureMatrix(value: Matrix): void;
  62091. /**
  62092. * Parses a JSON representation of an HDR Texture in order to create the texture
  62093. * @param parsedTexture Define the JSON representation
  62094. * @param scene Define the scene the texture should be created in
  62095. * @param rootUrl Define the root url in case we need to load relative dependencies
  62096. * @returns the newly created texture after parsing
  62097. */
  62098. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  62099. serialize(): any;
  62100. }
  62101. }
  62102. declare module "babylonjs/Physics/physicsEngine" {
  62103. import { Nullable } from "babylonjs/types";
  62104. import { Vector3 } from "babylonjs/Maths/math.vector";
  62105. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  62106. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  62107. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  62108. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62109. /**
  62110. * Class used to control physics engine
  62111. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62112. */
  62113. export class PhysicsEngine implements IPhysicsEngine {
  62114. private _physicsPlugin;
  62115. /**
  62116. * Global value used to control the smallest number supported by the simulation
  62117. */
  62118. static Epsilon: number;
  62119. private _impostors;
  62120. private _joints;
  62121. private _subTimeStep;
  62122. /**
  62123. * Gets the gravity vector used by the simulation
  62124. */
  62125. gravity: Vector3;
  62126. /**
  62127. * Factory used to create the default physics plugin.
  62128. * @returns The default physics plugin
  62129. */
  62130. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  62131. /**
  62132. * Creates a new Physics Engine
  62133. * @param gravity defines the gravity vector used by the simulation
  62134. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  62135. */
  62136. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  62137. /**
  62138. * Sets the gravity vector used by the simulation
  62139. * @param gravity defines the gravity vector to use
  62140. */
  62141. setGravity(gravity: Vector3): void;
  62142. /**
  62143. * Set the time step of the physics engine.
  62144. * Default is 1/60.
  62145. * To slow it down, enter 1/600 for example.
  62146. * To speed it up, 1/30
  62147. * @param newTimeStep defines the new timestep to apply to this world.
  62148. */
  62149. setTimeStep(newTimeStep?: number): void;
  62150. /**
  62151. * Get the time step of the physics engine.
  62152. * @returns the current time step
  62153. */
  62154. getTimeStep(): number;
  62155. /**
  62156. * Set the sub time step of the physics engine.
  62157. * Default is 0 meaning there is no sub steps
  62158. * To increase physics resolution precision, set a small value (like 1 ms)
  62159. * @param subTimeStep defines the new sub timestep used for physics resolution.
  62160. */
  62161. setSubTimeStep(subTimeStep?: number): void;
  62162. /**
  62163. * Get the sub time step of the physics engine.
  62164. * @returns the current sub time step
  62165. */
  62166. getSubTimeStep(): number;
  62167. /**
  62168. * Release all resources
  62169. */
  62170. dispose(): void;
  62171. /**
  62172. * Gets the name of the current physics plugin
  62173. * @returns the name of the plugin
  62174. */
  62175. getPhysicsPluginName(): string;
  62176. /**
  62177. * Adding a new impostor for the impostor tracking.
  62178. * This will be done by the impostor itself.
  62179. * @param impostor the impostor to add
  62180. */
  62181. addImpostor(impostor: PhysicsImpostor): void;
  62182. /**
  62183. * Remove an impostor from the engine.
  62184. * This impostor and its mesh will not longer be updated by the physics engine.
  62185. * @param impostor the impostor to remove
  62186. */
  62187. removeImpostor(impostor: PhysicsImpostor): void;
  62188. /**
  62189. * Add a joint to the physics engine
  62190. * @param mainImpostor defines the main impostor to which the joint is added.
  62191. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  62192. * @param joint defines the joint that will connect both impostors.
  62193. */
  62194. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62195. /**
  62196. * Removes a joint from the simulation
  62197. * @param mainImpostor defines the impostor used with the joint
  62198. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  62199. * @param joint defines the joint to remove
  62200. */
  62201. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  62202. /**
  62203. * Called by the scene. No need to call it.
  62204. * @param delta defines the timespam between frames
  62205. */
  62206. _step(delta: number): void;
  62207. /**
  62208. * Gets the current plugin used to run the simulation
  62209. * @returns current plugin
  62210. */
  62211. getPhysicsPlugin(): IPhysicsEnginePlugin;
  62212. /**
  62213. * Gets the list of physic impostors
  62214. * @returns an array of PhysicsImpostor
  62215. */
  62216. getImpostors(): Array<PhysicsImpostor>;
  62217. /**
  62218. * Gets the impostor for a physics enabled object
  62219. * @param object defines the object impersonated by the impostor
  62220. * @returns the PhysicsImpostor or null if not found
  62221. */
  62222. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  62223. /**
  62224. * Gets the impostor for a physics body object
  62225. * @param body defines physics body used by the impostor
  62226. * @returns the PhysicsImpostor or null if not found
  62227. */
  62228. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  62229. /**
  62230. * Does a raycast in the physics world
  62231. * @param from when should the ray start?
  62232. * @param to when should the ray end?
  62233. * @returns PhysicsRaycastResult
  62234. */
  62235. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62236. }
  62237. }
  62238. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  62239. import { Nullable } from "babylonjs/types";
  62240. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62242. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62243. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62244. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62245. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62246. /** @hidden */
  62247. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  62248. private _useDeltaForWorldStep;
  62249. world: any;
  62250. name: string;
  62251. private _physicsMaterials;
  62252. private _fixedTimeStep;
  62253. private _cannonRaycastResult;
  62254. private _raycastResult;
  62255. private _physicsBodysToRemoveAfterStep;
  62256. private _firstFrame;
  62257. BJSCANNON: any;
  62258. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  62259. setGravity(gravity: Vector3): void;
  62260. setTimeStep(timeStep: number): void;
  62261. getTimeStep(): number;
  62262. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62263. private _removeMarkedPhysicsBodiesFromWorld;
  62264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62267. private _processChildMeshes;
  62268. removePhysicsBody(impostor: PhysicsImpostor): void;
  62269. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62271. private _addMaterial;
  62272. private _checkWithEpsilon;
  62273. private _createShape;
  62274. private _createHeightmap;
  62275. private _minus90X;
  62276. private _plus90X;
  62277. private _tmpPosition;
  62278. private _tmpDeltaPosition;
  62279. private _tmpUnityRotation;
  62280. private _updatePhysicsBodyTransformation;
  62281. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62282. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62283. isSupported(): boolean;
  62284. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62285. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62286. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62287. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62288. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62289. getBodyMass(impostor: PhysicsImpostor): number;
  62290. getBodyFriction(impostor: PhysicsImpostor): number;
  62291. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62292. getBodyRestitution(impostor: PhysicsImpostor): number;
  62293. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62294. sleepBody(impostor: PhysicsImpostor): void;
  62295. wakeUpBody(impostor: PhysicsImpostor): void;
  62296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  62297. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62299. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62300. getRadius(impostor: PhysicsImpostor): number;
  62301. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62302. dispose(): void;
  62303. private _extendNamespace;
  62304. /**
  62305. * Does a raycast in the physics world
  62306. * @param from when should the ray start?
  62307. * @param to when should the ray end?
  62308. * @returns PhysicsRaycastResult
  62309. */
  62310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62311. }
  62312. }
  62313. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  62314. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62315. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62316. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62318. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  62319. import { Nullable } from "babylonjs/types";
  62320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62321. /** @hidden */
  62322. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  62323. private _useDeltaForWorldStep;
  62324. world: any;
  62325. name: string;
  62326. BJSOIMO: any;
  62327. private _raycastResult;
  62328. private _fixedTimeStep;
  62329. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  62330. setGravity(gravity: Vector3): void;
  62331. setTimeStep(timeStep: number): void;
  62332. getTimeStep(): number;
  62333. private _tmpImpostorsArray;
  62334. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62335. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62336. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62337. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62338. private _tmpPositionVector;
  62339. removePhysicsBody(impostor: PhysicsImpostor): void;
  62340. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62341. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62342. isSupported(): boolean;
  62343. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62346. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62347. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62348. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62349. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62350. getBodyMass(impostor: PhysicsImpostor): number;
  62351. getBodyFriction(impostor: PhysicsImpostor): number;
  62352. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62353. getBodyRestitution(impostor: PhysicsImpostor): number;
  62354. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62355. sleepBody(impostor: PhysicsImpostor): void;
  62356. wakeUpBody(impostor: PhysicsImpostor): void;
  62357. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62358. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  62359. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  62360. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62361. getRadius(impostor: PhysicsImpostor): number;
  62362. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62363. dispose(): void;
  62364. /**
  62365. * Does a raycast in the physics world
  62366. * @param from when should the ray start?
  62367. * @param to when should the ray end?
  62368. * @returns PhysicsRaycastResult
  62369. */
  62370. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62371. }
  62372. }
  62373. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  62374. import { Nullable } from "babylonjs/types";
  62375. import { Scene } from "babylonjs/scene";
  62376. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  62377. import { Color4 } from "babylonjs/Maths/math.color";
  62378. import { Mesh } from "babylonjs/Meshes/mesh";
  62379. /**
  62380. * Class containing static functions to help procedurally build meshes
  62381. */
  62382. export class RibbonBuilder {
  62383. /**
  62384. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  62385. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  62386. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  62387. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  62388. * * 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
  62389. * * 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
  62390. * * 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
  62391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62392. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62393. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62394. * * 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
  62395. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  62396. * * 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
  62397. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  62398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62399. * @param name defines the name of the mesh
  62400. * @param options defines the options used to create the mesh
  62401. * @param scene defines the hosting scene
  62402. * @returns the ribbon mesh
  62403. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  62404. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62405. */
  62406. static CreateRibbon(name: string, options: {
  62407. pathArray: Vector3[][];
  62408. closeArray?: boolean;
  62409. closePath?: boolean;
  62410. offset?: number;
  62411. updatable?: boolean;
  62412. sideOrientation?: number;
  62413. frontUVs?: Vector4;
  62414. backUVs?: Vector4;
  62415. instance?: Mesh;
  62416. invertUV?: boolean;
  62417. uvs?: Vector2[];
  62418. colors?: Color4[];
  62419. }, scene?: Nullable<Scene>): Mesh;
  62420. }
  62421. }
  62422. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  62423. import { Nullable } from "babylonjs/types";
  62424. import { Scene } from "babylonjs/scene";
  62425. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  62426. import { Mesh } from "babylonjs/Meshes/mesh";
  62427. /**
  62428. * Class containing static functions to help procedurally build meshes
  62429. */
  62430. export class ShapeBuilder {
  62431. /**
  62432. * 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.
  62433. * * 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.
  62434. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62435. * * 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.
  62436. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  62437. * * 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
  62438. * * 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
  62439. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  62440. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62441. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62442. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  62443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  62444. * @param name defines the name of the mesh
  62445. * @param options defines the options used to create the mesh
  62446. * @param scene defines the hosting scene
  62447. * @returns the extruded shape mesh
  62448. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62449. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62450. */
  62451. static ExtrudeShape(name: string, options: {
  62452. shape: Vector3[];
  62453. path: Vector3[];
  62454. scale?: number;
  62455. rotation?: number;
  62456. cap?: number;
  62457. updatable?: boolean;
  62458. sideOrientation?: number;
  62459. frontUVs?: Vector4;
  62460. backUVs?: Vector4;
  62461. instance?: Mesh;
  62462. invertUV?: boolean;
  62463. }, scene?: Nullable<Scene>): Mesh;
  62464. /**
  62465. * Creates an custom extruded shape mesh.
  62466. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  62467. * * 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.
  62468. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  62469. * * 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
  62470. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  62471. * * 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
  62472. * * It must returns a float value that will be the scale value applied to the shape on each path point
  62473. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  62474. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  62475. * * 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
  62476. * * 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
  62477. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  62478. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  62479. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  62480. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  62481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  62482. * @param name defines the name of the mesh
  62483. * @param options defines the options used to create the mesh
  62484. * @param scene defines the hosting scene
  62485. * @returns the custom extruded shape mesh
  62486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  62487. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  62488. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  62489. */
  62490. static ExtrudeShapeCustom(name: string, options: {
  62491. shape: Vector3[];
  62492. path: Vector3[];
  62493. scaleFunction?: any;
  62494. rotationFunction?: any;
  62495. ribbonCloseArray?: boolean;
  62496. ribbonClosePath?: boolean;
  62497. cap?: number;
  62498. updatable?: boolean;
  62499. sideOrientation?: number;
  62500. frontUVs?: Vector4;
  62501. backUVs?: Vector4;
  62502. instance?: Mesh;
  62503. invertUV?: boolean;
  62504. }, scene?: Nullable<Scene>): Mesh;
  62505. private static _ExtrudeShapeGeneric;
  62506. }
  62507. }
  62508. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  62509. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  62510. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  62511. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  62512. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  62513. import { Nullable } from "babylonjs/types";
  62514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62515. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  62516. /**
  62517. * AmmoJS Physics plugin
  62518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  62519. * @see https://github.com/kripken/ammo.js/
  62520. */
  62521. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  62522. private _useDeltaForWorldStep;
  62523. /**
  62524. * Reference to the Ammo library
  62525. */
  62526. bjsAMMO: any;
  62527. /**
  62528. * Created ammoJS world which physics bodies are added to
  62529. */
  62530. world: any;
  62531. /**
  62532. * Name of the plugin
  62533. */
  62534. name: string;
  62535. private _timeStep;
  62536. private _fixedTimeStep;
  62537. private _maxSteps;
  62538. private _tmpQuaternion;
  62539. private _tmpAmmoTransform;
  62540. private _tmpAmmoQuaternion;
  62541. private _tmpAmmoConcreteContactResultCallback;
  62542. private _collisionConfiguration;
  62543. private _dispatcher;
  62544. private _overlappingPairCache;
  62545. private _solver;
  62546. private _softBodySolver;
  62547. private _tmpAmmoVectorA;
  62548. private _tmpAmmoVectorB;
  62549. private _tmpAmmoVectorC;
  62550. private _tmpAmmoVectorD;
  62551. private _tmpContactCallbackResult;
  62552. private _tmpAmmoVectorRCA;
  62553. private _tmpAmmoVectorRCB;
  62554. private _raycastResult;
  62555. private static readonly DISABLE_COLLISION_FLAG;
  62556. private static readonly KINEMATIC_FLAG;
  62557. private static readonly DISABLE_DEACTIVATION_FLAG;
  62558. /**
  62559. * Initializes the ammoJS plugin
  62560. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  62561. * @param ammoInjection can be used to inject your own ammo reference
  62562. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  62563. */
  62564. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  62565. /**
  62566. * Sets the gravity of the physics world (m/(s^2))
  62567. * @param gravity Gravity to set
  62568. */
  62569. setGravity(gravity: Vector3): void;
  62570. /**
  62571. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  62572. * @param timeStep timestep to use in seconds
  62573. */
  62574. setTimeStep(timeStep: number): void;
  62575. /**
  62576. * 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)
  62577. * @param fixedTimeStep fixedTimeStep to use in seconds
  62578. */
  62579. setFixedTimeStep(fixedTimeStep: number): void;
  62580. /**
  62581. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  62582. * @param maxSteps the maximum number of steps by the physics engine per frame
  62583. */
  62584. setMaxSteps(maxSteps: number): void;
  62585. /**
  62586. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  62587. * @returns the current timestep in seconds
  62588. */
  62589. getTimeStep(): number;
  62590. /**
  62591. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  62592. */
  62593. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  62594. private _isImpostorInContact;
  62595. private _isImpostorPairInContact;
  62596. private _stepSimulation;
  62597. /**
  62598. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  62599. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  62600. * After the step the babylon meshes are set to the position of the physics imposters
  62601. * @param delta amount of time to step forward
  62602. * @param impostors array of imposters to update before/after the step
  62603. */
  62604. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  62605. /**
  62606. * Update babylon mesh to match physics world object
  62607. * @param impostor imposter to match
  62608. */
  62609. private _afterSoftStep;
  62610. /**
  62611. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62612. * @param impostor imposter to match
  62613. */
  62614. private _ropeStep;
  62615. /**
  62616. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  62617. * @param impostor imposter to match
  62618. */
  62619. private _softbodyOrClothStep;
  62620. private _tmpMatrix;
  62621. /**
  62622. * Applies an impulse on the imposter
  62623. * @param impostor imposter to apply impulse to
  62624. * @param force amount of force to be applied to the imposter
  62625. * @param contactPoint the location to apply the impulse on the imposter
  62626. */
  62627. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62628. /**
  62629. * Applies a force on the imposter
  62630. * @param impostor imposter to apply force
  62631. * @param force amount of force to be applied to the imposter
  62632. * @param contactPoint the location to apply the force on the imposter
  62633. */
  62634. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  62635. /**
  62636. * Creates a physics body using the plugin
  62637. * @param impostor the imposter to create the physics body on
  62638. */
  62639. generatePhysicsBody(impostor: PhysicsImpostor): void;
  62640. /**
  62641. * Removes the physics body from the imposter and disposes of the body's memory
  62642. * @param impostor imposter to remove the physics body from
  62643. */
  62644. removePhysicsBody(impostor: PhysicsImpostor): void;
  62645. /**
  62646. * Generates a joint
  62647. * @param impostorJoint the imposter joint to create the joint with
  62648. */
  62649. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  62650. /**
  62651. * Removes a joint
  62652. * @param impostorJoint the imposter joint to remove the joint from
  62653. */
  62654. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  62655. private _addMeshVerts;
  62656. /**
  62657. * Initialise the soft body vertices to match its object's (mesh) vertices
  62658. * Softbody vertices (nodes) are in world space and to match this
  62659. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  62660. * @param impostor to create the softbody for
  62661. */
  62662. private _softVertexData;
  62663. /**
  62664. * Create an impostor's soft body
  62665. * @param impostor to create the softbody for
  62666. */
  62667. private _createSoftbody;
  62668. /**
  62669. * Create cloth for an impostor
  62670. * @param impostor to create the softbody for
  62671. */
  62672. private _createCloth;
  62673. /**
  62674. * Create rope for an impostor
  62675. * @param impostor to create the softbody for
  62676. */
  62677. private _createRope;
  62678. /**
  62679. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  62680. * @param impostor to create the custom physics shape for
  62681. */
  62682. private _createCustom;
  62683. private _addHullVerts;
  62684. private _createShape;
  62685. /**
  62686. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  62687. * @param impostor imposter containing the physics body and babylon object
  62688. */
  62689. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  62690. /**
  62691. * Sets the babylon object's position/rotation from the physics body's position/rotation
  62692. * @param impostor imposter containing the physics body and babylon object
  62693. * @param newPosition new position
  62694. * @param newRotation new rotation
  62695. */
  62696. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  62697. /**
  62698. * If this plugin is supported
  62699. * @returns true if its supported
  62700. */
  62701. isSupported(): boolean;
  62702. /**
  62703. * Sets the linear velocity of the physics body
  62704. * @param impostor imposter to set the velocity on
  62705. * @param velocity velocity to set
  62706. */
  62707. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62708. /**
  62709. * Sets the angular velocity of the physics body
  62710. * @param impostor imposter to set the velocity on
  62711. * @param velocity velocity to set
  62712. */
  62713. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  62714. /**
  62715. * gets the linear velocity
  62716. * @param impostor imposter to get linear velocity from
  62717. * @returns linear velocity
  62718. */
  62719. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62720. /**
  62721. * gets the angular velocity
  62722. * @param impostor imposter to get angular velocity from
  62723. * @returns angular velocity
  62724. */
  62725. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  62726. /**
  62727. * Sets the mass of physics body
  62728. * @param impostor imposter to set the mass on
  62729. * @param mass mass to set
  62730. */
  62731. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  62732. /**
  62733. * Gets the mass of the physics body
  62734. * @param impostor imposter to get the mass from
  62735. * @returns mass
  62736. */
  62737. getBodyMass(impostor: PhysicsImpostor): number;
  62738. /**
  62739. * Gets friction of the impostor
  62740. * @param impostor impostor to get friction from
  62741. * @returns friction value
  62742. */
  62743. getBodyFriction(impostor: PhysicsImpostor): number;
  62744. /**
  62745. * Sets friction of the impostor
  62746. * @param impostor impostor to set friction on
  62747. * @param friction friction value
  62748. */
  62749. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  62750. /**
  62751. * Gets restitution of the impostor
  62752. * @param impostor impostor to get restitution from
  62753. * @returns restitution value
  62754. */
  62755. getBodyRestitution(impostor: PhysicsImpostor): number;
  62756. /**
  62757. * Sets resitution of the impostor
  62758. * @param impostor impostor to set resitution on
  62759. * @param restitution resitution value
  62760. */
  62761. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  62762. /**
  62763. * Gets pressure inside the impostor
  62764. * @param impostor impostor to get pressure from
  62765. * @returns pressure value
  62766. */
  62767. getBodyPressure(impostor: PhysicsImpostor): number;
  62768. /**
  62769. * Sets pressure inside a soft body impostor
  62770. * Cloth and rope must remain 0 pressure
  62771. * @param impostor impostor to set pressure on
  62772. * @param pressure pressure value
  62773. */
  62774. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  62775. /**
  62776. * Gets stiffness of the impostor
  62777. * @param impostor impostor to get stiffness from
  62778. * @returns pressure value
  62779. */
  62780. getBodyStiffness(impostor: PhysicsImpostor): number;
  62781. /**
  62782. * Sets stiffness of the impostor
  62783. * @param impostor impostor to set stiffness on
  62784. * @param stiffness stiffness value from 0 to 1
  62785. */
  62786. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  62787. /**
  62788. * Gets velocityIterations of the impostor
  62789. * @param impostor impostor to get velocity iterations from
  62790. * @returns velocityIterations value
  62791. */
  62792. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  62793. /**
  62794. * Sets velocityIterations of the impostor
  62795. * @param impostor impostor to set velocity iterations on
  62796. * @param velocityIterations velocityIterations value
  62797. */
  62798. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  62799. /**
  62800. * Gets positionIterations of the impostor
  62801. * @param impostor impostor to get position iterations from
  62802. * @returns positionIterations value
  62803. */
  62804. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  62805. /**
  62806. * Sets positionIterations of the impostor
  62807. * @param impostor impostor to set position on
  62808. * @param positionIterations positionIterations value
  62809. */
  62810. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  62811. /**
  62812. * Append an anchor to a cloth object
  62813. * @param impostor is the cloth impostor to add anchor to
  62814. * @param otherImpostor is the rigid impostor to anchor to
  62815. * @param width ratio across width from 0 to 1
  62816. * @param height ratio up height from 0 to 1
  62817. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  62818. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62819. */
  62820. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62821. /**
  62822. * Append an hook to a rope object
  62823. * @param impostor is the rope impostor to add hook to
  62824. * @param otherImpostor is the rigid impostor to hook to
  62825. * @param length ratio along the rope from 0 to 1
  62826. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  62827. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  62828. */
  62829. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  62830. /**
  62831. * Sleeps the physics body and stops it from being active
  62832. * @param impostor impostor to sleep
  62833. */
  62834. sleepBody(impostor: PhysicsImpostor): void;
  62835. /**
  62836. * Activates the physics body
  62837. * @param impostor impostor to activate
  62838. */
  62839. wakeUpBody(impostor: PhysicsImpostor): void;
  62840. /**
  62841. * Updates the distance parameters of the joint
  62842. * @param joint joint to update
  62843. * @param maxDistance maximum distance of the joint
  62844. * @param minDistance minimum distance of the joint
  62845. */
  62846. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  62847. /**
  62848. * Sets a motor on the joint
  62849. * @param joint joint to set motor on
  62850. * @param speed speed of the motor
  62851. * @param maxForce maximum force of the motor
  62852. * @param motorIndex index of the motor
  62853. */
  62854. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  62855. /**
  62856. * Sets the motors limit
  62857. * @param joint joint to set limit on
  62858. * @param upperLimit upper limit
  62859. * @param lowerLimit lower limit
  62860. */
  62861. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  62862. /**
  62863. * Syncs the position and rotation of a mesh with the impostor
  62864. * @param mesh mesh to sync
  62865. * @param impostor impostor to update the mesh with
  62866. */
  62867. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  62868. /**
  62869. * Gets the radius of the impostor
  62870. * @param impostor impostor to get radius from
  62871. * @returns the radius
  62872. */
  62873. getRadius(impostor: PhysicsImpostor): number;
  62874. /**
  62875. * Gets the box size of the impostor
  62876. * @param impostor impostor to get box size from
  62877. * @param result the resulting box size
  62878. */
  62879. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  62880. /**
  62881. * Disposes of the impostor
  62882. */
  62883. dispose(): void;
  62884. /**
  62885. * Does a raycast in the physics world
  62886. * @param from when should the ray start?
  62887. * @param to when should the ray end?
  62888. * @returns PhysicsRaycastResult
  62889. */
  62890. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  62891. }
  62892. }
  62893. declare module "babylonjs/Probes/reflectionProbe" {
  62894. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62895. import { Vector3 } from "babylonjs/Maths/math.vector";
  62896. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62897. import { Nullable } from "babylonjs/types";
  62898. import { Scene } from "babylonjs/scene";
  62899. module "babylonjs/abstractScene" {
  62900. interface AbstractScene {
  62901. /**
  62902. * The list of reflection probes added to the scene
  62903. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62904. */
  62905. reflectionProbes: Array<ReflectionProbe>;
  62906. /**
  62907. * Removes the given reflection probe from this scene.
  62908. * @param toRemove The reflection probe to remove
  62909. * @returns The index of the removed reflection probe
  62910. */
  62911. removeReflectionProbe(toRemove: ReflectionProbe): number;
  62912. /**
  62913. * Adds the given reflection probe to this scene.
  62914. * @param newReflectionProbe The reflection probe to add
  62915. */
  62916. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  62917. }
  62918. }
  62919. /**
  62920. * Class used to generate realtime reflection / refraction cube textures
  62921. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  62922. */
  62923. export class ReflectionProbe {
  62924. /** defines the name of the probe */
  62925. name: string;
  62926. private _scene;
  62927. private _renderTargetTexture;
  62928. private _projectionMatrix;
  62929. private _viewMatrix;
  62930. private _target;
  62931. private _add;
  62932. private _attachedMesh;
  62933. private _invertYAxis;
  62934. /** Gets or sets probe position (center of the cube map) */
  62935. position: Vector3;
  62936. /**
  62937. * Creates a new reflection probe
  62938. * @param name defines the name of the probe
  62939. * @param size defines the texture resolution (for each face)
  62940. * @param scene defines the hosting scene
  62941. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  62942. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  62943. */
  62944. constructor(
  62945. /** defines the name of the probe */
  62946. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  62947. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  62948. get samples(): number;
  62949. set samples(value: number);
  62950. /** Gets or sets the refresh rate to use (on every frame by default) */
  62951. get refreshRate(): number;
  62952. set refreshRate(value: number);
  62953. /**
  62954. * Gets the hosting scene
  62955. * @returns a Scene
  62956. */
  62957. getScene(): Scene;
  62958. /** Gets the internal CubeTexture used to render to */
  62959. get cubeTexture(): RenderTargetTexture;
  62960. /** Gets the list of meshes to render */
  62961. get renderList(): Nullable<AbstractMesh[]>;
  62962. /**
  62963. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  62964. * @param mesh defines the mesh to attach to
  62965. */
  62966. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  62967. /**
  62968. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  62969. * @param renderingGroupId The rendering group id corresponding to its index
  62970. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  62971. */
  62972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  62973. /**
  62974. * Clean all associated resources
  62975. */
  62976. dispose(): void;
  62977. /**
  62978. * Converts the reflection probe information to a readable string for debug purpose.
  62979. * @param fullDetails Supports for multiple levels of logging within scene loading
  62980. * @returns the human readable reflection probe info
  62981. */
  62982. toString(fullDetails?: boolean): string;
  62983. /**
  62984. * Get the class name of the relfection probe.
  62985. * @returns "ReflectionProbe"
  62986. */
  62987. getClassName(): string;
  62988. /**
  62989. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  62990. * @returns The JSON representation of the texture
  62991. */
  62992. serialize(): any;
  62993. /**
  62994. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  62995. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  62996. * @param scene Define the scene the parsed reflection probe should be instantiated in
  62997. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  62998. * @returns The parsed reflection probe if successful
  62999. */
  63000. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  63001. }
  63002. }
  63003. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  63004. /** @hidden */
  63005. export var _BabylonLoaderRegistered: boolean;
  63006. /**
  63007. * Helps setting up some configuration for the babylon file loader.
  63008. */
  63009. export class BabylonFileLoaderConfiguration {
  63010. /**
  63011. * The loader does not allow injecting custom physix engine into the plugins.
  63012. * Unfortunately in ES6, we need to manually inject them into the plugin.
  63013. * So you could set this variable to your engine import to make it work.
  63014. */
  63015. static LoaderInjectedPhysicsEngine: any;
  63016. }
  63017. }
  63018. declare module "babylonjs/Loading/Plugins/index" {
  63019. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  63020. }
  63021. declare module "babylonjs/Loading/index" {
  63022. export * from "babylonjs/Loading/loadingScreen";
  63023. export * from "babylonjs/Loading/Plugins/index";
  63024. export * from "babylonjs/Loading/sceneLoader";
  63025. export * from "babylonjs/Loading/sceneLoaderFlags";
  63026. }
  63027. declare module "babylonjs/Materials/Background/index" {
  63028. export * from "babylonjs/Materials/Background/backgroundMaterial";
  63029. }
  63030. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  63031. import { Scene } from "babylonjs/scene";
  63032. import { Color3 } from "babylonjs/Maths/math.color";
  63033. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63035. /**
  63036. * The Physically based simple base material of BJS.
  63037. *
  63038. * This enables better naming and convention enforcements on top of the pbrMaterial.
  63039. * It is used as the base class for both the specGloss and metalRough conventions.
  63040. */
  63041. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  63042. /**
  63043. * Number of Simultaneous lights allowed on the material.
  63044. */
  63045. maxSimultaneousLights: number;
  63046. /**
  63047. * If sets to true, disables all the lights affecting the material.
  63048. */
  63049. disableLighting: boolean;
  63050. /**
  63051. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  63052. */
  63053. environmentTexture: BaseTexture;
  63054. /**
  63055. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  63056. */
  63057. invertNormalMapX: boolean;
  63058. /**
  63059. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  63060. */
  63061. invertNormalMapY: boolean;
  63062. /**
  63063. * Normal map used in the model.
  63064. */
  63065. normalTexture: BaseTexture;
  63066. /**
  63067. * Emissivie color used to self-illuminate the model.
  63068. */
  63069. emissiveColor: Color3;
  63070. /**
  63071. * Emissivie texture used to self-illuminate the model.
  63072. */
  63073. emissiveTexture: BaseTexture;
  63074. /**
  63075. * Occlusion Channel Strenght.
  63076. */
  63077. occlusionStrength: number;
  63078. /**
  63079. * Occlusion Texture of the material (adding extra occlusion effects).
  63080. */
  63081. occlusionTexture: BaseTexture;
  63082. /**
  63083. * Defines the alpha limits in alpha test mode.
  63084. */
  63085. alphaCutOff: number;
  63086. /**
  63087. * Gets the current double sided mode.
  63088. */
  63089. get doubleSided(): boolean;
  63090. /**
  63091. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  63092. */
  63093. set doubleSided(value: boolean);
  63094. /**
  63095. * Stores the pre-calculated light information of a mesh in a texture.
  63096. */
  63097. lightmapTexture: BaseTexture;
  63098. /**
  63099. * If true, the light map contains occlusion information instead of lighting info.
  63100. */
  63101. useLightmapAsShadowmap: boolean;
  63102. /**
  63103. * Instantiates a new PBRMaterial instance.
  63104. *
  63105. * @param name The material name
  63106. * @param scene The scene the material will be use in.
  63107. */
  63108. constructor(name: string, scene: Scene);
  63109. getClassName(): string;
  63110. }
  63111. }
  63112. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  63113. import { Scene } from "babylonjs/scene";
  63114. import { Color3 } from "babylonjs/Maths/math.color";
  63115. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63116. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63117. /**
  63118. * The PBR material of BJS following the metal roughness convention.
  63119. *
  63120. * This fits to the PBR convention in the GLTF definition:
  63121. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  63122. */
  63123. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  63124. /**
  63125. * The base color has two different interpretations depending on the value of metalness.
  63126. * When the material is a metal, the base color is the specific measured reflectance value
  63127. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  63128. * of the material.
  63129. */
  63130. baseColor: Color3;
  63131. /**
  63132. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  63133. * well as opacity information in the alpha channel.
  63134. */
  63135. baseTexture: BaseTexture;
  63136. /**
  63137. * Specifies the metallic scalar value of the material.
  63138. * Can also be used to scale the metalness values of the metallic texture.
  63139. */
  63140. metallic: number;
  63141. /**
  63142. * Specifies the roughness scalar value of the material.
  63143. * Can also be used to scale the roughness values of the metallic texture.
  63144. */
  63145. roughness: number;
  63146. /**
  63147. * Texture containing both the metallic value in the B channel and the
  63148. * roughness value in the G channel to keep better precision.
  63149. */
  63150. metallicRoughnessTexture: BaseTexture;
  63151. /**
  63152. * Instantiates a new PBRMetalRoughnessMaterial instance.
  63153. *
  63154. * @param name The material name
  63155. * @param scene The scene the material will be use in.
  63156. */
  63157. constructor(name: string, scene: Scene);
  63158. /**
  63159. * Return the currrent class name of the material.
  63160. */
  63161. getClassName(): string;
  63162. /**
  63163. * Makes a duplicate of the current material.
  63164. * @param name - name to use for the new material.
  63165. */
  63166. clone(name: string): PBRMetallicRoughnessMaterial;
  63167. /**
  63168. * Serialize the material to a parsable JSON object.
  63169. */
  63170. serialize(): any;
  63171. /**
  63172. * Parses a JSON object correponding to the serialize function.
  63173. */
  63174. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  63175. }
  63176. }
  63177. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  63178. import { Scene } from "babylonjs/scene";
  63179. import { Color3 } from "babylonjs/Maths/math.color";
  63180. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63181. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63182. /**
  63183. * The PBR material of BJS following the specular glossiness convention.
  63184. *
  63185. * This fits to the PBR convention in the GLTF definition:
  63186. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  63187. */
  63188. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  63189. /**
  63190. * Specifies the diffuse color of the material.
  63191. */
  63192. diffuseColor: Color3;
  63193. /**
  63194. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  63195. * channel.
  63196. */
  63197. diffuseTexture: BaseTexture;
  63198. /**
  63199. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  63200. */
  63201. specularColor: Color3;
  63202. /**
  63203. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  63204. */
  63205. glossiness: number;
  63206. /**
  63207. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  63208. */
  63209. specularGlossinessTexture: BaseTexture;
  63210. /**
  63211. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  63212. *
  63213. * @param name The material name
  63214. * @param scene The scene the material will be use in.
  63215. */
  63216. constructor(name: string, scene: Scene);
  63217. /**
  63218. * Return the currrent class name of the material.
  63219. */
  63220. getClassName(): string;
  63221. /**
  63222. * Makes a duplicate of the current material.
  63223. * @param name - name to use for the new material.
  63224. */
  63225. clone(name: string): PBRSpecularGlossinessMaterial;
  63226. /**
  63227. * Serialize the material to a parsable JSON object.
  63228. */
  63229. serialize(): any;
  63230. /**
  63231. * Parses a JSON object correponding to the serialize function.
  63232. */
  63233. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  63234. }
  63235. }
  63236. declare module "babylonjs/Materials/PBR/index" {
  63237. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  63238. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  63239. export * from "babylonjs/Materials/PBR/pbrMaterial";
  63240. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  63241. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  63242. }
  63243. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  63244. import { Nullable } from "babylonjs/types";
  63245. import { Scene } from "babylonjs/scene";
  63246. import { Matrix } from "babylonjs/Maths/math.vector";
  63247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63248. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63249. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63250. /**
  63251. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  63252. * It can help converting any input color in a desired output one. This can then be used to create effects
  63253. * from sepia, black and white to sixties or futuristic rendering...
  63254. *
  63255. * The only supported format is currently 3dl.
  63256. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  63257. */
  63258. export class ColorGradingTexture extends BaseTexture {
  63259. /**
  63260. * The texture URL.
  63261. */
  63262. url: string;
  63263. /**
  63264. * Empty line regex stored for GC.
  63265. */
  63266. private static _noneEmptyLineRegex;
  63267. private _textureMatrix;
  63268. private _onLoad;
  63269. /**
  63270. * Instantiates a ColorGradingTexture from the following parameters.
  63271. *
  63272. * @param url The location of the color gradind data (currently only supporting 3dl)
  63273. * @param sceneOrEngine The scene or engine the texture will be used in
  63274. * @param onLoad defines a callback triggered when the texture has been loaded
  63275. */
  63276. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  63277. /**
  63278. * Fires the onload event from the constructor if requested.
  63279. */
  63280. private _triggerOnLoad;
  63281. /**
  63282. * Returns the texture matrix used in most of the material.
  63283. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  63284. */
  63285. getTextureMatrix(): Matrix;
  63286. /**
  63287. * Occurs when the file being loaded is a .3dl LUT file.
  63288. */
  63289. private load3dlTexture;
  63290. /**
  63291. * Starts the loading process of the texture.
  63292. */
  63293. private loadTexture;
  63294. /**
  63295. * Clones the color gradind texture.
  63296. */
  63297. clone(): ColorGradingTexture;
  63298. /**
  63299. * Called during delayed load for textures.
  63300. */
  63301. delayLoad(): void;
  63302. /**
  63303. * Parses a color grading texture serialized by Babylon.
  63304. * @param parsedTexture The texture information being parsedTexture
  63305. * @param scene The scene to load the texture in
  63306. * @param rootUrl The root url of the data assets to load
  63307. * @return A color gradind texture
  63308. */
  63309. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  63310. /**
  63311. * Serializes the LUT texture to json format.
  63312. */
  63313. serialize(): any;
  63314. }
  63315. }
  63316. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  63317. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63318. import { Scene } from "babylonjs/scene";
  63319. import { Nullable } from "babylonjs/types";
  63320. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63321. /**
  63322. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  63323. */
  63324. export class EquiRectangularCubeTexture extends BaseTexture {
  63325. /** The six faces of the cube. */
  63326. private static _FacesMapping;
  63327. private _noMipmap;
  63328. private _onLoad;
  63329. private _onError;
  63330. /** The size of the cubemap. */
  63331. private _size;
  63332. /** The buffer of the image. */
  63333. private _buffer;
  63334. /** The width of the input image. */
  63335. private _width;
  63336. /** The height of the input image. */
  63337. private _height;
  63338. /** The URL to the image. */
  63339. url: string;
  63340. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  63341. coordinatesMode: number;
  63342. /**
  63343. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  63344. * @param url The location of the image
  63345. * @param scene The scene the texture will be used in
  63346. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63347. * @param noMipmap Forces to not generate the mipmap if true
  63348. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  63349. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  63350. * @param onLoad — defines a callback called when texture is loaded
  63351. * @param onError — defines a callback called if there is an error
  63352. */
  63353. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  63354. /**
  63355. * Load the image data, by putting the image on a canvas and extracting its buffer.
  63356. */
  63357. private loadImage;
  63358. /**
  63359. * Convert the image buffer into a cubemap and create a CubeTexture.
  63360. */
  63361. private loadTexture;
  63362. /**
  63363. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  63364. * @param buffer The ArrayBuffer that should be converted.
  63365. * @returns The buffer as Float32Array.
  63366. */
  63367. private getFloat32ArrayFromArrayBuffer;
  63368. /**
  63369. * Get the current class name of the texture useful for serialization or dynamic coding.
  63370. * @returns "EquiRectangularCubeTexture"
  63371. */
  63372. getClassName(): string;
  63373. /**
  63374. * Create a clone of the current EquiRectangularCubeTexture and return it.
  63375. * @returns A clone of the current EquiRectangularCubeTexture.
  63376. */
  63377. clone(): EquiRectangularCubeTexture;
  63378. }
  63379. }
  63380. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  63381. import { Nullable } from "babylonjs/types";
  63382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63383. import { Matrix } from "babylonjs/Maths/math.vector";
  63384. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  63385. import "babylonjs/Engines/Extensions/engine.videoTexture";
  63386. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63387. import { Scene } from "babylonjs/scene";
  63388. /**
  63389. * Defines the options related to the creation of an HtmlElementTexture
  63390. */
  63391. export interface IHtmlElementTextureOptions {
  63392. /**
  63393. * Defines wether mip maps should be created or not.
  63394. */
  63395. generateMipMaps?: boolean;
  63396. /**
  63397. * Defines the sampling mode of the texture.
  63398. */
  63399. samplingMode?: number;
  63400. /**
  63401. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  63402. */
  63403. engine: Nullable<ThinEngine>;
  63404. /**
  63405. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  63406. */
  63407. scene: Nullable<Scene>;
  63408. }
  63409. /**
  63410. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  63411. * To be as efficient as possible depending on your constraints nothing aside the first upload
  63412. * is automatically managed.
  63413. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  63414. * in your application.
  63415. *
  63416. * As the update is not automatic, you need to call them manually.
  63417. */
  63418. export class HtmlElementTexture extends BaseTexture {
  63419. /**
  63420. * The texture URL.
  63421. */
  63422. element: HTMLVideoElement | HTMLCanvasElement;
  63423. private static readonly DefaultOptions;
  63424. private _textureMatrix;
  63425. private _isVideo;
  63426. private _generateMipMaps;
  63427. private _samplingMode;
  63428. /**
  63429. * Instantiates a HtmlElementTexture from the following parameters.
  63430. *
  63431. * @param name Defines the name of the texture
  63432. * @param element Defines the video or canvas the texture is filled with
  63433. * @param options Defines the other none mandatory texture creation options
  63434. */
  63435. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  63436. private _createInternalTexture;
  63437. /**
  63438. * Returns the texture matrix used in most of the material.
  63439. */
  63440. getTextureMatrix(): Matrix;
  63441. /**
  63442. * Updates the content of the texture.
  63443. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  63444. */
  63445. update(invertY?: Nullable<boolean>): void;
  63446. }
  63447. }
  63448. declare module "babylonjs/Misc/tga" {
  63449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63450. /**
  63451. * Based on jsTGALoader - Javascript loader for TGA file
  63452. * By Vincent Thibault
  63453. * @see http://blog.robrowser.com/javascript-tga-loader.html
  63454. */
  63455. export class TGATools {
  63456. private static _TYPE_INDEXED;
  63457. private static _TYPE_RGB;
  63458. private static _TYPE_GREY;
  63459. private static _TYPE_RLE_INDEXED;
  63460. private static _TYPE_RLE_RGB;
  63461. private static _TYPE_RLE_GREY;
  63462. private static _ORIGIN_MASK;
  63463. private static _ORIGIN_SHIFT;
  63464. private static _ORIGIN_BL;
  63465. private static _ORIGIN_BR;
  63466. private static _ORIGIN_UL;
  63467. private static _ORIGIN_UR;
  63468. /**
  63469. * Gets the header of a TGA file
  63470. * @param data defines the TGA data
  63471. * @returns the header
  63472. */
  63473. static GetTGAHeader(data: Uint8Array): any;
  63474. /**
  63475. * Uploads TGA content to a Babylon Texture
  63476. * @hidden
  63477. */
  63478. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  63479. /** @hidden */
  63480. 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;
  63481. /** @hidden */
  63482. 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;
  63483. /** @hidden */
  63484. 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;
  63485. /** @hidden */
  63486. 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;
  63487. /** @hidden */
  63488. 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;
  63489. /** @hidden */
  63490. 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;
  63491. }
  63492. }
  63493. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  63494. import { Nullable } from "babylonjs/types";
  63495. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63496. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63497. /**
  63498. * Implementation of the TGA Texture Loader.
  63499. * @hidden
  63500. */
  63501. export class _TGATextureLoader implements IInternalTextureLoader {
  63502. /**
  63503. * Defines wether the loader supports cascade loading the different faces.
  63504. */
  63505. readonly supportCascades: boolean;
  63506. /**
  63507. * This returns if the loader support the current file information.
  63508. * @param extension defines the file extension of the file being loaded
  63509. * @returns true if the loader can load the specified file
  63510. */
  63511. canLoad(extension: string): boolean;
  63512. /**
  63513. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63514. * @param data contains the texture data
  63515. * @param texture defines the BabylonJS internal texture
  63516. * @param createPolynomials will be true if polynomials have been requested
  63517. * @param onLoad defines the callback to trigger once the texture is ready
  63518. * @param onError defines the callback to trigger in case of error
  63519. */
  63520. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63521. /**
  63522. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63523. * @param data contains the texture data
  63524. * @param texture defines the BabylonJS internal texture
  63525. * @param callback defines the method to call once ready to upload
  63526. */
  63527. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63528. }
  63529. }
  63530. declare module "babylonjs/Misc/basis" {
  63531. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63532. /**
  63533. * Info about the .basis files
  63534. */
  63535. class BasisFileInfo {
  63536. /**
  63537. * If the file has alpha
  63538. */
  63539. hasAlpha: boolean;
  63540. /**
  63541. * Info about each image of the basis file
  63542. */
  63543. images: Array<{
  63544. levels: Array<{
  63545. width: number;
  63546. height: number;
  63547. transcodedPixels: ArrayBufferView;
  63548. }>;
  63549. }>;
  63550. }
  63551. /**
  63552. * Result of transcoding a basis file
  63553. */
  63554. class TranscodeResult {
  63555. /**
  63556. * Info about the .basis file
  63557. */
  63558. fileInfo: BasisFileInfo;
  63559. /**
  63560. * Format to use when loading the file
  63561. */
  63562. format: number;
  63563. }
  63564. /**
  63565. * Configuration options for the Basis transcoder
  63566. */
  63567. export class BasisTranscodeConfiguration {
  63568. /**
  63569. * Supported compression formats used to determine the supported output format of the transcoder
  63570. */
  63571. supportedCompressionFormats?: {
  63572. /**
  63573. * etc1 compression format
  63574. */
  63575. etc1?: boolean;
  63576. /**
  63577. * s3tc compression format
  63578. */
  63579. s3tc?: boolean;
  63580. /**
  63581. * pvrtc compression format
  63582. */
  63583. pvrtc?: boolean;
  63584. /**
  63585. * etc2 compression format
  63586. */
  63587. etc2?: boolean;
  63588. };
  63589. /**
  63590. * If mipmap levels should be loaded for transcoded images (Default: true)
  63591. */
  63592. loadMipmapLevels?: boolean;
  63593. /**
  63594. * Index of a single image to load (Default: all images)
  63595. */
  63596. loadSingleImage?: number;
  63597. }
  63598. /**
  63599. * Used to load .Basis files
  63600. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  63601. */
  63602. export class BasisTools {
  63603. private static _IgnoreSupportedFormats;
  63604. /**
  63605. * URL to use when loading the basis transcoder
  63606. */
  63607. static JSModuleURL: string;
  63608. /**
  63609. * URL to use when loading the wasm module for the transcoder
  63610. */
  63611. static WasmModuleURL: string;
  63612. /**
  63613. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  63614. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  63615. * @returns internal format corresponding to the Basis format
  63616. */
  63617. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  63618. private static _WorkerPromise;
  63619. private static _Worker;
  63620. private static _actionId;
  63621. private static _CreateWorkerAsync;
  63622. /**
  63623. * Transcodes a loaded image file to compressed pixel data
  63624. * @param data image data to transcode
  63625. * @param config configuration options for the transcoding
  63626. * @returns a promise resulting in the transcoded image
  63627. */
  63628. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  63629. /**
  63630. * Loads a texture from the transcode result
  63631. * @param texture texture load to
  63632. * @param transcodeResult the result of transcoding the basis file to load from
  63633. */
  63634. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  63635. }
  63636. }
  63637. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  63638. import { Nullable } from "babylonjs/types";
  63639. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63640. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  63641. /**
  63642. * Loader for .basis file format
  63643. */
  63644. export class _BasisTextureLoader implements IInternalTextureLoader {
  63645. /**
  63646. * Defines whether the loader supports cascade loading the different faces.
  63647. */
  63648. readonly supportCascades: boolean;
  63649. /**
  63650. * This returns if the loader support the current file information.
  63651. * @param extension defines the file extension of the file being loaded
  63652. * @returns true if the loader can load the specified file
  63653. */
  63654. canLoad(extension: string): boolean;
  63655. /**
  63656. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  63657. * @param data contains the texture data
  63658. * @param texture defines the BabylonJS internal texture
  63659. * @param createPolynomials will be true if polynomials have been requested
  63660. * @param onLoad defines the callback to trigger once the texture is ready
  63661. * @param onError defines the callback to trigger in case of error
  63662. */
  63663. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  63664. /**
  63665. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  63666. * @param data contains the texture data
  63667. * @param texture defines the BabylonJS internal texture
  63668. * @param callback defines the method to call once ready to upload
  63669. */
  63670. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  63671. }
  63672. }
  63673. declare module "babylonjs/Materials/Textures/Loaders/index" {
  63674. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  63675. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  63676. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  63677. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  63678. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  63679. }
  63680. declare module "babylonjs/Materials/Textures/Packer/frame" {
  63681. import { Vector2 } from "babylonjs/Maths/math.vector";
  63682. /**
  63683. * Defines the basic options interface of a TexturePacker Frame
  63684. */
  63685. export interface ITexturePackerFrame {
  63686. /**
  63687. * The frame ID
  63688. */
  63689. id: number;
  63690. /**
  63691. * The frames Scale
  63692. */
  63693. scale: Vector2;
  63694. /**
  63695. * The Frames offset
  63696. */
  63697. offset: Vector2;
  63698. }
  63699. /**
  63700. * This is a support class for frame Data on texture packer sets.
  63701. */
  63702. export class TexturePackerFrame implements ITexturePackerFrame {
  63703. /**
  63704. * The frame ID
  63705. */
  63706. id: number;
  63707. /**
  63708. * The frames Scale
  63709. */
  63710. scale: Vector2;
  63711. /**
  63712. * The Frames offset
  63713. */
  63714. offset: Vector2;
  63715. /**
  63716. * Initializes a texture package frame.
  63717. * @param id The numerical frame identifier
  63718. * @param scale Scalar Vector2 for UV frame
  63719. * @param offset Vector2 for the frame position in UV units.
  63720. * @returns TexturePackerFrame
  63721. */
  63722. constructor(id: number, scale: Vector2, offset: Vector2);
  63723. }
  63724. }
  63725. declare module "babylonjs/Materials/Textures/Packer/packer" {
  63726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63727. import { Scene } from "babylonjs/scene";
  63728. import { Nullable } from "babylonjs/types";
  63729. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  63730. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  63731. /**
  63732. * Defines the basic options interface of a TexturePacker
  63733. */
  63734. export interface ITexturePackerOptions {
  63735. /**
  63736. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  63737. */
  63738. map?: string[];
  63739. /**
  63740. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63741. */
  63742. uvsIn?: string;
  63743. /**
  63744. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  63745. */
  63746. uvsOut?: string;
  63747. /**
  63748. * number representing the layout style. Defaults to LAYOUT_STRIP
  63749. */
  63750. layout?: number;
  63751. /**
  63752. * number of columns if using custom column count layout(2). This defaults to 4.
  63753. */
  63754. colnum?: number;
  63755. /**
  63756. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  63757. */
  63758. updateInputMeshes?: boolean;
  63759. /**
  63760. * boolean flag to dispose all the source textures. Defaults to true.
  63761. */
  63762. disposeSources?: boolean;
  63763. /**
  63764. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  63765. */
  63766. fillBlanks?: boolean;
  63767. /**
  63768. * string value representing the context fill style color. Defaults to 'black'.
  63769. */
  63770. customFillColor?: string;
  63771. /**
  63772. * Width and Height Value of each Frame in the TexturePacker Sets
  63773. */
  63774. frameSize?: number;
  63775. /**
  63776. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  63777. */
  63778. paddingRatio?: number;
  63779. /**
  63780. * Number that declares the fill method for the padding gutter.
  63781. */
  63782. paddingMode?: number;
  63783. /**
  63784. * If in SUBUV_COLOR padding mode what color to use.
  63785. */
  63786. paddingColor?: Color3 | Color4;
  63787. }
  63788. /**
  63789. * Defines the basic interface of a TexturePacker JSON File
  63790. */
  63791. export interface ITexturePackerJSON {
  63792. /**
  63793. * The frame ID
  63794. */
  63795. name: string;
  63796. /**
  63797. * The base64 channel data
  63798. */
  63799. sets: any;
  63800. /**
  63801. * The options of the Packer
  63802. */
  63803. options: ITexturePackerOptions;
  63804. /**
  63805. * The frame data of the Packer
  63806. */
  63807. frames: Array<number>;
  63808. }
  63809. /**
  63810. * This is a support class that generates a series of packed texture sets.
  63811. * @see https://doc.babylonjs.com/babylon101/materials
  63812. */
  63813. export class TexturePacker {
  63814. /** Packer Layout Constant 0 */
  63815. static readonly LAYOUT_STRIP: number;
  63816. /** Packer Layout Constant 1 */
  63817. static readonly LAYOUT_POWER2: number;
  63818. /** Packer Layout Constant 2 */
  63819. static readonly LAYOUT_COLNUM: number;
  63820. /** Packer Layout Constant 0 */
  63821. static readonly SUBUV_WRAP: number;
  63822. /** Packer Layout Constant 1 */
  63823. static readonly SUBUV_EXTEND: number;
  63824. /** Packer Layout Constant 2 */
  63825. static readonly SUBUV_COLOR: number;
  63826. /** The Name of the Texture Package */
  63827. name: string;
  63828. /** The scene scope of the TexturePacker */
  63829. scene: Scene;
  63830. /** The Meshes to target */
  63831. meshes: AbstractMesh[];
  63832. /** Arguments passed with the Constructor */
  63833. options: ITexturePackerOptions;
  63834. /** The promise that is started upon initialization */
  63835. promise: Nullable<Promise<TexturePacker | string>>;
  63836. /** The Container object for the channel sets that are generated */
  63837. sets: object;
  63838. /** The Container array for the frames that are generated */
  63839. frames: TexturePackerFrame[];
  63840. /** The expected number of textures the system is parsing. */
  63841. private _expecting;
  63842. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  63843. private _paddingValue;
  63844. /**
  63845. * Initializes a texture package series from an array of meshes or a single mesh.
  63846. * @param name The name of the package
  63847. * @param meshes The target meshes to compose the package from
  63848. * @param options The arguments that texture packer should follow while building.
  63849. * @param scene The scene which the textures are scoped to.
  63850. * @returns TexturePacker
  63851. */
  63852. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  63853. /**
  63854. * Starts the package process
  63855. * @param resolve The promises resolution function
  63856. * @returns TexturePacker
  63857. */
  63858. private _createFrames;
  63859. /**
  63860. * Calculates the Size of the Channel Sets
  63861. * @returns Vector2
  63862. */
  63863. private _calculateSize;
  63864. /**
  63865. * Calculates the UV data for the frames.
  63866. * @param baseSize the base frameSize
  63867. * @param padding the base frame padding
  63868. * @param dtSize size of the Dynamic Texture for that channel
  63869. * @param dtUnits is 1/dtSize
  63870. * @param update flag to update the input meshes
  63871. */
  63872. private _calculateMeshUVFrames;
  63873. /**
  63874. * Calculates the frames Offset.
  63875. * @param index of the frame
  63876. * @returns Vector2
  63877. */
  63878. private _getFrameOffset;
  63879. /**
  63880. * Updates a Mesh to the frame data
  63881. * @param mesh that is the target
  63882. * @param frameID or the frame index
  63883. */
  63884. private _updateMeshUV;
  63885. /**
  63886. * Updates a Meshes materials to use the texture packer channels
  63887. * @param m is the mesh to target
  63888. * @param force all channels on the packer to be set.
  63889. */
  63890. private _updateTextureReferences;
  63891. /**
  63892. * Public method to set a Mesh to a frame
  63893. * @param m that is the target
  63894. * @param frameID or the frame index
  63895. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  63896. */
  63897. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  63898. /**
  63899. * Starts the async promise to compile the texture packer.
  63900. * @returns Promise<void>
  63901. */
  63902. processAsync(): Promise<void>;
  63903. /**
  63904. * Disposes all textures associated with this packer
  63905. */
  63906. dispose(): void;
  63907. /**
  63908. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  63909. * @param imageType is the image type to use.
  63910. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  63911. */
  63912. download(imageType?: string, quality?: number): void;
  63913. /**
  63914. * Public method to load a texturePacker JSON file.
  63915. * @param data of the JSON file in string format.
  63916. */
  63917. updateFromJSON(data: string): void;
  63918. }
  63919. }
  63920. declare module "babylonjs/Materials/Textures/Packer/index" {
  63921. export * from "babylonjs/Materials/Textures/Packer/packer";
  63922. export * from "babylonjs/Materials/Textures/Packer/frame";
  63923. }
  63924. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  63925. import { Scene } from "babylonjs/scene";
  63926. import { Texture } from "babylonjs/Materials/Textures/texture";
  63927. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63928. /**
  63929. * 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.
  63930. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63931. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63932. */
  63933. export class CustomProceduralTexture extends ProceduralTexture {
  63934. private _animate;
  63935. private _time;
  63936. private _config;
  63937. private _texturePath;
  63938. /**
  63939. * Instantiates a new Custom Procedural Texture.
  63940. * 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.
  63941. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  63942. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  63943. * @param name Define the name of the texture
  63944. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  63945. * @param size Define the size of the texture to create
  63946. * @param scene Define the scene the texture belongs to
  63947. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  63948. * @param generateMipMaps Define if the texture should creates mip maps or not
  63949. */
  63950. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  63951. private _loadJson;
  63952. /**
  63953. * Is the texture ready to be used ? (rendered at least once)
  63954. * @returns true if ready, otherwise, false.
  63955. */
  63956. isReady(): boolean;
  63957. /**
  63958. * Render the texture to its associated render target.
  63959. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  63960. */
  63961. render(useCameraPostProcess?: boolean): void;
  63962. /**
  63963. * Update the list of dependant textures samplers in the shader.
  63964. */
  63965. updateTextures(): void;
  63966. /**
  63967. * Update the uniform values of the procedural texture in the shader.
  63968. */
  63969. updateShaderUniforms(): void;
  63970. /**
  63971. * Define if the texture animates or not.
  63972. */
  63973. get animate(): boolean;
  63974. set animate(value: boolean);
  63975. }
  63976. }
  63977. declare module "babylonjs/Shaders/noise.fragment" {
  63978. /** @hidden */
  63979. export var noisePixelShader: {
  63980. name: string;
  63981. shader: string;
  63982. };
  63983. }
  63984. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  63985. import { Nullable } from "babylonjs/types";
  63986. import { Scene } from "babylonjs/scene";
  63987. import { Texture } from "babylonjs/Materials/Textures/texture";
  63988. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  63989. import "babylonjs/Shaders/noise.fragment";
  63990. /**
  63991. * Class used to generate noise procedural textures
  63992. */
  63993. export class NoiseProceduralTexture extends ProceduralTexture {
  63994. private _time;
  63995. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  63996. brightness: number;
  63997. /** Defines the number of octaves to process */
  63998. octaves: number;
  63999. /** Defines the level of persistence (0.8 by default) */
  64000. persistence: number;
  64001. /** Gets or sets animation speed factor (default is 1) */
  64002. animationSpeedFactor: number;
  64003. /**
  64004. * Creates a new NoiseProceduralTexture
  64005. * @param name defines the name fo the texture
  64006. * @param size defines the size of the texture (default is 256)
  64007. * @param scene defines the hosting scene
  64008. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  64009. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  64010. */
  64011. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  64012. private _updateShaderUniforms;
  64013. protected _getDefines(): string;
  64014. /** Generate the current state of the procedural texture */
  64015. render(useCameraPostProcess?: boolean): void;
  64016. /**
  64017. * Serializes this noise procedural texture
  64018. * @returns a serialized noise procedural texture object
  64019. */
  64020. serialize(): any;
  64021. /**
  64022. * Clone the texture.
  64023. * @returns the cloned texture
  64024. */
  64025. clone(): NoiseProceduralTexture;
  64026. /**
  64027. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  64028. * @param parsedTexture defines parsed texture data
  64029. * @param scene defines the current scene
  64030. * @param rootUrl defines the root URL containing noise procedural texture information
  64031. * @returns a parsed NoiseProceduralTexture
  64032. */
  64033. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  64034. }
  64035. }
  64036. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  64037. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  64038. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  64039. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  64040. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  64041. }
  64042. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  64043. import { Nullable } from "babylonjs/types";
  64044. import { Scene } from "babylonjs/scene";
  64045. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  64046. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64047. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64048. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64049. /**
  64050. * Raw cube texture where the raw buffers are passed in
  64051. */
  64052. export class RawCubeTexture extends CubeTexture {
  64053. /**
  64054. * Creates a cube texture where the raw buffers are passed in.
  64055. * @param scene defines the scene the texture is attached to
  64056. * @param data defines the array of data to use to create each face
  64057. * @param size defines the size of the textures
  64058. * @param format defines the format of the data
  64059. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  64060. * @param generateMipMaps defines if the engine should generate the mip levels
  64061. * @param invertY defines if data must be stored with Y axis inverted
  64062. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  64063. * @param compression defines the compression used (null by default)
  64064. */
  64065. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  64066. /**
  64067. * Updates the raw cube texture.
  64068. * @param data defines the data to store
  64069. * @param format defines the data format
  64070. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64071. * @param invertY defines if data must be stored with Y axis inverted
  64072. * @param compression defines the compression used (null by default)
  64073. * @param level defines which level of the texture to update
  64074. */
  64075. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  64076. /**
  64077. * Updates a raw cube texture with RGBD encoded data.
  64078. * @param data defines the array of data [mipmap][face] to use to create each face
  64079. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  64080. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  64081. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  64082. * @returns a promsie that resolves when the operation is complete
  64083. */
  64084. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  64085. /**
  64086. * Clones the raw cube texture.
  64087. * @return a new cube texture
  64088. */
  64089. clone(): CubeTexture;
  64090. /** @hidden */
  64091. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  64092. }
  64093. }
  64094. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  64095. import { Scene } from "babylonjs/scene";
  64096. import { Texture } from "babylonjs/Materials/Textures/texture";
  64097. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64098. /**
  64099. * Class used to store 2D array textures containing user data
  64100. */
  64101. export class RawTexture2DArray extends Texture {
  64102. /** Gets or sets the texture format to use */
  64103. format: number;
  64104. /**
  64105. * Create a new RawTexture2DArray
  64106. * @param data defines the data of the texture
  64107. * @param width defines the width of the texture
  64108. * @param height defines the height of the texture
  64109. * @param depth defines the number of layers of the texture
  64110. * @param format defines the texture format to use
  64111. * @param scene defines the hosting scene
  64112. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64113. * @param invertY defines if texture must be stored with Y axis inverted
  64114. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64115. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64116. */
  64117. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64118. /** Gets or sets the texture format to use */
  64119. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64120. /**
  64121. * Update the texture with new data
  64122. * @param data defines the data to store in the texture
  64123. */
  64124. update(data: ArrayBufferView): void;
  64125. }
  64126. }
  64127. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  64128. import { Scene } from "babylonjs/scene";
  64129. import { Texture } from "babylonjs/Materials/Textures/texture";
  64130. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64131. /**
  64132. * Class used to store 3D textures containing user data
  64133. */
  64134. export class RawTexture3D extends Texture {
  64135. /** Gets or sets the texture format to use */
  64136. format: number;
  64137. /**
  64138. * Create a new RawTexture3D
  64139. * @param data defines the data of the texture
  64140. * @param width defines the width of the texture
  64141. * @param height defines the height of the texture
  64142. * @param depth defines the depth of the texture
  64143. * @param format defines the texture format to use
  64144. * @param scene defines the hosting scene
  64145. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  64146. * @param invertY defines if texture must be stored with Y axis inverted
  64147. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  64148. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  64149. */
  64150. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  64151. /** Gets or sets the texture format to use */
  64152. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  64153. /**
  64154. * Update the texture with new data
  64155. * @param data defines the data to store in the texture
  64156. */
  64157. update(data: ArrayBufferView): void;
  64158. }
  64159. }
  64160. declare module "babylonjs/Materials/Textures/refractionTexture" {
  64161. import { Scene } from "babylonjs/scene";
  64162. import { Plane } from "babylonjs/Maths/math.plane";
  64163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64164. /**
  64165. * Creates a refraction texture used by refraction channel of the standard material.
  64166. * It is like a mirror but to see through a material.
  64167. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64168. */
  64169. export class RefractionTexture extends RenderTargetTexture {
  64170. /**
  64171. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  64172. * 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.
  64173. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64174. */
  64175. refractionPlane: Plane;
  64176. /**
  64177. * Define how deep under the surface we should see.
  64178. */
  64179. depth: number;
  64180. /**
  64181. * Creates a refraction texture used by refraction channel of the standard material.
  64182. * It is like a mirror but to see through a material.
  64183. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  64184. * @param name Define the texture name
  64185. * @param size Define the size of the underlying texture
  64186. * @param scene Define the scene the refraction belongs to
  64187. * @param generateMipMaps Define if we need to generate mips level for the refraction
  64188. */
  64189. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  64190. /**
  64191. * Clone the refraction texture.
  64192. * @returns the cloned texture
  64193. */
  64194. clone(): RefractionTexture;
  64195. /**
  64196. * Serialize the texture to a JSON representation you could use in Parse later on
  64197. * @returns the serialized JSON representation
  64198. */
  64199. serialize(): any;
  64200. }
  64201. }
  64202. declare module "babylonjs/Materials/Textures/index" {
  64203. export * from "babylonjs/Materials/Textures/baseTexture";
  64204. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  64205. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  64206. export * from "babylonjs/Materials/Textures/cubeTexture";
  64207. export * from "babylonjs/Materials/Textures/dynamicTexture";
  64208. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64209. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  64210. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  64211. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  64212. export * from "babylonjs/Materials/Textures/internalTexture";
  64213. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  64214. export * from "babylonjs/Materials/Textures/Loaders/index";
  64215. export * from "babylonjs/Materials/Textures/mirrorTexture";
  64216. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  64217. export * from "babylonjs/Materials/Textures/Packer/index";
  64218. export * from "babylonjs/Materials/Textures/Procedurals/index";
  64219. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  64220. export * from "babylonjs/Materials/Textures/rawTexture";
  64221. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  64222. export * from "babylonjs/Materials/Textures/rawTexture3D";
  64223. export * from "babylonjs/Materials/Textures/refractionTexture";
  64224. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  64225. export * from "babylonjs/Materials/Textures/texture";
  64226. export * from "babylonjs/Materials/Textures/videoTexture";
  64227. }
  64228. declare module "babylonjs/Materials/Node/Enums/index" {
  64229. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  64230. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  64231. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  64232. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  64233. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  64234. }
  64235. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  64236. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64237. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64239. import { Mesh } from "babylonjs/Meshes/mesh";
  64240. import { Effect } from "babylonjs/Materials/effect";
  64241. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64242. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64243. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64244. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64245. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  64246. /**
  64247. * Block used to add support for vertex skinning (bones)
  64248. */
  64249. export class BonesBlock extends NodeMaterialBlock {
  64250. /**
  64251. * Creates a new BonesBlock
  64252. * @param name defines the block name
  64253. */
  64254. constructor(name: string);
  64255. /**
  64256. * Initialize the block and prepare the context for build
  64257. * @param state defines the state that will be used for the build
  64258. */
  64259. initialize(state: NodeMaterialBuildState): void;
  64260. /**
  64261. * Gets the current class name
  64262. * @returns the class name
  64263. */
  64264. getClassName(): string;
  64265. /**
  64266. * Gets the matrix indices input component
  64267. */
  64268. get matricesIndices(): NodeMaterialConnectionPoint;
  64269. /**
  64270. * Gets the matrix weights input component
  64271. */
  64272. get matricesWeights(): NodeMaterialConnectionPoint;
  64273. /**
  64274. * Gets the extra matrix indices input component
  64275. */
  64276. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  64277. /**
  64278. * Gets the extra matrix weights input component
  64279. */
  64280. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  64281. /**
  64282. * Gets the world input component
  64283. */
  64284. get world(): NodeMaterialConnectionPoint;
  64285. /**
  64286. * Gets the output component
  64287. */
  64288. get output(): NodeMaterialConnectionPoint;
  64289. autoConfigure(material: NodeMaterial): void;
  64290. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  64291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64292. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64293. protected _buildBlock(state: NodeMaterialBuildState): this;
  64294. }
  64295. }
  64296. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  64297. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64298. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64299. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64300. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64301. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64302. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64303. /**
  64304. * Block used to add support for instances
  64305. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  64306. */
  64307. export class InstancesBlock extends NodeMaterialBlock {
  64308. /**
  64309. * Creates a new InstancesBlock
  64310. * @param name defines the block name
  64311. */
  64312. constructor(name: string);
  64313. /**
  64314. * Gets the current class name
  64315. * @returns the class name
  64316. */
  64317. getClassName(): string;
  64318. /**
  64319. * Gets the first world row input component
  64320. */
  64321. get world0(): NodeMaterialConnectionPoint;
  64322. /**
  64323. * Gets the second world row input component
  64324. */
  64325. get world1(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the third world row input component
  64328. */
  64329. get world2(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the forth world row input component
  64332. */
  64333. get world3(): NodeMaterialConnectionPoint;
  64334. /**
  64335. * Gets the world input component
  64336. */
  64337. get world(): NodeMaterialConnectionPoint;
  64338. /**
  64339. * Gets the output component
  64340. */
  64341. get output(): NodeMaterialConnectionPoint;
  64342. /**
  64343. * Gets the isntanceID component
  64344. */
  64345. get instanceID(): NodeMaterialConnectionPoint;
  64346. autoConfigure(material: NodeMaterial): void;
  64347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  64348. protected _buildBlock(state: NodeMaterialBuildState): this;
  64349. }
  64350. }
  64351. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  64352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64353. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64354. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64356. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64357. import { Effect } from "babylonjs/Materials/effect";
  64358. import { Mesh } from "babylonjs/Meshes/mesh";
  64359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64360. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64361. /**
  64362. * Block used to add morph targets support to vertex shader
  64363. */
  64364. export class MorphTargetsBlock extends NodeMaterialBlock {
  64365. private _repeatableContentAnchor;
  64366. /**
  64367. * Create a new MorphTargetsBlock
  64368. * @param name defines the block name
  64369. */
  64370. constructor(name: string);
  64371. /**
  64372. * Gets the current class name
  64373. * @returns the class name
  64374. */
  64375. getClassName(): string;
  64376. /**
  64377. * Gets the position input component
  64378. */
  64379. get position(): NodeMaterialConnectionPoint;
  64380. /**
  64381. * Gets the normal input component
  64382. */
  64383. get normal(): NodeMaterialConnectionPoint;
  64384. /**
  64385. * Gets the tangent input component
  64386. */
  64387. get tangent(): NodeMaterialConnectionPoint;
  64388. /**
  64389. * Gets the tangent input component
  64390. */
  64391. get uv(): NodeMaterialConnectionPoint;
  64392. /**
  64393. * Gets the position output component
  64394. */
  64395. get positionOutput(): NodeMaterialConnectionPoint;
  64396. /**
  64397. * Gets the normal output component
  64398. */
  64399. get normalOutput(): NodeMaterialConnectionPoint;
  64400. /**
  64401. * Gets the tangent output component
  64402. */
  64403. get tangentOutput(): NodeMaterialConnectionPoint;
  64404. /**
  64405. * Gets the tangent output component
  64406. */
  64407. get uvOutput(): NodeMaterialConnectionPoint;
  64408. initialize(state: NodeMaterialBuildState): void;
  64409. autoConfigure(material: NodeMaterial): void;
  64410. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64411. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64412. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  64413. protected _buildBlock(state: NodeMaterialBuildState): this;
  64414. }
  64415. }
  64416. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  64417. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64418. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64419. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64420. import { Nullable } from "babylonjs/types";
  64421. import { Scene } from "babylonjs/scene";
  64422. import { Effect } from "babylonjs/Materials/effect";
  64423. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64424. import { Mesh } from "babylonjs/Meshes/mesh";
  64425. import { Light } from "babylonjs/Lights/light";
  64426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64427. /**
  64428. * Block used to get data information from a light
  64429. */
  64430. export class LightInformationBlock extends NodeMaterialBlock {
  64431. private _lightDataUniformName;
  64432. private _lightColorUniformName;
  64433. private _lightTypeDefineName;
  64434. /**
  64435. * Gets or sets the light associated with this block
  64436. */
  64437. light: Nullable<Light>;
  64438. /**
  64439. * Creates a new LightInformationBlock
  64440. * @param name defines the block name
  64441. */
  64442. constructor(name: string);
  64443. /**
  64444. * Gets the current class name
  64445. * @returns the class name
  64446. */
  64447. getClassName(): string;
  64448. /**
  64449. * Gets the world position input component
  64450. */
  64451. get worldPosition(): NodeMaterialConnectionPoint;
  64452. /**
  64453. * Gets the direction output component
  64454. */
  64455. get direction(): NodeMaterialConnectionPoint;
  64456. /**
  64457. * Gets the direction output component
  64458. */
  64459. get color(): NodeMaterialConnectionPoint;
  64460. /**
  64461. * Gets the direction output component
  64462. */
  64463. get intensity(): NodeMaterialConnectionPoint;
  64464. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64466. protected _buildBlock(state: NodeMaterialBuildState): this;
  64467. serialize(): any;
  64468. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64469. }
  64470. }
  64471. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  64472. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  64473. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  64474. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  64475. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  64476. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  64477. }
  64478. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  64479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64483. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64484. import { Effect } from "babylonjs/Materials/effect";
  64485. import { Mesh } from "babylonjs/Meshes/mesh";
  64486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64487. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  64488. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  64489. /**
  64490. * Block used to add image processing support to fragment shader
  64491. */
  64492. export class ImageProcessingBlock extends NodeMaterialBlock {
  64493. /**
  64494. * Create a new ImageProcessingBlock
  64495. * @param name defines the block name
  64496. */
  64497. constructor(name: string);
  64498. /**
  64499. * Gets the current class name
  64500. * @returns the class name
  64501. */
  64502. getClassName(): string;
  64503. /**
  64504. * Gets the color input component
  64505. */
  64506. get color(): NodeMaterialConnectionPoint;
  64507. /**
  64508. * Gets the output component
  64509. */
  64510. get output(): NodeMaterialConnectionPoint;
  64511. /**
  64512. * Initialize the block and prepare the context for build
  64513. * @param state defines the state that will be used for the build
  64514. */
  64515. initialize(state: NodeMaterialBuildState): void;
  64516. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  64517. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64518. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64519. protected _buildBlock(state: NodeMaterialBuildState): this;
  64520. }
  64521. }
  64522. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  64523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64526. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64527. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64528. import { Effect } from "babylonjs/Materials/effect";
  64529. import { Mesh } from "babylonjs/Meshes/mesh";
  64530. import { Scene } from "babylonjs/scene";
  64531. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  64532. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  64533. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  64534. /**
  64535. * Block used to pertub normals based on a normal map
  64536. */
  64537. export class PerturbNormalBlock extends NodeMaterialBlock {
  64538. private _tangentSpaceParameterName;
  64539. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64540. invertX: boolean;
  64541. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  64542. invertY: boolean;
  64543. /**
  64544. * Create a new PerturbNormalBlock
  64545. * @param name defines the block name
  64546. */
  64547. constructor(name: string);
  64548. /**
  64549. * Gets the current class name
  64550. * @returns the class name
  64551. */
  64552. getClassName(): string;
  64553. /**
  64554. * Gets the world position input component
  64555. */
  64556. get worldPosition(): NodeMaterialConnectionPoint;
  64557. /**
  64558. * Gets the world normal input component
  64559. */
  64560. get worldNormal(): NodeMaterialConnectionPoint;
  64561. /**
  64562. * Gets the world tangent input component
  64563. */
  64564. get worldTangent(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the uv input component
  64567. */
  64568. get uv(): NodeMaterialConnectionPoint;
  64569. /**
  64570. * Gets the normal map color input component
  64571. */
  64572. get normalMapColor(): NodeMaterialConnectionPoint;
  64573. /**
  64574. * Gets the strength input component
  64575. */
  64576. get strength(): NodeMaterialConnectionPoint;
  64577. /**
  64578. * Gets the output component
  64579. */
  64580. get output(): NodeMaterialConnectionPoint;
  64581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64583. autoConfigure(material: NodeMaterial): void;
  64584. protected _buildBlock(state: NodeMaterialBuildState): this;
  64585. protected _dumpPropertiesCode(): string;
  64586. serialize(): any;
  64587. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64588. }
  64589. }
  64590. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  64591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64594. /**
  64595. * Block used to discard a pixel if a value is smaller than a cutoff
  64596. */
  64597. export class DiscardBlock extends NodeMaterialBlock {
  64598. /**
  64599. * Create a new DiscardBlock
  64600. * @param name defines the block name
  64601. */
  64602. constructor(name: string);
  64603. /**
  64604. * Gets the current class name
  64605. * @returns the class name
  64606. */
  64607. getClassName(): string;
  64608. /**
  64609. * Gets the color input component
  64610. */
  64611. get value(): NodeMaterialConnectionPoint;
  64612. /**
  64613. * Gets the cutoff input component
  64614. */
  64615. get cutoff(): NodeMaterialConnectionPoint;
  64616. protected _buildBlock(state: NodeMaterialBuildState): this;
  64617. }
  64618. }
  64619. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  64620. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64621. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64622. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64623. /**
  64624. * Block used to test if the fragment shader is front facing
  64625. */
  64626. export class FrontFacingBlock extends NodeMaterialBlock {
  64627. /**
  64628. * Creates a new FrontFacingBlock
  64629. * @param name defines the block name
  64630. */
  64631. constructor(name: string);
  64632. /**
  64633. * Gets the current class name
  64634. * @returns the class name
  64635. */
  64636. getClassName(): string;
  64637. /**
  64638. * Gets the output component
  64639. */
  64640. get output(): NodeMaterialConnectionPoint;
  64641. protected _buildBlock(state: NodeMaterialBuildState): this;
  64642. }
  64643. }
  64644. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  64645. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64646. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64647. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64648. /**
  64649. * Block used to get the derivative value on x and y of a given input
  64650. */
  64651. export class DerivativeBlock extends NodeMaterialBlock {
  64652. /**
  64653. * Create a new DerivativeBlock
  64654. * @param name defines the block name
  64655. */
  64656. constructor(name: string);
  64657. /**
  64658. * Gets the current class name
  64659. * @returns the class name
  64660. */
  64661. getClassName(): string;
  64662. /**
  64663. * Gets the input component
  64664. */
  64665. get input(): NodeMaterialConnectionPoint;
  64666. /**
  64667. * Gets the derivative output on x
  64668. */
  64669. get dx(): NodeMaterialConnectionPoint;
  64670. /**
  64671. * Gets the derivative output on y
  64672. */
  64673. get dy(): NodeMaterialConnectionPoint;
  64674. protected _buildBlock(state: NodeMaterialBuildState): this;
  64675. }
  64676. }
  64677. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  64678. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64679. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64680. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64681. /**
  64682. * Block used to make gl_FragCoord available
  64683. */
  64684. export class FragCoordBlock extends NodeMaterialBlock {
  64685. /**
  64686. * Creates a new FragCoordBlock
  64687. * @param name defines the block name
  64688. */
  64689. constructor(name: string);
  64690. /**
  64691. * Gets the current class name
  64692. * @returns the class name
  64693. */
  64694. getClassName(): string;
  64695. /**
  64696. * Gets the xy component
  64697. */
  64698. get xy(): NodeMaterialConnectionPoint;
  64699. /**
  64700. * Gets the xyz component
  64701. */
  64702. get xyz(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the xyzw component
  64705. */
  64706. get xyzw(): NodeMaterialConnectionPoint;
  64707. /**
  64708. * Gets the x component
  64709. */
  64710. get x(): NodeMaterialConnectionPoint;
  64711. /**
  64712. * Gets the y component
  64713. */
  64714. get y(): NodeMaterialConnectionPoint;
  64715. /**
  64716. * Gets the z component
  64717. */
  64718. get z(): NodeMaterialConnectionPoint;
  64719. /**
  64720. * Gets the w component
  64721. */
  64722. get output(): NodeMaterialConnectionPoint;
  64723. protected writeOutputs(state: NodeMaterialBuildState): string;
  64724. protected _buildBlock(state: NodeMaterialBuildState): this;
  64725. }
  64726. }
  64727. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  64728. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64729. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64730. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64731. import { Effect } from "babylonjs/Materials/effect";
  64732. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64733. import { Mesh } from "babylonjs/Meshes/mesh";
  64734. /**
  64735. * Block used to get the screen sizes
  64736. */
  64737. export class ScreenSizeBlock extends NodeMaterialBlock {
  64738. private _varName;
  64739. private _scene;
  64740. /**
  64741. * Creates a new ScreenSizeBlock
  64742. * @param name defines the block name
  64743. */
  64744. constructor(name: string);
  64745. /**
  64746. * Gets the current class name
  64747. * @returns the class name
  64748. */
  64749. getClassName(): string;
  64750. /**
  64751. * Gets the xy component
  64752. */
  64753. get xy(): NodeMaterialConnectionPoint;
  64754. /**
  64755. * Gets the x component
  64756. */
  64757. get x(): NodeMaterialConnectionPoint;
  64758. /**
  64759. * Gets the y component
  64760. */
  64761. get y(): NodeMaterialConnectionPoint;
  64762. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64763. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  64764. protected _buildBlock(state: NodeMaterialBuildState): this;
  64765. }
  64766. }
  64767. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  64768. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  64769. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  64770. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  64771. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  64772. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  64773. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  64774. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  64775. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  64776. }
  64777. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  64778. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64779. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64780. import { Mesh } from "babylonjs/Meshes/mesh";
  64781. import { Effect } from "babylonjs/Materials/effect";
  64782. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64784. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64785. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  64786. /**
  64787. * Block used to add support for scene fog
  64788. */
  64789. export class FogBlock extends NodeMaterialBlock {
  64790. private _fogDistanceName;
  64791. private _fogParameters;
  64792. /**
  64793. * Create a new FogBlock
  64794. * @param name defines the block name
  64795. */
  64796. constructor(name: string);
  64797. /**
  64798. * Gets the current class name
  64799. * @returns the class name
  64800. */
  64801. getClassName(): string;
  64802. /**
  64803. * Gets the world position input component
  64804. */
  64805. get worldPosition(): NodeMaterialConnectionPoint;
  64806. /**
  64807. * Gets the view input component
  64808. */
  64809. get view(): NodeMaterialConnectionPoint;
  64810. /**
  64811. * Gets the color input component
  64812. */
  64813. get input(): NodeMaterialConnectionPoint;
  64814. /**
  64815. * Gets the fog color input component
  64816. */
  64817. get fogColor(): NodeMaterialConnectionPoint;
  64818. /**
  64819. * Gets the output component
  64820. */
  64821. get output(): NodeMaterialConnectionPoint;
  64822. autoConfigure(material: NodeMaterial): void;
  64823. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64824. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64825. protected _buildBlock(state: NodeMaterialBuildState): this;
  64826. }
  64827. }
  64828. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  64829. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64830. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64831. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64833. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  64834. import { Effect } from "babylonjs/Materials/effect";
  64835. import { Mesh } from "babylonjs/Meshes/mesh";
  64836. import { Light } from "babylonjs/Lights/light";
  64837. import { Nullable } from "babylonjs/types";
  64838. import { Scene } from "babylonjs/scene";
  64839. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  64840. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  64841. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  64842. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  64843. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  64844. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  64845. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  64846. /**
  64847. * Block used to add light in the fragment shader
  64848. */
  64849. export class LightBlock extends NodeMaterialBlock {
  64850. private _lightId;
  64851. /**
  64852. * Gets or sets the light associated with this block
  64853. */
  64854. light: Nullable<Light>;
  64855. /**
  64856. * Create a new LightBlock
  64857. * @param name defines the block name
  64858. */
  64859. constructor(name: string);
  64860. /**
  64861. * Gets the current class name
  64862. * @returns the class name
  64863. */
  64864. getClassName(): string;
  64865. /**
  64866. * Gets the world position input component
  64867. */
  64868. get worldPosition(): NodeMaterialConnectionPoint;
  64869. /**
  64870. * Gets the world normal input component
  64871. */
  64872. get worldNormal(): NodeMaterialConnectionPoint;
  64873. /**
  64874. * Gets the camera (or eye) position component
  64875. */
  64876. get cameraPosition(): NodeMaterialConnectionPoint;
  64877. /**
  64878. * Gets the glossiness component
  64879. */
  64880. get glossiness(): NodeMaterialConnectionPoint;
  64881. /**
  64882. * Gets the glossinness power component
  64883. */
  64884. get glossPower(): NodeMaterialConnectionPoint;
  64885. /**
  64886. * Gets the diffuse color component
  64887. */
  64888. get diffuseColor(): NodeMaterialConnectionPoint;
  64889. /**
  64890. * Gets the specular color component
  64891. */
  64892. get specularColor(): NodeMaterialConnectionPoint;
  64893. /**
  64894. * Gets the diffuse output component
  64895. */
  64896. get diffuseOutput(): NodeMaterialConnectionPoint;
  64897. /**
  64898. * Gets the specular output component
  64899. */
  64900. get specularOutput(): NodeMaterialConnectionPoint;
  64901. /**
  64902. * Gets the shadow output component
  64903. */
  64904. get shadow(): NodeMaterialConnectionPoint;
  64905. autoConfigure(material: NodeMaterial): void;
  64906. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64907. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  64908. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  64909. private _injectVertexCode;
  64910. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64911. serialize(): any;
  64912. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64913. }
  64914. }
  64915. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  64916. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  64917. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  64918. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  64919. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  64920. /**
  64921. * Block used to read a reflection texture from a sampler
  64922. */
  64923. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  64924. /**
  64925. * Create a new ReflectionTextureBlock
  64926. * @param name defines the block name
  64927. */
  64928. constructor(name: string);
  64929. /**
  64930. * Gets the current class name
  64931. * @returns the class name
  64932. */
  64933. getClassName(): string;
  64934. /**
  64935. * Gets the world position input component
  64936. */
  64937. get position(): NodeMaterialConnectionPoint;
  64938. /**
  64939. * Gets the world position input component
  64940. */
  64941. get worldPosition(): NodeMaterialConnectionPoint;
  64942. /**
  64943. * Gets the world normal input component
  64944. */
  64945. get worldNormal(): NodeMaterialConnectionPoint;
  64946. /**
  64947. * Gets the world input component
  64948. */
  64949. get world(): NodeMaterialConnectionPoint;
  64950. /**
  64951. * Gets the camera (or eye) position component
  64952. */
  64953. get cameraPosition(): NodeMaterialConnectionPoint;
  64954. /**
  64955. * Gets the view input component
  64956. */
  64957. get view(): NodeMaterialConnectionPoint;
  64958. /**
  64959. * Gets the rgb output component
  64960. */
  64961. get rgb(): NodeMaterialConnectionPoint;
  64962. /**
  64963. * Gets the rgba output component
  64964. */
  64965. get rgba(): NodeMaterialConnectionPoint;
  64966. /**
  64967. * Gets the r output component
  64968. */
  64969. get r(): NodeMaterialConnectionPoint;
  64970. /**
  64971. * Gets the g output component
  64972. */
  64973. get g(): NodeMaterialConnectionPoint;
  64974. /**
  64975. * Gets the b output component
  64976. */
  64977. get b(): NodeMaterialConnectionPoint;
  64978. /**
  64979. * Gets the a output component
  64980. */
  64981. get a(): NodeMaterialConnectionPoint;
  64982. autoConfigure(material: NodeMaterial): void;
  64983. protected _buildBlock(state: NodeMaterialBuildState): this;
  64984. }
  64985. }
  64986. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  64987. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  64988. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  64989. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  64990. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  64991. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  64992. }
  64993. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  64994. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  64995. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  64996. }
  64997. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  64998. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  64999. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65000. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65001. /**
  65002. * Block used to add 2 vectors
  65003. */
  65004. export class AddBlock extends NodeMaterialBlock {
  65005. /**
  65006. * Creates a new AddBlock
  65007. * @param name defines the block name
  65008. */
  65009. constructor(name: string);
  65010. /**
  65011. * Gets the current class name
  65012. * @returns the class name
  65013. */
  65014. getClassName(): string;
  65015. /**
  65016. * Gets the left operand input component
  65017. */
  65018. get left(): NodeMaterialConnectionPoint;
  65019. /**
  65020. * Gets the right operand input component
  65021. */
  65022. get right(): NodeMaterialConnectionPoint;
  65023. /**
  65024. * Gets the output component
  65025. */
  65026. get output(): NodeMaterialConnectionPoint;
  65027. protected _buildBlock(state: NodeMaterialBuildState): this;
  65028. }
  65029. }
  65030. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  65031. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65032. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65033. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65034. /**
  65035. * Block used to scale a vector by a float
  65036. */
  65037. export class ScaleBlock extends NodeMaterialBlock {
  65038. /**
  65039. * Creates a new ScaleBlock
  65040. * @param name defines the block name
  65041. */
  65042. constructor(name: string);
  65043. /**
  65044. * Gets the current class name
  65045. * @returns the class name
  65046. */
  65047. getClassName(): string;
  65048. /**
  65049. * Gets the input component
  65050. */
  65051. get input(): NodeMaterialConnectionPoint;
  65052. /**
  65053. * Gets the factor input component
  65054. */
  65055. get factor(): NodeMaterialConnectionPoint;
  65056. /**
  65057. * Gets the output component
  65058. */
  65059. get output(): NodeMaterialConnectionPoint;
  65060. protected _buildBlock(state: NodeMaterialBuildState): this;
  65061. }
  65062. }
  65063. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  65064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65067. import { Scene } from "babylonjs/scene";
  65068. /**
  65069. * Block used to clamp a float
  65070. */
  65071. export class ClampBlock extends NodeMaterialBlock {
  65072. /** Gets or sets the minimum range */
  65073. minimum: number;
  65074. /** Gets or sets the maximum range */
  65075. maximum: number;
  65076. /**
  65077. * Creates a new ClampBlock
  65078. * @param name defines the block name
  65079. */
  65080. constructor(name: string);
  65081. /**
  65082. * Gets the current class name
  65083. * @returns the class name
  65084. */
  65085. getClassName(): string;
  65086. /**
  65087. * Gets the value input component
  65088. */
  65089. get value(): NodeMaterialConnectionPoint;
  65090. /**
  65091. * Gets the output component
  65092. */
  65093. get output(): NodeMaterialConnectionPoint;
  65094. protected _buildBlock(state: NodeMaterialBuildState): this;
  65095. protected _dumpPropertiesCode(): string;
  65096. serialize(): any;
  65097. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65098. }
  65099. }
  65100. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  65101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65104. /**
  65105. * Block used to apply a cross product between 2 vectors
  65106. */
  65107. export class CrossBlock extends NodeMaterialBlock {
  65108. /**
  65109. * Creates a new CrossBlock
  65110. * @param name defines the block name
  65111. */
  65112. constructor(name: string);
  65113. /**
  65114. * Gets the current class name
  65115. * @returns the class name
  65116. */
  65117. getClassName(): string;
  65118. /**
  65119. * Gets the left operand input component
  65120. */
  65121. get left(): NodeMaterialConnectionPoint;
  65122. /**
  65123. * Gets the right operand input component
  65124. */
  65125. get right(): NodeMaterialConnectionPoint;
  65126. /**
  65127. * Gets the output component
  65128. */
  65129. get output(): NodeMaterialConnectionPoint;
  65130. protected _buildBlock(state: NodeMaterialBuildState): this;
  65131. }
  65132. }
  65133. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  65134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65137. /**
  65138. * Block used to apply a dot product between 2 vectors
  65139. */
  65140. export class DotBlock extends NodeMaterialBlock {
  65141. /**
  65142. * Creates a new DotBlock
  65143. * @param name defines the block name
  65144. */
  65145. constructor(name: string);
  65146. /**
  65147. * Gets the current class name
  65148. * @returns the class name
  65149. */
  65150. getClassName(): string;
  65151. /**
  65152. * Gets the left operand input component
  65153. */
  65154. get left(): NodeMaterialConnectionPoint;
  65155. /**
  65156. * Gets the right operand input component
  65157. */
  65158. get right(): NodeMaterialConnectionPoint;
  65159. /**
  65160. * Gets the output component
  65161. */
  65162. get output(): NodeMaterialConnectionPoint;
  65163. protected _buildBlock(state: NodeMaterialBuildState): this;
  65164. }
  65165. }
  65166. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  65167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65170. /**
  65171. * Block used to normalize a vector
  65172. */
  65173. export class NormalizeBlock extends NodeMaterialBlock {
  65174. /**
  65175. * Creates a new NormalizeBlock
  65176. * @param name defines the block name
  65177. */
  65178. constructor(name: string);
  65179. /**
  65180. * Gets the current class name
  65181. * @returns the class name
  65182. */
  65183. getClassName(): string;
  65184. /**
  65185. * Gets the input component
  65186. */
  65187. get input(): NodeMaterialConnectionPoint;
  65188. /**
  65189. * Gets the output component
  65190. */
  65191. get output(): NodeMaterialConnectionPoint;
  65192. protected _buildBlock(state: NodeMaterialBuildState): this;
  65193. }
  65194. }
  65195. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  65196. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65197. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65199. import { Scene } from "babylonjs/scene";
  65200. /**
  65201. * Operations supported by the Trigonometry block
  65202. */
  65203. export enum TrigonometryBlockOperations {
  65204. /** Cos */
  65205. Cos = 0,
  65206. /** Sin */
  65207. Sin = 1,
  65208. /** Abs */
  65209. Abs = 2,
  65210. /** Exp */
  65211. Exp = 3,
  65212. /** Exp2 */
  65213. Exp2 = 4,
  65214. /** Round */
  65215. Round = 5,
  65216. /** Floor */
  65217. Floor = 6,
  65218. /** Ceiling */
  65219. Ceiling = 7,
  65220. /** Square root */
  65221. Sqrt = 8,
  65222. /** Log */
  65223. Log = 9,
  65224. /** Tangent */
  65225. Tan = 10,
  65226. /** Arc tangent */
  65227. ArcTan = 11,
  65228. /** Arc cosinus */
  65229. ArcCos = 12,
  65230. /** Arc sinus */
  65231. ArcSin = 13,
  65232. /** Fraction */
  65233. Fract = 14,
  65234. /** Sign */
  65235. Sign = 15,
  65236. /** To radians (from degrees) */
  65237. Radians = 16,
  65238. /** To degrees (from radians) */
  65239. Degrees = 17
  65240. }
  65241. /**
  65242. * Block used to apply trigonometry operation to floats
  65243. */
  65244. export class TrigonometryBlock extends NodeMaterialBlock {
  65245. /**
  65246. * Gets or sets the operation applied by the block
  65247. */
  65248. operation: TrigonometryBlockOperations;
  65249. /**
  65250. * Creates a new TrigonometryBlock
  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 input component
  65261. */
  65262. get input(): NodeMaterialConnectionPoint;
  65263. /**
  65264. * Gets the output component
  65265. */
  65266. get output(): NodeMaterialConnectionPoint;
  65267. protected _buildBlock(state: NodeMaterialBuildState): this;
  65268. serialize(): any;
  65269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65270. protected _dumpPropertiesCode(): string;
  65271. }
  65272. }
  65273. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  65274. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65275. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65276. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65277. /**
  65278. * Block used to create a Color3/4 out of individual inputs (one for each component)
  65279. */
  65280. export class ColorMergerBlock extends NodeMaterialBlock {
  65281. /**
  65282. * Create a new ColorMergerBlock
  65283. * @param name defines the block name
  65284. */
  65285. constructor(name: string);
  65286. /**
  65287. * Gets the current class name
  65288. * @returns the class name
  65289. */
  65290. getClassName(): string;
  65291. /**
  65292. * Gets the rgb component (input)
  65293. */
  65294. get rgbIn(): NodeMaterialConnectionPoint;
  65295. /**
  65296. * Gets the r component (input)
  65297. */
  65298. get r(): NodeMaterialConnectionPoint;
  65299. /**
  65300. * Gets the g component (input)
  65301. */
  65302. get g(): NodeMaterialConnectionPoint;
  65303. /**
  65304. * Gets the b component (input)
  65305. */
  65306. get b(): NodeMaterialConnectionPoint;
  65307. /**
  65308. * Gets the a component (input)
  65309. */
  65310. get a(): NodeMaterialConnectionPoint;
  65311. /**
  65312. * Gets the rgba component (output)
  65313. */
  65314. get rgba(): NodeMaterialConnectionPoint;
  65315. /**
  65316. * Gets the rgb component (output)
  65317. */
  65318. get rgbOut(): NodeMaterialConnectionPoint;
  65319. /**
  65320. * Gets the rgb component (output)
  65321. * @deprecated Please use rgbOut instead.
  65322. */
  65323. get rgb(): NodeMaterialConnectionPoint;
  65324. protected _buildBlock(state: NodeMaterialBuildState): this;
  65325. }
  65326. }
  65327. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  65328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65331. /**
  65332. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  65333. */
  65334. export class VectorSplitterBlock extends NodeMaterialBlock {
  65335. /**
  65336. * Create a new VectorSplitterBlock
  65337. * @param name defines the block name
  65338. */
  65339. constructor(name: string);
  65340. /**
  65341. * Gets the current class name
  65342. * @returns the class name
  65343. */
  65344. getClassName(): string;
  65345. /**
  65346. * Gets the xyzw component (input)
  65347. */
  65348. get xyzw(): NodeMaterialConnectionPoint;
  65349. /**
  65350. * Gets the xyz component (input)
  65351. */
  65352. get xyzIn(): NodeMaterialConnectionPoint;
  65353. /**
  65354. * Gets the xy component (input)
  65355. */
  65356. get xyIn(): NodeMaterialConnectionPoint;
  65357. /**
  65358. * Gets the xyz component (output)
  65359. */
  65360. get xyzOut(): NodeMaterialConnectionPoint;
  65361. /**
  65362. * Gets the xy component (output)
  65363. */
  65364. get xyOut(): NodeMaterialConnectionPoint;
  65365. /**
  65366. * Gets the x component (output)
  65367. */
  65368. get x(): NodeMaterialConnectionPoint;
  65369. /**
  65370. * Gets the y component (output)
  65371. */
  65372. get y(): NodeMaterialConnectionPoint;
  65373. /**
  65374. * Gets the z component (output)
  65375. */
  65376. get z(): NodeMaterialConnectionPoint;
  65377. /**
  65378. * Gets the w component (output)
  65379. */
  65380. get w(): NodeMaterialConnectionPoint;
  65381. protected _inputRename(name: string): string;
  65382. protected _outputRename(name: string): string;
  65383. protected _buildBlock(state: NodeMaterialBuildState): this;
  65384. }
  65385. }
  65386. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  65387. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65388. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65389. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65390. /**
  65391. * Block used to lerp between 2 values
  65392. */
  65393. export class LerpBlock extends NodeMaterialBlock {
  65394. /**
  65395. * Creates a new LerpBlock
  65396. * @param name defines the block name
  65397. */
  65398. constructor(name: string);
  65399. /**
  65400. * Gets the current class name
  65401. * @returns the class name
  65402. */
  65403. getClassName(): string;
  65404. /**
  65405. * Gets the left operand input component
  65406. */
  65407. get left(): NodeMaterialConnectionPoint;
  65408. /**
  65409. * Gets the right operand input component
  65410. */
  65411. get right(): NodeMaterialConnectionPoint;
  65412. /**
  65413. * Gets the gradient operand input component
  65414. */
  65415. get gradient(): NodeMaterialConnectionPoint;
  65416. /**
  65417. * Gets the output component
  65418. */
  65419. get output(): NodeMaterialConnectionPoint;
  65420. protected _buildBlock(state: NodeMaterialBuildState): this;
  65421. }
  65422. }
  65423. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  65424. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65425. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65426. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65427. /**
  65428. * Block used to divide 2 vectors
  65429. */
  65430. export class DivideBlock extends NodeMaterialBlock {
  65431. /**
  65432. * Creates a new DivideBlock
  65433. * @param name defines the block name
  65434. */
  65435. constructor(name: string);
  65436. /**
  65437. * Gets the current class name
  65438. * @returns the class name
  65439. */
  65440. getClassName(): string;
  65441. /**
  65442. * Gets the left operand input component
  65443. */
  65444. get left(): NodeMaterialConnectionPoint;
  65445. /**
  65446. * Gets the right operand input component
  65447. */
  65448. get right(): NodeMaterialConnectionPoint;
  65449. /**
  65450. * Gets the output component
  65451. */
  65452. get output(): NodeMaterialConnectionPoint;
  65453. protected _buildBlock(state: NodeMaterialBuildState): this;
  65454. }
  65455. }
  65456. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  65457. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65458. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65459. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65460. /**
  65461. * Block used to subtract 2 vectors
  65462. */
  65463. export class SubtractBlock extends NodeMaterialBlock {
  65464. /**
  65465. * Creates a new SubtractBlock
  65466. * @param name defines the block name
  65467. */
  65468. constructor(name: string);
  65469. /**
  65470. * Gets the current class name
  65471. * @returns the class name
  65472. */
  65473. getClassName(): string;
  65474. /**
  65475. * Gets the left operand input component
  65476. */
  65477. get left(): NodeMaterialConnectionPoint;
  65478. /**
  65479. * Gets the right operand input component
  65480. */
  65481. get right(): NodeMaterialConnectionPoint;
  65482. /**
  65483. * Gets the output component
  65484. */
  65485. get output(): NodeMaterialConnectionPoint;
  65486. protected _buildBlock(state: NodeMaterialBuildState): this;
  65487. }
  65488. }
  65489. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  65490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65491. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65492. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65493. /**
  65494. * Block used to step a value
  65495. */
  65496. export class StepBlock extends NodeMaterialBlock {
  65497. /**
  65498. * Creates a new StepBlock
  65499. * @param name defines the block name
  65500. */
  65501. constructor(name: string);
  65502. /**
  65503. * Gets the current class name
  65504. * @returns the class name
  65505. */
  65506. getClassName(): string;
  65507. /**
  65508. * Gets the value operand input component
  65509. */
  65510. get value(): NodeMaterialConnectionPoint;
  65511. /**
  65512. * Gets the edge operand input component
  65513. */
  65514. get edge(): NodeMaterialConnectionPoint;
  65515. /**
  65516. * Gets the output component
  65517. */
  65518. get output(): NodeMaterialConnectionPoint;
  65519. protected _buildBlock(state: NodeMaterialBuildState): this;
  65520. }
  65521. }
  65522. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  65523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65526. /**
  65527. * Block used to get the opposite (1 - x) of a value
  65528. */
  65529. export class OneMinusBlock extends NodeMaterialBlock {
  65530. /**
  65531. * Creates a new OneMinusBlock
  65532. * @param name defines the block name
  65533. */
  65534. constructor(name: string);
  65535. /**
  65536. * Gets the current class name
  65537. * @returns the class name
  65538. */
  65539. getClassName(): string;
  65540. /**
  65541. * Gets the input component
  65542. */
  65543. get input(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the output component
  65546. */
  65547. get output(): NodeMaterialConnectionPoint;
  65548. protected _buildBlock(state: NodeMaterialBuildState): this;
  65549. }
  65550. }
  65551. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  65552. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65553. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65554. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65555. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65556. /**
  65557. * Block used to get the view direction
  65558. */
  65559. export class ViewDirectionBlock extends NodeMaterialBlock {
  65560. /**
  65561. * Creates a new ViewDirectionBlock
  65562. * @param name defines the block name
  65563. */
  65564. constructor(name: string);
  65565. /**
  65566. * Gets the current class name
  65567. * @returns the class name
  65568. */
  65569. getClassName(): string;
  65570. /**
  65571. * Gets the world position component
  65572. */
  65573. get worldPosition(): NodeMaterialConnectionPoint;
  65574. /**
  65575. * Gets the camera position component
  65576. */
  65577. get cameraPosition(): NodeMaterialConnectionPoint;
  65578. /**
  65579. * Gets the output component
  65580. */
  65581. get output(): NodeMaterialConnectionPoint;
  65582. autoConfigure(material: NodeMaterial): void;
  65583. protected _buildBlock(state: NodeMaterialBuildState): this;
  65584. }
  65585. }
  65586. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  65587. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65588. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65589. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65590. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65591. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  65592. /**
  65593. * Block used to compute fresnel value
  65594. */
  65595. export class FresnelBlock extends NodeMaterialBlock {
  65596. /**
  65597. * Create a new FresnelBlock
  65598. * @param name defines the block name
  65599. */
  65600. constructor(name: string);
  65601. /**
  65602. * Gets the current class name
  65603. * @returns the class name
  65604. */
  65605. getClassName(): string;
  65606. /**
  65607. * Gets the world normal input component
  65608. */
  65609. get worldNormal(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the view direction input component
  65612. */
  65613. get viewDirection(): NodeMaterialConnectionPoint;
  65614. /**
  65615. * Gets the bias input component
  65616. */
  65617. get bias(): NodeMaterialConnectionPoint;
  65618. /**
  65619. * Gets the camera (or eye) position component
  65620. */
  65621. get power(): NodeMaterialConnectionPoint;
  65622. /**
  65623. * Gets the fresnel output component
  65624. */
  65625. get fresnel(): NodeMaterialConnectionPoint;
  65626. autoConfigure(material: NodeMaterial): void;
  65627. protected _buildBlock(state: NodeMaterialBuildState): this;
  65628. }
  65629. }
  65630. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  65631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65634. /**
  65635. * Block used to get the max of 2 values
  65636. */
  65637. export class MaxBlock extends NodeMaterialBlock {
  65638. /**
  65639. * Creates a new MaxBlock
  65640. * @param name defines the block name
  65641. */
  65642. constructor(name: string);
  65643. /**
  65644. * Gets the current class name
  65645. * @returns the class name
  65646. */
  65647. getClassName(): string;
  65648. /**
  65649. * Gets the left operand input component
  65650. */
  65651. get left(): NodeMaterialConnectionPoint;
  65652. /**
  65653. * Gets the right operand input component
  65654. */
  65655. get right(): NodeMaterialConnectionPoint;
  65656. /**
  65657. * Gets the output component
  65658. */
  65659. get output(): NodeMaterialConnectionPoint;
  65660. protected _buildBlock(state: NodeMaterialBuildState): this;
  65661. }
  65662. }
  65663. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  65664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65667. /**
  65668. * Block used to get the min of 2 values
  65669. */
  65670. export class MinBlock extends NodeMaterialBlock {
  65671. /**
  65672. * Creates a new MinBlock
  65673. * @param name defines the block name
  65674. */
  65675. constructor(name: string);
  65676. /**
  65677. * Gets the current class name
  65678. * @returns the class name
  65679. */
  65680. getClassName(): string;
  65681. /**
  65682. * Gets the left operand input component
  65683. */
  65684. get left(): NodeMaterialConnectionPoint;
  65685. /**
  65686. * Gets the right operand input component
  65687. */
  65688. get right(): NodeMaterialConnectionPoint;
  65689. /**
  65690. * Gets the output component
  65691. */
  65692. get output(): NodeMaterialConnectionPoint;
  65693. protected _buildBlock(state: NodeMaterialBuildState): this;
  65694. }
  65695. }
  65696. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  65697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65700. /**
  65701. * Block used to get the distance between 2 values
  65702. */
  65703. export class DistanceBlock extends NodeMaterialBlock {
  65704. /**
  65705. * Creates a new DistanceBlock
  65706. * @param name defines the block name
  65707. */
  65708. constructor(name: string);
  65709. /**
  65710. * Gets the current class name
  65711. * @returns the class name
  65712. */
  65713. getClassName(): string;
  65714. /**
  65715. * Gets the left operand input component
  65716. */
  65717. get left(): NodeMaterialConnectionPoint;
  65718. /**
  65719. * Gets the right operand input component
  65720. */
  65721. get right(): NodeMaterialConnectionPoint;
  65722. /**
  65723. * Gets the output component
  65724. */
  65725. get output(): NodeMaterialConnectionPoint;
  65726. protected _buildBlock(state: NodeMaterialBuildState): this;
  65727. }
  65728. }
  65729. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  65730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65733. /**
  65734. * Block used to get the length of a vector
  65735. */
  65736. export class LengthBlock extends NodeMaterialBlock {
  65737. /**
  65738. * Creates a new LengthBlock
  65739. * @param name defines the block name
  65740. */
  65741. constructor(name: string);
  65742. /**
  65743. * Gets the current class name
  65744. * @returns the class name
  65745. */
  65746. getClassName(): string;
  65747. /**
  65748. * Gets the value input component
  65749. */
  65750. get value(): NodeMaterialConnectionPoint;
  65751. /**
  65752. * Gets the output component
  65753. */
  65754. get output(): NodeMaterialConnectionPoint;
  65755. protected _buildBlock(state: NodeMaterialBuildState): this;
  65756. }
  65757. }
  65758. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  65759. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65760. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65761. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65762. /**
  65763. * Block used to get negative version of a value (i.e. x * -1)
  65764. */
  65765. export class NegateBlock extends NodeMaterialBlock {
  65766. /**
  65767. * Creates a new NegateBlock
  65768. * @param name defines the block name
  65769. */
  65770. constructor(name: string);
  65771. /**
  65772. * Gets the current class name
  65773. * @returns the class name
  65774. */
  65775. getClassName(): string;
  65776. /**
  65777. * Gets the value input component
  65778. */
  65779. get value(): NodeMaterialConnectionPoint;
  65780. /**
  65781. * Gets the output component
  65782. */
  65783. get output(): NodeMaterialConnectionPoint;
  65784. protected _buildBlock(state: NodeMaterialBuildState): this;
  65785. }
  65786. }
  65787. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  65788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65791. /**
  65792. * Block used to get the value of the first parameter raised to the power of the second
  65793. */
  65794. export class PowBlock extends NodeMaterialBlock {
  65795. /**
  65796. * Creates a new PowBlock
  65797. * @param name defines the block name
  65798. */
  65799. constructor(name: string);
  65800. /**
  65801. * Gets the current class name
  65802. * @returns the class name
  65803. */
  65804. getClassName(): string;
  65805. /**
  65806. * Gets the value operand input component
  65807. */
  65808. get value(): NodeMaterialConnectionPoint;
  65809. /**
  65810. * Gets the power operand input component
  65811. */
  65812. get power(): NodeMaterialConnectionPoint;
  65813. /**
  65814. * Gets the output component
  65815. */
  65816. get output(): NodeMaterialConnectionPoint;
  65817. protected _buildBlock(state: NodeMaterialBuildState): this;
  65818. }
  65819. }
  65820. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  65821. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65822. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65823. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65824. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65825. /**
  65826. * Block used to get a random number
  65827. */
  65828. export class RandomNumberBlock extends NodeMaterialBlock {
  65829. /**
  65830. * Creates a new RandomNumberBlock
  65831. * @param name defines the block name
  65832. */
  65833. constructor(name: string);
  65834. /**
  65835. * Gets the current class name
  65836. * @returns the class name
  65837. */
  65838. getClassName(): string;
  65839. /**
  65840. * Gets the seed input component
  65841. */
  65842. get seed(): NodeMaterialConnectionPoint;
  65843. /**
  65844. * Gets the output component
  65845. */
  65846. get output(): NodeMaterialConnectionPoint;
  65847. protected _buildBlock(state: NodeMaterialBuildState): this;
  65848. }
  65849. }
  65850. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  65851. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65852. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65853. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65854. /**
  65855. * Block used to compute arc tangent of 2 values
  65856. */
  65857. export class ArcTan2Block extends NodeMaterialBlock {
  65858. /**
  65859. * Creates a new ArcTan2Block
  65860. * @param name defines the block name
  65861. */
  65862. constructor(name: string);
  65863. /**
  65864. * Gets the current class name
  65865. * @returns the class name
  65866. */
  65867. getClassName(): string;
  65868. /**
  65869. * Gets the x operand input component
  65870. */
  65871. get x(): NodeMaterialConnectionPoint;
  65872. /**
  65873. * Gets the y operand input component
  65874. */
  65875. get y(): NodeMaterialConnectionPoint;
  65876. /**
  65877. * Gets the output component
  65878. */
  65879. get output(): NodeMaterialConnectionPoint;
  65880. protected _buildBlock(state: NodeMaterialBuildState): this;
  65881. }
  65882. }
  65883. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  65884. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65885. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65887. /**
  65888. * Block used to smooth step a value
  65889. */
  65890. export class SmoothStepBlock extends NodeMaterialBlock {
  65891. /**
  65892. * Creates a new SmoothStepBlock
  65893. * @param name defines the block name
  65894. */
  65895. constructor(name: string);
  65896. /**
  65897. * Gets the current class name
  65898. * @returns the class name
  65899. */
  65900. getClassName(): string;
  65901. /**
  65902. * Gets the value operand input component
  65903. */
  65904. get value(): NodeMaterialConnectionPoint;
  65905. /**
  65906. * Gets the first edge operand input component
  65907. */
  65908. get edge0(): NodeMaterialConnectionPoint;
  65909. /**
  65910. * Gets the second edge operand input component
  65911. */
  65912. get edge1(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the output component
  65915. */
  65916. get output(): NodeMaterialConnectionPoint;
  65917. protected _buildBlock(state: NodeMaterialBuildState): this;
  65918. }
  65919. }
  65920. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  65921. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65922. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65923. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65924. /**
  65925. * Block used to get the reciprocal (1 / x) of a value
  65926. */
  65927. export class ReciprocalBlock extends NodeMaterialBlock {
  65928. /**
  65929. * Creates a new ReciprocalBlock
  65930. * @param name defines the block name
  65931. */
  65932. constructor(name: string);
  65933. /**
  65934. * Gets the current class name
  65935. * @returns the class name
  65936. */
  65937. getClassName(): string;
  65938. /**
  65939. * Gets the input component
  65940. */
  65941. get input(): NodeMaterialConnectionPoint;
  65942. /**
  65943. * Gets the output component
  65944. */
  65945. get output(): NodeMaterialConnectionPoint;
  65946. protected _buildBlock(state: NodeMaterialBuildState): this;
  65947. }
  65948. }
  65949. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  65950. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65951. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65952. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65953. /**
  65954. * Block used to replace a color by another one
  65955. */
  65956. export class ReplaceColorBlock extends NodeMaterialBlock {
  65957. /**
  65958. * Creates a new ReplaceColorBlock
  65959. * @param name defines the block name
  65960. */
  65961. constructor(name: string);
  65962. /**
  65963. * Gets the current class name
  65964. * @returns the class name
  65965. */
  65966. getClassName(): string;
  65967. /**
  65968. * Gets the value input component
  65969. */
  65970. get value(): NodeMaterialConnectionPoint;
  65971. /**
  65972. * Gets the reference input component
  65973. */
  65974. get reference(): NodeMaterialConnectionPoint;
  65975. /**
  65976. * Gets the distance input component
  65977. */
  65978. get distance(): NodeMaterialConnectionPoint;
  65979. /**
  65980. * Gets the replacement input component
  65981. */
  65982. get replacement(): NodeMaterialConnectionPoint;
  65983. /**
  65984. * Gets the output component
  65985. */
  65986. get output(): NodeMaterialConnectionPoint;
  65987. protected _buildBlock(state: NodeMaterialBuildState): this;
  65988. }
  65989. }
  65990. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  65991. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65992. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65993. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65994. /**
  65995. * Block used to posterize a value
  65996. * @see https://en.wikipedia.org/wiki/Posterization
  65997. */
  65998. export class PosterizeBlock extends NodeMaterialBlock {
  65999. /**
  66000. * Creates a new PosterizeBlock
  66001. * @param name defines the block name
  66002. */
  66003. constructor(name: string);
  66004. /**
  66005. * Gets the current class name
  66006. * @returns the class name
  66007. */
  66008. getClassName(): string;
  66009. /**
  66010. * Gets the value input component
  66011. */
  66012. get value(): NodeMaterialConnectionPoint;
  66013. /**
  66014. * Gets the steps input component
  66015. */
  66016. get steps(): NodeMaterialConnectionPoint;
  66017. /**
  66018. * Gets the output component
  66019. */
  66020. get output(): NodeMaterialConnectionPoint;
  66021. protected _buildBlock(state: NodeMaterialBuildState): this;
  66022. }
  66023. }
  66024. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  66025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66028. import { Scene } from "babylonjs/scene";
  66029. /**
  66030. * Operations supported by the Wave block
  66031. */
  66032. export enum WaveBlockKind {
  66033. /** SawTooth */
  66034. SawTooth = 0,
  66035. /** Square */
  66036. Square = 1,
  66037. /** Triangle */
  66038. Triangle = 2
  66039. }
  66040. /**
  66041. * Block used to apply wave operation to floats
  66042. */
  66043. export class WaveBlock extends NodeMaterialBlock {
  66044. /**
  66045. * Gets or sets the kibnd of wave to be applied by the block
  66046. */
  66047. kind: WaveBlockKind;
  66048. /**
  66049. * Creates a new WaveBlock
  66050. * @param name defines the block name
  66051. */
  66052. constructor(name: string);
  66053. /**
  66054. * Gets the current class name
  66055. * @returns the class name
  66056. */
  66057. getClassName(): string;
  66058. /**
  66059. * Gets the input component
  66060. */
  66061. get input(): NodeMaterialConnectionPoint;
  66062. /**
  66063. * Gets the output component
  66064. */
  66065. get output(): NodeMaterialConnectionPoint;
  66066. protected _buildBlock(state: NodeMaterialBuildState): this;
  66067. serialize(): any;
  66068. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66069. }
  66070. }
  66071. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  66072. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66073. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66074. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66075. import { Color3 } from "babylonjs/Maths/math.color";
  66076. import { Scene } from "babylonjs/scene";
  66077. /**
  66078. * Class used to store a color step for the GradientBlock
  66079. */
  66080. export class GradientBlockColorStep {
  66081. /**
  66082. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66083. */
  66084. step: number;
  66085. /**
  66086. * Gets or sets the color associated with this step
  66087. */
  66088. color: Color3;
  66089. /**
  66090. * Creates a new GradientBlockColorStep
  66091. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  66092. * @param color defines the color associated with this step
  66093. */
  66094. constructor(
  66095. /**
  66096. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  66097. */
  66098. step: number,
  66099. /**
  66100. * Gets or sets the color associated with this step
  66101. */
  66102. color: Color3);
  66103. }
  66104. /**
  66105. * Block used to return a color from a gradient based on an input value between 0 and 1
  66106. */
  66107. export class GradientBlock extends NodeMaterialBlock {
  66108. /**
  66109. * Gets or sets the list of color steps
  66110. */
  66111. colorSteps: GradientBlockColorStep[];
  66112. /**
  66113. * Creates a new GradientBlock
  66114. * @param name defines the block name
  66115. */
  66116. constructor(name: string);
  66117. /**
  66118. * Gets the current class name
  66119. * @returns the class name
  66120. */
  66121. getClassName(): string;
  66122. /**
  66123. * Gets the gradient input component
  66124. */
  66125. get gradient(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the output component
  66128. */
  66129. get output(): NodeMaterialConnectionPoint;
  66130. private _writeColorConstant;
  66131. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66132. serialize(): any;
  66133. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66134. protected _dumpPropertiesCode(): string;
  66135. }
  66136. }
  66137. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  66138. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66139. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66140. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66141. /**
  66142. * Block used to normalize lerp between 2 values
  66143. */
  66144. export class NLerpBlock extends NodeMaterialBlock {
  66145. /**
  66146. * Creates a new NLerpBlock
  66147. * @param name defines the block name
  66148. */
  66149. constructor(name: string);
  66150. /**
  66151. * Gets the current class name
  66152. * @returns the class name
  66153. */
  66154. getClassName(): string;
  66155. /**
  66156. * Gets the left operand input component
  66157. */
  66158. get left(): NodeMaterialConnectionPoint;
  66159. /**
  66160. * Gets the right operand input component
  66161. */
  66162. get right(): NodeMaterialConnectionPoint;
  66163. /**
  66164. * Gets the gradient operand input component
  66165. */
  66166. get gradient(): NodeMaterialConnectionPoint;
  66167. /**
  66168. * Gets the output component
  66169. */
  66170. get output(): NodeMaterialConnectionPoint;
  66171. protected _buildBlock(state: NodeMaterialBuildState): this;
  66172. }
  66173. }
  66174. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  66175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66178. import { Scene } from "babylonjs/scene";
  66179. /**
  66180. * block used to Generate a Worley Noise 3D Noise Pattern
  66181. */
  66182. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  66183. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  66184. manhattanDistance: boolean;
  66185. /**
  66186. * Creates a new WorleyNoise3DBlock
  66187. * @param name defines the block name
  66188. */
  66189. constructor(name: string);
  66190. /**
  66191. * Gets the current class name
  66192. * @returns the class name
  66193. */
  66194. getClassName(): string;
  66195. /**
  66196. * Gets the seed input component
  66197. */
  66198. get seed(): NodeMaterialConnectionPoint;
  66199. /**
  66200. * Gets the jitter input component
  66201. */
  66202. get jitter(): NodeMaterialConnectionPoint;
  66203. /**
  66204. * Gets the output component
  66205. */
  66206. get output(): NodeMaterialConnectionPoint;
  66207. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66208. /**
  66209. * Exposes the properties to the UI?
  66210. */
  66211. protected _dumpPropertiesCode(): string;
  66212. /**
  66213. * Exposes the properties to the Seralize?
  66214. */
  66215. serialize(): any;
  66216. /**
  66217. * Exposes the properties to the deseralize?
  66218. */
  66219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66220. }
  66221. }
  66222. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  66223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66226. /**
  66227. * block used to Generate a Simplex Perlin 3d Noise Pattern
  66228. */
  66229. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  66230. /**
  66231. * Creates a new SimplexPerlin3DBlock
  66232. * @param name defines the block name
  66233. */
  66234. constructor(name: string);
  66235. /**
  66236. * Gets the current class name
  66237. * @returns the class name
  66238. */
  66239. getClassName(): string;
  66240. /**
  66241. * Gets the seed operand input component
  66242. */
  66243. get seed(): NodeMaterialConnectionPoint;
  66244. /**
  66245. * Gets the output component
  66246. */
  66247. get output(): NodeMaterialConnectionPoint;
  66248. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66249. }
  66250. }
  66251. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  66252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66255. /**
  66256. * Block used to blend normals
  66257. */
  66258. export class NormalBlendBlock extends NodeMaterialBlock {
  66259. /**
  66260. * Creates a new NormalBlendBlock
  66261. * @param name defines the block name
  66262. */
  66263. constructor(name: string);
  66264. /**
  66265. * Gets the current class name
  66266. * @returns the class name
  66267. */
  66268. getClassName(): string;
  66269. /**
  66270. * Gets the first input component
  66271. */
  66272. get normalMap0(): NodeMaterialConnectionPoint;
  66273. /**
  66274. * Gets the second input component
  66275. */
  66276. get normalMap1(): NodeMaterialConnectionPoint;
  66277. /**
  66278. * Gets the output component
  66279. */
  66280. get output(): NodeMaterialConnectionPoint;
  66281. protected _buildBlock(state: NodeMaterialBuildState): this;
  66282. }
  66283. }
  66284. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  66285. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66286. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66287. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66288. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66289. /**
  66290. * Block used to rotate a 2d vector by a given angle
  66291. */
  66292. export class Rotate2dBlock extends NodeMaterialBlock {
  66293. /**
  66294. * Creates a new Rotate2dBlock
  66295. * @param name defines the block name
  66296. */
  66297. constructor(name: string);
  66298. /**
  66299. * Gets the current class name
  66300. * @returns the class name
  66301. */
  66302. getClassName(): string;
  66303. /**
  66304. * Gets the input vector
  66305. */
  66306. get input(): NodeMaterialConnectionPoint;
  66307. /**
  66308. * Gets the input angle
  66309. */
  66310. get angle(): NodeMaterialConnectionPoint;
  66311. /**
  66312. * Gets the output component
  66313. */
  66314. get output(): NodeMaterialConnectionPoint;
  66315. autoConfigure(material: NodeMaterial): void;
  66316. protected _buildBlock(state: NodeMaterialBuildState): this;
  66317. }
  66318. }
  66319. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  66320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66323. /**
  66324. * Block used to get the reflected vector from a direction and a normal
  66325. */
  66326. export class ReflectBlock extends NodeMaterialBlock {
  66327. /**
  66328. * Creates a new ReflectBlock
  66329. * @param name defines the block name
  66330. */
  66331. constructor(name: string);
  66332. /**
  66333. * Gets the current class name
  66334. * @returns the class name
  66335. */
  66336. getClassName(): string;
  66337. /**
  66338. * Gets the incident component
  66339. */
  66340. get incident(): NodeMaterialConnectionPoint;
  66341. /**
  66342. * Gets the normal component
  66343. */
  66344. get normal(): NodeMaterialConnectionPoint;
  66345. /**
  66346. * Gets the output component
  66347. */
  66348. get output(): NodeMaterialConnectionPoint;
  66349. protected _buildBlock(state: NodeMaterialBuildState): this;
  66350. }
  66351. }
  66352. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  66353. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66354. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66355. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66356. /**
  66357. * Block used to get the refracted vector from a direction and a normal
  66358. */
  66359. export class RefractBlock extends NodeMaterialBlock {
  66360. /**
  66361. * Creates a new RefractBlock
  66362. * @param name defines the block name
  66363. */
  66364. constructor(name: string);
  66365. /**
  66366. * Gets the current class name
  66367. * @returns the class name
  66368. */
  66369. getClassName(): string;
  66370. /**
  66371. * Gets the incident component
  66372. */
  66373. get incident(): NodeMaterialConnectionPoint;
  66374. /**
  66375. * Gets the normal component
  66376. */
  66377. get normal(): NodeMaterialConnectionPoint;
  66378. /**
  66379. * Gets the index of refraction component
  66380. */
  66381. get ior(): NodeMaterialConnectionPoint;
  66382. /**
  66383. * Gets the output component
  66384. */
  66385. get output(): NodeMaterialConnectionPoint;
  66386. protected _buildBlock(state: NodeMaterialBuildState): this;
  66387. }
  66388. }
  66389. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  66390. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66391. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66392. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66393. /**
  66394. * Block used to desaturate a color
  66395. */
  66396. export class DesaturateBlock extends NodeMaterialBlock {
  66397. /**
  66398. * Creates a new DesaturateBlock
  66399. * @param name defines the block name
  66400. */
  66401. constructor(name: string);
  66402. /**
  66403. * Gets the current class name
  66404. * @returns the class name
  66405. */
  66406. getClassName(): string;
  66407. /**
  66408. * Gets the color operand input component
  66409. */
  66410. get color(): NodeMaterialConnectionPoint;
  66411. /**
  66412. * Gets the level operand input component
  66413. */
  66414. get level(): NodeMaterialConnectionPoint;
  66415. /**
  66416. * Gets the output component
  66417. */
  66418. get output(): NodeMaterialConnectionPoint;
  66419. protected _buildBlock(state: NodeMaterialBuildState): this;
  66420. }
  66421. }
  66422. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  66423. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66424. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66425. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66426. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66427. import { Nullable } from "babylonjs/types";
  66428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66429. import { Scene } from "babylonjs/scene";
  66430. /**
  66431. * Block used to implement the ambient occlusion module of the PBR material
  66432. */
  66433. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  66434. /**
  66435. * Create a new AmbientOcclusionBlock
  66436. * @param name defines the block name
  66437. */
  66438. constructor(name: string);
  66439. /**
  66440. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  66441. */
  66442. useAmbientInGrayScale: boolean;
  66443. /**
  66444. * Initialize the block and prepare the context for build
  66445. * @param state defines the state that will be used for the build
  66446. */
  66447. initialize(state: NodeMaterialBuildState): void;
  66448. /**
  66449. * Gets the current class name
  66450. * @returns the class name
  66451. */
  66452. getClassName(): string;
  66453. /**
  66454. * Gets the texture input component
  66455. */
  66456. get texture(): NodeMaterialConnectionPoint;
  66457. /**
  66458. * Gets the texture intensity component
  66459. */
  66460. get intensity(): NodeMaterialConnectionPoint;
  66461. /**
  66462. * Gets the direct light intensity input component
  66463. */
  66464. get directLightIntensity(): NodeMaterialConnectionPoint;
  66465. /**
  66466. * Gets the ambient occlusion object output component
  66467. */
  66468. get ambientOcclusion(): NodeMaterialConnectionPoint;
  66469. /**
  66470. * Gets the main code of the block (fragment side)
  66471. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  66472. * @returns the shader code
  66473. */
  66474. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  66475. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66476. protected _buildBlock(state: NodeMaterialBuildState): this;
  66477. protected _dumpPropertiesCode(): string;
  66478. serialize(): any;
  66479. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66480. }
  66481. }
  66482. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  66483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66485. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66486. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66487. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66488. import { Nullable } from "babylonjs/types";
  66489. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  66490. import { Mesh } from "babylonjs/Meshes/mesh";
  66491. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66492. import { Effect } from "babylonjs/Materials/effect";
  66493. import { Scene } from "babylonjs/scene";
  66494. /**
  66495. * Block used to implement the reflection module of the PBR material
  66496. */
  66497. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  66498. /** @hidden */
  66499. _defineLODReflectionAlpha: string;
  66500. /** @hidden */
  66501. _defineLinearSpecularReflection: string;
  66502. private _vEnvironmentIrradianceName;
  66503. /** @hidden */
  66504. _vReflectionMicrosurfaceInfosName: string;
  66505. /** @hidden */
  66506. _vReflectionInfosName: string;
  66507. /** @hidden */
  66508. _vReflectionFilteringInfoName: string;
  66509. private _scene;
  66510. /**
  66511. * The three properties below are set by the main PBR block prior to calling methods of this class.
  66512. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66513. * It's less burden on the user side in the editor part.
  66514. */
  66515. /** @hidden */
  66516. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66517. /** @hidden */
  66518. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66519. /** @hidden */
  66520. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  66521. /**
  66522. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  66523. * diffuse part of the IBL.
  66524. */
  66525. useSphericalHarmonics: boolean;
  66526. /**
  66527. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  66528. */
  66529. forceIrradianceInFragment: boolean;
  66530. /**
  66531. * Create a new ReflectionBlock
  66532. * @param name defines the block name
  66533. */
  66534. constructor(name: string);
  66535. /**
  66536. * Gets the current class name
  66537. * @returns the class name
  66538. */
  66539. getClassName(): string;
  66540. /**
  66541. * Gets the position input component
  66542. */
  66543. get position(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the world position input component
  66546. */
  66547. get worldPosition(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the world normal input component
  66550. */
  66551. get worldNormal(): NodeMaterialConnectionPoint;
  66552. /**
  66553. * Gets the world input component
  66554. */
  66555. get world(): NodeMaterialConnectionPoint;
  66556. /**
  66557. * Gets the camera (or eye) position component
  66558. */
  66559. get cameraPosition(): NodeMaterialConnectionPoint;
  66560. /**
  66561. * Gets the view input component
  66562. */
  66563. get view(): NodeMaterialConnectionPoint;
  66564. /**
  66565. * Gets the color input component
  66566. */
  66567. get color(): NodeMaterialConnectionPoint;
  66568. /**
  66569. * Gets the reflection object output component
  66570. */
  66571. get reflection(): NodeMaterialConnectionPoint;
  66572. /**
  66573. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  66574. */
  66575. get hasTexture(): boolean;
  66576. /**
  66577. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  66578. */
  66579. get reflectionColor(): string;
  66580. protected _getTexture(): Nullable<BaseTexture>;
  66581. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66582. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66583. /**
  66584. * Gets the code to inject in the vertex shader
  66585. * @param state current state of the node material building
  66586. * @returns the shader code
  66587. */
  66588. handleVertexSide(state: NodeMaterialBuildState): string;
  66589. /**
  66590. * Gets the main code of the block (fragment side)
  66591. * @param state current state of the node material building
  66592. * @param normalVarName name of the existing variable corresponding to the normal
  66593. * @returns the shader code
  66594. */
  66595. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  66596. protected _buildBlock(state: NodeMaterialBuildState): this;
  66597. protected _dumpPropertiesCode(): string;
  66598. serialize(): any;
  66599. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66600. }
  66601. }
  66602. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  66603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66606. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66608. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66609. import { Scene } from "babylonjs/scene";
  66610. import { Nullable } from "babylonjs/types";
  66611. /**
  66612. * Block used to implement the sheen module of the PBR material
  66613. */
  66614. export class SheenBlock extends NodeMaterialBlock {
  66615. /**
  66616. * Create a new SheenBlock
  66617. * @param name defines the block name
  66618. */
  66619. constructor(name: string);
  66620. /**
  66621. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  66622. * It allows the strength of the sheen effect to not depend on the base color of the material,
  66623. * making it easier to setup and tweak the effect
  66624. */
  66625. albedoScaling: boolean;
  66626. /**
  66627. * Defines if the sheen is linked to the sheen color.
  66628. */
  66629. linkSheenWithAlbedo: boolean;
  66630. /**
  66631. * Initialize the block and prepare the context for build
  66632. * @param state defines the state that will be used for the build
  66633. */
  66634. initialize(state: NodeMaterialBuildState): void;
  66635. /**
  66636. * Gets the current class name
  66637. * @returns the class name
  66638. */
  66639. getClassName(): string;
  66640. /**
  66641. * Gets the intensity input component
  66642. */
  66643. get intensity(): NodeMaterialConnectionPoint;
  66644. /**
  66645. * Gets the color input component
  66646. */
  66647. get color(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the roughness input component
  66650. */
  66651. get roughness(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the sheen object output component
  66654. */
  66655. get sheen(): NodeMaterialConnectionPoint;
  66656. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66657. /**
  66658. * Gets the main code of the block (fragment side)
  66659. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66660. * @returns the shader code
  66661. */
  66662. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  66663. protected _buildBlock(state: NodeMaterialBuildState): this;
  66664. protected _dumpPropertiesCode(): string;
  66665. serialize(): any;
  66666. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66667. }
  66668. }
  66669. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  66670. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66671. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66675. import { Scene } from "babylonjs/scene";
  66676. import { Nullable } from "babylonjs/types";
  66677. import { Mesh } from "babylonjs/Meshes/mesh";
  66678. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66679. import { Effect } from "babylonjs/Materials/effect";
  66680. /**
  66681. * Block used to implement the reflectivity module of the PBR material
  66682. */
  66683. export class ReflectivityBlock extends NodeMaterialBlock {
  66684. private _metallicReflectanceColor;
  66685. private _metallicF0Factor;
  66686. /** @hidden */
  66687. _vMetallicReflectanceFactorsName: string;
  66688. /**
  66689. * The property below is set by the main PBR block prior to calling methods of this class.
  66690. */
  66691. /** @hidden */
  66692. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  66693. /**
  66694. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  66695. */
  66696. useAmbientOcclusionFromMetallicTextureRed: boolean;
  66697. /**
  66698. * Specifies if the metallic texture contains the metallness information in its blue channel.
  66699. */
  66700. useMetallnessFromMetallicTextureBlue: boolean;
  66701. /**
  66702. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  66703. */
  66704. useRoughnessFromMetallicTextureAlpha: boolean;
  66705. /**
  66706. * Specifies if the metallic texture contains the roughness information in its green channel.
  66707. */
  66708. useRoughnessFromMetallicTextureGreen: boolean;
  66709. /**
  66710. * Create a new ReflectivityBlock
  66711. * @param name defines the block name
  66712. */
  66713. constructor(name: string);
  66714. /**
  66715. * Initialize the block and prepare the context for build
  66716. * @param state defines the state that will be used for the build
  66717. */
  66718. initialize(state: NodeMaterialBuildState): void;
  66719. /**
  66720. * Gets the current class name
  66721. * @returns the class name
  66722. */
  66723. getClassName(): string;
  66724. /**
  66725. * Gets the metallic input component
  66726. */
  66727. get metallic(): NodeMaterialConnectionPoint;
  66728. /**
  66729. * Gets the roughness input component
  66730. */
  66731. get roughness(): NodeMaterialConnectionPoint;
  66732. /**
  66733. * Gets the texture input component
  66734. */
  66735. get texture(): NodeMaterialConnectionPoint;
  66736. /**
  66737. * Gets the reflectivity object output component
  66738. */
  66739. get reflectivity(): NodeMaterialConnectionPoint;
  66740. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66741. /**
  66742. * Gets the main code of the block (fragment side)
  66743. * @param state current state of the node material building
  66744. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  66745. * @returns the shader code
  66746. */
  66747. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  66748. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66749. protected _buildBlock(state: NodeMaterialBuildState): this;
  66750. protected _dumpPropertiesCode(): string;
  66751. serialize(): any;
  66752. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66753. }
  66754. }
  66755. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  66756. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66757. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66758. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66759. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66761. /**
  66762. * Block used to implement the anisotropy module of the PBR material
  66763. */
  66764. export class AnisotropyBlock extends NodeMaterialBlock {
  66765. /**
  66766. * The two properties below are set by the main PBR block prior to calling methods of this class.
  66767. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  66768. * It's less burden on the user side in the editor part.
  66769. */
  66770. /** @hidden */
  66771. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  66772. /** @hidden */
  66773. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  66774. /**
  66775. * Create a new AnisotropyBlock
  66776. * @param name defines the block name
  66777. */
  66778. constructor(name: string);
  66779. /**
  66780. * Initialize the block and prepare the context for build
  66781. * @param state defines the state that will be used for the build
  66782. */
  66783. initialize(state: NodeMaterialBuildState): void;
  66784. /**
  66785. * Gets the current class name
  66786. * @returns the class name
  66787. */
  66788. getClassName(): string;
  66789. /**
  66790. * Gets the intensity input component
  66791. */
  66792. get intensity(): NodeMaterialConnectionPoint;
  66793. /**
  66794. * Gets the direction input component
  66795. */
  66796. get direction(): NodeMaterialConnectionPoint;
  66797. /**
  66798. * Gets the texture input component
  66799. */
  66800. get texture(): NodeMaterialConnectionPoint;
  66801. /**
  66802. * Gets the uv input component
  66803. */
  66804. get uv(): NodeMaterialConnectionPoint;
  66805. /**
  66806. * Gets the worldTangent input component
  66807. */
  66808. get worldTangent(): NodeMaterialConnectionPoint;
  66809. /**
  66810. * Gets the anisotropy object output component
  66811. */
  66812. get anisotropy(): NodeMaterialConnectionPoint;
  66813. private _generateTBNSpace;
  66814. /**
  66815. * Gets the main code of the block (fragment side)
  66816. * @param state current state of the node material building
  66817. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66818. * @returns the shader code
  66819. */
  66820. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  66821. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66822. protected _buildBlock(state: NodeMaterialBuildState): this;
  66823. }
  66824. }
  66825. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  66826. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66829. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66831. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66832. import { Nullable } from "babylonjs/types";
  66833. import { Mesh } from "babylonjs/Meshes/mesh";
  66834. import { SubMesh } from "babylonjs/Meshes/subMesh";
  66835. import { Effect } from "babylonjs/Materials/effect";
  66836. /**
  66837. * Block used to implement the clear coat module of the PBR material
  66838. */
  66839. export class ClearCoatBlock extends NodeMaterialBlock {
  66840. private _scene;
  66841. /**
  66842. * Create a new ClearCoatBlock
  66843. * @param name defines the block name
  66844. */
  66845. constructor(name: string);
  66846. /**
  66847. * Initialize the block and prepare the context for build
  66848. * @param state defines the state that will be used for the build
  66849. */
  66850. initialize(state: NodeMaterialBuildState): void;
  66851. /**
  66852. * Gets the current class name
  66853. * @returns the class name
  66854. */
  66855. getClassName(): string;
  66856. /**
  66857. * Gets the intensity input component
  66858. */
  66859. get intensity(): NodeMaterialConnectionPoint;
  66860. /**
  66861. * Gets the roughness input component
  66862. */
  66863. get roughness(): NodeMaterialConnectionPoint;
  66864. /**
  66865. * Gets the ior input component
  66866. */
  66867. get ior(): NodeMaterialConnectionPoint;
  66868. /**
  66869. * Gets the texture input component
  66870. */
  66871. get texture(): NodeMaterialConnectionPoint;
  66872. /**
  66873. * Gets the bump texture input component
  66874. */
  66875. get bumpTexture(): NodeMaterialConnectionPoint;
  66876. /**
  66877. * Gets the uv input component
  66878. */
  66879. get uv(): NodeMaterialConnectionPoint;
  66880. /**
  66881. * Gets the tint color input component
  66882. */
  66883. get tintColor(): NodeMaterialConnectionPoint;
  66884. /**
  66885. * Gets the tint "at distance" input component
  66886. */
  66887. get tintAtDistance(): NodeMaterialConnectionPoint;
  66888. /**
  66889. * Gets the tint thickness input component
  66890. */
  66891. get tintThickness(): NodeMaterialConnectionPoint;
  66892. /**
  66893. * Gets the world tangent input component
  66894. */
  66895. get worldTangent(): NodeMaterialConnectionPoint;
  66896. /**
  66897. * Gets the clear coat object output component
  66898. */
  66899. get clearcoat(): NodeMaterialConnectionPoint;
  66900. autoConfigure(material: NodeMaterial): void;
  66901. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66902. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  66903. private _generateTBNSpace;
  66904. /**
  66905. * Gets the main code of the block (fragment side)
  66906. * @param state current state of the node material building
  66907. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  66908. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66909. * @param worldPosVarName name of the variable holding the world position
  66910. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  66911. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  66912. * @param worldNormalVarName name of the variable holding the world normal
  66913. * @returns the shader code
  66914. */
  66915. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  66916. protected _buildBlock(state: NodeMaterialBuildState): this;
  66917. }
  66918. }
  66919. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  66920. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66921. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66922. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66923. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66925. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  66926. import { Nullable } from "babylonjs/types";
  66927. /**
  66928. * Block used to implement the sub surface module of the PBR material
  66929. */
  66930. export class SubSurfaceBlock extends NodeMaterialBlock {
  66931. /**
  66932. * Create a new SubSurfaceBlock
  66933. * @param name defines the block name
  66934. */
  66935. constructor(name: string);
  66936. /**
  66937. * Stores the intensity of the different subsurface effects in the thickness texture.
  66938. * * the green channel is the translucency intensity.
  66939. * * the blue channel is the scattering intensity.
  66940. * * the alpha channel is the refraction intensity.
  66941. */
  66942. useMaskFromThicknessTexture: boolean;
  66943. /**
  66944. * Initialize the block and prepare the context for build
  66945. * @param state defines the state that will be used for the build
  66946. */
  66947. initialize(state: NodeMaterialBuildState): void;
  66948. /**
  66949. * Gets the current class name
  66950. * @returns the class name
  66951. */
  66952. getClassName(): string;
  66953. /**
  66954. * Gets the min thickness input component
  66955. */
  66956. get minThickness(): NodeMaterialConnectionPoint;
  66957. /**
  66958. * Gets the max thickness input component
  66959. */
  66960. get maxThickness(): NodeMaterialConnectionPoint;
  66961. /**
  66962. * Gets the thickness texture component
  66963. */
  66964. get thicknessTexture(): NodeMaterialConnectionPoint;
  66965. /**
  66966. * Gets the tint color input component
  66967. */
  66968. get tintColor(): NodeMaterialConnectionPoint;
  66969. /**
  66970. * Gets the translucency intensity input component
  66971. */
  66972. get translucencyIntensity(): NodeMaterialConnectionPoint;
  66973. /**
  66974. * Gets the translucency diffusion distance input component
  66975. */
  66976. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  66977. /**
  66978. * Gets the refraction object parameters
  66979. */
  66980. get refraction(): NodeMaterialConnectionPoint;
  66981. /**
  66982. * Gets the sub surface object output component
  66983. */
  66984. get subsurface(): NodeMaterialConnectionPoint;
  66985. autoConfigure(material: NodeMaterial): void;
  66986. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66987. /**
  66988. * Gets the main code of the block (fragment side)
  66989. * @param state current state of the node material building
  66990. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  66991. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  66992. * @param worldPosVarName name of the variable holding the world position
  66993. * @returns the shader code
  66994. */
  66995. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  66996. protected _buildBlock(state: NodeMaterialBuildState): this;
  66997. }
  66998. }
  66999. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  67000. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67001. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67002. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67003. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67004. import { Light } from "babylonjs/Lights/light";
  67005. import { Nullable } from "babylonjs/types";
  67006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67007. import { Effect } from "babylonjs/Materials/effect";
  67008. import { Mesh } from "babylonjs/Meshes/mesh";
  67009. import { Scene } from "babylonjs/scene";
  67010. /**
  67011. * Block used to implement the PBR metallic/roughness model
  67012. */
  67013. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  67014. /**
  67015. * Gets or sets the light associated with this block
  67016. */
  67017. light: Nullable<Light>;
  67018. private _lightId;
  67019. private _scene;
  67020. private _environmentBRDFTexture;
  67021. private _environmentBrdfSamplerName;
  67022. private _vNormalWName;
  67023. private _invertNormalName;
  67024. /**
  67025. * Create a new ReflectionBlock
  67026. * @param name defines the block name
  67027. */
  67028. constructor(name: string);
  67029. /**
  67030. * Intensity of the direct lights e.g. the four lights available in your scene.
  67031. * This impacts both the direct diffuse and specular highlights.
  67032. */
  67033. directIntensity: number;
  67034. /**
  67035. * Intensity of the environment e.g. how much the environment will light the object
  67036. * either through harmonics for rough material or through the refelction for shiny ones.
  67037. */
  67038. environmentIntensity: number;
  67039. /**
  67040. * This is a special control allowing the reduction of the specular highlights coming from the
  67041. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  67042. */
  67043. specularIntensity: number;
  67044. /**
  67045. * Defines the falloff type used in this material.
  67046. * It by default is Physical.
  67047. */
  67048. lightFalloff: number;
  67049. /**
  67050. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  67051. */
  67052. useAlphaFromAlbedoTexture: boolean;
  67053. /**
  67054. * Specifies that alpha test should be used
  67055. */
  67056. useAlphaTest: boolean;
  67057. /**
  67058. * Defines the alpha limits in alpha test mode.
  67059. */
  67060. alphaTestCutoff: number;
  67061. /**
  67062. * Specifies that alpha blending should be used
  67063. */
  67064. useAlphaBlending: boolean;
  67065. /**
  67066. * Defines if the alpha value should be determined via the rgb values.
  67067. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  67068. */
  67069. opacityRGB: boolean;
  67070. /**
  67071. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  67072. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  67073. */
  67074. useRadianceOverAlpha: boolean;
  67075. /**
  67076. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  67077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  67078. */
  67079. useSpecularOverAlpha: boolean;
  67080. /**
  67081. * Enables specular anti aliasing in the PBR shader.
  67082. * It will both interacts on the Geometry for analytical and IBL lighting.
  67083. * It also prefilter the roughness map based on the bump values.
  67084. */
  67085. enableSpecularAntiAliasing: boolean;
  67086. /**
  67087. * Enables realtime filtering on the texture.
  67088. */
  67089. realTimeFiltering: boolean;
  67090. /**
  67091. * Quality switch for realtime filtering
  67092. */
  67093. realTimeFilteringQuality: number;
  67094. /**
  67095. * Defines if the material uses energy conservation.
  67096. */
  67097. useEnergyConservation: boolean;
  67098. /**
  67099. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  67100. * too much the area relying on ambient texture to define their ambient occlusion.
  67101. */
  67102. useRadianceOcclusion: boolean;
  67103. /**
  67104. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  67105. * makes the reflect vector face the model (under horizon).
  67106. */
  67107. useHorizonOcclusion: boolean;
  67108. /**
  67109. * If set to true, no lighting calculations will be applied.
  67110. */
  67111. unlit: boolean;
  67112. /**
  67113. * Force normal to face away from face.
  67114. */
  67115. forceNormalForward: boolean;
  67116. /**
  67117. * Defines the material debug mode.
  67118. * It helps seeing only some components of the material while troubleshooting.
  67119. */
  67120. debugMode: number;
  67121. /**
  67122. * Specify from where on screen the debug mode should start.
  67123. * The value goes from -1 (full screen) to 1 (not visible)
  67124. * It helps with side by side comparison against the final render
  67125. * This defaults to 0
  67126. */
  67127. debugLimit: number;
  67128. /**
  67129. * As the default viewing range might not be enough (if the ambient is really small for instance)
  67130. * You can use the factor to better multiply the final value.
  67131. */
  67132. debugFactor: number;
  67133. /**
  67134. * Initialize the block and prepare the context for build
  67135. * @param state defines the state that will be used for the build
  67136. */
  67137. initialize(state: NodeMaterialBuildState): void;
  67138. /**
  67139. * Gets the current class name
  67140. * @returns the class name
  67141. */
  67142. getClassName(): string;
  67143. /**
  67144. * Gets the world position input component
  67145. */
  67146. get worldPosition(): NodeMaterialConnectionPoint;
  67147. /**
  67148. * Gets the world normal input component
  67149. */
  67150. get worldNormal(): NodeMaterialConnectionPoint;
  67151. /**
  67152. * Gets the perturbed normal input component
  67153. */
  67154. get perturbedNormal(): NodeMaterialConnectionPoint;
  67155. /**
  67156. * Gets the camera position input component
  67157. */
  67158. get cameraPosition(): NodeMaterialConnectionPoint;
  67159. /**
  67160. * Gets the base color input component
  67161. */
  67162. get baseColor(): NodeMaterialConnectionPoint;
  67163. /**
  67164. * Gets the opacity texture input component
  67165. */
  67166. get opacityTexture(): NodeMaterialConnectionPoint;
  67167. /**
  67168. * Gets the ambient color input component
  67169. */
  67170. get ambientColor(): NodeMaterialConnectionPoint;
  67171. /**
  67172. * Gets the reflectivity object parameters
  67173. */
  67174. get reflectivity(): NodeMaterialConnectionPoint;
  67175. /**
  67176. * Gets the ambient occlusion object parameters
  67177. */
  67178. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67179. /**
  67180. * Gets the reflection object parameters
  67181. */
  67182. get reflection(): NodeMaterialConnectionPoint;
  67183. /**
  67184. * Gets the sheen object parameters
  67185. */
  67186. get sheen(): NodeMaterialConnectionPoint;
  67187. /**
  67188. * Gets the clear coat object parameters
  67189. */
  67190. get clearcoat(): NodeMaterialConnectionPoint;
  67191. /**
  67192. * Gets the sub surface object parameters
  67193. */
  67194. get subsurface(): NodeMaterialConnectionPoint;
  67195. /**
  67196. * Gets the anisotropy object parameters
  67197. */
  67198. get anisotropy(): NodeMaterialConnectionPoint;
  67199. /**
  67200. * Gets the ambient output component
  67201. */
  67202. get ambient(): NodeMaterialConnectionPoint;
  67203. /**
  67204. * Gets the diffuse output component
  67205. */
  67206. get diffuse(): NodeMaterialConnectionPoint;
  67207. /**
  67208. * Gets the specular output component
  67209. */
  67210. get specular(): NodeMaterialConnectionPoint;
  67211. /**
  67212. * Gets the sheen output component
  67213. */
  67214. get sheenDir(): NodeMaterialConnectionPoint;
  67215. /**
  67216. * Gets the clear coat output component
  67217. */
  67218. get clearcoatDir(): NodeMaterialConnectionPoint;
  67219. /**
  67220. * Gets the indirect diffuse output component
  67221. */
  67222. get diffuseIndirect(): NodeMaterialConnectionPoint;
  67223. /**
  67224. * Gets the indirect specular output component
  67225. */
  67226. get specularIndirect(): NodeMaterialConnectionPoint;
  67227. /**
  67228. * Gets the indirect sheen output component
  67229. */
  67230. get sheenIndirect(): NodeMaterialConnectionPoint;
  67231. /**
  67232. * Gets the indirect clear coat output component
  67233. */
  67234. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  67235. /**
  67236. * Gets the refraction output component
  67237. */
  67238. get refraction(): NodeMaterialConnectionPoint;
  67239. /**
  67240. * Gets the global lighting output component
  67241. */
  67242. get lighting(): NodeMaterialConnectionPoint;
  67243. /**
  67244. * Gets the shadow output component
  67245. */
  67246. get shadow(): NodeMaterialConnectionPoint;
  67247. /**
  67248. * Gets the alpha output component
  67249. */
  67250. get alpha(): NodeMaterialConnectionPoint;
  67251. autoConfigure(material: NodeMaterial): void;
  67252. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67253. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  67254. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  67255. private _injectVertexCode;
  67256. /**
  67257. * Gets the code corresponding to the albedo/opacity module
  67258. * @returns the shader code
  67259. */
  67260. getAlbedoOpacityCode(): string;
  67261. protected _buildBlock(state: NodeMaterialBuildState): this;
  67262. protected _dumpPropertiesCode(): string;
  67263. serialize(): any;
  67264. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67265. }
  67266. }
  67267. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  67268. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  67269. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  67270. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  67271. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  67272. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  67273. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67274. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  67275. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  67276. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  67277. }
  67278. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  67279. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  67280. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  67281. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  67282. }
  67283. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  67284. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67285. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67286. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67287. /**
  67288. * Block used to compute value of one parameter modulo another
  67289. */
  67290. export class ModBlock extends NodeMaterialBlock {
  67291. /**
  67292. * Creates a new ModBlock
  67293. * @param name defines the block name
  67294. */
  67295. constructor(name: string);
  67296. /**
  67297. * Gets the current class name
  67298. * @returns the class name
  67299. */
  67300. getClassName(): string;
  67301. /**
  67302. * Gets the left operand input component
  67303. */
  67304. get left(): NodeMaterialConnectionPoint;
  67305. /**
  67306. * Gets the right operand input component
  67307. */
  67308. get right(): NodeMaterialConnectionPoint;
  67309. /**
  67310. * Gets the output component
  67311. */
  67312. get output(): NodeMaterialConnectionPoint;
  67313. protected _buildBlock(state: NodeMaterialBuildState): this;
  67314. }
  67315. }
  67316. declare module "babylonjs/Materials/Node/Blocks/index" {
  67317. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  67318. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  67319. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  67320. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  67321. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  67322. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  67323. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  67324. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  67325. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  67326. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  67327. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  67328. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  67329. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  67330. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  67331. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  67332. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  67333. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  67334. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  67335. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  67336. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  67337. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  67338. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  67339. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  67340. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  67341. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  67342. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  67343. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  67344. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  67345. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  67346. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  67347. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  67348. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  67349. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  67350. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  67351. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  67352. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  67353. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  67354. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  67355. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  67356. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  67357. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  67358. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  67359. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  67360. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  67361. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  67362. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  67363. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  67364. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  67365. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  67366. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  67367. }
  67368. declare module "babylonjs/Materials/Node/Optimizers/index" {
  67369. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  67370. }
  67371. declare module "babylonjs/Materials/Node/index" {
  67372. export * from "babylonjs/Materials/Node/Enums/index";
  67373. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67374. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  67375. export * from "babylonjs/Materials/Node/nodeMaterial";
  67376. export * from "babylonjs/Materials/Node/Blocks/index";
  67377. export * from "babylonjs/Materials/Node/Optimizers/index";
  67378. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  67379. }
  67380. declare module "babylonjs/Materials/index" {
  67381. export * from "babylonjs/Materials/Background/index";
  67382. export * from "babylonjs/Materials/colorCurves";
  67383. export * from "babylonjs/Materials/iEffectFallbacks";
  67384. export * from "babylonjs/Materials/effectFallbacks";
  67385. export * from "babylonjs/Materials/effect";
  67386. export * from "babylonjs/Materials/fresnelParameters";
  67387. export * from "babylonjs/Materials/imageProcessingConfiguration";
  67388. export * from "babylonjs/Materials/material";
  67389. export * from "babylonjs/Materials/materialDefines";
  67390. export * from "babylonjs/Materials/materialHelper";
  67391. export * from "babylonjs/Materials/multiMaterial";
  67392. export * from "babylonjs/Materials/PBR/index";
  67393. export * from "babylonjs/Materials/pushMaterial";
  67394. export * from "babylonjs/Materials/shaderMaterial";
  67395. export * from "babylonjs/Materials/standardMaterial";
  67396. export * from "babylonjs/Materials/Textures/index";
  67397. export * from "babylonjs/Materials/uniformBuffer";
  67398. export * from "babylonjs/Materials/materialFlags";
  67399. export * from "babylonjs/Materials/Node/index";
  67400. export * from "babylonjs/Materials/effectRenderer";
  67401. export * from "babylonjs/Materials/shadowDepthWrapper";
  67402. }
  67403. declare module "babylonjs/Maths/index" {
  67404. export * from "babylonjs/Maths/math.scalar";
  67405. export * from "babylonjs/Maths/math";
  67406. export * from "babylonjs/Maths/sphericalPolynomial";
  67407. }
  67408. declare module "babylonjs/Misc/workerPool" {
  67409. import { IDisposable } from "babylonjs/scene";
  67410. /**
  67411. * Helper class to push actions to a pool of workers.
  67412. */
  67413. export class WorkerPool implements IDisposable {
  67414. private _workerInfos;
  67415. private _pendingActions;
  67416. /**
  67417. * Constructor
  67418. * @param workers Array of workers to use for actions
  67419. */
  67420. constructor(workers: Array<Worker>);
  67421. /**
  67422. * Terminates all workers and clears any pending actions.
  67423. */
  67424. dispose(): void;
  67425. /**
  67426. * Pushes an action to the worker pool. If all the workers are active, the action will be
  67427. * pended until a worker has completed its action.
  67428. * @param action The action to perform. Call onComplete when the action is complete.
  67429. */
  67430. push(action: (worker: Worker, onComplete: () => void) => void): void;
  67431. private _execute;
  67432. }
  67433. }
  67434. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  67435. import { IDisposable } from "babylonjs/scene";
  67436. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67437. /**
  67438. * Configuration for Draco compression
  67439. */
  67440. export interface IDracoCompressionConfiguration {
  67441. /**
  67442. * Configuration for the decoder.
  67443. */
  67444. decoder: {
  67445. /**
  67446. * The url to the WebAssembly module.
  67447. */
  67448. wasmUrl?: string;
  67449. /**
  67450. * The url to the WebAssembly binary.
  67451. */
  67452. wasmBinaryUrl?: string;
  67453. /**
  67454. * The url to the fallback JavaScript module.
  67455. */
  67456. fallbackUrl?: string;
  67457. };
  67458. }
  67459. /**
  67460. * Draco compression (https://google.github.io/draco/)
  67461. *
  67462. * This class wraps the Draco module.
  67463. *
  67464. * **Encoder**
  67465. *
  67466. * The encoder is not currently implemented.
  67467. *
  67468. * **Decoder**
  67469. *
  67470. * 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.
  67471. *
  67472. * To update the configuration, use the following code:
  67473. * ```javascript
  67474. * DracoCompression.Configuration = {
  67475. * decoder: {
  67476. * wasmUrl: "<url to the WebAssembly library>",
  67477. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  67478. * fallbackUrl: "<url to the fallback JavaScript library>",
  67479. * }
  67480. * };
  67481. * ```
  67482. *
  67483. * 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.
  67484. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  67485. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  67486. *
  67487. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  67488. * ```javascript
  67489. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  67490. * ```
  67491. *
  67492. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  67493. */
  67494. export class DracoCompression implements IDisposable {
  67495. private _workerPoolPromise?;
  67496. private _decoderModulePromise?;
  67497. /**
  67498. * The configuration. Defaults to the following urls:
  67499. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  67500. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  67501. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  67502. */
  67503. static Configuration: IDracoCompressionConfiguration;
  67504. /**
  67505. * Returns true if the decoder configuration is available.
  67506. */
  67507. static get DecoderAvailable(): boolean;
  67508. /**
  67509. * Default number of workers to create when creating the draco compression object.
  67510. */
  67511. static DefaultNumWorkers: number;
  67512. private static GetDefaultNumWorkers;
  67513. private static _Default;
  67514. /**
  67515. * Default instance for the draco compression object.
  67516. */
  67517. static get Default(): DracoCompression;
  67518. /**
  67519. * Constructor
  67520. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  67521. */
  67522. constructor(numWorkers?: number);
  67523. /**
  67524. * Stop all async operations and release resources.
  67525. */
  67526. dispose(): void;
  67527. /**
  67528. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  67529. * @returns a promise that resolves when ready
  67530. */
  67531. whenReadyAsync(): Promise<void>;
  67532. /**
  67533. * Decode Draco compressed mesh data to vertex data.
  67534. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  67535. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  67536. * @returns A promise that resolves with the decoded vertex data
  67537. */
  67538. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  67539. [kind: string]: number;
  67540. }): Promise<VertexData>;
  67541. }
  67542. }
  67543. declare module "babylonjs/Meshes/Compression/index" {
  67544. export * from "babylonjs/Meshes/Compression/dracoCompression";
  67545. }
  67546. declare module "babylonjs/Meshes/csg" {
  67547. import { Nullable } from "babylonjs/types";
  67548. import { Scene } from "babylonjs/scene";
  67549. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  67550. import { Mesh } from "babylonjs/Meshes/mesh";
  67551. import { Material } from "babylonjs/Materials/material";
  67552. /**
  67553. * Class for building Constructive Solid Geometry
  67554. */
  67555. export class CSG {
  67556. private polygons;
  67557. /**
  67558. * The world matrix
  67559. */
  67560. matrix: Matrix;
  67561. /**
  67562. * Stores the position
  67563. */
  67564. position: Vector3;
  67565. /**
  67566. * Stores the rotation
  67567. */
  67568. rotation: Vector3;
  67569. /**
  67570. * Stores the rotation quaternion
  67571. */
  67572. rotationQuaternion: Nullable<Quaternion>;
  67573. /**
  67574. * Stores the scaling vector
  67575. */
  67576. scaling: Vector3;
  67577. /**
  67578. * Convert the Mesh to CSG
  67579. * @param mesh The Mesh to convert to CSG
  67580. * @returns A new CSG from the Mesh
  67581. */
  67582. static FromMesh(mesh: Mesh): CSG;
  67583. /**
  67584. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  67585. * @param polygons Polygons used to construct a CSG solid
  67586. */
  67587. private static FromPolygons;
  67588. /**
  67589. * Clones, or makes a deep copy, of the CSG
  67590. * @returns A new CSG
  67591. */
  67592. clone(): CSG;
  67593. /**
  67594. * Unions this CSG with another CSG
  67595. * @param csg The CSG to union against this CSG
  67596. * @returns The unioned CSG
  67597. */
  67598. union(csg: CSG): CSG;
  67599. /**
  67600. * Unions this CSG with another CSG in place
  67601. * @param csg The CSG to union against this CSG
  67602. */
  67603. unionInPlace(csg: CSG): void;
  67604. /**
  67605. * Subtracts this CSG with another CSG
  67606. * @param csg The CSG to subtract against this CSG
  67607. * @returns A new CSG
  67608. */
  67609. subtract(csg: CSG): CSG;
  67610. /**
  67611. * Subtracts this CSG with another CSG in place
  67612. * @param csg The CSG to subtact against this CSG
  67613. */
  67614. subtractInPlace(csg: CSG): void;
  67615. /**
  67616. * Intersect this CSG with another CSG
  67617. * @param csg The CSG to intersect against this CSG
  67618. * @returns A new CSG
  67619. */
  67620. intersect(csg: CSG): CSG;
  67621. /**
  67622. * Intersects this CSG with another CSG in place
  67623. * @param csg The CSG to intersect against this CSG
  67624. */
  67625. intersectInPlace(csg: CSG): void;
  67626. /**
  67627. * Return a new CSG solid with solid and empty space switched. This solid is
  67628. * not modified.
  67629. * @returns A new CSG solid with solid and empty space switched
  67630. */
  67631. inverse(): CSG;
  67632. /**
  67633. * Inverses the CSG in place
  67634. */
  67635. inverseInPlace(): void;
  67636. /**
  67637. * This is used to keep meshes transformations so they can be restored
  67638. * when we build back a Babylon Mesh
  67639. * NB : All CSG operations are performed in world coordinates
  67640. * @param csg The CSG to copy the transform attributes from
  67641. * @returns This CSG
  67642. */
  67643. copyTransformAttributes(csg: CSG): CSG;
  67644. /**
  67645. * Build Raw mesh from CSG
  67646. * Coordinates here are in world space
  67647. * @param name The name of the mesh geometry
  67648. * @param scene The Scene
  67649. * @param keepSubMeshes Specifies if the submeshes should be kept
  67650. * @returns A new Mesh
  67651. */
  67652. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67653. /**
  67654. * Build Mesh from CSG taking material and transforms into account
  67655. * @param name The name of the Mesh
  67656. * @param material The material of the Mesh
  67657. * @param scene The Scene
  67658. * @param keepSubMeshes Specifies if submeshes should be kept
  67659. * @returns The new Mesh
  67660. */
  67661. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  67662. }
  67663. }
  67664. declare module "babylonjs/Meshes/trailMesh" {
  67665. import { Mesh } from "babylonjs/Meshes/mesh";
  67666. import { Scene } from "babylonjs/scene";
  67667. import { TransformNode } from "babylonjs/Meshes/transformNode";
  67668. /**
  67669. * Class used to create a trail following a mesh
  67670. */
  67671. export class TrailMesh extends Mesh {
  67672. private _generator;
  67673. private _autoStart;
  67674. private _running;
  67675. private _diameter;
  67676. private _length;
  67677. private _sectionPolygonPointsCount;
  67678. private _sectionVectors;
  67679. private _sectionNormalVectors;
  67680. private _beforeRenderObserver;
  67681. /**
  67682. * @constructor
  67683. * @param name The value used by scene.getMeshByName() to do a lookup.
  67684. * @param generator The mesh or transform node to generate a trail.
  67685. * @param scene The scene to add this mesh to.
  67686. * @param diameter Diameter of trailing mesh. Default is 1.
  67687. * @param length Length of trailing mesh. Default is 60.
  67688. * @param autoStart Automatically start trailing mesh. Default true.
  67689. */
  67690. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  67691. /**
  67692. * "TrailMesh"
  67693. * @returns "TrailMesh"
  67694. */
  67695. getClassName(): string;
  67696. private _createMesh;
  67697. /**
  67698. * Start trailing mesh.
  67699. */
  67700. start(): void;
  67701. /**
  67702. * Stop trailing mesh.
  67703. */
  67704. stop(): void;
  67705. /**
  67706. * Update trailing mesh geometry.
  67707. */
  67708. update(): void;
  67709. /**
  67710. * Returns a new TrailMesh object.
  67711. * @param name is a string, the name given to the new mesh
  67712. * @param newGenerator use new generator object for cloned trail mesh
  67713. * @returns a new mesh
  67714. */
  67715. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  67716. /**
  67717. * Serializes this trail mesh
  67718. * @param serializationObject object to write serialization to
  67719. */
  67720. serialize(serializationObject: any): void;
  67721. /**
  67722. * Parses a serialized trail mesh
  67723. * @param parsedMesh the serialized mesh
  67724. * @param scene the scene to create the trail mesh in
  67725. * @returns the created trail mesh
  67726. */
  67727. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  67728. }
  67729. }
  67730. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  67731. import { Nullable } from "babylonjs/types";
  67732. import { Scene } from "babylonjs/scene";
  67733. import { Vector4 } from "babylonjs/Maths/math.vector";
  67734. import { Color4 } from "babylonjs/Maths/math.color";
  67735. import { Mesh } from "babylonjs/Meshes/mesh";
  67736. /**
  67737. * Class containing static functions to help procedurally build meshes
  67738. */
  67739. export class TiledBoxBuilder {
  67740. /**
  67741. * Creates a box mesh
  67742. * 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)
  67743. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67744. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67745. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67746. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67747. * @param name defines the name of the mesh
  67748. * @param options defines the options used to create the mesh
  67749. * @param scene defines the hosting scene
  67750. * @returns the box mesh
  67751. */
  67752. static CreateTiledBox(name: string, options: {
  67753. pattern?: number;
  67754. width?: number;
  67755. height?: number;
  67756. depth?: number;
  67757. tileSize?: number;
  67758. tileWidth?: number;
  67759. tileHeight?: number;
  67760. alignHorizontal?: number;
  67761. alignVertical?: number;
  67762. faceUV?: Vector4[];
  67763. faceColors?: Color4[];
  67764. sideOrientation?: number;
  67765. updatable?: boolean;
  67766. }, scene?: Nullable<Scene>): Mesh;
  67767. }
  67768. }
  67769. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  67770. import { Vector4 } from "babylonjs/Maths/math.vector";
  67771. import { Mesh } from "babylonjs/Meshes/mesh";
  67772. /**
  67773. * Class containing static functions to help procedurally build meshes
  67774. */
  67775. export class TorusKnotBuilder {
  67776. /**
  67777. * Creates a torus knot mesh
  67778. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  67779. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  67780. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  67781. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  67782. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67783. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67784. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  67785. * @param name defines the name of the mesh
  67786. * @param options defines the options used to create the mesh
  67787. * @param scene defines the hosting scene
  67788. * @returns the torus knot mesh
  67789. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  67790. */
  67791. static CreateTorusKnot(name: string, options: {
  67792. radius?: number;
  67793. tube?: number;
  67794. radialSegments?: number;
  67795. tubularSegments?: number;
  67796. p?: number;
  67797. q?: number;
  67798. updatable?: boolean;
  67799. sideOrientation?: number;
  67800. frontUVs?: Vector4;
  67801. backUVs?: Vector4;
  67802. }, scene: any): Mesh;
  67803. }
  67804. }
  67805. declare module "babylonjs/Meshes/polygonMesh" {
  67806. import { Scene } from "babylonjs/scene";
  67807. import { Vector2 } from "babylonjs/Maths/math.vector";
  67808. import { Mesh } from "babylonjs/Meshes/mesh";
  67809. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  67810. import { Path2 } from "babylonjs/Maths/math.path";
  67811. /**
  67812. * Polygon
  67813. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  67814. */
  67815. export class Polygon {
  67816. /**
  67817. * Creates a rectangle
  67818. * @param xmin bottom X coord
  67819. * @param ymin bottom Y coord
  67820. * @param xmax top X coord
  67821. * @param ymax top Y coord
  67822. * @returns points that make the resulting rectation
  67823. */
  67824. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  67825. /**
  67826. * Creates a circle
  67827. * @param radius radius of circle
  67828. * @param cx scale in x
  67829. * @param cy scale in y
  67830. * @param numberOfSides number of sides that make up the circle
  67831. * @returns points that make the resulting circle
  67832. */
  67833. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  67834. /**
  67835. * Creates a polygon from input string
  67836. * @param input Input polygon data
  67837. * @returns the parsed points
  67838. */
  67839. static Parse(input: string): Vector2[];
  67840. /**
  67841. * Starts building a polygon from x and y coordinates
  67842. * @param x x coordinate
  67843. * @param y y coordinate
  67844. * @returns the started path2
  67845. */
  67846. static StartingAt(x: number, y: number): Path2;
  67847. }
  67848. /**
  67849. * Builds a polygon
  67850. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  67851. */
  67852. export class PolygonMeshBuilder {
  67853. private _points;
  67854. private _outlinepoints;
  67855. private _holes;
  67856. private _name;
  67857. private _scene;
  67858. private _epoints;
  67859. private _eholes;
  67860. private _addToepoint;
  67861. /**
  67862. * Babylon reference to the earcut plugin.
  67863. */
  67864. bjsEarcut: any;
  67865. /**
  67866. * Creates a PolygonMeshBuilder
  67867. * @param name name of the builder
  67868. * @param contours Path of the polygon
  67869. * @param scene scene to add to when creating the mesh
  67870. * @param earcutInjection can be used to inject your own earcut reference
  67871. */
  67872. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  67873. /**
  67874. * Adds a whole within the polygon
  67875. * @param hole Array of points defining the hole
  67876. * @returns this
  67877. */
  67878. addHole(hole: Vector2[]): PolygonMeshBuilder;
  67879. /**
  67880. * Creates the polygon
  67881. * @param updatable If the mesh should be updatable
  67882. * @param depth The depth of the mesh created
  67883. * @returns the created mesh
  67884. */
  67885. build(updatable?: boolean, depth?: number): Mesh;
  67886. /**
  67887. * Creates the polygon
  67888. * @param depth The depth of the mesh created
  67889. * @returns the created VertexData
  67890. */
  67891. buildVertexData(depth?: number): VertexData;
  67892. /**
  67893. * Adds a side to the polygon
  67894. * @param positions points that make the polygon
  67895. * @param normals normals of the polygon
  67896. * @param uvs uvs of the polygon
  67897. * @param indices indices of the polygon
  67898. * @param bounds bounds of the polygon
  67899. * @param points points of the polygon
  67900. * @param depth depth of the polygon
  67901. * @param flip flip of the polygon
  67902. */
  67903. private addSide;
  67904. }
  67905. }
  67906. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  67907. import { Scene } from "babylonjs/scene";
  67908. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67909. import { Color4 } from "babylonjs/Maths/math.color";
  67910. import { Mesh } from "babylonjs/Meshes/mesh";
  67911. import { Nullable } from "babylonjs/types";
  67912. /**
  67913. * Class containing static functions to help procedurally build meshes
  67914. */
  67915. export class PolygonBuilder {
  67916. /**
  67917. * Creates a polygon mesh
  67918. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  67919. * * 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
  67920. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  67921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67922. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  67923. * * Remember you can only change the shape positions, not their number when updating a polygon
  67924. * @param name defines the name of the mesh
  67925. * @param options defines the options used to create the mesh
  67926. * @param scene defines the hosting scene
  67927. * @param earcutInjection can be used to inject your own earcut reference
  67928. * @returns the polygon mesh
  67929. */
  67930. static CreatePolygon(name: string, options: {
  67931. shape: Vector3[];
  67932. holes?: Vector3[][];
  67933. depth?: number;
  67934. faceUV?: Vector4[];
  67935. faceColors?: Color4[];
  67936. updatable?: boolean;
  67937. sideOrientation?: number;
  67938. frontUVs?: Vector4;
  67939. backUVs?: Vector4;
  67940. wrap?: boolean;
  67941. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67942. /**
  67943. * Creates an extruded polygon mesh, with depth in the Y direction.
  67944. * * 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)
  67945. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  67946. * @param name defines the name of the mesh
  67947. * @param options defines the options used to create the mesh
  67948. * @param scene defines the hosting scene
  67949. * @param earcutInjection can be used to inject your own earcut reference
  67950. * @returns the polygon mesh
  67951. */
  67952. static ExtrudePolygon(name: string, options: {
  67953. shape: Vector3[];
  67954. holes?: Vector3[][];
  67955. depth?: number;
  67956. faceUV?: Vector4[];
  67957. faceColors?: Color4[];
  67958. updatable?: boolean;
  67959. sideOrientation?: number;
  67960. frontUVs?: Vector4;
  67961. backUVs?: Vector4;
  67962. wrap?: boolean;
  67963. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  67964. }
  67965. }
  67966. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  67967. import { Scene } from "babylonjs/scene";
  67968. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  67969. import { Mesh } from "babylonjs/Meshes/mesh";
  67970. import { Nullable } from "babylonjs/types";
  67971. /**
  67972. * Class containing static functions to help procedurally build meshes
  67973. */
  67974. export class LatheBuilder {
  67975. /**
  67976. * Creates lathe mesh.
  67977. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  67978. * * 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
  67979. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  67980. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  67981. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  67982. * * 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
  67983. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  67984. * * 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
  67985. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67986. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  67987. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  67988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67989. * @param name defines the name of the mesh
  67990. * @param options defines the options used to create the mesh
  67991. * @param scene defines the hosting scene
  67992. * @returns the lathe mesh
  67993. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  67994. */
  67995. static CreateLathe(name: string, options: {
  67996. shape: Vector3[];
  67997. radius?: number;
  67998. tessellation?: number;
  67999. clip?: number;
  68000. arc?: number;
  68001. closed?: boolean;
  68002. updatable?: boolean;
  68003. sideOrientation?: number;
  68004. frontUVs?: Vector4;
  68005. backUVs?: Vector4;
  68006. cap?: number;
  68007. invertUV?: boolean;
  68008. }, scene?: Nullable<Scene>): Mesh;
  68009. }
  68010. }
  68011. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  68012. import { Nullable } from "babylonjs/types";
  68013. import { Scene } from "babylonjs/scene";
  68014. import { Vector4 } from "babylonjs/Maths/math.vector";
  68015. import { Mesh } from "babylonjs/Meshes/mesh";
  68016. /**
  68017. * Class containing static functions to help procedurally build meshes
  68018. */
  68019. export class TiledPlaneBuilder {
  68020. /**
  68021. * Creates a tiled plane mesh
  68022. * * The parameter `pattern` will, depending on value, do nothing or
  68023. * * * flip (reflect about central vertical) alternate tiles across and up
  68024. * * * flip every tile on alternate rows
  68025. * * * rotate (180 degs) alternate tiles across and up
  68026. * * * rotate every tile on alternate rows
  68027. * * * flip and rotate alternate tiles across and up
  68028. * * * flip and rotate every tile on alternate rows
  68029. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  68030. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  68031. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68032. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68033. * * 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)
  68034. * * 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)
  68035. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68036. * @param name defines the name of the mesh
  68037. * @param options defines the options used to create the mesh
  68038. * @param scene defines the hosting scene
  68039. * @returns the box mesh
  68040. */
  68041. static CreateTiledPlane(name: string, options: {
  68042. pattern?: number;
  68043. tileSize?: number;
  68044. tileWidth?: number;
  68045. tileHeight?: number;
  68046. size?: number;
  68047. width?: number;
  68048. height?: number;
  68049. alignHorizontal?: number;
  68050. alignVertical?: number;
  68051. sideOrientation?: number;
  68052. frontUVs?: Vector4;
  68053. backUVs?: Vector4;
  68054. updatable?: boolean;
  68055. }, scene?: Nullable<Scene>): Mesh;
  68056. }
  68057. }
  68058. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  68059. import { Nullable } from "babylonjs/types";
  68060. import { Scene } from "babylonjs/scene";
  68061. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  68062. import { Mesh } from "babylonjs/Meshes/mesh";
  68063. /**
  68064. * Class containing static functions to help procedurally build meshes
  68065. */
  68066. export class TubeBuilder {
  68067. /**
  68068. * Creates a tube mesh.
  68069. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68070. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68071. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68072. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68073. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68074. * * 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)
  68075. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68076. * * 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
  68077. * * 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
  68078. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68079. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68080. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68081. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68082. * @param name defines the name of the mesh
  68083. * @param options defines the options used to create the mesh
  68084. * @param scene defines the hosting scene
  68085. * @returns the tube mesh
  68086. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68087. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68088. */
  68089. static CreateTube(name: string, options: {
  68090. path: Vector3[];
  68091. radius?: number;
  68092. tessellation?: number;
  68093. radiusFunction?: {
  68094. (i: number, distance: number): number;
  68095. };
  68096. cap?: number;
  68097. arc?: number;
  68098. updatable?: boolean;
  68099. sideOrientation?: number;
  68100. frontUVs?: Vector4;
  68101. backUVs?: Vector4;
  68102. instance?: Mesh;
  68103. invertUV?: boolean;
  68104. }, scene?: Nullable<Scene>): Mesh;
  68105. }
  68106. }
  68107. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  68108. import { Scene } from "babylonjs/scene";
  68109. import { Vector4 } from "babylonjs/Maths/math.vector";
  68110. import { Mesh } from "babylonjs/Meshes/mesh";
  68111. import { Nullable } from "babylonjs/types";
  68112. /**
  68113. * Class containing static functions to help procedurally build meshes
  68114. */
  68115. export class IcoSphereBuilder {
  68116. /**
  68117. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68118. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68119. * * 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`)
  68120. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68121. * * 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
  68122. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68123. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68124. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68125. * @param name defines the name of the mesh
  68126. * @param options defines the options used to create the mesh
  68127. * @param scene defines the hosting scene
  68128. * @returns the icosahedron mesh
  68129. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68130. */
  68131. static CreateIcoSphere(name: string, options: {
  68132. radius?: number;
  68133. radiusX?: number;
  68134. radiusY?: number;
  68135. radiusZ?: number;
  68136. flat?: boolean;
  68137. subdivisions?: number;
  68138. sideOrientation?: number;
  68139. frontUVs?: Vector4;
  68140. backUVs?: Vector4;
  68141. updatable?: boolean;
  68142. }, scene?: Nullable<Scene>): Mesh;
  68143. }
  68144. }
  68145. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  68146. import { Vector3 } from "babylonjs/Maths/math.vector";
  68147. import { Mesh } from "babylonjs/Meshes/mesh";
  68148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68149. /**
  68150. * Class containing static functions to help procedurally build meshes
  68151. */
  68152. export class DecalBuilder {
  68153. /**
  68154. * Creates a decal mesh.
  68155. * 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
  68156. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68157. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68158. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68159. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68160. * @param name defines the name of the mesh
  68161. * @param sourceMesh defines the mesh where the decal must be applied
  68162. * @param options defines the options used to create the mesh
  68163. * @param scene defines the hosting scene
  68164. * @returns the decal mesh
  68165. * @see https://doc.babylonjs.com/how_to/decals
  68166. */
  68167. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68168. position?: Vector3;
  68169. normal?: Vector3;
  68170. size?: Vector3;
  68171. angle?: number;
  68172. }): Mesh;
  68173. }
  68174. }
  68175. declare module "babylonjs/Meshes/meshBuilder" {
  68176. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  68177. import { Nullable } from "babylonjs/types";
  68178. import { Scene } from "babylonjs/scene";
  68179. import { Mesh } from "babylonjs/Meshes/mesh";
  68180. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  68181. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  68182. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68183. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  68184. import { Plane } from "babylonjs/Maths/math.plane";
  68185. /**
  68186. * Class containing static functions to help procedurally build meshes
  68187. */
  68188. export class MeshBuilder {
  68189. /**
  68190. * Creates a box mesh
  68191. * * The parameter `size` sets the size (float) of each box side (default 1)
  68192. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  68193. * * 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)
  68194. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68198. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  68199. * @param name defines the name of the mesh
  68200. * @param options defines the options used to create the mesh
  68201. * @param scene defines the hosting scene
  68202. * @returns the box mesh
  68203. */
  68204. static CreateBox(name: string, options: {
  68205. size?: number;
  68206. width?: number;
  68207. height?: number;
  68208. depth?: number;
  68209. faceUV?: Vector4[];
  68210. faceColors?: Color4[];
  68211. sideOrientation?: number;
  68212. frontUVs?: Vector4;
  68213. backUVs?: Vector4;
  68214. wrap?: boolean;
  68215. topBaseAt?: number;
  68216. bottomBaseAt?: number;
  68217. updatable?: boolean;
  68218. }, scene?: Nullable<Scene>): Mesh;
  68219. /**
  68220. * Creates a tiled box mesh
  68221. * * faceTiles sets the pattern, tile size and number of tiles for a face
  68222. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68223. * @param name defines the name of the mesh
  68224. * @param options defines the options used to create the mesh
  68225. * @param scene defines the hosting scene
  68226. * @returns the tiled box mesh
  68227. */
  68228. static CreateTiledBox(name: string, options: {
  68229. pattern?: number;
  68230. size?: number;
  68231. width?: number;
  68232. height?: number;
  68233. depth: number;
  68234. tileSize?: number;
  68235. tileWidth?: number;
  68236. tileHeight?: number;
  68237. faceUV?: Vector4[];
  68238. faceColors?: Color4[];
  68239. alignHorizontal?: number;
  68240. alignVertical?: number;
  68241. sideOrientation?: number;
  68242. updatable?: boolean;
  68243. }, scene?: Nullable<Scene>): Mesh;
  68244. /**
  68245. * Creates a sphere mesh
  68246. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  68247. * * 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`)
  68248. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  68249. * * 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
  68250. * * 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)
  68251. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68252. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68253. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68254. * @param name defines the name of the mesh
  68255. * @param options defines the options used to create the mesh
  68256. * @param scene defines the hosting scene
  68257. * @returns the sphere mesh
  68258. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  68259. */
  68260. static CreateSphere(name: string, options: {
  68261. segments?: number;
  68262. diameter?: number;
  68263. diameterX?: number;
  68264. diameterY?: number;
  68265. diameterZ?: number;
  68266. arc?: number;
  68267. slice?: number;
  68268. sideOrientation?: number;
  68269. frontUVs?: Vector4;
  68270. backUVs?: Vector4;
  68271. updatable?: boolean;
  68272. }, scene?: Nullable<Scene>): Mesh;
  68273. /**
  68274. * Creates a plane polygonal mesh. By default, this is a disc
  68275. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  68276. * * 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
  68277. * * 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
  68278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68281. * @param name defines the name of the mesh
  68282. * @param options defines the options used to create the mesh
  68283. * @param scene defines the hosting scene
  68284. * @returns the plane polygonal mesh
  68285. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  68286. */
  68287. static CreateDisc(name: string, options: {
  68288. radius?: number;
  68289. tessellation?: number;
  68290. arc?: number;
  68291. updatable?: boolean;
  68292. sideOrientation?: number;
  68293. frontUVs?: Vector4;
  68294. backUVs?: Vector4;
  68295. }, scene?: Nullable<Scene>): Mesh;
  68296. /**
  68297. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  68298. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  68299. * * 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`)
  68300. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  68301. * * 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
  68302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68303. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68305. * @param name defines the name of the mesh
  68306. * @param options defines the options used to create the mesh
  68307. * @param scene defines the hosting scene
  68308. * @returns the icosahedron mesh
  68309. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  68310. */
  68311. static CreateIcoSphere(name: string, options: {
  68312. radius?: number;
  68313. radiusX?: number;
  68314. radiusY?: number;
  68315. radiusZ?: number;
  68316. flat?: boolean;
  68317. subdivisions?: number;
  68318. sideOrientation?: number;
  68319. frontUVs?: Vector4;
  68320. backUVs?: Vector4;
  68321. updatable?: boolean;
  68322. }, scene?: Nullable<Scene>): Mesh;
  68323. /**
  68324. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68325. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  68326. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  68327. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  68328. * * 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
  68329. * * 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
  68330. * * 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
  68331. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68332. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68333. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68334. * * 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
  68335. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  68336. * * 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
  68337. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  68338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68339. * @param name defines the name of the mesh
  68340. * @param options defines the options used to create the mesh
  68341. * @param scene defines the hosting scene
  68342. * @returns the ribbon mesh
  68343. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  68344. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68345. */
  68346. static CreateRibbon(name: string, options: {
  68347. pathArray: Vector3[][];
  68348. closeArray?: boolean;
  68349. closePath?: boolean;
  68350. offset?: number;
  68351. updatable?: boolean;
  68352. sideOrientation?: number;
  68353. frontUVs?: Vector4;
  68354. backUVs?: Vector4;
  68355. instance?: Mesh;
  68356. invertUV?: boolean;
  68357. uvs?: Vector2[];
  68358. colors?: Color4[];
  68359. }, scene?: Nullable<Scene>): Mesh;
  68360. /**
  68361. * Creates a cylinder or a cone mesh
  68362. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  68363. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  68364. * * 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.
  68365. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  68366. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  68367. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  68368. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  68369. * * 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).
  68370. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  68371. * * 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).
  68372. * * 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
  68373. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  68374. * * 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
  68375. * * 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.
  68376. * * If `enclose` is false, a ring surface is one element.
  68377. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  68378. * * 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
  68379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68381. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68382. * @param name defines the name of the mesh
  68383. * @param options defines the options used to create the mesh
  68384. * @param scene defines the hosting scene
  68385. * @returns the cylinder mesh
  68386. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  68387. */
  68388. static CreateCylinder(name: string, options: {
  68389. height?: number;
  68390. diameterTop?: number;
  68391. diameterBottom?: number;
  68392. diameter?: number;
  68393. tessellation?: number;
  68394. subdivisions?: number;
  68395. arc?: number;
  68396. faceColors?: Color4[];
  68397. faceUV?: Vector4[];
  68398. updatable?: boolean;
  68399. hasRings?: boolean;
  68400. enclose?: boolean;
  68401. cap?: number;
  68402. sideOrientation?: number;
  68403. frontUVs?: Vector4;
  68404. backUVs?: Vector4;
  68405. }, scene?: Nullable<Scene>): Mesh;
  68406. /**
  68407. * Creates a torus mesh
  68408. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  68409. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  68410. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  68411. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68412. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68413. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68414. * @param name defines the name of the mesh
  68415. * @param options defines the options used to create the mesh
  68416. * @param scene defines the hosting scene
  68417. * @returns the torus mesh
  68418. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  68419. */
  68420. static CreateTorus(name: string, options: {
  68421. diameter?: number;
  68422. thickness?: number;
  68423. tessellation?: number;
  68424. updatable?: boolean;
  68425. sideOrientation?: number;
  68426. frontUVs?: Vector4;
  68427. backUVs?: Vector4;
  68428. }, scene?: Nullable<Scene>): Mesh;
  68429. /**
  68430. * Creates a torus knot mesh
  68431. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68432. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68433. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68434. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68435. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68436. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68438. * @param name defines the name of the mesh
  68439. * @param options defines the options used to create the mesh
  68440. * @param scene defines the hosting scene
  68441. * @returns the torus knot mesh
  68442. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68443. */
  68444. static CreateTorusKnot(name: string, options: {
  68445. radius?: number;
  68446. tube?: number;
  68447. radialSegments?: number;
  68448. tubularSegments?: number;
  68449. p?: number;
  68450. q?: number;
  68451. updatable?: boolean;
  68452. sideOrientation?: number;
  68453. frontUVs?: Vector4;
  68454. backUVs?: Vector4;
  68455. }, scene?: Nullable<Scene>): Mesh;
  68456. /**
  68457. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  68458. * * 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
  68459. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  68460. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  68461. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  68462. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  68463. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  68464. * * 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
  68465. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  68466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  68468. * @param name defines the name of the new line system
  68469. * @param options defines the options used to create the line system
  68470. * @param scene defines the hosting scene
  68471. * @returns a new line system mesh
  68472. */
  68473. static CreateLineSystem(name: string, options: {
  68474. lines: Vector3[][];
  68475. updatable?: boolean;
  68476. instance?: Nullable<LinesMesh>;
  68477. colors?: Nullable<Color4[][]>;
  68478. useVertexAlpha?: boolean;
  68479. }, scene: Nullable<Scene>): LinesMesh;
  68480. /**
  68481. * Creates a line mesh
  68482. * 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
  68483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68484. * * The parameter `points` is an array successive Vector3
  68485. * * 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
  68486. * * The optional parameter `colors` is an array of successive Color4, one per line point
  68487. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  68488. * * When updating an instance, remember that only point positions can change, not the number of points
  68489. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  68491. * @param name defines the name of the new line system
  68492. * @param options defines the options used to create the line system
  68493. * @param scene defines the hosting scene
  68494. * @returns a new line mesh
  68495. */
  68496. static CreateLines(name: string, options: {
  68497. points: Vector3[];
  68498. updatable?: boolean;
  68499. instance?: Nullable<LinesMesh>;
  68500. colors?: Color4[];
  68501. useVertexAlpha?: boolean;
  68502. }, scene?: Nullable<Scene>): LinesMesh;
  68503. /**
  68504. * Creates a dashed line mesh
  68505. * * 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
  68506. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  68507. * * The parameter `points` is an array successive Vector3
  68508. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  68509. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  68510. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  68511. * * 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
  68512. * * When updating an instance, remember that only point positions can change, not the number of points
  68513. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68514. * @param name defines the name of the mesh
  68515. * @param options defines the options used to create the mesh
  68516. * @param scene defines the hosting scene
  68517. * @returns the dashed line mesh
  68518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  68519. */
  68520. static CreateDashedLines(name: string, options: {
  68521. points: Vector3[];
  68522. dashSize?: number;
  68523. gapSize?: number;
  68524. dashNb?: number;
  68525. updatable?: boolean;
  68526. instance?: LinesMesh;
  68527. }, scene?: Nullable<Scene>): LinesMesh;
  68528. /**
  68529. * 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.
  68530. * * 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.
  68531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68532. * * 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.
  68533. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  68534. * * 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
  68535. * * 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
  68536. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  68537. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68538. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68539. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  68540. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68541. * @param name defines the name of the mesh
  68542. * @param options defines the options used to create the mesh
  68543. * @param scene defines the hosting scene
  68544. * @returns the extruded shape mesh
  68545. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68547. */
  68548. static ExtrudeShape(name: string, options: {
  68549. shape: Vector3[];
  68550. path: Vector3[];
  68551. scale?: number;
  68552. rotation?: number;
  68553. cap?: number;
  68554. updatable?: boolean;
  68555. sideOrientation?: number;
  68556. frontUVs?: Vector4;
  68557. backUVs?: Vector4;
  68558. instance?: Mesh;
  68559. invertUV?: boolean;
  68560. }, scene?: Nullable<Scene>): Mesh;
  68561. /**
  68562. * Creates an custom extruded shape mesh.
  68563. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  68564. * * 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.
  68565. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  68566. * * 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
  68567. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  68568. * * 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
  68569. * * It must returns a float value that will be the scale value applied to the shape on each path point
  68570. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  68571. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  68572. * * 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
  68573. * * 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
  68574. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  68575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68579. * @param name defines the name of the mesh
  68580. * @param options defines the options used to create the mesh
  68581. * @param scene defines the hosting scene
  68582. * @returns the custom extruded shape mesh
  68583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  68584. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  68586. */
  68587. static ExtrudeShapeCustom(name: string, options: {
  68588. shape: Vector3[];
  68589. path: Vector3[];
  68590. scaleFunction?: any;
  68591. rotationFunction?: any;
  68592. ribbonCloseArray?: boolean;
  68593. ribbonClosePath?: boolean;
  68594. cap?: number;
  68595. updatable?: boolean;
  68596. sideOrientation?: number;
  68597. frontUVs?: Vector4;
  68598. backUVs?: Vector4;
  68599. instance?: Mesh;
  68600. invertUV?: boolean;
  68601. }, scene?: Nullable<Scene>): Mesh;
  68602. /**
  68603. * Creates lathe mesh.
  68604. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  68605. * * 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
  68606. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  68607. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  68608. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  68609. * * 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
  68610. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  68611. * * 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
  68612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68614. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68616. * @param name defines the name of the mesh
  68617. * @param options defines the options used to create the mesh
  68618. * @param scene defines the hosting scene
  68619. * @returns the lathe mesh
  68620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  68621. */
  68622. static CreateLathe(name: string, options: {
  68623. shape: Vector3[];
  68624. radius?: number;
  68625. tessellation?: number;
  68626. clip?: number;
  68627. arc?: number;
  68628. closed?: boolean;
  68629. updatable?: boolean;
  68630. sideOrientation?: number;
  68631. frontUVs?: Vector4;
  68632. backUVs?: Vector4;
  68633. cap?: number;
  68634. invertUV?: boolean;
  68635. }, scene?: Nullable<Scene>): Mesh;
  68636. /**
  68637. * Creates a tiled plane mesh
  68638. * * You can set a limited pattern arrangement with the tiles
  68639. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68640. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68641. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68642. * @param name defines the name of the mesh
  68643. * @param options defines the options used to create the mesh
  68644. * @param scene defines the hosting scene
  68645. * @returns the plane mesh
  68646. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68647. */
  68648. static CreateTiledPlane(name: string, options: {
  68649. pattern?: number;
  68650. tileSize?: number;
  68651. tileWidth?: number;
  68652. tileHeight?: number;
  68653. size?: number;
  68654. width?: number;
  68655. height?: number;
  68656. alignHorizontal?: number;
  68657. alignVertical?: number;
  68658. sideOrientation?: number;
  68659. frontUVs?: Vector4;
  68660. backUVs?: Vector4;
  68661. updatable?: boolean;
  68662. }, scene?: Nullable<Scene>): Mesh;
  68663. /**
  68664. * Creates a plane mesh
  68665. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  68666. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  68667. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  68668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68671. * @param name defines the name of the mesh
  68672. * @param options defines the options used to create the mesh
  68673. * @param scene defines the hosting scene
  68674. * @returns the plane mesh
  68675. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  68676. */
  68677. static CreatePlane(name: string, options: {
  68678. size?: number;
  68679. width?: number;
  68680. height?: number;
  68681. sideOrientation?: number;
  68682. frontUVs?: Vector4;
  68683. backUVs?: Vector4;
  68684. updatable?: boolean;
  68685. sourcePlane?: Plane;
  68686. }, scene?: Nullable<Scene>): Mesh;
  68687. /**
  68688. * Creates a ground mesh
  68689. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  68690. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  68691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68692. * @param name defines the name of the mesh
  68693. * @param options defines the options used to create the mesh
  68694. * @param scene defines the hosting scene
  68695. * @returns the ground mesh
  68696. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  68697. */
  68698. static CreateGround(name: string, options: {
  68699. width?: number;
  68700. height?: number;
  68701. subdivisions?: number;
  68702. subdivisionsX?: number;
  68703. subdivisionsY?: number;
  68704. updatable?: boolean;
  68705. }, scene?: Nullable<Scene>): Mesh;
  68706. /**
  68707. * Creates a tiled ground mesh
  68708. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  68709. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  68710. * * 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
  68711. * * 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
  68712. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68713. * @param name defines the name of the mesh
  68714. * @param options defines the options used to create the mesh
  68715. * @param scene defines the hosting scene
  68716. * @returns the tiled ground mesh
  68717. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  68718. */
  68719. static CreateTiledGround(name: string, options: {
  68720. xmin: number;
  68721. zmin: number;
  68722. xmax: number;
  68723. zmax: number;
  68724. subdivisions?: {
  68725. w: number;
  68726. h: number;
  68727. };
  68728. precision?: {
  68729. w: number;
  68730. h: number;
  68731. };
  68732. updatable?: boolean;
  68733. }, scene?: Nullable<Scene>): Mesh;
  68734. /**
  68735. * Creates a ground mesh from a height map
  68736. * * The parameter `url` sets the URL of the height map image resource.
  68737. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  68738. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  68739. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  68740. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  68741. * * 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.
  68742. * * 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).
  68743. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  68744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68745. * @param name defines the name of the mesh
  68746. * @param url defines the url to the height map
  68747. * @param options defines the options used to create the mesh
  68748. * @param scene defines the hosting scene
  68749. * @returns the ground mesh
  68750. * @see https://doc.babylonjs.com/babylon101/height_map
  68751. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  68752. */
  68753. static CreateGroundFromHeightMap(name: string, url: string, options: {
  68754. width?: number;
  68755. height?: number;
  68756. subdivisions?: number;
  68757. minHeight?: number;
  68758. maxHeight?: number;
  68759. colorFilter?: Color3;
  68760. alphaFilter?: number;
  68761. updatable?: boolean;
  68762. onReady?: (mesh: GroundMesh) => void;
  68763. }, scene?: Nullable<Scene>): GroundMesh;
  68764. /**
  68765. * Creates a polygon mesh
  68766. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  68767. * * 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
  68768. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  68769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68770. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  68771. * * Remember you can only change the shape positions, not their number when updating a polygon
  68772. * @param name defines the name of the mesh
  68773. * @param options defines the options used to create the mesh
  68774. * @param scene defines the hosting scene
  68775. * @param earcutInjection can be used to inject your own earcut reference
  68776. * @returns the polygon mesh
  68777. */
  68778. static CreatePolygon(name: string, options: {
  68779. shape: Vector3[];
  68780. holes?: Vector3[][];
  68781. depth?: number;
  68782. faceUV?: Vector4[];
  68783. faceColors?: Color4[];
  68784. updatable?: boolean;
  68785. sideOrientation?: number;
  68786. frontUVs?: Vector4;
  68787. backUVs?: Vector4;
  68788. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68789. /**
  68790. * Creates an extruded polygon mesh, with depth in the Y direction.
  68791. * * 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)
  68792. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  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. * @param earcutInjection can be used to inject your own earcut reference
  68797. * @returns the polygon mesh
  68798. */
  68799. static ExtrudePolygon(name: string, options: {
  68800. shape: Vector3[];
  68801. holes?: Vector3[][];
  68802. depth?: number;
  68803. faceUV?: Vector4[];
  68804. faceColors?: Color4[];
  68805. updatable?: boolean;
  68806. sideOrientation?: number;
  68807. frontUVs?: Vector4;
  68808. backUVs?: Vector4;
  68809. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  68810. /**
  68811. * Creates a tube mesh.
  68812. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  68813. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  68814. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  68815. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  68816. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  68817. * * 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)
  68818. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  68819. * * 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
  68820. * * 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
  68821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68823. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  68824. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68825. * @param name defines the name of the mesh
  68826. * @param options defines the options used to create the mesh
  68827. * @param scene defines the hosting scene
  68828. * @returns the tube mesh
  68829. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  68830. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  68831. */
  68832. static CreateTube(name: string, options: {
  68833. path: Vector3[];
  68834. radius?: number;
  68835. tessellation?: number;
  68836. radiusFunction?: {
  68837. (i: number, distance: number): number;
  68838. };
  68839. cap?: number;
  68840. arc?: number;
  68841. updatable?: boolean;
  68842. sideOrientation?: number;
  68843. frontUVs?: Vector4;
  68844. backUVs?: Vector4;
  68845. instance?: Mesh;
  68846. invertUV?: boolean;
  68847. }, scene?: Nullable<Scene>): Mesh;
  68848. /**
  68849. * Creates a polyhedron mesh
  68850. * * 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
  68851. * * The parameter `size` (positive float, default 1) sets the polygon size
  68852. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  68853. * * 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`
  68854. * * 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
  68855. * * 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)`)
  68856. * * 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
  68857. * * 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
  68858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68859. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  68860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68861. * @param name defines the name of the mesh
  68862. * @param options defines the options used to create the mesh
  68863. * @param scene defines the hosting scene
  68864. * @returns the polyhedron mesh
  68865. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  68866. */
  68867. static CreatePolyhedron(name: string, options: {
  68868. type?: number;
  68869. size?: number;
  68870. sizeX?: number;
  68871. sizeY?: number;
  68872. sizeZ?: number;
  68873. custom?: any;
  68874. faceUV?: Vector4[];
  68875. faceColors?: Color4[];
  68876. flat?: boolean;
  68877. updatable?: boolean;
  68878. sideOrientation?: number;
  68879. frontUVs?: Vector4;
  68880. backUVs?: Vector4;
  68881. }, scene?: Nullable<Scene>): Mesh;
  68882. /**
  68883. * Creates a decal mesh.
  68884. * 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
  68885. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  68886. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  68887. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  68888. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  68889. * @param name defines the name of the mesh
  68890. * @param sourceMesh defines the mesh where the decal must be applied
  68891. * @param options defines the options used to create the mesh
  68892. * @param scene defines the hosting scene
  68893. * @returns the decal mesh
  68894. * @see https://doc.babylonjs.com/how_to/decals
  68895. */
  68896. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  68897. position?: Vector3;
  68898. normal?: Vector3;
  68899. size?: Vector3;
  68900. angle?: number;
  68901. }): Mesh;
  68902. }
  68903. }
  68904. declare module "babylonjs/Meshes/meshSimplification" {
  68905. import { Mesh } from "babylonjs/Meshes/mesh";
  68906. /**
  68907. * A simplifier interface for future simplification implementations
  68908. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68909. */
  68910. export interface ISimplifier {
  68911. /**
  68912. * Simplification of a given mesh according to the given settings.
  68913. * Since this requires computation, it is assumed that the function runs async.
  68914. * @param settings The settings of the simplification, including quality and distance
  68915. * @param successCallback A callback that will be called after the mesh was simplified.
  68916. * @param errorCallback in case of an error, this callback will be called. optional.
  68917. */
  68918. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  68919. }
  68920. /**
  68921. * Expected simplification settings.
  68922. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  68923. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68924. */
  68925. export interface ISimplificationSettings {
  68926. /**
  68927. * Gets or sets the expected quality
  68928. */
  68929. quality: number;
  68930. /**
  68931. * Gets or sets the distance when this optimized version should be used
  68932. */
  68933. distance: number;
  68934. /**
  68935. * Gets an already optimized mesh
  68936. */
  68937. optimizeMesh?: boolean;
  68938. }
  68939. /**
  68940. * Class used to specify simplification options
  68941. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68942. */
  68943. export class SimplificationSettings implements ISimplificationSettings {
  68944. /** expected quality */
  68945. quality: number;
  68946. /** distance when this optimized version should be used */
  68947. distance: number;
  68948. /** already optimized mesh */
  68949. optimizeMesh?: boolean | undefined;
  68950. /**
  68951. * Creates a SimplificationSettings
  68952. * @param quality expected quality
  68953. * @param distance distance when this optimized version should be used
  68954. * @param optimizeMesh already optimized mesh
  68955. */
  68956. constructor(
  68957. /** expected quality */
  68958. quality: number,
  68959. /** distance when this optimized version should be used */
  68960. distance: number,
  68961. /** already optimized mesh */
  68962. optimizeMesh?: boolean | undefined);
  68963. }
  68964. /**
  68965. * Interface used to define a simplification task
  68966. */
  68967. export interface ISimplificationTask {
  68968. /**
  68969. * Array of settings
  68970. */
  68971. settings: Array<ISimplificationSettings>;
  68972. /**
  68973. * Simplification type
  68974. */
  68975. simplificationType: SimplificationType;
  68976. /**
  68977. * Mesh to simplify
  68978. */
  68979. mesh: Mesh;
  68980. /**
  68981. * Callback called on success
  68982. */
  68983. successCallback?: () => void;
  68984. /**
  68985. * Defines if parallel processing can be used
  68986. */
  68987. parallelProcessing: boolean;
  68988. }
  68989. /**
  68990. * Queue used to order the simplification tasks
  68991. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  68992. */
  68993. export class SimplificationQueue {
  68994. private _simplificationArray;
  68995. /**
  68996. * Gets a boolean indicating that the process is still running
  68997. */
  68998. running: boolean;
  68999. /**
  69000. * Creates a new queue
  69001. */
  69002. constructor();
  69003. /**
  69004. * Adds a new simplification task
  69005. * @param task defines a task to add
  69006. */
  69007. addTask(task: ISimplificationTask): void;
  69008. /**
  69009. * Execute next task
  69010. */
  69011. executeNext(): void;
  69012. /**
  69013. * Execute a simplification task
  69014. * @param task defines the task to run
  69015. */
  69016. runSimplification(task: ISimplificationTask): void;
  69017. private getSimplifier;
  69018. }
  69019. /**
  69020. * The implemented types of simplification
  69021. * At the moment only Quadratic Error Decimation is implemented
  69022. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69023. */
  69024. export enum SimplificationType {
  69025. /** Quadratic error decimation */
  69026. QUADRATIC = 0
  69027. }
  69028. /**
  69029. * An implementation of the Quadratic Error simplification algorithm.
  69030. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  69031. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  69032. * @author RaananW
  69033. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69034. */
  69035. export class QuadraticErrorSimplification implements ISimplifier {
  69036. private _mesh;
  69037. private triangles;
  69038. private vertices;
  69039. private references;
  69040. private _reconstructedMesh;
  69041. /** Gets or sets the number pf sync interations */
  69042. syncIterations: number;
  69043. /** Gets or sets the aggressiveness of the simplifier */
  69044. aggressiveness: number;
  69045. /** Gets or sets the number of allowed iterations for decimation */
  69046. decimationIterations: number;
  69047. /** Gets or sets the espilon to use for bounding box computation */
  69048. boundingBoxEpsilon: number;
  69049. /**
  69050. * Creates a new QuadraticErrorSimplification
  69051. * @param _mesh defines the target mesh
  69052. */
  69053. constructor(_mesh: Mesh);
  69054. /**
  69055. * Simplification of a given mesh according to the given settings.
  69056. * Since this requires computation, it is assumed that the function runs async.
  69057. * @param settings The settings of the simplification, including quality and distance
  69058. * @param successCallback A callback that will be called after the mesh was simplified.
  69059. */
  69060. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  69061. private runDecimation;
  69062. private initWithMesh;
  69063. private init;
  69064. private reconstructMesh;
  69065. private initDecimatedMesh;
  69066. private isFlipped;
  69067. private updateTriangles;
  69068. private identifyBorder;
  69069. private updateMesh;
  69070. private vertexError;
  69071. private calculateError;
  69072. }
  69073. }
  69074. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  69075. import { Scene } from "babylonjs/scene";
  69076. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  69077. import { ISceneComponent } from "babylonjs/sceneComponent";
  69078. module "babylonjs/scene" {
  69079. interface Scene {
  69080. /** @hidden (Backing field) */
  69081. _simplificationQueue: SimplificationQueue;
  69082. /**
  69083. * Gets or sets the simplification queue attached to the scene
  69084. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  69085. */
  69086. simplificationQueue: SimplificationQueue;
  69087. }
  69088. }
  69089. module "babylonjs/Meshes/mesh" {
  69090. interface Mesh {
  69091. /**
  69092. * Simplify the mesh according to the given array of settings.
  69093. * Function will return immediately and will simplify async
  69094. * @param settings a collection of simplification settings
  69095. * @param parallelProcessing should all levels calculate parallel or one after the other
  69096. * @param simplificationType the type of simplification to run
  69097. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  69098. * @returns the current mesh
  69099. */
  69100. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  69101. }
  69102. }
  69103. /**
  69104. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  69105. * created in a scene
  69106. */
  69107. export class SimplicationQueueSceneComponent implements ISceneComponent {
  69108. /**
  69109. * The component name helpfull to identify the component in the list of scene components.
  69110. */
  69111. readonly name: string;
  69112. /**
  69113. * The scene the component belongs to.
  69114. */
  69115. scene: Scene;
  69116. /**
  69117. * Creates a new instance of the component for the given scene
  69118. * @param scene Defines the scene to register the component in
  69119. */
  69120. constructor(scene: Scene);
  69121. /**
  69122. * Registers the component in a given scene
  69123. */
  69124. register(): void;
  69125. /**
  69126. * Rebuilds the elements related to this component in case of
  69127. * context lost for instance.
  69128. */
  69129. rebuild(): void;
  69130. /**
  69131. * Disposes the component and the associated ressources
  69132. */
  69133. dispose(): void;
  69134. private _beforeCameraUpdate;
  69135. }
  69136. }
  69137. declare module "babylonjs/Meshes/Builders/index" {
  69138. export * from "babylonjs/Meshes/Builders/boxBuilder";
  69139. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  69140. export * from "babylonjs/Meshes/Builders/discBuilder";
  69141. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  69142. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  69143. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  69144. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  69145. export * from "babylonjs/Meshes/Builders/torusBuilder";
  69146. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  69147. export * from "babylonjs/Meshes/Builders/linesBuilder";
  69148. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  69149. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  69150. export * from "babylonjs/Meshes/Builders/latheBuilder";
  69151. export * from "babylonjs/Meshes/Builders/planeBuilder";
  69152. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  69153. export * from "babylonjs/Meshes/Builders/groundBuilder";
  69154. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  69155. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  69156. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  69157. export * from "babylonjs/Meshes/Builders/decalBuilder";
  69158. }
  69159. declare module "babylonjs/Meshes/thinInstanceMesh" {
  69160. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  69161. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  69162. import { Matrix } from "babylonjs/Maths/math.vector";
  69163. module "babylonjs/Meshes/mesh" {
  69164. interface Mesh {
  69165. /**
  69166. * Creates a new thin instance
  69167. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  69168. * @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
  69169. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  69170. */
  69171. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  69172. /**
  69173. * Adds the transformation (matrix) of the current mesh as a thin instance
  69174. * @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
  69175. * @returns the thin instance index number
  69176. */
  69177. thinInstanceAddSelf(refresh: boolean): number;
  69178. /**
  69179. * Registers a custom attribute to be used with thin instances
  69180. * @param kind name of the attribute
  69181. * @param stride size in floats of the attribute
  69182. */
  69183. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  69184. /**
  69185. * Sets the matrix of a thin instance
  69186. * @param index index of the thin instance
  69187. * @param matrix matrix to set
  69188. * @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
  69189. */
  69190. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  69191. /**
  69192. * Sets the value of a custom attribute for a thin instance
  69193. * @param kind name of the attribute
  69194. * @param index index of the thin instance
  69195. * @param value value to set
  69196. * @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
  69197. */
  69198. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  69199. /**
  69200. * 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.
  69201. */
  69202. thinInstanceCount: number;
  69203. /**
  69204. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  69205. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  69206. * @param buffer buffer to set
  69207. * @param stride size in floats of each value of the buffer
  69208. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  69209. */
  69210. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  69211. /**
  69212. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  69213. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  69214. */
  69215. thinInstanceBufferUpdated(kind: string): void;
  69216. /**
  69217. * Refreshes the bounding info, taking into account all the thin instances defined
  69218. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  69219. */
  69220. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  69221. /** @hidden */
  69222. _thinInstanceInitializeUserStorage(): void;
  69223. /** @hidden */
  69224. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  69225. /** @hidden */
  69226. _userThinInstanceBuffersStorage: {
  69227. data: {
  69228. [key: string]: Float32Array;
  69229. };
  69230. sizes: {
  69231. [key: string]: number;
  69232. };
  69233. vertexBuffers: {
  69234. [key: string]: Nullable<VertexBuffer>;
  69235. };
  69236. strides: {
  69237. [key: string]: number;
  69238. };
  69239. };
  69240. }
  69241. }
  69242. }
  69243. declare module "babylonjs/Meshes/index" {
  69244. export * from "babylonjs/Meshes/abstractMesh";
  69245. export * from "babylonjs/Meshes/buffer";
  69246. export * from "babylonjs/Meshes/Compression/index";
  69247. export * from "babylonjs/Meshes/csg";
  69248. export * from "babylonjs/Meshes/geometry";
  69249. export * from "babylonjs/Meshes/groundMesh";
  69250. export * from "babylonjs/Meshes/trailMesh";
  69251. export * from "babylonjs/Meshes/instancedMesh";
  69252. export * from "babylonjs/Meshes/linesMesh";
  69253. export * from "babylonjs/Meshes/mesh";
  69254. export * from "babylonjs/Meshes/mesh.vertexData";
  69255. export * from "babylonjs/Meshes/meshBuilder";
  69256. export * from "babylonjs/Meshes/meshSimplification";
  69257. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  69258. export * from "babylonjs/Meshes/polygonMesh";
  69259. export * from "babylonjs/Meshes/subMesh";
  69260. export * from "babylonjs/Meshes/meshLODLevel";
  69261. export * from "babylonjs/Meshes/transformNode";
  69262. export * from "babylonjs/Meshes/Builders/index";
  69263. export * from "babylonjs/Meshes/dataBuffer";
  69264. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  69265. import "babylonjs/Meshes/thinInstanceMesh";
  69266. export * from "babylonjs/Meshes/thinInstanceMesh";
  69267. }
  69268. declare module "babylonjs/Morph/index" {
  69269. export * from "babylonjs/Morph/morphTarget";
  69270. export * from "babylonjs/Morph/morphTargetManager";
  69271. }
  69272. declare module "babylonjs/Navigation/INavigationEngine" {
  69273. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69274. import { Vector3 } from "babylonjs/Maths/math";
  69275. import { Mesh } from "babylonjs/Meshes/mesh";
  69276. import { Scene } from "babylonjs/scene";
  69277. /**
  69278. * Navigation plugin interface to add navigation constrained by a navigation mesh
  69279. */
  69280. export interface INavigationEnginePlugin {
  69281. /**
  69282. * plugin name
  69283. */
  69284. name: string;
  69285. /**
  69286. * Creates a navigation mesh
  69287. * @param meshes array of all the geometry used to compute the navigatio mesh
  69288. * @param parameters bunch of parameters used to filter geometry
  69289. */
  69290. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69291. /**
  69292. * Create a navigation mesh debug mesh
  69293. * @param scene is where the mesh will be added
  69294. * @returns debug display mesh
  69295. */
  69296. createDebugNavMesh(scene: Scene): Mesh;
  69297. /**
  69298. * Get a navigation mesh constrained position, closest to the parameter position
  69299. * @param position world position
  69300. * @returns the closest point to position constrained by the navigation mesh
  69301. */
  69302. getClosestPoint(position: Vector3): Vector3;
  69303. /**
  69304. * Get a navigation mesh constrained position, closest to the parameter position
  69305. * @param position world position
  69306. * @param result output the closest point to position constrained by the navigation mesh
  69307. */
  69308. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69309. /**
  69310. * Get a navigation mesh constrained position, within a particular radius
  69311. * @param position world position
  69312. * @param maxRadius the maximum distance to the constrained world position
  69313. * @returns the closest point to position constrained by the navigation mesh
  69314. */
  69315. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69316. /**
  69317. * Get a navigation mesh constrained position, within a particular radius
  69318. * @param position world position
  69319. * @param maxRadius the maximum distance to the constrained world position
  69320. * @param result output the closest point to position constrained by the navigation mesh
  69321. */
  69322. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69323. /**
  69324. * Compute the final position from a segment made of destination-position
  69325. * @param position world position
  69326. * @param destination world position
  69327. * @returns the resulting point along the navmesh
  69328. */
  69329. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69330. /**
  69331. * Compute the final position from a segment made of destination-position
  69332. * @param position world position
  69333. * @param destination world position
  69334. * @param result output the resulting point along the navmesh
  69335. */
  69336. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69337. /**
  69338. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69339. * @param start world position
  69340. * @param end world position
  69341. * @returns array containing world position composing the path
  69342. */
  69343. computePath(start: Vector3, end: Vector3): Vector3[];
  69344. /**
  69345. * If this plugin is supported
  69346. * @returns true if plugin is supported
  69347. */
  69348. isSupported(): boolean;
  69349. /**
  69350. * Create a new Crowd so you can add agents
  69351. * @param maxAgents the maximum agent count in the crowd
  69352. * @param maxAgentRadius the maximum radius an agent can have
  69353. * @param scene to attach the crowd to
  69354. * @returns the crowd you can add agents to
  69355. */
  69356. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69357. /**
  69358. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69359. * The queries will try to find a solution within those bounds
  69360. * default is (1,1,1)
  69361. * @param extent x,y,z value that define the extent around the queries point of reference
  69362. */
  69363. setDefaultQueryExtent(extent: Vector3): void;
  69364. /**
  69365. * Get the Bounding box extent specified by setDefaultQueryExtent
  69366. * @returns the box extent values
  69367. */
  69368. getDefaultQueryExtent(): Vector3;
  69369. /**
  69370. * build the navmesh from a previously saved state using getNavmeshData
  69371. * @param data the Uint8Array returned by getNavmeshData
  69372. */
  69373. buildFromNavmeshData(data: Uint8Array): void;
  69374. /**
  69375. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69376. * @returns data the Uint8Array that can be saved and reused
  69377. */
  69378. getNavmeshData(): Uint8Array;
  69379. /**
  69380. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69381. * @param result output the box extent values
  69382. */
  69383. getDefaultQueryExtentToRef(result: Vector3): void;
  69384. /**
  69385. * Release all resources
  69386. */
  69387. dispose(): void;
  69388. }
  69389. /**
  69390. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  69391. */
  69392. export interface ICrowd {
  69393. /**
  69394. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69395. * You can attach anything to that node. The node position is updated in the scene update tick.
  69396. * @param pos world position that will be constrained by the navigation mesh
  69397. * @param parameters agent parameters
  69398. * @param transform hooked to the agent that will be update by the scene
  69399. * @returns agent index
  69400. */
  69401. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69402. /**
  69403. * Returns the agent position in world space
  69404. * @param index agent index returned by addAgent
  69405. * @returns world space position
  69406. */
  69407. getAgentPosition(index: number): Vector3;
  69408. /**
  69409. * Gets the agent position result in world space
  69410. * @param index agent index returned by addAgent
  69411. * @param result output world space position
  69412. */
  69413. getAgentPositionToRef(index: number, result: Vector3): void;
  69414. /**
  69415. * Gets the agent velocity in world space
  69416. * @param index agent index returned by addAgent
  69417. * @returns world space velocity
  69418. */
  69419. getAgentVelocity(index: number): Vector3;
  69420. /**
  69421. * Gets the agent velocity result in world space
  69422. * @param index agent index returned by addAgent
  69423. * @param result output world space velocity
  69424. */
  69425. getAgentVelocityToRef(index: number, result: Vector3): void;
  69426. /**
  69427. * remove a particular agent previously created
  69428. * @param index agent index returned by addAgent
  69429. */
  69430. removeAgent(index: number): void;
  69431. /**
  69432. * get the list of all agents attached to this crowd
  69433. * @returns list of agent indices
  69434. */
  69435. getAgents(): number[];
  69436. /**
  69437. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69438. * @param deltaTime in seconds
  69439. */
  69440. update(deltaTime: number): void;
  69441. /**
  69442. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69443. * @param index agent index returned by addAgent
  69444. * @param destination targeted world position
  69445. */
  69446. agentGoto(index: number, destination: Vector3): void;
  69447. /**
  69448. * Teleport the agent to a new position
  69449. * @param index agent index returned by addAgent
  69450. * @param destination targeted world position
  69451. */
  69452. agentTeleport(index: number, destination: Vector3): void;
  69453. /**
  69454. * Update agent parameters
  69455. * @param index agent index returned by addAgent
  69456. * @param parameters agent parameters
  69457. */
  69458. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69459. /**
  69460. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69461. * The queries will try to find a solution within those bounds
  69462. * default is (1,1,1)
  69463. * @param extent x,y,z value that define the extent around the queries point of reference
  69464. */
  69465. setDefaultQueryExtent(extent: Vector3): void;
  69466. /**
  69467. * Get the Bounding box extent specified by setDefaultQueryExtent
  69468. * @returns the box extent values
  69469. */
  69470. getDefaultQueryExtent(): Vector3;
  69471. /**
  69472. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69473. * @param result output the box extent values
  69474. */
  69475. getDefaultQueryExtentToRef(result: Vector3): void;
  69476. /**
  69477. * Release all resources
  69478. */
  69479. dispose(): void;
  69480. }
  69481. /**
  69482. * Configures an agent
  69483. */
  69484. export interface IAgentParameters {
  69485. /**
  69486. * Agent radius. [Limit: >= 0]
  69487. */
  69488. radius: number;
  69489. /**
  69490. * Agent height. [Limit: > 0]
  69491. */
  69492. height: number;
  69493. /**
  69494. * Maximum allowed acceleration. [Limit: >= 0]
  69495. */
  69496. maxAcceleration: number;
  69497. /**
  69498. * Maximum allowed speed. [Limit: >= 0]
  69499. */
  69500. maxSpeed: number;
  69501. /**
  69502. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  69503. */
  69504. collisionQueryRange: number;
  69505. /**
  69506. * The path visibility optimization range. [Limit: > 0]
  69507. */
  69508. pathOptimizationRange: number;
  69509. /**
  69510. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  69511. */
  69512. separationWeight: number;
  69513. }
  69514. /**
  69515. * Configures the navigation mesh creation
  69516. */
  69517. export interface INavMeshParameters {
  69518. /**
  69519. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  69520. */
  69521. cs: number;
  69522. /**
  69523. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  69524. */
  69525. ch: number;
  69526. /**
  69527. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  69528. */
  69529. walkableSlopeAngle: number;
  69530. /**
  69531. * Minimum floor to 'ceiling' height that will still allow the floor area to
  69532. * be considered walkable. [Limit: >= 3] [Units: vx]
  69533. */
  69534. walkableHeight: number;
  69535. /**
  69536. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  69537. */
  69538. walkableClimb: number;
  69539. /**
  69540. * The distance to erode/shrink the walkable area of the heightfield away from
  69541. * obstructions. [Limit: >=0] [Units: vx]
  69542. */
  69543. walkableRadius: number;
  69544. /**
  69545. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  69546. */
  69547. maxEdgeLen: number;
  69548. /**
  69549. * The maximum distance a simplfied contour's border edges should deviate
  69550. * the original raw contour. [Limit: >=0] [Units: vx]
  69551. */
  69552. maxSimplificationError: number;
  69553. /**
  69554. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  69555. */
  69556. minRegionArea: number;
  69557. /**
  69558. * Any regions with a span count smaller than this value will, if possible,
  69559. * be merged with larger regions. [Limit: >=0] [Units: vx]
  69560. */
  69561. mergeRegionArea: number;
  69562. /**
  69563. * The maximum number of vertices allowed for polygons generated during the
  69564. * contour to polygon conversion process. [Limit: >= 3]
  69565. */
  69566. maxVertsPerPoly: number;
  69567. /**
  69568. * Sets the sampling distance to use when generating the detail mesh.
  69569. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  69570. */
  69571. detailSampleDist: number;
  69572. /**
  69573. * The maximum distance the detail mesh surface should deviate from heightfield
  69574. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  69575. */
  69576. detailSampleMaxError: number;
  69577. }
  69578. }
  69579. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  69580. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  69581. import { Mesh } from "babylonjs/Meshes/mesh";
  69582. import { Scene } from "babylonjs/scene";
  69583. import { Vector3 } from "babylonjs/Maths/math";
  69584. import { TransformNode } from "babylonjs/Meshes/transformNode";
  69585. /**
  69586. * RecastJS navigation plugin
  69587. */
  69588. export class RecastJSPlugin implements INavigationEnginePlugin {
  69589. /**
  69590. * Reference to the Recast library
  69591. */
  69592. bjsRECAST: any;
  69593. /**
  69594. * plugin name
  69595. */
  69596. name: string;
  69597. /**
  69598. * the first navmesh created. We might extend this to support multiple navmeshes
  69599. */
  69600. navMesh: any;
  69601. /**
  69602. * Initializes the recastJS plugin
  69603. * @param recastInjection can be used to inject your own recast reference
  69604. */
  69605. constructor(recastInjection?: any);
  69606. /**
  69607. * Creates a navigation mesh
  69608. * @param meshes array of all the geometry used to compute the navigatio mesh
  69609. * @param parameters bunch of parameters used to filter geometry
  69610. */
  69611. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  69612. /**
  69613. * Create a navigation mesh debug mesh
  69614. * @param scene is where the mesh will be added
  69615. * @returns debug display mesh
  69616. */
  69617. createDebugNavMesh(scene: Scene): Mesh;
  69618. /**
  69619. * Get a navigation mesh constrained position, closest to the parameter position
  69620. * @param position world position
  69621. * @returns the closest point to position constrained by the navigation mesh
  69622. */
  69623. getClosestPoint(position: Vector3): Vector3;
  69624. /**
  69625. * Get a navigation mesh constrained position, closest to the parameter position
  69626. * @param position world position
  69627. * @param result output the closest point to position constrained by the navigation mesh
  69628. */
  69629. getClosestPointToRef(position: Vector3, result: Vector3): void;
  69630. /**
  69631. * Get a navigation mesh constrained position, within a particular radius
  69632. * @param position world position
  69633. * @param maxRadius the maximum distance to the constrained world position
  69634. * @returns the closest point to position constrained by the navigation mesh
  69635. */
  69636. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  69637. /**
  69638. * Get a navigation mesh constrained position, within a particular radius
  69639. * @param position world position
  69640. * @param maxRadius the maximum distance to the constrained world position
  69641. * @param result output the closest point to position constrained by the navigation mesh
  69642. */
  69643. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  69644. /**
  69645. * Compute the final position from a segment made of destination-position
  69646. * @param position world position
  69647. * @param destination world position
  69648. * @returns the resulting point along the navmesh
  69649. */
  69650. moveAlong(position: Vector3, destination: Vector3): Vector3;
  69651. /**
  69652. * Compute the final position from a segment made of destination-position
  69653. * @param position world position
  69654. * @param destination world position
  69655. * @param result output the resulting point along the navmesh
  69656. */
  69657. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  69658. /**
  69659. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  69660. * @param start world position
  69661. * @param end world position
  69662. * @returns array containing world position composing the path
  69663. */
  69664. computePath(start: Vector3, end: Vector3): Vector3[];
  69665. /**
  69666. * Create a new Crowd so you can add agents
  69667. * @param maxAgents the maximum agent count in the crowd
  69668. * @param maxAgentRadius the maximum radius an agent can have
  69669. * @param scene to attach the crowd to
  69670. * @returns the crowd you can add agents to
  69671. */
  69672. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  69673. /**
  69674. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69675. * The queries will try to find a solution within those bounds
  69676. * default is (1,1,1)
  69677. * @param extent x,y,z value that define the extent around the queries point of reference
  69678. */
  69679. setDefaultQueryExtent(extent: Vector3): void;
  69680. /**
  69681. * Get the Bounding box extent specified by setDefaultQueryExtent
  69682. * @returns the box extent values
  69683. */
  69684. getDefaultQueryExtent(): Vector3;
  69685. /**
  69686. * build the navmesh from a previously saved state using getNavmeshData
  69687. * @param data the Uint8Array returned by getNavmeshData
  69688. */
  69689. buildFromNavmeshData(data: Uint8Array): void;
  69690. /**
  69691. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  69692. * @returns data the Uint8Array that can be saved and reused
  69693. */
  69694. getNavmeshData(): Uint8Array;
  69695. /**
  69696. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69697. * @param result output the box extent values
  69698. */
  69699. getDefaultQueryExtentToRef(result: Vector3): void;
  69700. /**
  69701. * Disposes
  69702. */
  69703. dispose(): void;
  69704. /**
  69705. * If this plugin is supported
  69706. * @returns true if plugin is supported
  69707. */
  69708. isSupported(): boolean;
  69709. }
  69710. /**
  69711. * Recast detour crowd implementation
  69712. */
  69713. export class RecastJSCrowd implements ICrowd {
  69714. /**
  69715. * Recast/detour plugin
  69716. */
  69717. bjsRECASTPlugin: RecastJSPlugin;
  69718. /**
  69719. * Link to the detour crowd
  69720. */
  69721. recastCrowd: any;
  69722. /**
  69723. * One transform per agent
  69724. */
  69725. transforms: TransformNode[];
  69726. /**
  69727. * All agents created
  69728. */
  69729. agents: number[];
  69730. /**
  69731. * Link to the scene is kept to unregister the crowd from the scene
  69732. */
  69733. private _scene;
  69734. /**
  69735. * Observer for crowd updates
  69736. */
  69737. private _onBeforeAnimationsObserver;
  69738. /**
  69739. * Constructor
  69740. * @param plugin recastJS plugin
  69741. * @param maxAgents the maximum agent count in the crowd
  69742. * @param maxAgentRadius the maximum radius an agent can have
  69743. * @param scene to attach the crowd to
  69744. * @returns the crowd you can add agents to
  69745. */
  69746. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  69747. /**
  69748. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  69749. * You can attach anything to that node. The node position is updated in the scene update tick.
  69750. * @param pos world position that will be constrained by the navigation mesh
  69751. * @param parameters agent parameters
  69752. * @param transform hooked to the agent that will be update by the scene
  69753. * @returns agent index
  69754. */
  69755. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  69756. /**
  69757. * Returns the agent position in world space
  69758. * @param index agent index returned by addAgent
  69759. * @returns world space position
  69760. */
  69761. getAgentPosition(index: number): Vector3;
  69762. /**
  69763. * Returns the agent position result in world space
  69764. * @param index agent index returned by addAgent
  69765. * @param result output world space position
  69766. */
  69767. getAgentPositionToRef(index: number, result: Vector3): void;
  69768. /**
  69769. * Returns the agent velocity in world space
  69770. * @param index agent index returned by addAgent
  69771. * @returns world space velocity
  69772. */
  69773. getAgentVelocity(index: number): Vector3;
  69774. /**
  69775. * Returns the agent velocity result in world space
  69776. * @param index agent index returned by addAgent
  69777. * @param result output world space velocity
  69778. */
  69779. getAgentVelocityToRef(index: number, result: Vector3): void;
  69780. /**
  69781. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  69782. * @param index agent index returned by addAgent
  69783. * @param destination targeted world position
  69784. */
  69785. agentGoto(index: number, destination: Vector3): void;
  69786. /**
  69787. * Teleport the agent to a new position
  69788. * @param index agent index returned by addAgent
  69789. * @param destination targeted world position
  69790. */
  69791. agentTeleport(index: number, destination: Vector3): void;
  69792. /**
  69793. * Update agent parameters
  69794. * @param index agent index returned by addAgent
  69795. * @param parameters agent parameters
  69796. */
  69797. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  69798. /**
  69799. * remove a particular agent previously created
  69800. * @param index agent index returned by addAgent
  69801. */
  69802. removeAgent(index: number): void;
  69803. /**
  69804. * get the list of all agents attached to this crowd
  69805. * @returns list of agent indices
  69806. */
  69807. getAgents(): number[];
  69808. /**
  69809. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  69810. * @param deltaTime in seconds
  69811. */
  69812. update(deltaTime: number): void;
  69813. /**
  69814. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  69815. * The queries will try to find a solution within those bounds
  69816. * default is (1,1,1)
  69817. * @param extent x,y,z value that define the extent around the queries point of reference
  69818. */
  69819. setDefaultQueryExtent(extent: Vector3): void;
  69820. /**
  69821. * Get the Bounding box extent specified by setDefaultQueryExtent
  69822. * @returns the box extent values
  69823. */
  69824. getDefaultQueryExtent(): Vector3;
  69825. /**
  69826. * Get the Bounding box extent result specified by setDefaultQueryExtent
  69827. * @param result output the box extent values
  69828. */
  69829. getDefaultQueryExtentToRef(result: Vector3): void;
  69830. /**
  69831. * Release all resources
  69832. */
  69833. dispose(): void;
  69834. }
  69835. }
  69836. declare module "babylonjs/Navigation/Plugins/index" {
  69837. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  69838. }
  69839. declare module "babylonjs/Navigation/index" {
  69840. export * from "babylonjs/Navigation/INavigationEngine";
  69841. export * from "babylonjs/Navigation/Plugins/index";
  69842. }
  69843. declare module "babylonjs/Offline/database" {
  69844. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  69845. /**
  69846. * Class used to enable access to IndexedDB
  69847. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  69848. */
  69849. export class Database implements IOfflineProvider {
  69850. private _callbackManifestChecked;
  69851. private _currentSceneUrl;
  69852. private _db;
  69853. private _enableSceneOffline;
  69854. private _enableTexturesOffline;
  69855. private _manifestVersionFound;
  69856. private _mustUpdateRessources;
  69857. private _hasReachedQuota;
  69858. private _isSupported;
  69859. private _idbFactory;
  69860. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  69861. private static IsUASupportingBlobStorage;
  69862. /**
  69863. * Gets a boolean indicating if Database storate is enabled (off by default)
  69864. */
  69865. static IDBStorageEnabled: boolean;
  69866. /**
  69867. * Gets a boolean indicating if scene must be saved in the database
  69868. */
  69869. get enableSceneOffline(): boolean;
  69870. /**
  69871. * Gets a boolean indicating if textures must be saved in the database
  69872. */
  69873. get enableTexturesOffline(): boolean;
  69874. /**
  69875. * Creates a new Database
  69876. * @param urlToScene defines the url to load the scene
  69877. * @param callbackManifestChecked defines the callback to use when manifest is checked
  69878. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  69879. */
  69880. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  69881. private static _ParseURL;
  69882. private static _ReturnFullUrlLocation;
  69883. private _checkManifestFile;
  69884. /**
  69885. * Open the database and make it available
  69886. * @param successCallback defines the callback to call on success
  69887. * @param errorCallback defines the callback to call on error
  69888. */
  69889. open(successCallback: () => void, errorCallback: () => void): void;
  69890. /**
  69891. * Loads an image from the database
  69892. * @param url defines the url to load from
  69893. * @param image defines the target DOM image
  69894. */
  69895. loadImage(url: string, image: HTMLImageElement): void;
  69896. private _loadImageFromDBAsync;
  69897. private _saveImageIntoDBAsync;
  69898. private _checkVersionFromDB;
  69899. private _loadVersionFromDBAsync;
  69900. private _saveVersionIntoDBAsync;
  69901. /**
  69902. * Loads a file from database
  69903. * @param url defines the URL to load from
  69904. * @param sceneLoaded defines a callback to call on success
  69905. * @param progressCallBack defines a callback to call when progress changed
  69906. * @param errorCallback defines a callback to call on error
  69907. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  69908. */
  69909. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  69910. private _loadFileAsync;
  69911. private _saveFileAsync;
  69912. /**
  69913. * Validates if xhr data is correct
  69914. * @param xhr defines the request to validate
  69915. * @param dataType defines the expected data type
  69916. * @returns true if data is correct
  69917. */
  69918. private static _ValidateXHRData;
  69919. }
  69920. }
  69921. declare module "babylonjs/Offline/index" {
  69922. export * from "babylonjs/Offline/database";
  69923. export * from "babylonjs/Offline/IOfflineProvider";
  69924. }
  69925. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  69926. /** @hidden */
  69927. export var gpuUpdateParticlesPixelShader: {
  69928. name: string;
  69929. shader: string;
  69930. };
  69931. }
  69932. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  69933. /** @hidden */
  69934. export var gpuUpdateParticlesVertexShader: {
  69935. name: string;
  69936. shader: string;
  69937. };
  69938. }
  69939. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  69940. /** @hidden */
  69941. export var clipPlaneFragmentDeclaration2: {
  69942. name: string;
  69943. shader: string;
  69944. };
  69945. }
  69946. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  69947. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  69948. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  69949. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  69950. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  69951. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  69952. /** @hidden */
  69953. export var gpuRenderParticlesPixelShader: {
  69954. name: string;
  69955. shader: string;
  69956. };
  69957. }
  69958. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  69959. /** @hidden */
  69960. export var clipPlaneVertexDeclaration2: {
  69961. name: string;
  69962. shader: string;
  69963. };
  69964. }
  69965. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  69966. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  69967. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  69968. /** @hidden */
  69969. export var gpuRenderParticlesVertexShader: {
  69970. name: string;
  69971. shader: string;
  69972. };
  69973. }
  69974. declare module "babylonjs/Particles/gpuParticleSystem" {
  69975. import { Nullable } from "babylonjs/types";
  69976. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  69977. import { Observable } from "babylonjs/Misc/observable";
  69978. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69979. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  69980. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  69981. import { Scene, IDisposable } from "babylonjs/scene";
  69982. import { Effect } from "babylonjs/Materials/effect";
  69983. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  69984. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69985. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  69986. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  69987. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  69988. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  69989. /**
  69990. * This represents a GPU particle system in Babylon
  69991. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  69992. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  69993. */
  69994. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  69995. /**
  69996. * The layer mask we are rendering the particles through.
  69997. */
  69998. layerMask: number;
  69999. private _capacity;
  70000. private _activeCount;
  70001. private _currentActiveCount;
  70002. private _accumulatedCount;
  70003. private _renderEffect;
  70004. private _updateEffect;
  70005. private _buffer0;
  70006. private _buffer1;
  70007. private _spriteBuffer;
  70008. private _updateVAO;
  70009. private _renderVAO;
  70010. private _targetIndex;
  70011. private _sourceBuffer;
  70012. private _targetBuffer;
  70013. private _engine;
  70014. private _currentRenderId;
  70015. private _started;
  70016. private _stopped;
  70017. private _timeDelta;
  70018. private _randomTexture;
  70019. private _randomTexture2;
  70020. private _attributesStrideSize;
  70021. private _updateEffectOptions;
  70022. private _randomTextureSize;
  70023. private _actualFrame;
  70024. private _customEffect;
  70025. private readonly _rawTextureWidth;
  70026. /**
  70027. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  70028. */
  70029. static get IsSupported(): boolean;
  70030. /**
  70031. * An event triggered when the system is disposed.
  70032. */
  70033. onDisposeObservable: Observable<IParticleSystem>;
  70034. /**
  70035. * Gets the maximum number of particles active at the same time.
  70036. * @returns The max number of active particles.
  70037. */
  70038. getCapacity(): number;
  70039. /**
  70040. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  70041. * to override the particles.
  70042. */
  70043. forceDepthWrite: boolean;
  70044. /**
  70045. * Gets or set the number of active particles
  70046. */
  70047. get activeParticleCount(): number;
  70048. set activeParticleCount(value: number);
  70049. private _preWarmDone;
  70050. /**
  70051. * Specifies if the particles are updated in emitter local space or world space.
  70052. */
  70053. isLocal: boolean;
  70054. /**
  70055. * Is this system ready to be used/rendered
  70056. * @return true if the system is ready
  70057. */
  70058. isReady(): boolean;
  70059. /**
  70060. * Gets if the system has been started. (Note: this will still be true after stop is called)
  70061. * @returns True if it has been started, otherwise false.
  70062. */
  70063. isStarted(): boolean;
  70064. /**
  70065. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  70066. * @returns True if it has been stopped, otherwise false.
  70067. */
  70068. isStopped(): boolean;
  70069. /**
  70070. * Gets a boolean indicating that the system is stopping
  70071. * @returns true if the system is currently stopping
  70072. */
  70073. isStopping(): boolean;
  70074. /**
  70075. * Gets the number of particles active at the same time.
  70076. * @returns The number of active particles.
  70077. */
  70078. getActiveCount(): number;
  70079. /**
  70080. * Starts the particle system and begins to emit
  70081. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  70082. */
  70083. start(delay?: number): void;
  70084. /**
  70085. * Stops the particle system.
  70086. */
  70087. stop(): void;
  70088. /**
  70089. * Remove all active particles
  70090. */
  70091. reset(): void;
  70092. /**
  70093. * Returns the string "GPUParticleSystem"
  70094. * @returns a string containing the class name
  70095. */
  70096. getClassName(): string;
  70097. /**
  70098. * Gets the custom effect used to render the particles
  70099. * @param blendMode Blend mode for which the effect should be retrieved
  70100. * @returns The effect
  70101. */
  70102. getCustomEffect(blendMode?: number): Nullable<Effect>;
  70103. /**
  70104. * Sets the custom effect used to render the particles
  70105. * @param effect The effect to set
  70106. * @param blendMode Blend mode for which the effect should be set
  70107. */
  70108. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  70109. /** @hidden */
  70110. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  70111. /**
  70112. * Observable that will be called just before the particles are drawn
  70113. */
  70114. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  70115. /**
  70116. * Gets the name of the particle vertex shader
  70117. */
  70118. get vertexShaderName(): string;
  70119. private _colorGradientsTexture;
  70120. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  70121. /**
  70122. * Adds a new color gradient
  70123. * @param gradient defines the gradient to use (between 0 and 1)
  70124. * @param color1 defines the color to affect to the specified gradient
  70125. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  70126. * @returns the current particle system
  70127. */
  70128. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  70129. private _refreshColorGradient;
  70130. /** Force the system to rebuild all gradients that need to be resync */
  70131. forceRefreshGradients(): void;
  70132. /**
  70133. * Remove a specific color gradient
  70134. * @param gradient defines the gradient to remove
  70135. * @returns the current particle system
  70136. */
  70137. removeColorGradient(gradient: number): GPUParticleSystem;
  70138. private _angularSpeedGradientsTexture;
  70139. private _sizeGradientsTexture;
  70140. private _velocityGradientsTexture;
  70141. private _limitVelocityGradientsTexture;
  70142. private _dragGradientsTexture;
  70143. private _addFactorGradient;
  70144. /**
  70145. * Adds a new size gradient
  70146. * @param gradient defines the gradient to use (between 0 and 1)
  70147. * @param factor defines the size factor to affect to the specified gradient
  70148. * @returns the current particle system
  70149. */
  70150. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  70151. /**
  70152. * Remove a specific size gradient
  70153. * @param gradient defines the gradient to remove
  70154. * @returns the current particle system
  70155. */
  70156. removeSizeGradient(gradient: number): GPUParticleSystem;
  70157. private _refreshFactorGradient;
  70158. /**
  70159. * Adds a new angular speed gradient
  70160. * @param gradient defines the gradient to use (between 0 and 1)
  70161. * @param factor defines the angular speed to affect to the specified gradient
  70162. * @returns the current particle system
  70163. */
  70164. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  70165. /**
  70166. * Remove a specific angular speed gradient
  70167. * @param gradient defines the gradient to remove
  70168. * @returns the current particle system
  70169. */
  70170. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  70171. /**
  70172. * Adds a new velocity gradient
  70173. * @param gradient defines the gradient to use (between 0 and 1)
  70174. * @param factor defines the velocity to affect to the specified gradient
  70175. * @returns the current particle system
  70176. */
  70177. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70178. /**
  70179. * Remove a specific velocity gradient
  70180. * @param gradient defines the gradient to remove
  70181. * @returns the current particle system
  70182. */
  70183. removeVelocityGradient(gradient: number): GPUParticleSystem;
  70184. /**
  70185. * Adds a new limit velocity gradient
  70186. * @param gradient defines the gradient to use (between 0 and 1)
  70187. * @param factor defines the limit velocity value to affect to the specified gradient
  70188. * @returns the current particle system
  70189. */
  70190. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  70191. /**
  70192. * Remove a specific limit velocity gradient
  70193. * @param gradient defines the gradient to remove
  70194. * @returns the current particle system
  70195. */
  70196. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  70197. /**
  70198. * Adds a new drag gradient
  70199. * @param gradient defines the gradient to use (between 0 and 1)
  70200. * @param factor defines the drag value to affect to the specified gradient
  70201. * @returns the current particle system
  70202. */
  70203. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  70204. /**
  70205. * Remove a specific drag gradient
  70206. * @param gradient defines the gradient to remove
  70207. * @returns the current particle system
  70208. */
  70209. removeDragGradient(gradient: number): GPUParticleSystem;
  70210. /**
  70211. * Not supported by GPUParticleSystem
  70212. * @param gradient defines the gradient to use (between 0 and 1)
  70213. * @param factor defines the emit rate value to affect to the specified gradient
  70214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70215. * @returns the current particle system
  70216. */
  70217. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70218. /**
  70219. * Not supported by GPUParticleSystem
  70220. * @param gradient defines the gradient to remove
  70221. * @returns the current particle system
  70222. */
  70223. removeEmitRateGradient(gradient: number): IParticleSystem;
  70224. /**
  70225. * Not supported by GPUParticleSystem
  70226. * @param gradient defines the gradient to use (between 0 and 1)
  70227. * @param factor defines the start size value to affect to the specified gradient
  70228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70229. * @returns the current particle system
  70230. */
  70231. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70232. /**
  70233. * Not supported by GPUParticleSystem
  70234. * @param gradient defines the gradient to remove
  70235. * @returns the current particle system
  70236. */
  70237. removeStartSizeGradient(gradient: number): IParticleSystem;
  70238. /**
  70239. * Not supported by GPUParticleSystem
  70240. * @param gradient defines the gradient to use (between 0 and 1)
  70241. * @param min defines the color remap minimal range
  70242. * @param max defines the color remap maximal range
  70243. * @returns the current particle system
  70244. */
  70245. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70246. /**
  70247. * Not supported by GPUParticleSystem
  70248. * @param gradient defines the gradient to remove
  70249. * @returns the current particle system
  70250. */
  70251. removeColorRemapGradient(): IParticleSystem;
  70252. /**
  70253. * Not supported by GPUParticleSystem
  70254. * @param gradient defines the gradient to use (between 0 and 1)
  70255. * @param min defines the alpha remap minimal range
  70256. * @param max defines the alpha remap maximal range
  70257. * @returns the current particle system
  70258. */
  70259. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  70260. /**
  70261. * Not supported by GPUParticleSystem
  70262. * @param gradient defines the gradient to remove
  70263. * @returns the current particle system
  70264. */
  70265. removeAlphaRemapGradient(): IParticleSystem;
  70266. /**
  70267. * Not supported by GPUParticleSystem
  70268. * @param gradient defines the gradient to use (between 0 and 1)
  70269. * @param color defines the color to affect to the specified gradient
  70270. * @returns the current particle system
  70271. */
  70272. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  70273. /**
  70274. * Not supported by GPUParticleSystem
  70275. * @param gradient defines the gradient to remove
  70276. * @returns the current particle system
  70277. */
  70278. removeRampGradient(): IParticleSystem;
  70279. /**
  70280. * Not supported by GPUParticleSystem
  70281. * @returns the list of ramp gradients
  70282. */
  70283. getRampGradients(): Nullable<Array<Color3Gradient>>;
  70284. /**
  70285. * Not supported by GPUParticleSystem
  70286. * Gets or sets a boolean indicating that ramp gradients must be used
  70287. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  70288. */
  70289. get useRampGradients(): boolean;
  70290. set useRampGradients(value: boolean);
  70291. /**
  70292. * Not supported by GPUParticleSystem
  70293. * @param gradient defines the gradient to use (between 0 and 1)
  70294. * @param factor defines the life time factor to affect to the specified gradient
  70295. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  70296. * @returns the current particle system
  70297. */
  70298. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  70299. /**
  70300. * Not supported by GPUParticleSystem
  70301. * @param gradient defines the gradient to remove
  70302. * @returns the current particle system
  70303. */
  70304. removeLifeTimeGradient(gradient: number): IParticleSystem;
  70305. /**
  70306. * Instantiates a GPU particle system.
  70307. * 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.
  70308. * @param name The name of the particle system
  70309. * @param options The options used to create the system
  70310. * @param scene The scene the particle system belongs to
  70311. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  70312. * @param customEffect a custom effect used to change the way particles are rendered by default
  70313. */
  70314. constructor(name: string, options: Partial<{
  70315. capacity: number;
  70316. randomTextureSize: number;
  70317. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  70318. protected _reset(): void;
  70319. private _createUpdateVAO;
  70320. private _createRenderVAO;
  70321. private _initialize;
  70322. /** @hidden */
  70323. _recreateUpdateEffect(): void;
  70324. private _getEffect;
  70325. /**
  70326. * Fill the defines array according to the current settings of the particle system
  70327. * @param defines Array to be updated
  70328. * @param blendMode blend mode to take into account when updating the array
  70329. */
  70330. fillDefines(defines: Array<string>, blendMode?: number): void;
  70331. /**
  70332. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  70333. * @param uniforms Uniforms array to fill
  70334. * @param attributes Attributes array to fill
  70335. * @param samplers Samplers array to fill
  70336. */
  70337. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  70338. /** @hidden */
  70339. _recreateRenderEffect(): Effect;
  70340. /**
  70341. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  70342. * @param preWarm defines if we are in the pre-warmimg phase
  70343. */
  70344. animate(preWarm?: boolean): void;
  70345. private _createFactorGradientTexture;
  70346. private _createSizeGradientTexture;
  70347. private _createAngularSpeedGradientTexture;
  70348. private _createVelocityGradientTexture;
  70349. private _createLimitVelocityGradientTexture;
  70350. private _createDragGradientTexture;
  70351. private _createColorGradientTexture;
  70352. /**
  70353. * Renders the particle system in its current state
  70354. * @param preWarm defines if the system should only update the particles but not render them
  70355. * @returns the current number of particles
  70356. */
  70357. render(preWarm?: boolean): number;
  70358. /**
  70359. * Rebuilds the particle system
  70360. */
  70361. rebuild(): void;
  70362. private _releaseBuffers;
  70363. private _releaseVAOs;
  70364. /**
  70365. * Disposes the particle system and free the associated resources
  70366. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  70367. */
  70368. dispose(disposeTexture?: boolean): void;
  70369. /**
  70370. * Clones the particle system.
  70371. * @param name The name of the cloned object
  70372. * @param newEmitter The new emitter to use
  70373. * @returns the cloned particle system
  70374. */
  70375. clone(name: string, newEmitter: any): GPUParticleSystem;
  70376. /**
  70377. * Serializes the particle system to a JSON object
  70378. * @param serializeTexture defines if the texture must be serialized as well
  70379. * @returns the JSON object
  70380. */
  70381. serialize(serializeTexture?: boolean): any;
  70382. /**
  70383. * Parses a JSON object to create a GPU particle system.
  70384. * @param parsedParticleSystem The JSON object to parse
  70385. * @param scene The scene to create the particle system in
  70386. * @param rootUrl The root url to use to load external dependencies like texture
  70387. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  70388. * @returns the parsed GPU particle system
  70389. */
  70390. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  70391. }
  70392. }
  70393. declare module "babylonjs/Particles/particleSystemSet" {
  70394. import { Nullable } from "babylonjs/types";
  70395. import { Color3 } from "babylonjs/Maths/math.color";
  70396. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70398. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70399. import { Scene, IDisposable } from "babylonjs/scene";
  70400. /**
  70401. * Represents a set of particle systems working together to create a specific effect
  70402. */
  70403. export class ParticleSystemSet implements IDisposable {
  70404. /**
  70405. * Gets or sets base Assets URL
  70406. */
  70407. static BaseAssetsUrl: string;
  70408. private _emitterCreationOptions;
  70409. private _emitterNode;
  70410. /**
  70411. * Gets the particle system list
  70412. */
  70413. systems: IParticleSystem[];
  70414. /**
  70415. * Gets the emitter node used with this set
  70416. */
  70417. get emitterNode(): Nullable<TransformNode>;
  70418. /**
  70419. * Creates a new emitter mesh as a sphere
  70420. * @param options defines the options used to create the sphere
  70421. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  70422. * @param scene defines the hosting scene
  70423. */
  70424. setEmitterAsSphere(options: {
  70425. diameter: number;
  70426. segments: number;
  70427. color: Color3;
  70428. }, renderingGroupId: number, scene: Scene): void;
  70429. /**
  70430. * Starts all particle systems of the set
  70431. * @param emitter defines an optional mesh to use as emitter for the particle systems
  70432. */
  70433. start(emitter?: AbstractMesh): void;
  70434. /**
  70435. * Release all associated resources
  70436. */
  70437. dispose(): void;
  70438. /**
  70439. * Serialize the set into a JSON compatible object
  70440. * @param serializeTexture defines if the texture must be serialized as well
  70441. * @returns a JSON compatible representation of the set
  70442. */
  70443. serialize(serializeTexture?: boolean): any;
  70444. /**
  70445. * Parse a new ParticleSystemSet from a serialized source
  70446. * @param data defines a JSON compatible representation of the set
  70447. * @param scene defines the hosting scene
  70448. * @param gpu defines if we want GPU particles or CPU particles
  70449. * @returns a new ParticleSystemSet
  70450. */
  70451. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  70452. }
  70453. }
  70454. declare module "babylonjs/Particles/particleHelper" {
  70455. import { Nullable } from "babylonjs/types";
  70456. import { Scene } from "babylonjs/scene";
  70457. import { Vector3 } from "babylonjs/Maths/math.vector";
  70458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70459. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70460. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  70461. /**
  70462. * This class is made for on one-liner static method to help creating particle system set.
  70463. */
  70464. export class ParticleHelper {
  70465. /**
  70466. * Gets or sets base Assets URL
  70467. */
  70468. static BaseAssetsUrl: string;
  70469. /** Define the Url to load snippets */
  70470. static SnippetUrl: string;
  70471. /**
  70472. * Create a default particle system that you can tweak
  70473. * @param emitter defines the emitter to use
  70474. * @param capacity defines the system capacity (default is 500 particles)
  70475. * @param scene defines the hosting scene
  70476. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  70477. * @returns the new Particle system
  70478. */
  70479. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  70480. /**
  70481. * This is the main static method (one-liner) of this helper to create different particle systems
  70482. * @param type This string represents the type to the particle system to create
  70483. * @param scene The scene where the particle system should live
  70484. * @param gpu If the system will use gpu
  70485. * @returns the ParticleSystemSet created
  70486. */
  70487. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  70488. /**
  70489. * Static function used to export a particle system to a ParticleSystemSet variable.
  70490. * Please note that the emitter shape is not exported
  70491. * @param systems defines the particle systems to export
  70492. * @returns the created particle system set
  70493. */
  70494. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  70495. /**
  70496. * Creates a particle system from a snippet saved in a remote file
  70497. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  70498. * @param url defines the url to load from
  70499. * @param scene defines the hosting scene
  70500. * @param gpu If the system will use gpu
  70501. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70502. * @returns a promise that will resolve to the new particle system
  70503. */
  70504. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70505. /**
  70506. * Creates a particle system from a snippet saved by the particle system editor
  70507. * @param snippetId defines the snippet to load
  70508. * @param scene defines the hosting scene
  70509. * @param gpu If the system will use gpu
  70510. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  70511. * @returns a promise that will resolve to the new particle system
  70512. */
  70513. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  70514. }
  70515. }
  70516. declare module "babylonjs/Particles/particleSystemComponent" {
  70517. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70518. import { Effect } from "babylonjs/Materials/effect";
  70519. import "babylonjs/Shaders/particles.vertex";
  70520. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  70521. module "babylonjs/Engines/engine" {
  70522. interface Engine {
  70523. /**
  70524. * Create an effect to use with particle systems.
  70525. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  70526. * the particle system for which you want to create a custom effect in the last parameter
  70527. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  70528. * @param uniformsNames defines a list of attribute names
  70529. * @param samplers defines an array of string used to represent textures
  70530. * @param defines defines the string containing the defines to use to compile the shaders
  70531. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  70532. * @param onCompiled defines a function to call when the effect creation is successful
  70533. * @param onError defines a function to call when the effect creation has failed
  70534. * @param particleSystem the particle system you want to create the effect for
  70535. * @returns the new Effect
  70536. */
  70537. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  70538. }
  70539. }
  70540. module "babylonjs/Meshes/mesh" {
  70541. interface Mesh {
  70542. /**
  70543. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  70544. * @returns an array of IParticleSystem
  70545. */
  70546. getEmittedParticleSystems(): IParticleSystem[];
  70547. /**
  70548. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  70549. * @returns an array of IParticleSystem
  70550. */
  70551. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  70552. }
  70553. }
  70554. }
  70555. declare module "babylonjs/Particles/pointsCloudSystem" {
  70556. import { Color4 } from "babylonjs/Maths/math";
  70557. import { Mesh } from "babylonjs/Meshes/mesh";
  70558. import { Scene, IDisposable } from "babylonjs/scene";
  70559. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  70560. /** Defines the 4 color options */
  70561. export enum PointColor {
  70562. /** color value */
  70563. Color = 2,
  70564. /** uv value */
  70565. UV = 1,
  70566. /** random value */
  70567. Random = 0,
  70568. /** stated value */
  70569. Stated = 3
  70570. }
  70571. /**
  70572. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  70573. * 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.
  70574. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  70575. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  70576. *
  70577. * Full documentation here : TO BE ENTERED
  70578. */
  70579. export class PointsCloudSystem implements IDisposable {
  70580. /**
  70581. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  70582. * Example : var p = SPS.particles[i];
  70583. */
  70584. particles: CloudPoint[];
  70585. /**
  70586. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  70587. */
  70588. nbParticles: number;
  70589. /**
  70590. * This a counter for your own usage. It's not set by any SPS functions.
  70591. */
  70592. counter: number;
  70593. /**
  70594. * The PCS name. This name is also given to the underlying mesh.
  70595. */
  70596. name: string;
  70597. /**
  70598. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  70599. */
  70600. mesh: Mesh;
  70601. /**
  70602. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  70603. * Please read :
  70604. */
  70605. vars: any;
  70606. /**
  70607. * @hidden
  70608. */
  70609. _size: number;
  70610. private _scene;
  70611. private _promises;
  70612. private _positions;
  70613. private _indices;
  70614. private _normals;
  70615. private _colors;
  70616. private _uvs;
  70617. private _indices32;
  70618. private _positions32;
  70619. private _colors32;
  70620. private _uvs32;
  70621. private _updatable;
  70622. private _isVisibilityBoxLocked;
  70623. private _alwaysVisible;
  70624. private _groups;
  70625. private _groupCounter;
  70626. private _computeParticleColor;
  70627. private _computeParticleTexture;
  70628. private _computeParticleRotation;
  70629. private _computeBoundingBox;
  70630. private _isReady;
  70631. /**
  70632. * Creates a PCS (Points Cloud System) object
  70633. * @param name (String) is the PCS name, this will be the underlying mesh name
  70634. * @param pointSize (number) is the size for each point
  70635. * @param scene (Scene) is the scene in which the PCS is added
  70636. * @param options defines the options of the PCS e.g.
  70637. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  70638. */
  70639. constructor(name: string, pointSize: number, scene: Scene, options?: {
  70640. updatable?: boolean;
  70641. });
  70642. /**
  70643. * Builds the PCS underlying mesh. Returns a standard Mesh.
  70644. * If no points were added to the PCS, the returned mesh is just a single point.
  70645. * @returns a promise for the created mesh
  70646. */
  70647. buildMeshAsync(): Promise<Mesh>;
  70648. /**
  70649. * @hidden
  70650. */
  70651. private _buildMesh;
  70652. private _addParticle;
  70653. private _randomUnitVector;
  70654. private _getColorIndicesForCoord;
  70655. private _setPointsColorOrUV;
  70656. private _colorFromTexture;
  70657. private _calculateDensity;
  70658. /**
  70659. * Adds points to the PCS in random positions within a unit sphere
  70660. * @param nb (positive integer) the number of particles to be created from this model
  70661. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  70662. * @returns the number of groups in the system
  70663. */
  70664. addPoints(nb: number, pointFunction?: any): number;
  70665. /**
  70666. * Adds points to the PCS from the surface of the model shape
  70667. * @param mesh is any Mesh object that will be used as a surface model for the points
  70668. * @param nb (positive integer) the number of particles to be created from this model
  70669. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70670. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70671. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70672. * @returns the number of groups in the system
  70673. */
  70674. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70675. /**
  70676. * Adds points to the PCS inside the model shape
  70677. * @param mesh is any Mesh object that will be used as a surface model for the points
  70678. * @param nb (positive integer) the number of particles to be created from this model
  70679. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  70680. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  70681. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  70682. * @returns the number of groups in the system
  70683. */
  70684. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  70685. /**
  70686. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  70687. * This method calls `updateParticle()` for each particle of the SPS.
  70688. * For an animated SPS, it is usually called within the render loop.
  70689. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  70690. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  70691. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  70692. * @returns the PCS.
  70693. */
  70694. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  70695. /**
  70696. * Disposes the PCS.
  70697. */
  70698. dispose(): void;
  70699. /**
  70700. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  70701. * doc :
  70702. * @returns the PCS.
  70703. */
  70704. refreshVisibleSize(): PointsCloudSystem;
  70705. /**
  70706. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  70707. * @param size the size (float) of the visibility box
  70708. * note : this doesn't lock the PCS mesh bounding box.
  70709. * doc :
  70710. */
  70711. setVisibilityBox(size: number): void;
  70712. /**
  70713. * Gets whether the PCS is always visible or not
  70714. * doc :
  70715. */
  70716. get isAlwaysVisible(): boolean;
  70717. /**
  70718. * Sets the PCS as always visible or not
  70719. * doc :
  70720. */
  70721. set isAlwaysVisible(val: boolean);
  70722. /**
  70723. * Tells to `setParticles()` to compute the particle rotations or not
  70724. * Default value : false. The PCS is faster when it's set to false
  70725. * Note : particle rotations are only applied to parent particles
  70726. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  70727. */
  70728. set computeParticleRotation(val: boolean);
  70729. /**
  70730. * Tells to `setParticles()` to compute the particle colors or not.
  70731. * Default value : true. The PCS is faster when it's set to false.
  70732. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70733. */
  70734. set computeParticleColor(val: boolean);
  70735. set computeParticleTexture(val: boolean);
  70736. /**
  70737. * Gets if `setParticles()` computes the particle colors or not.
  70738. * Default value : false. The PCS is faster when it's set to false.
  70739. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  70740. */
  70741. get computeParticleColor(): boolean;
  70742. /**
  70743. * Gets if `setParticles()` computes the particle textures or not.
  70744. * Default value : false. The PCS is faster when it's set to false.
  70745. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  70746. */
  70747. get computeParticleTexture(): boolean;
  70748. /**
  70749. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  70750. */
  70751. set computeBoundingBox(val: boolean);
  70752. /**
  70753. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  70754. */
  70755. get computeBoundingBox(): boolean;
  70756. /**
  70757. * This function does nothing. It may be overwritten to set all the particle first values.
  70758. * The PCS doesn't call this function, you may have to call it by your own.
  70759. * doc :
  70760. */
  70761. initParticles(): void;
  70762. /**
  70763. * This function does nothing. It may be overwritten to recycle a particle
  70764. * The PCS doesn't call this function, you can to call it
  70765. * doc :
  70766. * @param particle The particle to recycle
  70767. * @returns the recycled particle
  70768. */
  70769. recycleParticle(particle: CloudPoint): CloudPoint;
  70770. /**
  70771. * Updates a particle : this function should be overwritten by the user.
  70772. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  70773. * doc :
  70774. * @example : just set a particle position or velocity and recycle conditions
  70775. * @param particle The particle to update
  70776. * @returns the updated particle
  70777. */
  70778. updateParticle(particle: CloudPoint): CloudPoint;
  70779. /**
  70780. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  70781. * This does nothing and may be overwritten by the user.
  70782. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70783. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70784. * @param update the boolean update value actually passed to setParticles()
  70785. */
  70786. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70787. /**
  70788. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  70789. * This will be passed three parameters.
  70790. * This does nothing and may be overwritten by the user.
  70791. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  70792. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  70793. * @param update the boolean update value actually passed to setParticles()
  70794. */
  70795. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  70796. }
  70797. }
  70798. declare module "babylonjs/Particles/cloudPoint" {
  70799. import { Nullable } from "babylonjs/types";
  70800. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  70801. import { Mesh } from "babylonjs/Meshes/mesh";
  70802. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  70803. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  70804. /**
  70805. * Represents one particle of a points cloud system.
  70806. */
  70807. export class CloudPoint {
  70808. /**
  70809. * particle global index
  70810. */
  70811. idx: number;
  70812. /**
  70813. * The color of the particle
  70814. */
  70815. color: Nullable<Color4>;
  70816. /**
  70817. * The world space position of the particle.
  70818. */
  70819. position: Vector3;
  70820. /**
  70821. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  70822. */
  70823. rotation: Vector3;
  70824. /**
  70825. * The world space rotation quaternion of the particle.
  70826. */
  70827. rotationQuaternion: Nullable<Quaternion>;
  70828. /**
  70829. * The uv of the particle.
  70830. */
  70831. uv: Nullable<Vector2>;
  70832. /**
  70833. * The current speed of the particle.
  70834. */
  70835. velocity: Vector3;
  70836. /**
  70837. * The pivot point in the particle local space.
  70838. */
  70839. pivot: Vector3;
  70840. /**
  70841. * Must the particle be translated from its pivot point in its local space ?
  70842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  70843. * Default : false
  70844. */
  70845. translateFromPivot: boolean;
  70846. /**
  70847. * Index of this particle in the global "positions" array (Internal use)
  70848. * @hidden
  70849. */
  70850. _pos: number;
  70851. /**
  70852. * @hidden Index of this particle in the global "indices" array (Internal use)
  70853. */
  70854. _ind: number;
  70855. /**
  70856. * Group this particle belongs to
  70857. */
  70858. _group: PointsGroup;
  70859. /**
  70860. * Group id of this particle
  70861. */
  70862. groupId: number;
  70863. /**
  70864. * Index of the particle in its group id (Internal use)
  70865. */
  70866. idxInGroup: number;
  70867. /**
  70868. * @hidden Particle BoundingInfo object (Internal use)
  70869. */
  70870. _boundingInfo: BoundingInfo;
  70871. /**
  70872. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  70873. */
  70874. _pcs: PointsCloudSystem;
  70875. /**
  70876. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  70877. */
  70878. _stillInvisible: boolean;
  70879. /**
  70880. * @hidden Last computed particle rotation matrix
  70881. */
  70882. _rotationMatrix: number[];
  70883. /**
  70884. * Parent particle Id, if any.
  70885. * Default null.
  70886. */
  70887. parentId: Nullable<number>;
  70888. /**
  70889. * @hidden Internal global position in the PCS.
  70890. */
  70891. _globalPosition: Vector3;
  70892. /**
  70893. * Creates a Point Cloud object.
  70894. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  70895. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  70896. * @param group (PointsGroup) is the group the particle belongs to
  70897. * @param groupId (integer) is the group identifier in the PCS.
  70898. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  70899. * @param pcs defines the PCS it is associated to
  70900. */
  70901. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  70902. /**
  70903. * get point size
  70904. */
  70905. get size(): Vector3;
  70906. /**
  70907. * Set point size
  70908. */
  70909. set size(scale: Vector3);
  70910. /**
  70911. * Legacy support, changed quaternion to rotationQuaternion
  70912. */
  70913. get quaternion(): Nullable<Quaternion>;
  70914. /**
  70915. * Legacy support, changed quaternion to rotationQuaternion
  70916. */
  70917. set quaternion(q: Nullable<Quaternion>);
  70918. /**
  70919. * Returns a boolean. True if the particle intersects a mesh, else false
  70920. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  70921. * @param target is the object (point or mesh) what the intersection is computed against
  70922. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  70923. * @returns true if it intersects
  70924. */
  70925. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  70926. /**
  70927. * get the rotation matrix of the particle
  70928. * @hidden
  70929. */
  70930. getRotationMatrix(m: Matrix): void;
  70931. }
  70932. /**
  70933. * Represents a group of points in a points cloud system
  70934. * * PCS internal tool, don't use it manually.
  70935. */
  70936. export class PointsGroup {
  70937. /**
  70938. * The group id
  70939. * @hidden
  70940. */
  70941. groupID: number;
  70942. /**
  70943. * image data for group (internal use)
  70944. * @hidden
  70945. */
  70946. _groupImageData: Nullable<ArrayBufferView>;
  70947. /**
  70948. * Image Width (internal use)
  70949. * @hidden
  70950. */
  70951. _groupImgWidth: number;
  70952. /**
  70953. * Image Height (internal use)
  70954. * @hidden
  70955. */
  70956. _groupImgHeight: number;
  70957. /**
  70958. * Custom position function (internal use)
  70959. * @hidden
  70960. */
  70961. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  70962. /**
  70963. * density per facet for surface points
  70964. * @hidden
  70965. */
  70966. _groupDensity: number[];
  70967. /**
  70968. * Only when points are colored by texture carries pointer to texture list array
  70969. * @hidden
  70970. */
  70971. _textureNb: number;
  70972. /**
  70973. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  70974. * PCS internal tool, don't use it manually.
  70975. * @hidden
  70976. */
  70977. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  70978. }
  70979. }
  70980. declare module "babylonjs/Particles/index" {
  70981. export * from "babylonjs/Particles/baseParticleSystem";
  70982. export * from "babylonjs/Particles/EmitterTypes/index";
  70983. export * from "babylonjs/Particles/gpuParticleSystem";
  70984. export * from "babylonjs/Particles/IParticleSystem";
  70985. export * from "babylonjs/Particles/particle";
  70986. export * from "babylonjs/Particles/particleHelper";
  70987. export * from "babylonjs/Particles/particleSystem";
  70988. import "babylonjs/Particles/particleSystemComponent";
  70989. export * from "babylonjs/Particles/particleSystemComponent";
  70990. export * from "babylonjs/Particles/particleSystemSet";
  70991. export * from "babylonjs/Particles/solidParticle";
  70992. export * from "babylonjs/Particles/solidParticleSystem";
  70993. export * from "babylonjs/Particles/cloudPoint";
  70994. export * from "babylonjs/Particles/pointsCloudSystem";
  70995. export * from "babylonjs/Particles/subEmitter";
  70996. }
  70997. declare module "babylonjs/Physics/physicsEngineComponent" {
  70998. import { Nullable } from "babylonjs/types";
  70999. import { Observable, Observer } from "babylonjs/Misc/observable";
  71000. import { Vector3 } from "babylonjs/Maths/math.vector";
  71001. import { Mesh } from "babylonjs/Meshes/mesh";
  71002. import { ISceneComponent } from "babylonjs/sceneComponent";
  71003. import { Scene } from "babylonjs/scene";
  71004. import { Node } from "babylonjs/node";
  71005. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  71006. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71007. module "babylonjs/scene" {
  71008. interface Scene {
  71009. /** @hidden (Backing field) */
  71010. _physicsEngine: Nullable<IPhysicsEngine>;
  71011. /** @hidden */
  71012. _physicsTimeAccumulator: number;
  71013. /**
  71014. * Gets the current physics engine
  71015. * @returns a IPhysicsEngine or null if none attached
  71016. */
  71017. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  71018. /**
  71019. * Enables physics to the current scene
  71020. * @param gravity defines the scene's gravity for the physics engine
  71021. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  71022. * @return a boolean indicating if the physics engine was initialized
  71023. */
  71024. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  71025. /**
  71026. * Disables and disposes the physics engine associated with the scene
  71027. */
  71028. disablePhysicsEngine(): void;
  71029. /**
  71030. * Gets a boolean indicating if there is an active physics engine
  71031. * @returns a boolean indicating if there is an active physics engine
  71032. */
  71033. isPhysicsEnabled(): boolean;
  71034. /**
  71035. * Deletes a physics compound impostor
  71036. * @param compound defines the compound to delete
  71037. */
  71038. deleteCompoundImpostor(compound: any): void;
  71039. /**
  71040. * An event triggered when physic simulation is about to be run
  71041. */
  71042. onBeforePhysicsObservable: Observable<Scene>;
  71043. /**
  71044. * An event triggered when physic simulation has been done
  71045. */
  71046. onAfterPhysicsObservable: Observable<Scene>;
  71047. }
  71048. }
  71049. module "babylonjs/Meshes/abstractMesh" {
  71050. interface AbstractMesh {
  71051. /** @hidden */
  71052. _physicsImpostor: Nullable<PhysicsImpostor>;
  71053. /**
  71054. * Gets or sets impostor used for physic simulation
  71055. * @see https://doc.babylonjs.com/features/physics_engine
  71056. */
  71057. physicsImpostor: Nullable<PhysicsImpostor>;
  71058. /**
  71059. * Gets the current physics impostor
  71060. * @see https://doc.babylonjs.com/features/physics_engine
  71061. * @returns a physics impostor or null
  71062. */
  71063. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  71064. /** Apply a physic impulse to the mesh
  71065. * @param force defines the force to apply
  71066. * @param contactPoint defines where to apply the force
  71067. * @returns the current mesh
  71068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  71069. */
  71070. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  71071. /**
  71072. * Creates a physic joint between two meshes
  71073. * @param otherMesh defines the other mesh to use
  71074. * @param pivot1 defines the pivot to use on this mesh
  71075. * @param pivot2 defines the pivot to use on the other mesh
  71076. * @param options defines additional options (can be plugin dependent)
  71077. * @returns the current mesh
  71078. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  71079. */
  71080. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  71081. /** @hidden */
  71082. _disposePhysicsObserver: Nullable<Observer<Node>>;
  71083. }
  71084. }
  71085. /**
  71086. * Defines the physics engine scene component responsible to manage a physics engine
  71087. */
  71088. export class PhysicsEngineSceneComponent implements ISceneComponent {
  71089. /**
  71090. * The component name helpful to identify the component in the list of scene components.
  71091. */
  71092. readonly name: string;
  71093. /**
  71094. * The scene the component belongs to.
  71095. */
  71096. scene: Scene;
  71097. /**
  71098. * Creates a new instance of the component for the given scene
  71099. * @param scene Defines the scene to register the component in
  71100. */
  71101. constructor(scene: Scene);
  71102. /**
  71103. * Registers the component in a given scene
  71104. */
  71105. register(): void;
  71106. /**
  71107. * Rebuilds the elements related to this component in case of
  71108. * context lost for instance.
  71109. */
  71110. rebuild(): void;
  71111. /**
  71112. * Disposes the component and the associated ressources
  71113. */
  71114. dispose(): void;
  71115. }
  71116. }
  71117. declare module "babylonjs/Physics/physicsHelper" {
  71118. import { Nullable } from "babylonjs/types";
  71119. import { Vector3 } from "babylonjs/Maths/math.vector";
  71120. import { Mesh } from "babylonjs/Meshes/mesh";
  71121. import { Scene } from "babylonjs/scene";
  71122. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  71123. /**
  71124. * A helper for physics simulations
  71125. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71126. */
  71127. export class PhysicsHelper {
  71128. private _scene;
  71129. private _physicsEngine;
  71130. /**
  71131. * Initializes the Physics helper
  71132. * @param scene Babylon.js scene
  71133. */
  71134. constructor(scene: Scene);
  71135. /**
  71136. * Applies a radial explosion impulse
  71137. * @param origin the origin of the explosion
  71138. * @param radiusOrEventOptions the radius or the options of radial explosion
  71139. * @param strength the explosion strength
  71140. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71141. * @returns A physics radial explosion event, or null
  71142. */
  71143. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71144. /**
  71145. * Applies a radial explosion force
  71146. * @param origin the origin of the explosion
  71147. * @param radiusOrEventOptions the radius or the options of radial explosion
  71148. * @param strength the explosion strength
  71149. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71150. * @returns A physics radial explosion event, or null
  71151. */
  71152. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  71153. /**
  71154. * Creates a gravitational field
  71155. * @param origin the origin of the explosion
  71156. * @param radiusOrEventOptions the radius or the options of radial explosion
  71157. * @param strength the explosion strength
  71158. * @param falloff possible options: Constant & Linear. Defaults to Constant
  71159. * @returns A physics gravitational field event, or null
  71160. */
  71161. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  71162. /**
  71163. * Creates a physics updraft event
  71164. * @param origin the origin of the updraft
  71165. * @param radiusOrEventOptions the radius or the options of the updraft
  71166. * @param strength the strength of the updraft
  71167. * @param height the height of the updraft
  71168. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  71169. * @returns A physics updraft event, or null
  71170. */
  71171. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  71172. /**
  71173. * Creates a physics vortex event
  71174. * @param origin the of the vortex
  71175. * @param radiusOrEventOptions the radius or the options of the vortex
  71176. * @param strength the strength of the vortex
  71177. * @param height the height of the vortex
  71178. * @returns a Physics vortex event, or null
  71179. * A physics vortex event or null
  71180. */
  71181. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  71182. }
  71183. /**
  71184. * Represents a physics radial explosion event
  71185. */
  71186. class PhysicsRadialExplosionEvent {
  71187. private _scene;
  71188. private _options;
  71189. private _sphere;
  71190. private _dataFetched;
  71191. /**
  71192. * Initializes a radial explosioin event
  71193. * @param _scene BabylonJS scene
  71194. * @param _options The options for the vortex event
  71195. */
  71196. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  71197. /**
  71198. * Returns the data related to the radial explosion event (sphere).
  71199. * @returns The radial explosion event data
  71200. */
  71201. getData(): PhysicsRadialExplosionEventData;
  71202. /**
  71203. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  71204. * @param impostor A physics imposter
  71205. * @param origin the origin of the explosion
  71206. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  71207. */
  71208. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  71209. /**
  71210. * Triggers affecterd impostors callbacks
  71211. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  71212. */
  71213. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  71214. /**
  71215. * Disposes the sphere.
  71216. * @param force Specifies if the sphere should be disposed by force
  71217. */
  71218. dispose(force?: boolean): void;
  71219. /*** Helpers ***/
  71220. private _prepareSphere;
  71221. private _intersectsWithSphere;
  71222. }
  71223. /**
  71224. * Represents a gravitational field event
  71225. */
  71226. class PhysicsGravitationalFieldEvent {
  71227. private _physicsHelper;
  71228. private _scene;
  71229. private _origin;
  71230. private _options;
  71231. private _tickCallback;
  71232. private _sphere;
  71233. private _dataFetched;
  71234. /**
  71235. * Initializes the physics gravitational field event
  71236. * @param _physicsHelper A physics helper
  71237. * @param _scene BabylonJS scene
  71238. * @param _origin The origin position of the gravitational field event
  71239. * @param _options The options for the vortex event
  71240. */
  71241. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  71242. /**
  71243. * Returns the data related to the gravitational field event (sphere).
  71244. * @returns A gravitational field event
  71245. */
  71246. getData(): PhysicsGravitationalFieldEventData;
  71247. /**
  71248. * Enables the gravitational field.
  71249. */
  71250. enable(): void;
  71251. /**
  71252. * Disables the gravitational field.
  71253. */
  71254. disable(): void;
  71255. /**
  71256. * Disposes the sphere.
  71257. * @param force The force to dispose from the gravitational field event
  71258. */
  71259. dispose(force?: boolean): void;
  71260. private _tick;
  71261. }
  71262. /**
  71263. * Represents a physics updraft event
  71264. */
  71265. class PhysicsUpdraftEvent {
  71266. private _scene;
  71267. private _origin;
  71268. private _options;
  71269. private _physicsEngine;
  71270. private _originTop;
  71271. private _originDirection;
  71272. private _tickCallback;
  71273. private _cylinder;
  71274. private _cylinderPosition;
  71275. private _dataFetched;
  71276. /**
  71277. * Initializes the physics updraft event
  71278. * @param _scene BabylonJS scene
  71279. * @param _origin The origin position of the updraft
  71280. * @param _options The options for the updraft event
  71281. */
  71282. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  71283. /**
  71284. * Returns the data related to the updraft event (cylinder).
  71285. * @returns A physics updraft event
  71286. */
  71287. getData(): PhysicsUpdraftEventData;
  71288. /**
  71289. * Enables the updraft.
  71290. */
  71291. enable(): void;
  71292. /**
  71293. * Disables the updraft.
  71294. */
  71295. disable(): void;
  71296. /**
  71297. * Disposes the cylinder.
  71298. * @param force Specifies if the updraft should be disposed by force
  71299. */
  71300. dispose(force?: boolean): void;
  71301. private getImpostorHitData;
  71302. private _tick;
  71303. /*** Helpers ***/
  71304. private _prepareCylinder;
  71305. private _intersectsWithCylinder;
  71306. }
  71307. /**
  71308. * Represents a physics vortex event
  71309. */
  71310. class PhysicsVortexEvent {
  71311. private _scene;
  71312. private _origin;
  71313. private _options;
  71314. private _physicsEngine;
  71315. private _originTop;
  71316. private _tickCallback;
  71317. private _cylinder;
  71318. private _cylinderPosition;
  71319. private _dataFetched;
  71320. /**
  71321. * Initializes the physics vortex event
  71322. * @param _scene The BabylonJS scene
  71323. * @param _origin The origin position of the vortex
  71324. * @param _options The options for the vortex event
  71325. */
  71326. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  71327. /**
  71328. * Returns the data related to the vortex event (cylinder).
  71329. * @returns The physics vortex event data
  71330. */
  71331. getData(): PhysicsVortexEventData;
  71332. /**
  71333. * Enables the vortex.
  71334. */
  71335. enable(): void;
  71336. /**
  71337. * Disables the cortex.
  71338. */
  71339. disable(): void;
  71340. /**
  71341. * Disposes the sphere.
  71342. * @param force
  71343. */
  71344. dispose(force?: boolean): void;
  71345. private getImpostorHitData;
  71346. private _tick;
  71347. /*** Helpers ***/
  71348. private _prepareCylinder;
  71349. private _intersectsWithCylinder;
  71350. }
  71351. /**
  71352. * Options fot the radial explosion event
  71353. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71354. */
  71355. export class PhysicsRadialExplosionEventOptions {
  71356. /**
  71357. * The radius of the sphere for the radial explosion.
  71358. */
  71359. radius: number;
  71360. /**
  71361. * The strenth of the explosion.
  71362. */
  71363. strength: number;
  71364. /**
  71365. * The strenght of the force in correspondence to the distance of the affected object
  71366. */
  71367. falloff: PhysicsRadialImpulseFalloff;
  71368. /**
  71369. * Sphere options for the radial explosion.
  71370. */
  71371. sphere: {
  71372. segments: number;
  71373. diameter: number;
  71374. };
  71375. /**
  71376. * Sphere options for the radial explosion.
  71377. */
  71378. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  71379. }
  71380. /**
  71381. * Options fot the updraft event
  71382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71383. */
  71384. export class PhysicsUpdraftEventOptions {
  71385. /**
  71386. * The radius of the cylinder for the vortex
  71387. */
  71388. radius: number;
  71389. /**
  71390. * The strenth of the updraft.
  71391. */
  71392. strength: number;
  71393. /**
  71394. * The height of the cylinder for the updraft.
  71395. */
  71396. height: number;
  71397. /**
  71398. * The mode for the the updraft.
  71399. */
  71400. updraftMode: PhysicsUpdraftMode;
  71401. }
  71402. /**
  71403. * Options fot the vortex event
  71404. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71405. */
  71406. export class PhysicsVortexEventOptions {
  71407. /**
  71408. * The radius of the cylinder for the vortex
  71409. */
  71410. radius: number;
  71411. /**
  71412. * The strenth of the vortex.
  71413. */
  71414. strength: number;
  71415. /**
  71416. * The height of the cylinder for the vortex.
  71417. */
  71418. height: number;
  71419. /**
  71420. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  71421. */
  71422. centripetalForceThreshold: number;
  71423. /**
  71424. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  71425. */
  71426. centripetalForceMultiplier: number;
  71427. /**
  71428. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  71429. */
  71430. centrifugalForceMultiplier: number;
  71431. /**
  71432. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  71433. */
  71434. updraftForceMultiplier: number;
  71435. }
  71436. /**
  71437. * The strenght of the force in correspondence to the distance of the affected object
  71438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71439. */
  71440. export enum PhysicsRadialImpulseFalloff {
  71441. /** Defines that impulse is constant in strength across it's whole radius */
  71442. Constant = 0,
  71443. /** Defines that impulse gets weaker if it's further from the origin */
  71444. Linear = 1
  71445. }
  71446. /**
  71447. * The strength of the force in correspondence to the distance of the affected object
  71448. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71449. */
  71450. export enum PhysicsUpdraftMode {
  71451. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  71452. Center = 0,
  71453. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  71454. Perpendicular = 1
  71455. }
  71456. /**
  71457. * Interface for a physics hit data
  71458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71459. */
  71460. export interface PhysicsHitData {
  71461. /**
  71462. * The force applied at the contact point
  71463. */
  71464. force: Vector3;
  71465. /**
  71466. * The contact point
  71467. */
  71468. contactPoint: Vector3;
  71469. /**
  71470. * The distance from the origin to the contact point
  71471. */
  71472. distanceFromOrigin: number;
  71473. }
  71474. /**
  71475. * Interface for radial explosion event data
  71476. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71477. */
  71478. export interface PhysicsRadialExplosionEventData {
  71479. /**
  71480. * A sphere used for the radial explosion event
  71481. */
  71482. sphere: Mesh;
  71483. }
  71484. /**
  71485. * Interface for gravitational field event data
  71486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71487. */
  71488. export interface PhysicsGravitationalFieldEventData {
  71489. /**
  71490. * A sphere mesh used for the gravitational field event
  71491. */
  71492. sphere: Mesh;
  71493. }
  71494. /**
  71495. * Interface for updraft event data
  71496. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71497. */
  71498. export interface PhysicsUpdraftEventData {
  71499. /**
  71500. * A cylinder used for the updraft event
  71501. */
  71502. cylinder: Mesh;
  71503. }
  71504. /**
  71505. * Interface for vortex event data
  71506. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71507. */
  71508. export interface PhysicsVortexEventData {
  71509. /**
  71510. * A cylinder used for the vortex event
  71511. */
  71512. cylinder: Mesh;
  71513. }
  71514. /**
  71515. * Interface for an affected physics impostor
  71516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  71517. */
  71518. export interface PhysicsAffectedImpostorWithData {
  71519. /**
  71520. * The impostor affected by the effect
  71521. */
  71522. impostor: PhysicsImpostor;
  71523. /**
  71524. * The data about the hit/horce from the explosion
  71525. */
  71526. hitData: PhysicsHitData;
  71527. }
  71528. }
  71529. declare module "babylonjs/Physics/Plugins/index" {
  71530. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  71531. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  71532. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  71533. }
  71534. declare module "babylonjs/Physics/index" {
  71535. export * from "babylonjs/Physics/IPhysicsEngine";
  71536. export * from "babylonjs/Physics/physicsEngine";
  71537. export * from "babylonjs/Physics/physicsEngineComponent";
  71538. export * from "babylonjs/Physics/physicsHelper";
  71539. export * from "babylonjs/Physics/physicsImpostor";
  71540. export * from "babylonjs/Physics/physicsJoint";
  71541. export * from "babylonjs/Physics/Plugins/index";
  71542. }
  71543. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  71544. /** @hidden */
  71545. export var blackAndWhitePixelShader: {
  71546. name: string;
  71547. shader: string;
  71548. };
  71549. }
  71550. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  71551. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71552. import { Camera } from "babylonjs/Cameras/camera";
  71553. import { Engine } from "babylonjs/Engines/engine";
  71554. import "babylonjs/Shaders/blackAndWhite.fragment";
  71555. /**
  71556. * Post process used to render in black and white
  71557. */
  71558. export class BlackAndWhitePostProcess extends PostProcess {
  71559. /**
  71560. * Linear about to convert he result to black and white (default: 1)
  71561. */
  71562. degree: number;
  71563. /**
  71564. * Creates a black and white post process
  71565. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  71566. * @param name The name of the effect.
  71567. * @param options The required width/height ratio to downsize to before computing the render pass.
  71568. * @param camera The camera to apply the render pass to.
  71569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71570. * @param engine The engine which the post process will be applied. (default: current engine)
  71571. * @param reusable If the post process can be reused on the same frame. (default: false)
  71572. */
  71573. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71574. }
  71575. }
  71576. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  71577. import { Nullable } from "babylonjs/types";
  71578. import { Camera } from "babylonjs/Cameras/camera";
  71579. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71580. import { Engine } from "babylonjs/Engines/engine";
  71581. /**
  71582. * This represents a set of one or more post processes in Babylon.
  71583. * A post process can be used to apply a shader to a texture after it is rendered.
  71584. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  71585. */
  71586. export class PostProcessRenderEffect {
  71587. private _postProcesses;
  71588. private _getPostProcesses;
  71589. private _singleInstance;
  71590. private _cameras;
  71591. private _indicesForCamera;
  71592. /**
  71593. * Name of the effect
  71594. * @hidden
  71595. */
  71596. _name: string;
  71597. /**
  71598. * Instantiates a post process render effect.
  71599. * A post process can be used to apply a shader to a texture after it is rendered.
  71600. * @param engine The engine the effect is tied to
  71601. * @param name The name of the effect
  71602. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  71603. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  71604. */
  71605. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  71606. /**
  71607. * Checks if all the post processes in the effect are supported.
  71608. */
  71609. get isSupported(): boolean;
  71610. /**
  71611. * Updates the current state of the effect
  71612. * @hidden
  71613. */
  71614. _update(): void;
  71615. /**
  71616. * Attaches the effect on cameras
  71617. * @param cameras The camera to attach to.
  71618. * @hidden
  71619. */
  71620. _attachCameras(cameras: Camera): void;
  71621. /**
  71622. * Attaches the effect on cameras
  71623. * @param cameras The camera to attach to.
  71624. * @hidden
  71625. */
  71626. _attachCameras(cameras: Camera[]): void;
  71627. /**
  71628. * Detaches the effect on cameras
  71629. * @param cameras The camera to detatch from.
  71630. * @hidden
  71631. */
  71632. _detachCameras(cameras: Camera): void;
  71633. /**
  71634. * Detatches the effect on cameras
  71635. * @param cameras The camera to detatch from.
  71636. * @hidden
  71637. */
  71638. _detachCameras(cameras: Camera[]): void;
  71639. /**
  71640. * Enables the effect on given cameras
  71641. * @param cameras The camera to enable.
  71642. * @hidden
  71643. */
  71644. _enable(cameras: Camera): void;
  71645. /**
  71646. * Enables the effect on given cameras
  71647. * @param cameras The camera to enable.
  71648. * @hidden
  71649. */
  71650. _enable(cameras: Nullable<Camera[]>): void;
  71651. /**
  71652. * Disables the effect on the given cameras
  71653. * @param cameras The camera to disable.
  71654. * @hidden
  71655. */
  71656. _disable(cameras: Camera): void;
  71657. /**
  71658. * Disables the effect on the given cameras
  71659. * @param cameras The camera to disable.
  71660. * @hidden
  71661. */
  71662. _disable(cameras: Nullable<Camera[]>): void;
  71663. /**
  71664. * Gets a list of the post processes contained in the effect.
  71665. * @param camera The camera to get the post processes on.
  71666. * @returns The list of the post processes in the effect.
  71667. */
  71668. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  71669. }
  71670. }
  71671. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  71672. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71673. /** @hidden */
  71674. export var extractHighlightsPixelShader: {
  71675. name: string;
  71676. shader: string;
  71677. };
  71678. }
  71679. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  71680. import { Nullable } from "babylonjs/types";
  71681. import { Camera } from "babylonjs/Cameras/camera";
  71682. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71683. import { Engine } from "babylonjs/Engines/engine";
  71684. import "babylonjs/Shaders/extractHighlights.fragment";
  71685. /**
  71686. * 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.
  71687. */
  71688. export class ExtractHighlightsPostProcess extends PostProcess {
  71689. /**
  71690. * The luminance threshold, pixels below this value will be set to black.
  71691. */
  71692. threshold: number;
  71693. /** @hidden */
  71694. _exposure: number;
  71695. /**
  71696. * Post process which has the input texture to be used when performing highlight extraction
  71697. * @hidden
  71698. */
  71699. _inputPostProcess: Nullable<PostProcess>;
  71700. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71701. }
  71702. }
  71703. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  71704. /** @hidden */
  71705. export var bloomMergePixelShader: {
  71706. name: string;
  71707. shader: string;
  71708. };
  71709. }
  71710. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  71711. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71712. import { Nullable } from "babylonjs/types";
  71713. import { Engine } from "babylonjs/Engines/engine";
  71714. import { Camera } from "babylonjs/Cameras/camera";
  71715. import "babylonjs/Shaders/bloomMerge.fragment";
  71716. /**
  71717. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  71718. */
  71719. export class BloomMergePostProcess extends PostProcess {
  71720. /** Weight of the bloom to be added to the original input. */
  71721. weight: number;
  71722. /**
  71723. * Creates a new instance of @see BloomMergePostProcess
  71724. * @param name The name of the effect.
  71725. * @param originalFromInput Post process which's input will be used for the merge.
  71726. * @param blurred Blurred highlights post process which's output will be used.
  71727. * @param weight Weight of the bloom to be added to the original input.
  71728. * @param options The required width/height ratio to downsize to before computing the render pass.
  71729. * @param camera The camera to apply the render pass to.
  71730. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71731. * @param engine The engine which the post process will be applied. (default: current engine)
  71732. * @param reusable If the post process can be reused on the same frame. (default: false)
  71733. * @param textureType Type of textures used when performing the post process. (default: 0)
  71734. * @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)
  71735. */
  71736. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  71737. /** Weight of the bloom to be added to the original input. */
  71738. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71739. }
  71740. }
  71741. declare module "babylonjs/PostProcesses/bloomEffect" {
  71742. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  71743. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  71744. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  71745. import { Camera } from "babylonjs/Cameras/camera";
  71746. import { Scene } from "babylonjs/scene";
  71747. /**
  71748. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  71749. */
  71750. export class BloomEffect extends PostProcessRenderEffect {
  71751. private bloomScale;
  71752. /**
  71753. * @hidden Internal
  71754. */
  71755. _effects: Array<PostProcess>;
  71756. /**
  71757. * @hidden Internal
  71758. */
  71759. _downscale: ExtractHighlightsPostProcess;
  71760. private _blurX;
  71761. private _blurY;
  71762. private _merge;
  71763. /**
  71764. * The luminance threshold to find bright areas of the image to bloom.
  71765. */
  71766. get threshold(): number;
  71767. set threshold(value: number);
  71768. /**
  71769. * The strength of the bloom.
  71770. */
  71771. get weight(): number;
  71772. set weight(value: number);
  71773. /**
  71774. * Specifies the size of the bloom blur kernel, relative to the final output size
  71775. */
  71776. get kernel(): number;
  71777. set kernel(value: number);
  71778. /**
  71779. * Creates a new instance of @see BloomEffect
  71780. * @param scene The scene the effect belongs to.
  71781. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  71782. * @param bloomKernel The size of the kernel to be used when applying the blur.
  71783. * @param bloomWeight The the strength of bloom.
  71784. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  71785. * @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)
  71786. */
  71787. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  71788. /**
  71789. * Disposes each of the internal effects for a given camera.
  71790. * @param camera The camera to dispose the effect on.
  71791. */
  71792. disposeEffects(camera: Camera): void;
  71793. /**
  71794. * @hidden Internal
  71795. */
  71796. _updateEffects(): void;
  71797. /**
  71798. * Internal
  71799. * @returns if all the contained post processes are ready.
  71800. * @hidden
  71801. */
  71802. _isReady(): boolean;
  71803. }
  71804. }
  71805. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  71806. /** @hidden */
  71807. export var chromaticAberrationPixelShader: {
  71808. name: string;
  71809. shader: string;
  71810. };
  71811. }
  71812. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  71813. import { Vector2 } from "babylonjs/Maths/math.vector";
  71814. import { Nullable } from "babylonjs/types";
  71815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71816. import { Camera } from "babylonjs/Cameras/camera";
  71817. import { Engine } from "babylonjs/Engines/engine";
  71818. import "babylonjs/Shaders/chromaticAberration.fragment";
  71819. /**
  71820. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  71821. */
  71822. export class ChromaticAberrationPostProcess extends PostProcess {
  71823. /**
  71824. * The amount of seperation of rgb channels (default: 30)
  71825. */
  71826. aberrationAmount: number;
  71827. /**
  71828. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  71829. */
  71830. radialIntensity: number;
  71831. /**
  71832. * 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))
  71833. */
  71834. direction: Vector2;
  71835. /**
  71836. * 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))
  71837. */
  71838. centerPosition: Vector2;
  71839. /**
  71840. * Creates a new instance ChromaticAberrationPostProcess
  71841. * @param name The name of the effect.
  71842. * @param screenWidth The width of the screen to apply the effect on.
  71843. * @param screenHeight The height of the screen to apply the effect on.
  71844. * @param options The required width/height ratio to downsize to before computing the render pass.
  71845. * @param camera The camera to apply the render pass to.
  71846. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71847. * @param engine The engine which the post process will be applied. (default: current engine)
  71848. * @param reusable If the post process can be reused on the same frame. (default: false)
  71849. * @param textureType Type of textures used when performing the post process. (default: 0)
  71850. * @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)
  71851. */
  71852. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71853. }
  71854. }
  71855. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  71856. /** @hidden */
  71857. export var circleOfConfusionPixelShader: {
  71858. name: string;
  71859. shader: string;
  71860. };
  71861. }
  71862. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  71863. import { Nullable } from "babylonjs/types";
  71864. import { Engine } from "babylonjs/Engines/engine";
  71865. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71866. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  71867. import { Camera } from "babylonjs/Cameras/camera";
  71868. import "babylonjs/Shaders/circleOfConfusion.fragment";
  71869. /**
  71870. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  71871. */
  71872. export class CircleOfConfusionPostProcess extends PostProcess {
  71873. /**
  71874. * 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.
  71875. */
  71876. lensSize: number;
  71877. /**
  71878. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  71879. */
  71880. fStop: number;
  71881. /**
  71882. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  71883. */
  71884. focusDistance: number;
  71885. /**
  71886. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  71887. */
  71888. focalLength: number;
  71889. private _depthTexture;
  71890. /**
  71891. * Creates a new instance CircleOfConfusionPostProcess
  71892. * @param name The name of the effect.
  71893. * @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.
  71894. * @param options The required width/height ratio to downsize to before computing the render pass.
  71895. * @param camera The camera to apply the render pass to.
  71896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71897. * @param engine The engine which the post process will be applied. (default: current engine)
  71898. * @param reusable If the post process can be reused on the same frame. (default: false)
  71899. * @param textureType Type of textures used when performing the post process. (default: 0)
  71900. * @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)
  71901. */
  71902. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  71903. /**
  71904. * 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.
  71905. */
  71906. set depthTexture(value: RenderTargetTexture);
  71907. }
  71908. }
  71909. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  71910. /** @hidden */
  71911. export var colorCorrectionPixelShader: {
  71912. name: string;
  71913. shader: string;
  71914. };
  71915. }
  71916. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  71917. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71918. import { Engine } from "babylonjs/Engines/engine";
  71919. import { Camera } from "babylonjs/Cameras/camera";
  71920. import "babylonjs/Shaders/colorCorrection.fragment";
  71921. /**
  71922. *
  71923. * This post-process allows the modification of rendered colors by using
  71924. * a 'look-up table' (LUT). This effect is also called Color Grading.
  71925. *
  71926. * The object needs to be provided an url to a texture containing the color
  71927. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  71928. * Use an image editing software to tweak the LUT to match your needs.
  71929. *
  71930. * For an example of a color LUT, see here:
  71931. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  71932. * For explanations on color grading, see here:
  71933. * @see http://udn.epicgames.com/Three/ColorGrading.html
  71934. *
  71935. */
  71936. export class ColorCorrectionPostProcess extends PostProcess {
  71937. private _colorTableTexture;
  71938. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  71939. }
  71940. }
  71941. declare module "babylonjs/Shaders/convolution.fragment" {
  71942. /** @hidden */
  71943. export var convolutionPixelShader: {
  71944. name: string;
  71945. shader: string;
  71946. };
  71947. }
  71948. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  71949. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  71950. import { Nullable } from "babylonjs/types";
  71951. import { Camera } from "babylonjs/Cameras/camera";
  71952. import { Engine } from "babylonjs/Engines/engine";
  71953. import "babylonjs/Shaders/convolution.fragment";
  71954. /**
  71955. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  71956. * input texture to perform effects such as edge detection or sharpening
  71957. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  71958. */
  71959. export class ConvolutionPostProcess extends PostProcess {
  71960. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71961. kernel: number[];
  71962. /**
  71963. * Creates a new instance ConvolutionPostProcess
  71964. * @param name The name of the effect.
  71965. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  71966. * @param options The required width/height ratio to downsize to before computing the render pass.
  71967. * @param camera The camera to apply the render pass to.
  71968. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71969. * @param engine The engine which the post process will be applied. (default: current engine)
  71970. * @param reusable If the post process can be reused on the same frame. (default: false)
  71971. * @param textureType Type of textures used when performing the post process. (default: 0)
  71972. */
  71973. constructor(name: string,
  71974. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  71975. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  71976. /**
  71977. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71978. */
  71979. static EdgeDetect0Kernel: number[];
  71980. /**
  71981. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71982. */
  71983. static EdgeDetect1Kernel: number[];
  71984. /**
  71985. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71986. */
  71987. static EdgeDetect2Kernel: number[];
  71988. /**
  71989. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71990. */
  71991. static SharpenKernel: number[];
  71992. /**
  71993. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71994. */
  71995. static EmbossKernel: number[];
  71996. /**
  71997. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  71998. */
  71999. static GaussianKernel: number[];
  72000. }
  72001. }
  72002. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  72003. import { Nullable } from "babylonjs/types";
  72004. import { Vector2 } from "babylonjs/Maths/math.vector";
  72005. import { Camera } from "babylonjs/Cameras/camera";
  72006. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72007. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  72008. import { Engine } from "babylonjs/Engines/engine";
  72009. import { Scene } from "babylonjs/scene";
  72010. /**
  72011. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  72012. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  72013. * based on samples that have a large difference in distance than the center pixel.
  72014. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  72015. */
  72016. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  72017. direction: Vector2;
  72018. /**
  72019. * Creates a new instance CircleOfConfusionPostProcess
  72020. * @param name The name of the effect.
  72021. * @param scene The scene the effect belongs to.
  72022. * @param direction The direction the blur should be applied.
  72023. * @param kernel The size of the kernel used to blur.
  72024. * @param options The required width/height ratio to downsize to before computing the render pass.
  72025. * @param camera The camera to apply the render pass to.
  72026. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  72027. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  72028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72029. * @param engine The engine which the post process will be applied. (default: current engine)
  72030. * @param reusable If the post process can be reused on the same frame. (default: false)
  72031. * @param textureType Type of textures used when performing the post process. (default: 0)
  72032. * @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)
  72033. */
  72034. 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);
  72035. }
  72036. }
  72037. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  72038. /** @hidden */
  72039. export var depthOfFieldMergePixelShader: {
  72040. name: string;
  72041. shader: string;
  72042. };
  72043. }
  72044. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  72045. import { Nullable } from "babylonjs/types";
  72046. import { Camera } from "babylonjs/Cameras/camera";
  72047. import { Effect } from "babylonjs/Materials/effect";
  72048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72049. import { Engine } from "babylonjs/Engines/engine";
  72050. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  72051. /**
  72052. * Options to be set when merging outputs from the default pipeline.
  72053. */
  72054. export class DepthOfFieldMergePostProcessOptions {
  72055. /**
  72056. * The original image to merge on top of
  72057. */
  72058. originalFromInput: PostProcess;
  72059. /**
  72060. * Parameters to perform the merge of the depth of field effect
  72061. */
  72062. depthOfField?: {
  72063. circleOfConfusion: PostProcess;
  72064. blurSteps: Array<PostProcess>;
  72065. };
  72066. /**
  72067. * Parameters to perform the merge of bloom effect
  72068. */
  72069. bloom?: {
  72070. blurred: PostProcess;
  72071. weight: number;
  72072. };
  72073. }
  72074. /**
  72075. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72076. */
  72077. export class DepthOfFieldMergePostProcess extends PostProcess {
  72078. private blurSteps;
  72079. /**
  72080. * Creates a new instance of DepthOfFieldMergePostProcess
  72081. * @param name The name of the effect.
  72082. * @param originalFromInput Post process which's input will be used for the merge.
  72083. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  72084. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  72085. * @param options The required width/height ratio to downsize to before computing the render pass.
  72086. * @param camera The camera to apply the render pass to.
  72087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72088. * @param engine The engine which the post process will be applied. (default: current engine)
  72089. * @param reusable If the post process can be reused on the same frame. (default: false)
  72090. * @param textureType Type of textures used when performing the post process. (default: 0)
  72091. * @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)
  72092. */
  72093. 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);
  72094. /**
  72095. * Updates the effect with the current post process compile time values and recompiles the shader.
  72096. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  72097. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  72098. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  72099. * @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
  72100. * @param onCompiled Called when the shader has been compiled.
  72101. * @param onError Called if there is an error when compiling a shader.
  72102. */
  72103. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  72104. }
  72105. }
  72106. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  72107. import { Nullable } from "babylonjs/types";
  72108. import { Camera } from "babylonjs/Cameras/camera";
  72109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  72110. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72111. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72112. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  72113. import { Scene } from "babylonjs/scene";
  72114. /**
  72115. * Specifies the level of max blur that should be applied when using the depth of field effect
  72116. */
  72117. export enum DepthOfFieldEffectBlurLevel {
  72118. /**
  72119. * Subtle blur
  72120. */
  72121. Low = 0,
  72122. /**
  72123. * Medium blur
  72124. */
  72125. Medium = 1,
  72126. /**
  72127. * Large blur
  72128. */
  72129. High = 2
  72130. }
  72131. /**
  72132. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  72133. */
  72134. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  72135. private _circleOfConfusion;
  72136. /**
  72137. * @hidden Internal, blurs from high to low
  72138. */
  72139. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  72140. private _depthOfFieldBlurY;
  72141. private _dofMerge;
  72142. /**
  72143. * @hidden Internal post processes in depth of field effect
  72144. */
  72145. _effects: Array<PostProcess>;
  72146. /**
  72147. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  72148. */
  72149. set focalLength(value: number);
  72150. get focalLength(): number;
  72151. /**
  72152. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  72153. */
  72154. set fStop(value: number);
  72155. get fStop(): number;
  72156. /**
  72157. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  72158. */
  72159. set focusDistance(value: number);
  72160. get focusDistance(): number;
  72161. /**
  72162. * 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.
  72163. */
  72164. set lensSize(value: number);
  72165. get lensSize(): number;
  72166. /**
  72167. * Creates a new instance DepthOfFieldEffect
  72168. * @param scene The scene the effect belongs to.
  72169. * @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.
  72170. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72171. * @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)
  72172. */
  72173. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  72174. /**
  72175. * Get the current class name of the current effet
  72176. * @returns "DepthOfFieldEffect"
  72177. */
  72178. getClassName(): string;
  72179. /**
  72180. * 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.
  72181. */
  72182. set depthTexture(value: RenderTargetTexture);
  72183. /**
  72184. * Disposes each of the internal effects for a given camera.
  72185. * @param camera The camera to dispose the effect on.
  72186. */
  72187. disposeEffects(camera: Camera): void;
  72188. /**
  72189. * @hidden Internal
  72190. */
  72191. _updateEffects(): void;
  72192. /**
  72193. * Internal
  72194. * @returns if all the contained post processes are ready.
  72195. * @hidden
  72196. */
  72197. _isReady(): boolean;
  72198. }
  72199. }
  72200. declare module "babylonjs/Shaders/displayPass.fragment" {
  72201. /** @hidden */
  72202. export var displayPassPixelShader: {
  72203. name: string;
  72204. shader: string;
  72205. };
  72206. }
  72207. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  72208. import { Nullable } from "babylonjs/types";
  72209. import { Camera } from "babylonjs/Cameras/camera";
  72210. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72211. import { Engine } from "babylonjs/Engines/engine";
  72212. import "babylonjs/Shaders/displayPass.fragment";
  72213. /**
  72214. * DisplayPassPostProcess which produces an output the same as it's input
  72215. */
  72216. export class DisplayPassPostProcess extends PostProcess {
  72217. /**
  72218. * Creates the DisplayPassPostProcess
  72219. * @param name The name of the effect.
  72220. * @param options The required width/height ratio to downsize to before computing the render pass.
  72221. * @param camera The camera to apply the render pass to.
  72222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72223. * @param engine The engine which the post process will be applied. (default: current engine)
  72224. * @param reusable If the post process can be reused on the same frame. (default: false)
  72225. */
  72226. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72227. }
  72228. }
  72229. declare module "babylonjs/Shaders/filter.fragment" {
  72230. /** @hidden */
  72231. export var filterPixelShader: {
  72232. name: string;
  72233. shader: string;
  72234. };
  72235. }
  72236. declare module "babylonjs/PostProcesses/filterPostProcess" {
  72237. import { Nullable } from "babylonjs/types";
  72238. import { Matrix } from "babylonjs/Maths/math.vector";
  72239. import { Camera } from "babylonjs/Cameras/camera";
  72240. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72241. import { Engine } from "babylonjs/Engines/engine";
  72242. import "babylonjs/Shaders/filter.fragment";
  72243. /**
  72244. * Applies a kernel filter to the image
  72245. */
  72246. export class FilterPostProcess extends PostProcess {
  72247. /** The matrix to be applied to the image */
  72248. kernelMatrix: Matrix;
  72249. /**
  72250. *
  72251. * @param name The name of the effect.
  72252. * @param kernelMatrix The matrix to be applied to the image
  72253. * @param options The required width/height ratio to downsize to before computing the render pass.
  72254. * @param camera The camera to apply the render pass to.
  72255. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72256. * @param engine The engine which the post process will be applied. (default: current engine)
  72257. * @param reusable If the post process can be reused on the same frame. (default: false)
  72258. */
  72259. constructor(name: string,
  72260. /** The matrix to be applied to the image */
  72261. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72262. }
  72263. }
  72264. declare module "babylonjs/Shaders/fxaa.fragment" {
  72265. /** @hidden */
  72266. export var fxaaPixelShader: {
  72267. name: string;
  72268. shader: string;
  72269. };
  72270. }
  72271. declare module "babylonjs/Shaders/fxaa.vertex" {
  72272. /** @hidden */
  72273. export var fxaaVertexShader: {
  72274. name: string;
  72275. shader: string;
  72276. };
  72277. }
  72278. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  72279. import { Nullable } from "babylonjs/types";
  72280. import { Camera } from "babylonjs/Cameras/camera";
  72281. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72282. import { Engine } from "babylonjs/Engines/engine";
  72283. import "babylonjs/Shaders/fxaa.fragment";
  72284. import "babylonjs/Shaders/fxaa.vertex";
  72285. /**
  72286. * Fxaa post process
  72287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  72288. */
  72289. export class FxaaPostProcess extends PostProcess {
  72290. /** @hidden */
  72291. texelWidth: number;
  72292. /** @hidden */
  72293. texelHeight: number;
  72294. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72295. private _getDefines;
  72296. }
  72297. }
  72298. declare module "babylonjs/Shaders/grain.fragment" {
  72299. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72300. /** @hidden */
  72301. export var grainPixelShader: {
  72302. name: string;
  72303. shader: string;
  72304. };
  72305. }
  72306. declare module "babylonjs/PostProcesses/grainPostProcess" {
  72307. import { Nullable } from "babylonjs/types";
  72308. import { Camera } from "babylonjs/Cameras/camera";
  72309. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72310. import { Engine } from "babylonjs/Engines/engine";
  72311. import "babylonjs/Shaders/grain.fragment";
  72312. /**
  72313. * The GrainPostProcess adds noise to the image at mid luminance levels
  72314. */
  72315. export class GrainPostProcess extends PostProcess {
  72316. /**
  72317. * The intensity of the grain added (default: 30)
  72318. */
  72319. intensity: number;
  72320. /**
  72321. * If the grain should be randomized on every frame
  72322. */
  72323. animated: boolean;
  72324. /**
  72325. * Creates a new instance of @see GrainPostProcess
  72326. * @param name The name of the effect.
  72327. * @param options The required width/height ratio to downsize to before computing the render pass.
  72328. * @param camera The camera to apply the render pass to.
  72329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72330. * @param engine The engine which the post process will be applied. (default: current engine)
  72331. * @param reusable If the post process can be reused on the same frame. (default: false)
  72332. * @param textureType Type of textures used when performing the post process. (default: 0)
  72333. * @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)
  72334. */
  72335. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72336. }
  72337. }
  72338. declare module "babylonjs/Shaders/highlights.fragment" {
  72339. /** @hidden */
  72340. export var highlightsPixelShader: {
  72341. name: string;
  72342. shader: string;
  72343. };
  72344. }
  72345. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  72346. import { Nullable } from "babylonjs/types";
  72347. import { Camera } from "babylonjs/Cameras/camera";
  72348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72349. import { Engine } from "babylonjs/Engines/engine";
  72350. import "babylonjs/Shaders/highlights.fragment";
  72351. /**
  72352. * Extracts highlights from the image
  72353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72354. */
  72355. export class HighlightsPostProcess extends PostProcess {
  72356. /**
  72357. * Extracts highlights from the image
  72358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72359. * @param name The name of the effect.
  72360. * @param options The required width/height ratio to downsize to before computing the render pass.
  72361. * @param camera The camera to apply the render pass to.
  72362. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72363. * @param engine The engine which the post process will be applied. (default: current engine)
  72364. * @param reusable If the post process can be reused on the same frame. (default: false)
  72365. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  72366. */
  72367. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72368. }
  72369. }
  72370. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  72371. /** @hidden */
  72372. export var mrtFragmentDeclaration: {
  72373. name: string;
  72374. shader: string;
  72375. };
  72376. }
  72377. declare module "babylonjs/Shaders/geometry.fragment" {
  72378. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  72379. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  72380. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  72381. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  72382. /** @hidden */
  72383. export var geometryPixelShader: {
  72384. name: string;
  72385. shader: string;
  72386. };
  72387. }
  72388. declare module "babylonjs/Shaders/geometry.vertex" {
  72389. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  72390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  72391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  72392. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  72393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  72394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  72395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  72396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  72397. /** @hidden */
  72398. export var geometryVertexShader: {
  72399. name: string;
  72400. shader: string;
  72401. };
  72402. }
  72403. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  72404. import { Matrix } from "babylonjs/Maths/math.vector";
  72405. import { SubMesh } from "babylonjs/Meshes/subMesh";
  72406. import { Mesh } from "babylonjs/Meshes/mesh";
  72407. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  72408. import { Effect } from "babylonjs/Materials/effect";
  72409. import { Scene } from "babylonjs/scene";
  72410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72411. import "babylonjs/Shaders/geometry.fragment";
  72412. import "babylonjs/Shaders/geometry.vertex";
  72413. /** @hidden */
  72414. interface ISavedTransformationMatrix {
  72415. world: Matrix;
  72416. viewProjection: Matrix;
  72417. }
  72418. /**
  72419. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  72420. */
  72421. export class GeometryBufferRenderer {
  72422. /**
  72423. * Constant used to retrieve the position texture index in the G-Buffer textures array
  72424. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  72425. */
  72426. static readonly POSITION_TEXTURE_TYPE: number;
  72427. /**
  72428. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  72429. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  72430. */
  72431. static readonly VELOCITY_TEXTURE_TYPE: number;
  72432. /**
  72433. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  72434. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  72435. */
  72436. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  72437. /**
  72438. * Dictionary used to store the previous transformation matrices of each rendered mesh
  72439. * in order to compute objects velocities when enableVelocity is set to "true"
  72440. * @hidden
  72441. */
  72442. _previousTransformationMatrices: {
  72443. [index: number]: ISavedTransformationMatrix;
  72444. };
  72445. /**
  72446. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  72447. * in order to compute objects velocities when enableVelocity is set to "true"
  72448. * @hidden
  72449. */
  72450. _previousBonesTransformationMatrices: {
  72451. [index: number]: Float32Array;
  72452. };
  72453. /**
  72454. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  72455. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  72456. */
  72457. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  72458. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  72459. renderTransparentMeshes: boolean;
  72460. private _scene;
  72461. private _multiRenderTarget;
  72462. private _ratio;
  72463. private _enablePosition;
  72464. private _enableVelocity;
  72465. private _enableReflectivity;
  72466. private _positionIndex;
  72467. private _velocityIndex;
  72468. private _reflectivityIndex;
  72469. protected _effect: Effect;
  72470. protected _cachedDefines: string;
  72471. /**
  72472. * Set the render list (meshes to be rendered) used in the G buffer.
  72473. */
  72474. set renderList(meshes: Mesh[]);
  72475. /**
  72476. * Gets wether or not G buffer are supported by the running hardware.
  72477. * This requires draw buffer supports
  72478. */
  72479. get isSupported(): boolean;
  72480. /**
  72481. * Returns the index of the given texture type in the G-Buffer textures array
  72482. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  72483. * @returns the index of the given texture type in the G-Buffer textures array
  72484. */
  72485. getTextureIndex(textureType: number): number;
  72486. /**
  72487. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  72488. */
  72489. get enablePosition(): boolean;
  72490. /**
  72491. * Sets whether or not objects positions are enabled for the G buffer.
  72492. */
  72493. set enablePosition(enable: boolean);
  72494. /**
  72495. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  72496. */
  72497. get enableVelocity(): boolean;
  72498. /**
  72499. * Sets wether or not objects velocities are enabled for the G buffer.
  72500. */
  72501. set enableVelocity(enable: boolean);
  72502. /**
  72503. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  72504. */
  72505. get enableReflectivity(): boolean;
  72506. /**
  72507. * Sets wether or not objects roughness are enabled for the G buffer.
  72508. */
  72509. set enableReflectivity(enable: boolean);
  72510. /**
  72511. * Gets the scene associated with the buffer.
  72512. */
  72513. get scene(): Scene;
  72514. /**
  72515. * Gets the ratio used by the buffer during its creation.
  72516. * How big is the buffer related to the main canvas.
  72517. */
  72518. get ratio(): number;
  72519. /** @hidden */
  72520. static _SceneComponentInitialization: (scene: Scene) => void;
  72521. /**
  72522. * Creates a new G Buffer for the scene
  72523. * @param scene The scene the buffer belongs to
  72524. * @param ratio How big is the buffer related to the main canvas.
  72525. */
  72526. constructor(scene: Scene, ratio?: number);
  72527. /**
  72528. * Checks wether everything is ready to render a submesh to the G buffer.
  72529. * @param subMesh the submesh to check readiness for
  72530. * @param useInstances is the mesh drawn using instance or not
  72531. * @returns true if ready otherwise false
  72532. */
  72533. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72534. /**
  72535. * Gets the current underlying G Buffer.
  72536. * @returns the buffer
  72537. */
  72538. getGBuffer(): MultiRenderTarget;
  72539. /**
  72540. * Gets the number of samples used to render the buffer (anti aliasing).
  72541. */
  72542. get samples(): number;
  72543. /**
  72544. * Sets the number of samples used to render the buffer (anti aliasing).
  72545. */
  72546. set samples(value: number);
  72547. /**
  72548. * Disposes the renderer and frees up associated resources.
  72549. */
  72550. dispose(): void;
  72551. protected _createRenderTargets(): void;
  72552. private _copyBonesTransformationMatrices;
  72553. }
  72554. }
  72555. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  72556. import { Nullable } from "babylonjs/types";
  72557. import { Scene } from "babylonjs/scene";
  72558. import { ISceneComponent } from "babylonjs/sceneComponent";
  72559. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  72560. module "babylonjs/scene" {
  72561. interface Scene {
  72562. /** @hidden (Backing field) */
  72563. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72564. /**
  72565. * Gets or Sets the current geometry buffer associated to the scene.
  72566. */
  72567. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  72568. /**
  72569. * Enables a GeometryBufferRender and associates it with the scene
  72570. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  72571. * @returns the GeometryBufferRenderer
  72572. */
  72573. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  72574. /**
  72575. * Disables the GeometryBufferRender associated with the scene
  72576. */
  72577. disableGeometryBufferRenderer(): void;
  72578. }
  72579. }
  72580. /**
  72581. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72582. * in several rendering techniques.
  72583. */
  72584. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  72585. /**
  72586. * The component name helpful to identify the component in the list of scene components.
  72587. */
  72588. readonly name: string;
  72589. /**
  72590. * The scene the component belongs to.
  72591. */
  72592. scene: Scene;
  72593. /**
  72594. * Creates a new instance of the component for the given scene
  72595. * @param scene Defines the scene to register the component in
  72596. */
  72597. constructor(scene: Scene);
  72598. /**
  72599. * Registers the component in a given scene
  72600. */
  72601. register(): void;
  72602. /**
  72603. * Rebuilds the elements related to this component in case of
  72604. * context lost for instance.
  72605. */
  72606. rebuild(): void;
  72607. /**
  72608. * Disposes the component and the associated ressources
  72609. */
  72610. dispose(): void;
  72611. private _gatherRenderTargets;
  72612. }
  72613. }
  72614. declare module "babylonjs/Shaders/motionBlur.fragment" {
  72615. /** @hidden */
  72616. export var motionBlurPixelShader: {
  72617. name: string;
  72618. shader: string;
  72619. };
  72620. }
  72621. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  72622. import { Nullable } from "babylonjs/types";
  72623. import { Camera } from "babylonjs/Cameras/camera";
  72624. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72625. import { Scene } from "babylonjs/scene";
  72626. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72627. import "babylonjs/Animations/animatable";
  72628. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  72629. import "babylonjs/Shaders/motionBlur.fragment";
  72630. import { Engine } from "babylonjs/Engines/engine";
  72631. /**
  72632. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  72633. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  72634. * As an example, all you have to do is to create the post-process:
  72635. * var mb = new BABYLON.MotionBlurPostProcess(
  72636. * 'mb', // The name of the effect.
  72637. * scene, // The scene containing the objects to blur according to their velocity.
  72638. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  72639. * camera // The camera to apply the render pass to.
  72640. * );
  72641. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  72642. */
  72643. export class MotionBlurPostProcess extends PostProcess {
  72644. /**
  72645. * Defines how much the image is blurred by the movement. Default value is equal to 1
  72646. */
  72647. motionStrength: number;
  72648. /**
  72649. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  72650. */
  72651. get motionBlurSamples(): number;
  72652. /**
  72653. * Sets the number of iterations to be used for motion blur quality
  72654. */
  72655. set motionBlurSamples(samples: number);
  72656. private _motionBlurSamples;
  72657. private _geometryBufferRenderer;
  72658. /**
  72659. * Creates a new instance MotionBlurPostProcess
  72660. * @param name The name of the effect.
  72661. * @param scene The scene containing the objects to blur according to their velocity.
  72662. * @param options The required width/height ratio to downsize to before computing the render pass.
  72663. * @param camera The camera to apply the render pass to.
  72664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72665. * @param engine The engine which the post process will be applied. (default: current engine)
  72666. * @param reusable If the post process can be reused on the same frame. (default: false)
  72667. * @param textureType Type of textures used when performing the post process. (default: 0)
  72668. * @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)
  72669. */
  72670. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72671. /**
  72672. * Excludes the given skinned mesh from computing bones velocities.
  72673. * 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.
  72674. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  72675. */
  72676. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72677. /**
  72678. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  72679. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  72680. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  72681. */
  72682. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  72683. /**
  72684. * Disposes the post process.
  72685. * @param camera The camera to dispose the post process on.
  72686. */
  72687. dispose(camera?: Camera): void;
  72688. }
  72689. }
  72690. declare module "babylonjs/Shaders/refraction.fragment" {
  72691. /** @hidden */
  72692. export var refractionPixelShader: {
  72693. name: string;
  72694. shader: string;
  72695. };
  72696. }
  72697. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  72698. import { Color3 } from "babylonjs/Maths/math.color";
  72699. import { Camera } from "babylonjs/Cameras/camera";
  72700. import { Texture } from "babylonjs/Materials/Textures/texture";
  72701. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72702. import { Engine } from "babylonjs/Engines/engine";
  72703. import "babylonjs/Shaders/refraction.fragment";
  72704. /**
  72705. * Post process which applies a refractin texture
  72706. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72707. */
  72708. export class RefractionPostProcess extends PostProcess {
  72709. /** the base color of the refraction (used to taint the rendering) */
  72710. color: Color3;
  72711. /** simulated refraction depth */
  72712. depth: number;
  72713. /** the coefficient of the base color (0 to remove base color tainting) */
  72714. colorLevel: number;
  72715. private _refTexture;
  72716. private _ownRefractionTexture;
  72717. /**
  72718. * Gets or sets the refraction texture
  72719. * Please note that you are responsible for disposing the texture if you set it manually
  72720. */
  72721. get refractionTexture(): Texture;
  72722. set refractionTexture(value: Texture);
  72723. /**
  72724. * Initializes the RefractionPostProcess
  72725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  72726. * @param name The name of the effect.
  72727. * @param refractionTextureUrl Url of the refraction texture to use
  72728. * @param color the base color of the refraction (used to taint the rendering)
  72729. * @param depth simulated refraction depth
  72730. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  72731. * @param camera The camera to apply the render pass to.
  72732. * @param options The required width/height ratio to downsize to before computing the render pass.
  72733. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72734. * @param engine The engine which the post process will be applied. (default: current engine)
  72735. * @param reusable If the post process can be reused on the same frame. (default: false)
  72736. */
  72737. constructor(name: string, refractionTextureUrl: string,
  72738. /** the base color of the refraction (used to taint the rendering) */
  72739. color: Color3,
  72740. /** simulated refraction depth */
  72741. depth: number,
  72742. /** the coefficient of the base color (0 to remove base color tainting) */
  72743. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72744. /**
  72745. * Disposes of the post process
  72746. * @param camera Camera to dispose post process on
  72747. */
  72748. dispose(camera: Camera): void;
  72749. }
  72750. }
  72751. declare module "babylonjs/Shaders/sharpen.fragment" {
  72752. /** @hidden */
  72753. export var sharpenPixelShader: {
  72754. name: string;
  72755. shader: string;
  72756. };
  72757. }
  72758. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  72759. import { Nullable } from "babylonjs/types";
  72760. import { Camera } from "babylonjs/Cameras/camera";
  72761. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72762. import "babylonjs/Shaders/sharpen.fragment";
  72763. import { Engine } from "babylonjs/Engines/engine";
  72764. /**
  72765. * The SharpenPostProcess applies a sharpen kernel to every pixel
  72766. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  72767. */
  72768. export class SharpenPostProcess extends PostProcess {
  72769. /**
  72770. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  72771. */
  72772. colorAmount: number;
  72773. /**
  72774. * How much sharpness should be applied (default: 0.3)
  72775. */
  72776. edgeAmount: number;
  72777. /**
  72778. * Creates a new instance ConvolutionPostProcess
  72779. * @param name The name of the effect.
  72780. * @param options The required width/height ratio to downsize to before computing the render pass.
  72781. * @param camera The camera to apply the render pass to.
  72782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72783. * @param engine The engine which the post process will be applied. (default: current engine)
  72784. * @param reusable If the post process can be reused on the same frame. (default: false)
  72785. * @param textureType Type of textures used when performing the post process. (default: 0)
  72786. * @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)
  72787. */
  72788. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72789. }
  72790. }
  72791. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  72792. import { Nullable } from "babylonjs/types";
  72793. import { Camera } from "babylonjs/Cameras/camera";
  72794. import { Engine } from "babylonjs/Engines/engine";
  72795. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72796. import { IInspectable } from "babylonjs/Misc/iInspectable";
  72797. /**
  72798. * PostProcessRenderPipeline
  72799. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72800. */
  72801. export class PostProcessRenderPipeline {
  72802. private engine;
  72803. private _renderEffects;
  72804. private _renderEffectsForIsolatedPass;
  72805. /**
  72806. * List of inspectable custom properties (used by the Inspector)
  72807. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72808. */
  72809. inspectableCustomProperties: IInspectable[];
  72810. /**
  72811. * @hidden
  72812. */
  72813. protected _cameras: Camera[];
  72814. /** @hidden */
  72815. _name: string;
  72816. /**
  72817. * Gets pipeline name
  72818. */
  72819. get name(): string;
  72820. /** Gets the list of attached cameras */
  72821. get cameras(): Camera[];
  72822. /**
  72823. * Initializes a PostProcessRenderPipeline
  72824. * @param engine engine to add the pipeline to
  72825. * @param name name of the pipeline
  72826. */
  72827. constructor(engine: Engine, name: string);
  72828. /**
  72829. * Gets the class name
  72830. * @returns "PostProcessRenderPipeline"
  72831. */
  72832. getClassName(): string;
  72833. /**
  72834. * If all the render effects in the pipeline are supported
  72835. */
  72836. get isSupported(): boolean;
  72837. /**
  72838. * Adds an effect to the pipeline
  72839. * @param renderEffect the effect to add
  72840. */
  72841. addEffect(renderEffect: PostProcessRenderEffect): void;
  72842. /** @hidden */
  72843. _rebuild(): void;
  72844. /** @hidden */
  72845. _enableEffect(renderEffectName: string, cameras: Camera): void;
  72846. /** @hidden */
  72847. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  72848. /** @hidden */
  72849. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72850. /** @hidden */
  72851. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  72852. /** @hidden */
  72853. _attachCameras(cameras: Camera, unique: boolean): void;
  72854. /** @hidden */
  72855. _attachCameras(cameras: Camera[], unique: boolean): void;
  72856. /** @hidden */
  72857. _detachCameras(cameras: Camera): void;
  72858. /** @hidden */
  72859. _detachCameras(cameras: Nullable<Camera[]>): void;
  72860. /** @hidden */
  72861. _update(): void;
  72862. /** @hidden */
  72863. _reset(): void;
  72864. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  72865. /**
  72866. * Disposes of the pipeline
  72867. */
  72868. dispose(): void;
  72869. }
  72870. }
  72871. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  72872. import { Camera } from "babylonjs/Cameras/camera";
  72873. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72874. /**
  72875. * PostProcessRenderPipelineManager class
  72876. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72877. */
  72878. export class PostProcessRenderPipelineManager {
  72879. private _renderPipelines;
  72880. /**
  72881. * Initializes a PostProcessRenderPipelineManager
  72882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72883. */
  72884. constructor();
  72885. /**
  72886. * Gets the list of supported render pipelines
  72887. */
  72888. get supportedPipelines(): PostProcessRenderPipeline[];
  72889. /**
  72890. * Adds a pipeline to the manager
  72891. * @param renderPipeline The pipeline to add
  72892. */
  72893. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  72894. /**
  72895. * Attaches a camera to the pipeline
  72896. * @param renderPipelineName The name of the pipeline to attach to
  72897. * @param cameras the camera to attach
  72898. * @param unique if the camera can be attached multiple times to the pipeline
  72899. */
  72900. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  72901. /**
  72902. * Detaches a camera from the pipeline
  72903. * @param renderPipelineName The name of the pipeline to detach from
  72904. * @param cameras the camera to detach
  72905. */
  72906. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  72907. /**
  72908. * Enables an effect by name on a pipeline
  72909. * @param renderPipelineName the name of the pipeline to enable the effect in
  72910. * @param renderEffectName the name of the effect to enable
  72911. * @param cameras the cameras that the effect should be enabled on
  72912. */
  72913. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72914. /**
  72915. * Disables an effect by name on a pipeline
  72916. * @param renderPipelineName the name of the pipeline to disable the effect in
  72917. * @param renderEffectName the name of the effect to disable
  72918. * @param cameras the cameras that the effect should be disabled on
  72919. */
  72920. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  72921. /**
  72922. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  72923. */
  72924. update(): void;
  72925. /** @hidden */
  72926. _rebuild(): void;
  72927. /**
  72928. * Disposes of the manager and pipelines
  72929. */
  72930. dispose(): void;
  72931. }
  72932. }
  72933. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  72934. import { ISceneComponent } from "babylonjs/sceneComponent";
  72935. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  72936. import { Scene } from "babylonjs/scene";
  72937. module "babylonjs/scene" {
  72938. interface Scene {
  72939. /** @hidden (Backing field) */
  72940. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72941. /**
  72942. * Gets the postprocess render pipeline manager
  72943. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72944. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  72945. */
  72946. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  72947. }
  72948. }
  72949. /**
  72950. * Defines the Render Pipeline scene component responsible to rendering pipelines
  72951. */
  72952. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  72953. /**
  72954. * The component name helpfull to identify the component in the list of scene components.
  72955. */
  72956. readonly name: string;
  72957. /**
  72958. * The scene the component belongs to.
  72959. */
  72960. scene: Scene;
  72961. /**
  72962. * Creates a new instance of the component for the given scene
  72963. * @param scene Defines the scene to register the component in
  72964. */
  72965. constructor(scene: Scene);
  72966. /**
  72967. * Registers the component in a given scene
  72968. */
  72969. register(): void;
  72970. /**
  72971. * Rebuilds the elements related to this component in case of
  72972. * context lost for instance.
  72973. */
  72974. rebuild(): void;
  72975. /**
  72976. * Disposes the component and the associated ressources
  72977. */
  72978. dispose(): void;
  72979. private _gatherRenderTargets;
  72980. }
  72981. }
  72982. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  72983. import { Nullable } from "babylonjs/types";
  72984. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  72985. import { Camera } from "babylonjs/Cameras/camera";
  72986. import { IDisposable } from "babylonjs/scene";
  72987. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  72988. import { Scene } from "babylonjs/scene";
  72989. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  72990. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  72991. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  72992. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  72993. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  72994. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  72995. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  72996. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  72997. import { Animation } from "babylonjs/Animations/animation";
  72998. /**
  72999. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  73000. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  73001. */
  73002. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  73003. private _scene;
  73004. private _camerasToBeAttached;
  73005. /**
  73006. * ID of the sharpen post process,
  73007. */
  73008. private readonly SharpenPostProcessId;
  73009. /**
  73010. * @ignore
  73011. * ID of the image processing post process;
  73012. */
  73013. readonly ImageProcessingPostProcessId: string;
  73014. /**
  73015. * @ignore
  73016. * ID of the Fast Approximate Anti-Aliasing post process;
  73017. */
  73018. readonly FxaaPostProcessId: string;
  73019. /**
  73020. * ID of the chromatic aberration post process,
  73021. */
  73022. private readonly ChromaticAberrationPostProcessId;
  73023. /**
  73024. * ID of the grain post process
  73025. */
  73026. private readonly GrainPostProcessId;
  73027. /**
  73028. * Sharpen post process which will apply a sharpen convolution to enhance edges
  73029. */
  73030. sharpen: SharpenPostProcess;
  73031. private _sharpenEffect;
  73032. private bloom;
  73033. /**
  73034. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  73035. */
  73036. depthOfField: DepthOfFieldEffect;
  73037. /**
  73038. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  73039. */
  73040. fxaa: FxaaPostProcess;
  73041. /**
  73042. * Image post processing pass used to perform operations such as tone mapping or color grading.
  73043. */
  73044. imageProcessing: ImageProcessingPostProcess;
  73045. /**
  73046. * Chromatic aberration post process which will shift rgb colors in the image
  73047. */
  73048. chromaticAberration: ChromaticAberrationPostProcess;
  73049. private _chromaticAberrationEffect;
  73050. /**
  73051. * Grain post process which add noise to the image
  73052. */
  73053. grain: GrainPostProcess;
  73054. private _grainEffect;
  73055. /**
  73056. * Glow post process which adds a glow to emissive areas of the image
  73057. */
  73058. private _glowLayer;
  73059. /**
  73060. * Animations which can be used to tweak settings over a period of time
  73061. */
  73062. animations: Animation[];
  73063. private _imageProcessingConfigurationObserver;
  73064. private _sharpenEnabled;
  73065. private _bloomEnabled;
  73066. private _depthOfFieldEnabled;
  73067. private _depthOfFieldBlurLevel;
  73068. private _fxaaEnabled;
  73069. private _imageProcessingEnabled;
  73070. private _defaultPipelineTextureType;
  73071. private _bloomScale;
  73072. private _chromaticAberrationEnabled;
  73073. private _grainEnabled;
  73074. private _buildAllowed;
  73075. /**
  73076. * Gets active scene
  73077. */
  73078. get scene(): Scene;
  73079. /**
  73080. * Enable or disable the sharpen process from the pipeline
  73081. */
  73082. set sharpenEnabled(enabled: boolean);
  73083. get sharpenEnabled(): boolean;
  73084. private _resizeObserver;
  73085. private _hardwareScaleLevel;
  73086. private _bloomKernel;
  73087. /**
  73088. * Specifies the size of the bloom blur kernel, relative to the final output size
  73089. */
  73090. get bloomKernel(): number;
  73091. set bloomKernel(value: number);
  73092. /**
  73093. * Specifies the weight of the bloom in the final rendering
  73094. */
  73095. private _bloomWeight;
  73096. /**
  73097. * Specifies the luma threshold for the area that will be blurred by the bloom
  73098. */
  73099. private _bloomThreshold;
  73100. private _hdr;
  73101. /**
  73102. * The strength of the bloom.
  73103. */
  73104. set bloomWeight(value: number);
  73105. get bloomWeight(): number;
  73106. /**
  73107. * The strength of the bloom.
  73108. */
  73109. set bloomThreshold(value: number);
  73110. get bloomThreshold(): number;
  73111. /**
  73112. * The scale of the bloom, lower value will provide better performance.
  73113. */
  73114. set bloomScale(value: number);
  73115. get bloomScale(): number;
  73116. /**
  73117. * Enable or disable the bloom from the pipeline
  73118. */
  73119. set bloomEnabled(enabled: boolean);
  73120. get bloomEnabled(): boolean;
  73121. private _rebuildBloom;
  73122. /**
  73123. * If the depth of field is enabled.
  73124. */
  73125. get depthOfFieldEnabled(): boolean;
  73126. set depthOfFieldEnabled(enabled: boolean);
  73127. /**
  73128. * Blur level of the depth of field effect. (Higher blur will effect performance)
  73129. */
  73130. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  73131. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  73132. /**
  73133. * If the anti aliasing is enabled.
  73134. */
  73135. set fxaaEnabled(enabled: boolean);
  73136. get fxaaEnabled(): boolean;
  73137. private _samples;
  73138. /**
  73139. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  73140. */
  73141. set samples(sampleCount: number);
  73142. get samples(): number;
  73143. /**
  73144. * If image processing is enabled.
  73145. */
  73146. set imageProcessingEnabled(enabled: boolean);
  73147. get imageProcessingEnabled(): boolean;
  73148. /**
  73149. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  73150. */
  73151. set glowLayerEnabled(enabled: boolean);
  73152. get glowLayerEnabled(): boolean;
  73153. /**
  73154. * Gets the glow layer (or null if not defined)
  73155. */
  73156. get glowLayer(): Nullable<GlowLayer>;
  73157. /**
  73158. * Enable or disable the chromaticAberration process from the pipeline
  73159. */
  73160. set chromaticAberrationEnabled(enabled: boolean);
  73161. get chromaticAberrationEnabled(): boolean;
  73162. /**
  73163. * Enable or disable the grain process from the pipeline
  73164. */
  73165. set grainEnabled(enabled: boolean);
  73166. get grainEnabled(): boolean;
  73167. /**
  73168. * @constructor
  73169. * @param name - The rendering pipeline name (default: "")
  73170. * @param hdr - If high dynamic range textures should be used (default: true)
  73171. * @param scene - The scene linked to this pipeline (default: the last created scene)
  73172. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  73173. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  73174. */
  73175. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  73176. /**
  73177. * Get the class name
  73178. * @returns "DefaultRenderingPipeline"
  73179. */
  73180. getClassName(): string;
  73181. /**
  73182. * Force the compilation of the entire pipeline.
  73183. */
  73184. prepare(): void;
  73185. private _hasCleared;
  73186. private _prevPostProcess;
  73187. private _prevPrevPostProcess;
  73188. private _setAutoClearAndTextureSharing;
  73189. private _depthOfFieldSceneObserver;
  73190. private _buildPipeline;
  73191. private _disposePostProcesses;
  73192. /**
  73193. * Adds a camera to the pipeline
  73194. * @param camera the camera to be added
  73195. */
  73196. addCamera(camera: Camera): void;
  73197. /**
  73198. * Removes a camera from the pipeline
  73199. * @param camera the camera to remove
  73200. */
  73201. removeCamera(camera: Camera): void;
  73202. /**
  73203. * Dispose of the pipeline and stop all post processes
  73204. */
  73205. dispose(): void;
  73206. /**
  73207. * Serialize the rendering pipeline (Used when exporting)
  73208. * @returns the serialized object
  73209. */
  73210. serialize(): any;
  73211. /**
  73212. * Parse the serialized pipeline
  73213. * @param source Source pipeline.
  73214. * @param scene The scene to load the pipeline to.
  73215. * @param rootUrl The URL of the serialized pipeline.
  73216. * @returns An instantiated pipeline from the serialized object.
  73217. */
  73218. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  73219. }
  73220. }
  73221. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  73222. /** @hidden */
  73223. export var lensHighlightsPixelShader: {
  73224. name: string;
  73225. shader: string;
  73226. };
  73227. }
  73228. declare module "babylonjs/Shaders/depthOfField.fragment" {
  73229. /** @hidden */
  73230. export var depthOfFieldPixelShader: {
  73231. name: string;
  73232. shader: string;
  73233. };
  73234. }
  73235. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  73236. import { Camera } from "babylonjs/Cameras/camera";
  73237. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73238. import { Scene } from "babylonjs/scene";
  73239. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73240. import "babylonjs/Shaders/chromaticAberration.fragment";
  73241. import "babylonjs/Shaders/lensHighlights.fragment";
  73242. import "babylonjs/Shaders/depthOfField.fragment";
  73243. /**
  73244. * BABYLON.JS Chromatic Aberration GLSL Shader
  73245. * Author: Olivier Guyot
  73246. * Separates very slightly R, G and B colors on the edges of the screen
  73247. * Inspired by Francois Tarlier & Martins Upitis
  73248. */
  73249. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  73250. /**
  73251. * @ignore
  73252. * The chromatic aberration PostProcess id in the pipeline
  73253. */
  73254. LensChromaticAberrationEffect: string;
  73255. /**
  73256. * @ignore
  73257. * The highlights enhancing PostProcess id in the pipeline
  73258. */
  73259. HighlightsEnhancingEffect: string;
  73260. /**
  73261. * @ignore
  73262. * The depth-of-field PostProcess id in the pipeline
  73263. */
  73264. LensDepthOfFieldEffect: string;
  73265. private _scene;
  73266. private _depthTexture;
  73267. private _grainTexture;
  73268. private _chromaticAberrationPostProcess;
  73269. private _highlightsPostProcess;
  73270. private _depthOfFieldPostProcess;
  73271. private _edgeBlur;
  73272. private _grainAmount;
  73273. private _chromaticAberration;
  73274. private _distortion;
  73275. private _highlightsGain;
  73276. private _highlightsThreshold;
  73277. private _dofDistance;
  73278. private _dofAperture;
  73279. private _dofDarken;
  73280. private _dofPentagon;
  73281. private _blurNoise;
  73282. /**
  73283. * @constructor
  73284. *
  73285. * Effect parameters are as follow:
  73286. * {
  73287. * chromatic_aberration: number; // from 0 to x (1 for realism)
  73288. * edge_blur: number; // from 0 to x (1 for realism)
  73289. * distortion: number; // from 0 to x (1 for realism)
  73290. * grain_amount: number; // from 0 to 1
  73291. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  73292. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  73293. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  73294. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  73295. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  73296. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  73297. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  73298. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  73299. * }
  73300. * Note: if an effect parameter is unset, effect is disabled
  73301. *
  73302. * @param name The rendering pipeline name
  73303. * @param parameters - An object containing all parameters (see above)
  73304. * @param scene The scene linked to this pipeline
  73305. * @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)
  73306. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73307. */
  73308. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  73309. /**
  73310. * Get the class name
  73311. * @returns "LensRenderingPipeline"
  73312. */
  73313. getClassName(): string;
  73314. /**
  73315. * Gets associated scene
  73316. */
  73317. get scene(): Scene;
  73318. /**
  73319. * Gets or sets the edge blur
  73320. */
  73321. get edgeBlur(): number;
  73322. set edgeBlur(value: number);
  73323. /**
  73324. * Gets or sets the grain amount
  73325. */
  73326. get grainAmount(): number;
  73327. set grainAmount(value: number);
  73328. /**
  73329. * Gets or sets the chromatic aberration amount
  73330. */
  73331. get chromaticAberration(): number;
  73332. set chromaticAberration(value: number);
  73333. /**
  73334. * Gets or sets the depth of field aperture
  73335. */
  73336. get dofAperture(): number;
  73337. set dofAperture(value: number);
  73338. /**
  73339. * Gets or sets the edge distortion
  73340. */
  73341. get edgeDistortion(): number;
  73342. set edgeDistortion(value: number);
  73343. /**
  73344. * Gets or sets the depth of field distortion
  73345. */
  73346. get dofDistortion(): number;
  73347. set dofDistortion(value: number);
  73348. /**
  73349. * Gets or sets the darken out of focus amount
  73350. */
  73351. get darkenOutOfFocus(): number;
  73352. set darkenOutOfFocus(value: number);
  73353. /**
  73354. * Gets or sets a boolean indicating if blur noise is enabled
  73355. */
  73356. get blurNoise(): boolean;
  73357. set blurNoise(value: boolean);
  73358. /**
  73359. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  73360. */
  73361. get pentagonBokeh(): boolean;
  73362. set pentagonBokeh(value: boolean);
  73363. /**
  73364. * Gets or sets the highlight grain amount
  73365. */
  73366. get highlightsGain(): number;
  73367. set highlightsGain(value: number);
  73368. /**
  73369. * Gets or sets the highlight threshold
  73370. */
  73371. get highlightsThreshold(): number;
  73372. set highlightsThreshold(value: number);
  73373. /**
  73374. * Sets the amount of blur at the edges
  73375. * @param amount blur amount
  73376. */
  73377. setEdgeBlur(amount: number): void;
  73378. /**
  73379. * Sets edge blur to 0
  73380. */
  73381. disableEdgeBlur(): void;
  73382. /**
  73383. * Sets the amout of grain
  73384. * @param amount Amount of grain
  73385. */
  73386. setGrainAmount(amount: number): void;
  73387. /**
  73388. * Set grain amount to 0
  73389. */
  73390. disableGrain(): void;
  73391. /**
  73392. * Sets the chromatic aberration amount
  73393. * @param amount amount of chromatic aberration
  73394. */
  73395. setChromaticAberration(amount: number): void;
  73396. /**
  73397. * Sets chromatic aberration amount to 0
  73398. */
  73399. disableChromaticAberration(): void;
  73400. /**
  73401. * Sets the EdgeDistortion amount
  73402. * @param amount amount of EdgeDistortion
  73403. */
  73404. setEdgeDistortion(amount: number): void;
  73405. /**
  73406. * Sets edge distortion to 0
  73407. */
  73408. disableEdgeDistortion(): void;
  73409. /**
  73410. * Sets the FocusDistance amount
  73411. * @param amount amount of FocusDistance
  73412. */
  73413. setFocusDistance(amount: number): void;
  73414. /**
  73415. * Disables depth of field
  73416. */
  73417. disableDepthOfField(): void;
  73418. /**
  73419. * Sets the Aperture amount
  73420. * @param amount amount of Aperture
  73421. */
  73422. setAperture(amount: number): void;
  73423. /**
  73424. * Sets the DarkenOutOfFocus amount
  73425. * @param amount amount of DarkenOutOfFocus
  73426. */
  73427. setDarkenOutOfFocus(amount: number): void;
  73428. private _pentagonBokehIsEnabled;
  73429. /**
  73430. * Creates a pentagon bokeh effect
  73431. */
  73432. enablePentagonBokeh(): void;
  73433. /**
  73434. * Disables the pentagon bokeh effect
  73435. */
  73436. disablePentagonBokeh(): void;
  73437. /**
  73438. * Enables noise blur
  73439. */
  73440. enableNoiseBlur(): void;
  73441. /**
  73442. * Disables noise blur
  73443. */
  73444. disableNoiseBlur(): void;
  73445. /**
  73446. * Sets the HighlightsGain amount
  73447. * @param amount amount of HighlightsGain
  73448. */
  73449. setHighlightsGain(amount: number): void;
  73450. /**
  73451. * Sets the HighlightsThreshold amount
  73452. * @param amount amount of HighlightsThreshold
  73453. */
  73454. setHighlightsThreshold(amount: number): void;
  73455. /**
  73456. * Disables highlights
  73457. */
  73458. disableHighlights(): void;
  73459. /**
  73460. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  73461. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  73462. */
  73463. dispose(disableDepthRender?: boolean): void;
  73464. private _createChromaticAberrationPostProcess;
  73465. private _createHighlightsPostProcess;
  73466. private _createDepthOfFieldPostProcess;
  73467. private _createGrainTexture;
  73468. }
  73469. }
  73470. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  73471. /** @hidden */
  73472. export var fibonacci: {
  73473. name: string;
  73474. shader: string;
  73475. };
  73476. }
  73477. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  73478. /** @hidden */
  73479. export var diffusionProfile: {
  73480. name: string;
  73481. shader: string;
  73482. };
  73483. }
  73484. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  73485. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  73486. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73487. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  73488. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  73489. /** @hidden */
  73490. export var subSurfaceScatteringPixelShader: {
  73491. name: string;
  73492. shader: string;
  73493. };
  73494. }
  73495. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  73496. import { Nullable } from "babylonjs/types";
  73497. import { Camera } from "babylonjs/Cameras/camera";
  73498. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73499. import { Engine } from "babylonjs/Engines/engine";
  73500. import { Scene } from "babylonjs/scene";
  73501. import "babylonjs/Shaders/imageProcessing.fragment";
  73502. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  73503. import "babylonjs/Shaders/postprocess.vertex";
  73504. /**
  73505. * Sub surface scattering post process
  73506. */
  73507. export class SubSurfaceScatteringPostProcess extends PostProcess {
  73508. /** @hidden */
  73509. texelWidth: number;
  73510. /** @hidden */
  73511. texelHeight: number;
  73512. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73513. }
  73514. }
  73515. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  73516. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73517. /**
  73518. * Interface for defining prepass effects in the prepass post-process pipeline
  73519. */
  73520. export interface PrePassEffectConfiguration {
  73521. /**
  73522. * Post process to attach for this effect
  73523. */
  73524. postProcess: PostProcess;
  73525. /**
  73526. * Is the effect enabled
  73527. */
  73528. enabled: boolean;
  73529. /**
  73530. * Disposes the effect configuration
  73531. */
  73532. dispose(): void;
  73533. /**
  73534. * Disposes the effect configuration
  73535. */
  73536. createPostProcess: () => PostProcess;
  73537. }
  73538. }
  73539. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  73540. import { Scene } from "babylonjs/scene";
  73541. import { Color3 } from "babylonjs/Maths/math.color";
  73542. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  73543. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  73544. /**
  73545. * Contains all parameters needed for the prepass to perform
  73546. * screen space subsurface scattering
  73547. */
  73548. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  73549. private _ssDiffusionS;
  73550. private _ssFilterRadii;
  73551. private _ssDiffusionD;
  73552. /**
  73553. * Post process to attach for screen space subsurface scattering
  73554. */
  73555. postProcess: SubSurfaceScatteringPostProcess;
  73556. /**
  73557. * Diffusion profile color for subsurface scattering
  73558. */
  73559. get ssDiffusionS(): number[];
  73560. /**
  73561. * Diffusion profile max color channel value for subsurface scattering
  73562. */
  73563. get ssDiffusionD(): number[];
  73564. /**
  73565. * Diffusion profile filter radius for subsurface scattering
  73566. */
  73567. get ssFilterRadii(): number[];
  73568. /**
  73569. * Is subsurface enabled
  73570. */
  73571. enabled: boolean;
  73572. /**
  73573. * Diffusion profile colors for subsurface scattering
  73574. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  73575. * See ...
  73576. * Note that you can only store up to 5 of them
  73577. */
  73578. ssDiffusionProfileColors: Color3[];
  73579. /**
  73580. * Defines the ratio real world => scene units.
  73581. * Used for subsurface scattering
  73582. */
  73583. metersPerUnit: number;
  73584. private _scene;
  73585. /**
  73586. * Builds a subsurface configuration object
  73587. * @param scene The scene
  73588. */
  73589. constructor(scene: Scene);
  73590. /**
  73591. * Adds a new diffusion profile.
  73592. * Useful for more realistic subsurface scattering on diverse materials.
  73593. * @param color The color of the diffusion profile. Should be the average color of the material.
  73594. * @return The index of the diffusion profile for the material subsurface configuration
  73595. */
  73596. addDiffusionProfile(color: Color3): number;
  73597. /**
  73598. * Creates the sss post process
  73599. * @return The created post process
  73600. */
  73601. createPostProcess(): SubSurfaceScatteringPostProcess;
  73602. /**
  73603. * Deletes all diffusion profiles.
  73604. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  73605. */
  73606. clearAllDiffusionProfiles(): void;
  73607. /**
  73608. * Disposes this object
  73609. */
  73610. dispose(): void;
  73611. /**
  73612. * @hidden
  73613. * https://zero-radiance.github.io/post/sampling-diffusion/
  73614. *
  73615. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  73616. * ------------------------------------------------------------------------------------
  73617. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  73618. * PDF[r, phi, s] = r * R[r, phi, s]
  73619. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  73620. * ------------------------------------------------------------------------------------
  73621. * We importance sample the color channel with the widest scattering distance.
  73622. */
  73623. getDiffusionProfileParameters(color: Color3): number;
  73624. /**
  73625. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  73626. * 'u' is the random number (the value of the CDF): [0, 1).
  73627. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  73628. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  73629. */
  73630. private _sampleBurleyDiffusionProfile;
  73631. }
  73632. }
  73633. declare module "babylonjs/Rendering/prePassRenderer" {
  73634. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73635. import { Scene } from "babylonjs/scene";
  73636. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  73637. import { Effect } from "babylonjs/Materials/effect";
  73638. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  73639. /**
  73640. * Renders a pre pass of the scene
  73641. * This means every mesh in the scene will be rendered to a render target texture
  73642. * And then this texture will be composited to the rendering canvas with post processes
  73643. * It is necessary for effects like subsurface scattering or deferred shading
  73644. */
  73645. export class PrePassRenderer {
  73646. /** @hidden */
  73647. static _SceneComponentInitialization: (scene: Scene) => void;
  73648. private _scene;
  73649. private _engine;
  73650. private _isDirty;
  73651. /**
  73652. * Number of textures in the multi render target texture where the scene is directly rendered
  73653. */
  73654. readonly mrtCount: number;
  73655. /**
  73656. * The render target where the scene is directly rendered
  73657. */
  73658. prePassRT: MultiRenderTarget;
  73659. private _mrtTypes;
  73660. private _multiRenderAttachments;
  73661. private _defaultAttachments;
  73662. private _clearAttachments;
  73663. private _postProcesses;
  73664. private readonly _clearColor;
  73665. /**
  73666. * Image processing post process for composition
  73667. */
  73668. imageProcessingPostProcess: ImageProcessingPostProcess;
  73669. /**
  73670. * Configuration for sub surface scattering post process
  73671. */
  73672. subSurfaceConfiguration: SubSurfaceConfiguration;
  73673. /**
  73674. * Should materials render their geometry on the MRT
  73675. */
  73676. materialsShouldRenderGeometry: boolean;
  73677. /**
  73678. * Should materials render the irradiance information on the MRT
  73679. */
  73680. materialsShouldRenderIrradiance: boolean;
  73681. private _enabled;
  73682. /**
  73683. * Indicates if the prepass is enabled
  73684. */
  73685. get enabled(): boolean;
  73686. /**
  73687. * How many samples are used for MSAA of the scene render target
  73688. */
  73689. get samples(): number;
  73690. set samples(n: number);
  73691. /**
  73692. * Instanciates a prepass renderer
  73693. * @param scene The scene
  73694. */
  73695. constructor(scene: Scene);
  73696. private _initializeAttachments;
  73697. private _createCompositionEffect;
  73698. /**
  73699. * Indicates if rendering a prepass is supported
  73700. */
  73701. get isSupported(): boolean;
  73702. /**
  73703. * Sets the proper output textures to draw in the engine.
  73704. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  73705. */
  73706. bindAttachmentsForEffect(effect: Effect): void;
  73707. /**
  73708. * @hidden
  73709. */
  73710. _beforeCameraDraw(): void;
  73711. /**
  73712. * @hidden
  73713. */
  73714. _afterCameraDraw(): void;
  73715. private _checkRTSize;
  73716. private _bindFrameBuffer;
  73717. /**
  73718. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  73719. */
  73720. clear(): void;
  73721. private _setState;
  73722. private _enable;
  73723. private _disable;
  73724. private _resetPostProcessChain;
  73725. private _bindPostProcessChain;
  73726. /**
  73727. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  73728. */
  73729. markAsDirty(): void;
  73730. private _update;
  73731. /**
  73732. * Disposes the prepass renderer.
  73733. */
  73734. dispose(): void;
  73735. }
  73736. }
  73737. declare module "babylonjs/Shaders/ssao2.fragment" {
  73738. /** @hidden */
  73739. export var ssao2PixelShader: {
  73740. name: string;
  73741. shader: string;
  73742. };
  73743. }
  73744. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  73745. /** @hidden */
  73746. export var ssaoCombinePixelShader: {
  73747. name: string;
  73748. shader: string;
  73749. };
  73750. }
  73751. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  73752. import { Camera } from "babylonjs/Cameras/camera";
  73753. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73754. import { Scene } from "babylonjs/scene";
  73755. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73756. import "babylonjs/Shaders/ssao2.fragment";
  73757. import "babylonjs/Shaders/ssaoCombine.fragment";
  73758. /**
  73759. * Render pipeline to produce ssao effect
  73760. */
  73761. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  73762. /**
  73763. * @ignore
  73764. * The PassPostProcess id in the pipeline that contains the original scene color
  73765. */
  73766. SSAOOriginalSceneColorEffect: string;
  73767. /**
  73768. * @ignore
  73769. * The SSAO PostProcess id in the pipeline
  73770. */
  73771. SSAORenderEffect: string;
  73772. /**
  73773. * @ignore
  73774. * The horizontal blur PostProcess id in the pipeline
  73775. */
  73776. SSAOBlurHRenderEffect: string;
  73777. /**
  73778. * @ignore
  73779. * The vertical blur PostProcess id in the pipeline
  73780. */
  73781. SSAOBlurVRenderEffect: string;
  73782. /**
  73783. * @ignore
  73784. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73785. */
  73786. SSAOCombineRenderEffect: string;
  73787. /**
  73788. * The output strength of the SSAO post-process. Default value is 1.0.
  73789. */
  73790. totalStrength: number;
  73791. /**
  73792. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  73793. */
  73794. maxZ: number;
  73795. /**
  73796. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  73797. */
  73798. minZAspect: number;
  73799. private _samples;
  73800. /**
  73801. * Number of samples used for the SSAO calculations. Default value is 8
  73802. */
  73803. set samples(n: number);
  73804. get samples(): number;
  73805. private _textureSamples;
  73806. /**
  73807. * Number of samples to use for antialiasing
  73808. */
  73809. set textureSamples(n: number);
  73810. get textureSamples(): number;
  73811. /**
  73812. * Force rendering the geometry through geometry buffer
  73813. */
  73814. private _forceGeometryBuffer;
  73815. /**
  73816. * Ratio object used for SSAO ratio and blur ratio
  73817. */
  73818. private _ratio;
  73819. /**
  73820. * Dynamically generated sphere sampler.
  73821. */
  73822. private _sampleSphere;
  73823. /**
  73824. * Blur filter offsets
  73825. */
  73826. private _samplerOffsets;
  73827. private _expensiveBlur;
  73828. /**
  73829. * If bilateral blur should be used
  73830. */
  73831. set expensiveBlur(b: boolean);
  73832. get expensiveBlur(): boolean;
  73833. /**
  73834. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  73835. */
  73836. radius: number;
  73837. /**
  73838. * The base color of the SSAO post-process
  73839. * The final result is "base + ssao" between [0, 1]
  73840. */
  73841. base: number;
  73842. /**
  73843. * Support test.
  73844. */
  73845. static get IsSupported(): boolean;
  73846. private _scene;
  73847. private _randomTexture;
  73848. private _originalColorPostProcess;
  73849. private _ssaoPostProcess;
  73850. private _blurHPostProcess;
  73851. private _blurVPostProcess;
  73852. private _ssaoCombinePostProcess;
  73853. private _prePassRenderer;
  73854. /**
  73855. * Gets active scene
  73856. */
  73857. get scene(): Scene;
  73858. /**
  73859. * @constructor
  73860. * @param name The rendering pipeline name
  73861. * @param scene The scene linked to this pipeline
  73862. * @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 }
  73863. * @param cameras The array of cameras that the rendering pipeline will be attached to
  73864. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  73865. */
  73866. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  73867. /**
  73868. * Get the class name
  73869. * @returns "SSAO2RenderingPipeline"
  73870. */
  73871. getClassName(): string;
  73872. /**
  73873. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73874. */
  73875. dispose(disableGeometryBufferRenderer?: boolean): void;
  73876. private _createBlurPostProcess;
  73877. /** @hidden */
  73878. _rebuild(): void;
  73879. private _bits;
  73880. private _radicalInverse_VdC;
  73881. private _hammersley;
  73882. private _hemisphereSample_uniform;
  73883. private _generateHemisphere;
  73884. private _getDefinesForSSAO;
  73885. private _createSSAOPostProcess;
  73886. private _createSSAOCombinePostProcess;
  73887. private _createRandomTexture;
  73888. /**
  73889. * Serialize the rendering pipeline (Used when exporting)
  73890. * @returns the serialized object
  73891. */
  73892. serialize(): any;
  73893. /**
  73894. * Parse the serialized pipeline
  73895. * @param source Source pipeline.
  73896. * @param scene The scene to load the pipeline to.
  73897. * @param rootUrl The URL of the serialized pipeline.
  73898. * @returns An instantiated pipeline from the serialized object.
  73899. */
  73900. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  73901. }
  73902. }
  73903. declare module "babylonjs/Shaders/ssao.fragment" {
  73904. /** @hidden */
  73905. export var ssaoPixelShader: {
  73906. name: string;
  73907. shader: string;
  73908. };
  73909. }
  73910. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  73911. import { Camera } from "babylonjs/Cameras/camera";
  73912. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  73913. import { Scene } from "babylonjs/scene";
  73914. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  73915. import "babylonjs/Shaders/ssao.fragment";
  73916. import "babylonjs/Shaders/ssaoCombine.fragment";
  73917. /**
  73918. * Render pipeline to produce ssao effect
  73919. */
  73920. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  73921. /**
  73922. * @ignore
  73923. * The PassPostProcess id in the pipeline that contains the original scene color
  73924. */
  73925. SSAOOriginalSceneColorEffect: string;
  73926. /**
  73927. * @ignore
  73928. * The SSAO PostProcess id in the pipeline
  73929. */
  73930. SSAORenderEffect: string;
  73931. /**
  73932. * @ignore
  73933. * The horizontal blur PostProcess id in the pipeline
  73934. */
  73935. SSAOBlurHRenderEffect: string;
  73936. /**
  73937. * @ignore
  73938. * The vertical blur PostProcess id in the pipeline
  73939. */
  73940. SSAOBlurVRenderEffect: string;
  73941. /**
  73942. * @ignore
  73943. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  73944. */
  73945. SSAOCombineRenderEffect: string;
  73946. /**
  73947. * The output strength of the SSAO post-process. Default value is 1.0.
  73948. */
  73949. totalStrength: number;
  73950. /**
  73951. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  73952. */
  73953. radius: number;
  73954. /**
  73955. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  73956. * Must not be equal to fallOff and superior to fallOff.
  73957. * Default value is 0.0075
  73958. */
  73959. area: number;
  73960. /**
  73961. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  73962. * Must not be equal to area and inferior to area.
  73963. * Default value is 0.000001
  73964. */
  73965. fallOff: number;
  73966. /**
  73967. * The base color of the SSAO post-process
  73968. * The final result is "base + ssao" between [0, 1]
  73969. */
  73970. base: number;
  73971. private _scene;
  73972. private _depthTexture;
  73973. private _randomTexture;
  73974. private _originalColorPostProcess;
  73975. private _ssaoPostProcess;
  73976. private _blurHPostProcess;
  73977. private _blurVPostProcess;
  73978. private _ssaoCombinePostProcess;
  73979. private _firstUpdate;
  73980. /**
  73981. * Gets active scene
  73982. */
  73983. get scene(): Scene;
  73984. /**
  73985. * @constructor
  73986. * @param name - The rendering pipeline name
  73987. * @param scene - The scene linked to this pipeline
  73988. * @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 }
  73989. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  73990. */
  73991. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  73992. /**
  73993. * Get the class name
  73994. * @returns "SSAORenderingPipeline"
  73995. */
  73996. getClassName(): string;
  73997. /**
  73998. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  73999. */
  74000. dispose(disableDepthRender?: boolean): void;
  74001. private _createBlurPostProcess;
  74002. /** @hidden */
  74003. _rebuild(): void;
  74004. private _createSSAOPostProcess;
  74005. private _createSSAOCombinePostProcess;
  74006. private _createRandomTexture;
  74007. }
  74008. }
  74009. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  74010. /** @hidden */
  74011. export var screenSpaceReflectionPixelShader: {
  74012. name: string;
  74013. shader: string;
  74014. };
  74015. }
  74016. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  74017. import { Nullable } from "babylonjs/types";
  74018. import { Camera } from "babylonjs/Cameras/camera";
  74019. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74020. import { Scene } from "babylonjs/scene";
  74021. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  74022. import { Engine } from "babylonjs/Engines/engine";
  74023. /**
  74024. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  74025. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  74026. */
  74027. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  74028. /**
  74029. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  74030. */
  74031. threshold: number;
  74032. /**
  74033. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  74034. */
  74035. strength: number;
  74036. /**
  74037. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  74038. */
  74039. reflectionSpecularFalloffExponent: number;
  74040. /**
  74041. * 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]
  74042. */
  74043. step: number;
  74044. /**
  74045. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  74046. */
  74047. roughnessFactor: number;
  74048. private _geometryBufferRenderer;
  74049. private _enableSmoothReflections;
  74050. private _reflectionSamples;
  74051. private _smoothSteps;
  74052. /**
  74053. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  74054. * @param name The name of the effect.
  74055. * @param scene The scene containing the objects to calculate reflections.
  74056. * @param options The required width/height ratio to downsize to before computing the render pass.
  74057. * @param camera The camera to apply the render pass to.
  74058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74059. * @param engine The engine which the post process will be applied. (default: current engine)
  74060. * @param reusable If the post process can be reused on the same frame. (default: false)
  74061. * @param textureType Type of textures used when performing the post process. (default: 0)
  74062. * @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)
  74063. */
  74064. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74065. /**
  74066. * Gets wether or not smoothing reflections is enabled.
  74067. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74068. */
  74069. get enableSmoothReflections(): boolean;
  74070. /**
  74071. * Sets wether or not smoothing reflections is enabled.
  74072. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  74073. */
  74074. set enableSmoothReflections(enabled: boolean);
  74075. /**
  74076. * Gets the number of samples taken while computing reflections. More samples count is high,
  74077. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74078. */
  74079. get reflectionSamples(): number;
  74080. /**
  74081. * Sets the number of samples taken while computing reflections. More samples count is high,
  74082. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  74083. */
  74084. set reflectionSamples(samples: number);
  74085. /**
  74086. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  74087. * more the post-process will require GPU power and can generate a drop in FPS.
  74088. * Default value (5.0) work pretty well in all cases but can be adjusted.
  74089. */
  74090. get smoothSteps(): number;
  74091. set smoothSteps(steps: number);
  74092. private _updateEffectDefines;
  74093. }
  74094. }
  74095. declare module "babylonjs/Shaders/standard.fragment" {
  74096. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  74097. /** @hidden */
  74098. export var standardPixelShader: {
  74099. name: string;
  74100. shader: string;
  74101. };
  74102. }
  74103. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  74104. import { Nullable } from "babylonjs/types";
  74105. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74106. import { Camera } from "babylonjs/Cameras/camera";
  74107. import { Texture } from "babylonjs/Materials/Textures/texture";
  74108. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74109. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74110. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  74111. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74112. import { IDisposable } from "babylonjs/scene";
  74113. import { SpotLight } from "babylonjs/Lights/spotLight";
  74114. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  74115. import { Scene } from "babylonjs/scene";
  74116. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74117. import { Animation } from "babylonjs/Animations/animation";
  74118. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74119. import "babylonjs/Shaders/standard.fragment";
  74120. /**
  74121. * Standard rendering pipeline
  74122. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74123. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  74124. */
  74125. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74126. /**
  74127. * Public members
  74128. */
  74129. /**
  74130. * Post-process which contains the original scene color before the pipeline applies all the effects
  74131. */
  74132. originalPostProcess: Nullable<PostProcess>;
  74133. /**
  74134. * Post-process used to down scale an image x4
  74135. */
  74136. downSampleX4PostProcess: Nullable<PostProcess>;
  74137. /**
  74138. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  74139. */
  74140. brightPassPostProcess: Nullable<PostProcess>;
  74141. /**
  74142. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  74143. */
  74144. blurHPostProcesses: PostProcess[];
  74145. /**
  74146. * Post-process array storing all the vertical blur post-processes used by the pipeline
  74147. */
  74148. blurVPostProcesses: PostProcess[];
  74149. /**
  74150. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  74151. */
  74152. textureAdderPostProcess: Nullable<PostProcess>;
  74153. /**
  74154. * Post-process used to create volumetric lighting effect
  74155. */
  74156. volumetricLightPostProcess: Nullable<PostProcess>;
  74157. /**
  74158. * Post-process used to smooth the previous volumetric light post-process on the X axis
  74159. */
  74160. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  74161. /**
  74162. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  74163. */
  74164. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  74165. /**
  74166. * Post-process used to merge the volumetric light effect and the real scene color
  74167. */
  74168. volumetricLightMergePostProces: Nullable<PostProcess>;
  74169. /**
  74170. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  74171. */
  74172. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  74173. /**
  74174. * Base post-process used to calculate the average luminance of the final image for HDR
  74175. */
  74176. luminancePostProcess: Nullable<PostProcess>;
  74177. /**
  74178. * Post-processes used to create down sample post-processes in order to get
  74179. * the average luminance of the final image for HDR
  74180. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  74181. */
  74182. luminanceDownSamplePostProcesses: PostProcess[];
  74183. /**
  74184. * Post-process used to create a HDR effect (light adaptation)
  74185. */
  74186. hdrPostProcess: Nullable<PostProcess>;
  74187. /**
  74188. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  74189. */
  74190. textureAdderFinalPostProcess: Nullable<PostProcess>;
  74191. /**
  74192. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  74193. */
  74194. lensFlareFinalPostProcess: Nullable<PostProcess>;
  74195. /**
  74196. * Post-process used to merge the final HDR post-process and the real scene color
  74197. */
  74198. hdrFinalPostProcess: Nullable<PostProcess>;
  74199. /**
  74200. * Post-process used to create a lens flare effect
  74201. */
  74202. lensFlarePostProcess: Nullable<PostProcess>;
  74203. /**
  74204. * Post-process that merges the result of the lens flare post-process and the real scene color
  74205. */
  74206. lensFlareComposePostProcess: Nullable<PostProcess>;
  74207. /**
  74208. * Post-process used to create a motion blur effect
  74209. */
  74210. motionBlurPostProcess: Nullable<PostProcess>;
  74211. /**
  74212. * Post-process used to create a depth of field effect
  74213. */
  74214. depthOfFieldPostProcess: Nullable<PostProcess>;
  74215. /**
  74216. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74217. */
  74218. fxaaPostProcess: Nullable<FxaaPostProcess>;
  74219. /**
  74220. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  74221. */
  74222. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  74223. /**
  74224. * Represents the brightness threshold in order to configure the illuminated surfaces
  74225. */
  74226. brightThreshold: number;
  74227. /**
  74228. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  74229. */
  74230. blurWidth: number;
  74231. /**
  74232. * Sets if the blur for highlighted surfaces must be only horizontal
  74233. */
  74234. horizontalBlur: boolean;
  74235. /**
  74236. * Gets the overall exposure used by the pipeline
  74237. */
  74238. get exposure(): number;
  74239. /**
  74240. * Sets the overall exposure used by the pipeline
  74241. */
  74242. set exposure(value: number);
  74243. /**
  74244. * Texture used typically to simulate "dirty" on camera lens
  74245. */
  74246. lensTexture: Nullable<Texture>;
  74247. /**
  74248. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  74249. */
  74250. volumetricLightCoefficient: number;
  74251. /**
  74252. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  74253. */
  74254. volumetricLightPower: number;
  74255. /**
  74256. * Used the set the blur intensity to smooth the volumetric lights
  74257. */
  74258. volumetricLightBlurScale: number;
  74259. /**
  74260. * Light (spot or directional) used to generate the volumetric lights rays
  74261. * The source light must have a shadow generate so the pipeline can get its
  74262. * depth map
  74263. */
  74264. sourceLight: Nullable<SpotLight | DirectionalLight>;
  74265. /**
  74266. * For eye adaptation, represents the minimum luminance the eye can see
  74267. */
  74268. hdrMinimumLuminance: number;
  74269. /**
  74270. * For eye adaptation, represents the decrease luminance speed
  74271. */
  74272. hdrDecreaseRate: number;
  74273. /**
  74274. * For eye adaptation, represents the increase luminance speed
  74275. */
  74276. hdrIncreaseRate: number;
  74277. /**
  74278. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74279. */
  74280. get hdrAutoExposure(): boolean;
  74281. /**
  74282. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  74283. */
  74284. set hdrAutoExposure(value: boolean);
  74285. /**
  74286. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  74287. */
  74288. lensColorTexture: Nullable<Texture>;
  74289. /**
  74290. * The overall strengh for the lens flare effect
  74291. */
  74292. lensFlareStrength: number;
  74293. /**
  74294. * Dispersion coefficient for lens flare ghosts
  74295. */
  74296. lensFlareGhostDispersal: number;
  74297. /**
  74298. * Main lens flare halo width
  74299. */
  74300. lensFlareHaloWidth: number;
  74301. /**
  74302. * Based on the lens distortion effect, defines how much the lens flare result
  74303. * is distorted
  74304. */
  74305. lensFlareDistortionStrength: number;
  74306. /**
  74307. * Configures the blur intensity used for for lens flare (halo)
  74308. */
  74309. lensFlareBlurWidth: number;
  74310. /**
  74311. * Lens star texture must be used to simulate rays on the flares and is available
  74312. * in the documentation
  74313. */
  74314. lensStarTexture: Nullable<Texture>;
  74315. /**
  74316. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  74317. * flare effect by taking account of the dirt texture
  74318. */
  74319. lensFlareDirtTexture: Nullable<Texture>;
  74320. /**
  74321. * Represents the focal length for the depth of field effect
  74322. */
  74323. depthOfFieldDistance: number;
  74324. /**
  74325. * Represents the blur intensity for the blurred part of the depth of field effect
  74326. */
  74327. depthOfFieldBlurWidth: number;
  74328. /**
  74329. * Gets how much the image is blurred by the movement while using the motion blur post-process
  74330. */
  74331. get motionStrength(): number;
  74332. /**
  74333. * Sets how much the image is blurred by the movement while using the motion blur post-process
  74334. */
  74335. set motionStrength(strength: number);
  74336. /**
  74337. * Gets wether or not the motion blur post-process is object based or screen based.
  74338. */
  74339. get objectBasedMotionBlur(): boolean;
  74340. /**
  74341. * Sets wether or not the motion blur post-process should be object based or screen based
  74342. */
  74343. set objectBasedMotionBlur(value: boolean);
  74344. /**
  74345. * List of animations for the pipeline (IAnimatable implementation)
  74346. */
  74347. animations: Animation[];
  74348. /**
  74349. * Private members
  74350. */
  74351. private _scene;
  74352. private _currentDepthOfFieldSource;
  74353. private _basePostProcess;
  74354. private _fixedExposure;
  74355. private _currentExposure;
  74356. private _hdrAutoExposure;
  74357. private _hdrCurrentLuminance;
  74358. private _motionStrength;
  74359. private _isObjectBasedMotionBlur;
  74360. private _floatTextureType;
  74361. private _camerasToBeAttached;
  74362. private _ratio;
  74363. private _bloomEnabled;
  74364. private _depthOfFieldEnabled;
  74365. private _vlsEnabled;
  74366. private _lensFlareEnabled;
  74367. private _hdrEnabled;
  74368. private _motionBlurEnabled;
  74369. private _fxaaEnabled;
  74370. private _screenSpaceReflectionsEnabled;
  74371. private _motionBlurSamples;
  74372. private _volumetricLightStepsCount;
  74373. private _samples;
  74374. /**
  74375. * @ignore
  74376. * Specifies if the bloom pipeline is enabled
  74377. */
  74378. get BloomEnabled(): boolean;
  74379. set BloomEnabled(enabled: boolean);
  74380. /**
  74381. * @ignore
  74382. * Specifies if the depth of field pipeline is enabed
  74383. */
  74384. get DepthOfFieldEnabled(): boolean;
  74385. set DepthOfFieldEnabled(enabled: boolean);
  74386. /**
  74387. * @ignore
  74388. * Specifies if the lens flare pipeline is enabed
  74389. */
  74390. get LensFlareEnabled(): boolean;
  74391. set LensFlareEnabled(enabled: boolean);
  74392. /**
  74393. * @ignore
  74394. * Specifies if the HDR pipeline is enabled
  74395. */
  74396. get HDREnabled(): boolean;
  74397. set HDREnabled(enabled: boolean);
  74398. /**
  74399. * @ignore
  74400. * Specifies if the volumetric lights scattering effect is enabled
  74401. */
  74402. get VLSEnabled(): boolean;
  74403. set VLSEnabled(enabled: boolean);
  74404. /**
  74405. * @ignore
  74406. * Specifies if the motion blur effect is enabled
  74407. */
  74408. get MotionBlurEnabled(): boolean;
  74409. set MotionBlurEnabled(enabled: boolean);
  74410. /**
  74411. * Specifies if anti-aliasing is enabled
  74412. */
  74413. get fxaaEnabled(): boolean;
  74414. set fxaaEnabled(enabled: boolean);
  74415. /**
  74416. * Specifies if screen space reflections are enabled.
  74417. */
  74418. get screenSpaceReflectionsEnabled(): boolean;
  74419. set screenSpaceReflectionsEnabled(enabled: boolean);
  74420. /**
  74421. * Specifies the number of steps used to calculate the volumetric lights
  74422. * Typically in interval [50, 200]
  74423. */
  74424. get volumetricLightStepsCount(): number;
  74425. set volumetricLightStepsCount(count: number);
  74426. /**
  74427. * Specifies the number of samples used for the motion blur effect
  74428. * Typically in interval [16, 64]
  74429. */
  74430. get motionBlurSamples(): number;
  74431. set motionBlurSamples(samples: number);
  74432. /**
  74433. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74434. */
  74435. get samples(): number;
  74436. set samples(sampleCount: number);
  74437. /**
  74438. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  74439. * @constructor
  74440. * @param name The rendering pipeline name
  74441. * @param scene The scene linked to this pipeline
  74442. * @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)
  74443. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  74444. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74445. */
  74446. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  74447. private _buildPipeline;
  74448. private _createDownSampleX4PostProcess;
  74449. private _createBrightPassPostProcess;
  74450. private _createBlurPostProcesses;
  74451. private _createTextureAdderPostProcess;
  74452. private _createVolumetricLightPostProcess;
  74453. private _createLuminancePostProcesses;
  74454. private _createHdrPostProcess;
  74455. private _createLensFlarePostProcess;
  74456. private _createDepthOfFieldPostProcess;
  74457. private _createMotionBlurPostProcess;
  74458. private _getDepthTexture;
  74459. private _disposePostProcesses;
  74460. /**
  74461. * Dispose of the pipeline and stop all post processes
  74462. */
  74463. dispose(): void;
  74464. /**
  74465. * Serialize the rendering pipeline (Used when exporting)
  74466. * @returns the serialized object
  74467. */
  74468. serialize(): any;
  74469. /**
  74470. * Parse the serialized pipeline
  74471. * @param source Source pipeline.
  74472. * @param scene The scene to load the pipeline to.
  74473. * @param rootUrl The URL of the serialized pipeline.
  74474. * @returns An instantiated pipeline from the serialized object.
  74475. */
  74476. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  74477. /**
  74478. * Luminance steps
  74479. */
  74480. static LuminanceSteps: number;
  74481. }
  74482. }
  74483. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  74484. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  74485. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  74486. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  74487. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  74488. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  74489. }
  74490. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  74491. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  74492. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74493. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74494. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74495. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74496. }
  74497. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  74498. /** @hidden */
  74499. export var stereoscopicInterlacePixelShader: {
  74500. name: string;
  74501. shader: string;
  74502. };
  74503. }
  74504. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  74505. import { Camera } from "babylonjs/Cameras/camera";
  74506. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74507. import { Engine } from "babylonjs/Engines/engine";
  74508. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  74509. /**
  74510. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  74511. */
  74512. export class StereoscopicInterlacePostProcessI extends PostProcess {
  74513. private _stepSize;
  74514. private _passedProcess;
  74515. /**
  74516. * Initializes a StereoscopicInterlacePostProcessI
  74517. * @param name The name of the effect.
  74518. * @param rigCameras The rig cameras to be appled to the post process
  74519. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  74520. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  74521. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74522. * @param engine The engine which the post process will be applied. (default: current engine)
  74523. * @param reusable If the post process can be reused on the same frame. (default: false)
  74524. */
  74525. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74526. }
  74527. /**
  74528. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  74529. */
  74530. export class StereoscopicInterlacePostProcess extends PostProcess {
  74531. private _stepSize;
  74532. private _passedProcess;
  74533. /**
  74534. * Initializes a StereoscopicInterlacePostProcess
  74535. * @param name The name of the effect.
  74536. * @param rigCameras The rig cameras to be appled to the post process
  74537. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  74538. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74539. * @param engine The engine which the post process will be applied. (default: current engine)
  74540. * @param reusable If the post process can be reused on the same frame. (default: false)
  74541. */
  74542. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74543. }
  74544. }
  74545. declare module "babylonjs/Shaders/tonemap.fragment" {
  74546. /** @hidden */
  74547. export var tonemapPixelShader: {
  74548. name: string;
  74549. shader: string;
  74550. };
  74551. }
  74552. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  74553. import { Camera } from "babylonjs/Cameras/camera";
  74554. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74555. import "babylonjs/Shaders/tonemap.fragment";
  74556. import { Engine } from "babylonjs/Engines/engine";
  74557. /** Defines operator used for tonemapping */
  74558. export enum TonemappingOperator {
  74559. /** Hable */
  74560. Hable = 0,
  74561. /** Reinhard */
  74562. Reinhard = 1,
  74563. /** HejiDawson */
  74564. HejiDawson = 2,
  74565. /** Photographic */
  74566. Photographic = 3
  74567. }
  74568. /**
  74569. * Defines a post process to apply tone mapping
  74570. */
  74571. export class TonemapPostProcess extends PostProcess {
  74572. private _operator;
  74573. /** Defines the required exposure adjustement */
  74574. exposureAdjustment: number;
  74575. /**
  74576. * Creates a new TonemapPostProcess
  74577. * @param name defines the name of the postprocess
  74578. * @param _operator defines the operator to use
  74579. * @param exposureAdjustment defines the required exposure adjustement
  74580. * @param camera defines the camera to use (can be null)
  74581. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  74582. * @param engine defines the hosting engine (can be ignore if camera is set)
  74583. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  74584. */
  74585. constructor(name: string, _operator: TonemappingOperator,
  74586. /** Defines the required exposure adjustement */
  74587. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  74588. }
  74589. }
  74590. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  74591. /** @hidden */
  74592. export var volumetricLightScatteringPixelShader: {
  74593. name: string;
  74594. shader: string;
  74595. };
  74596. }
  74597. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  74598. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  74599. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  74600. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  74601. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  74602. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  74603. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  74604. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  74605. /** @hidden */
  74606. export var volumetricLightScatteringPassVertexShader: {
  74607. name: string;
  74608. shader: string;
  74609. };
  74610. }
  74611. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  74612. /** @hidden */
  74613. export var volumetricLightScatteringPassPixelShader: {
  74614. name: string;
  74615. shader: string;
  74616. };
  74617. }
  74618. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  74619. import { Vector3 } from "babylonjs/Maths/math.vector";
  74620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74621. import { Mesh } from "babylonjs/Meshes/mesh";
  74622. import { Camera } from "babylonjs/Cameras/camera";
  74623. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  74624. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  74625. import { Scene } from "babylonjs/scene";
  74626. import "babylonjs/Meshes/Builders/planeBuilder";
  74627. import "babylonjs/Shaders/depth.vertex";
  74628. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  74629. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  74630. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  74631. import { Engine } from "babylonjs/Engines/engine";
  74632. /**
  74633. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  74634. */
  74635. export class VolumetricLightScatteringPostProcess extends PostProcess {
  74636. private _volumetricLightScatteringPass;
  74637. private _volumetricLightScatteringRTT;
  74638. private _viewPort;
  74639. private _screenCoordinates;
  74640. private _cachedDefines;
  74641. /**
  74642. * If not undefined, the mesh position is computed from the attached node position
  74643. */
  74644. attachedNode: {
  74645. position: Vector3;
  74646. };
  74647. /**
  74648. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  74649. */
  74650. customMeshPosition: Vector3;
  74651. /**
  74652. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  74653. */
  74654. useCustomMeshPosition: boolean;
  74655. /**
  74656. * If the post-process should inverse the light scattering direction
  74657. */
  74658. invert: boolean;
  74659. /**
  74660. * The internal mesh used by the post-process
  74661. */
  74662. mesh: Mesh;
  74663. /**
  74664. * @hidden
  74665. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  74666. */
  74667. get useDiffuseColor(): boolean;
  74668. set useDiffuseColor(useDiffuseColor: boolean);
  74669. /**
  74670. * Array containing the excluded meshes not rendered in the internal pass
  74671. */
  74672. excludedMeshes: AbstractMesh[];
  74673. /**
  74674. * Controls the overall intensity of the post-process
  74675. */
  74676. exposure: number;
  74677. /**
  74678. * Dissipates each sample's contribution in range [0, 1]
  74679. */
  74680. decay: number;
  74681. /**
  74682. * Controls the overall intensity of each sample
  74683. */
  74684. weight: number;
  74685. /**
  74686. * Controls the density of each sample
  74687. */
  74688. density: number;
  74689. /**
  74690. * @constructor
  74691. * @param name The post-process name
  74692. * @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)
  74693. * @param camera The camera that the post-process will be attached to
  74694. * @param mesh The mesh used to create the light scattering
  74695. * @param samples The post-process quality, default 100
  74696. * @param samplingModeThe post-process filtering mode
  74697. * @param engine The babylon engine
  74698. * @param reusable If the post-process is reusable
  74699. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  74700. */
  74701. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  74702. /**
  74703. * Returns the string "VolumetricLightScatteringPostProcess"
  74704. * @returns "VolumetricLightScatteringPostProcess"
  74705. */
  74706. getClassName(): string;
  74707. private _isReady;
  74708. /**
  74709. * Sets the new light position for light scattering effect
  74710. * @param position The new custom light position
  74711. */
  74712. setCustomMeshPosition(position: Vector3): void;
  74713. /**
  74714. * Returns the light position for light scattering effect
  74715. * @return Vector3 The custom light position
  74716. */
  74717. getCustomMeshPosition(): Vector3;
  74718. /**
  74719. * Disposes the internal assets and detaches the post-process from the camera
  74720. */
  74721. dispose(camera: Camera): void;
  74722. /**
  74723. * Returns the render target texture used by the post-process
  74724. * @return the render target texture used by the post-process
  74725. */
  74726. getPass(): RenderTargetTexture;
  74727. private _meshExcluded;
  74728. private _createPass;
  74729. private _updateMeshScreenCoordinates;
  74730. /**
  74731. * Creates a default mesh for the Volumeric Light Scattering post-process
  74732. * @param name The mesh name
  74733. * @param scene The scene where to create the mesh
  74734. * @return the default mesh
  74735. */
  74736. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  74737. }
  74738. }
  74739. declare module "babylonjs/PostProcesses/index" {
  74740. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  74741. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  74742. export * from "babylonjs/PostProcesses/bloomEffect";
  74743. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  74744. export * from "babylonjs/PostProcesses/blurPostProcess";
  74745. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74746. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  74747. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  74748. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  74749. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  74750. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  74751. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  74752. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  74753. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  74754. export * from "babylonjs/PostProcesses/filterPostProcess";
  74755. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  74756. export * from "babylonjs/PostProcesses/grainPostProcess";
  74757. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  74758. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74759. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  74760. export * from "babylonjs/PostProcesses/passPostProcess";
  74761. export * from "babylonjs/PostProcesses/postProcess";
  74762. export * from "babylonjs/PostProcesses/postProcessManager";
  74763. export * from "babylonjs/PostProcesses/refractionPostProcess";
  74764. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  74765. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  74766. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  74767. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  74768. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  74769. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  74770. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  74771. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  74772. }
  74773. declare module "babylonjs/Probes/index" {
  74774. export * from "babylonjs/Probes/reflectionProbe";
  74775. }
  74776. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  74777. import { Scene } from "babylonjs/scene";
  74778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74779. import { SmartArray } from "babylonjs/Misc/smartArray";
  74780. import { ISceneComponent } from "babylonjs/sceneComponent";
  74781. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  74782. import "babylonjs/Meshes/Builders/boxBuilder";
  74783. import "babylonjs/Shaders/color.fragment";
  74784. import "babylonjs/Shaders/color.vertex";
  74785. import { Color3 } from "babylonjs/Maths/math.color";
  74786. import { Observable } from "babylonjs/Misc/observable";
  74787. module "babylonjs/scene" {
  74788. interface Scene {
  74789. /** @hidden (Backing field) */
  74790. _boundingBoxRenderer: BoundingBoxRenderer;
  74791. /** @hidden (Backing field) */
  74792. _forceShowBoundingBoxes: boolean;
  74793. /**
  74794. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  74795. */
  74796. forceShowBoundingBoxes: boolean;
  74797. /**
  74798. * Gets the bounding box renderer associated with the scene
  74799. * @returns a BoundingBoxRenderer
  74800. */
  74801. getBoundingBoxRenderer(): BoundingBoxRenderer;
  74802. }
  74803. }
  74804. module "babylonjs/Meshes/abstractMesh" {
  74805. interface AbstractMesh {
  74806. /** @hidden (Backing field) */
  74807. _showBoundingBox: boolean;
  74808. /**
  74809. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  74810. */
  74811. showBoundingBox: boolean;
  74812. }
  74813. }
  74814. /**
  74815. * Component responsible of rendering the bounding box of the meshes in a scene.
  74816. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  74817. */
  74818. export class BoundingBoxRenderer implements ISceneComponent {
  74819. /**
  74820. * The component name helpfull to identify the component in the list of scene components.
  74821. */
  74822. readonly name: string;
  74823. /**
  74824. * The scene the component belongs to.
  74825. */
  74826. scene: Scene;
  74827. /**
  74828. * Color of the bounding box lines placed in front of an object
  74829. */
  74830. frontColor: Color3;
  74831. /**
  74832. * Color of the bounding box lines placed behind an object
  74833. */
  74834. backColor: Color3;
  74835. /**
  74836. * Defines if the renderer should show the back lines or not
  74837. */
  74838. showBackLines: boolean;
  74839. /**
  74840. * Observable raised before rendering a bounding box
  74841. */
  74842. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  74843. /**
  74844. * Observable raised after rendering a bounding box
  74845. */
  74846. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  74847. /**
  74848. * @hidden
  74849. */
  74850. renderList: SmartArray<BoundingBox>;
  74851. private _colorShader;
  74852. private _vertexBuffers;
  74853. private _indexBuffer;
  74854. private _fillIndexBuffer;
  74855. private _fillIndexData;
  74856. /**
  74857. * Instantiates a new bounding box renderer in a scene.
  74858. * @param scene the scene the renderer renders in
  74859. */
  74860. constructor(scene: Scene);
  74861. /**
  74862. * Registers the component in a given scene
  74863. */
  74864. register(): void;
  74865. private _evaluateSubMesh;
  74866. private _activeMesh;
  74867. private _prepareRessources;
  74868. private _createIndexBuffer;
  74869. /**
  74870. * Rebuilds the elements related to this component in case of
  74871. * context lost for instance.
  74872. */
  74873. rebuild(): void;
  74874. /**
  74875. * @hidden
  74876. */
  74877. reset(): void;
  74878. /**
  74879. * Render the bounding boxes of a specific rendering group
  74880. * @param renderingGroupId defines the rendering group to render
  74881. */
  74882. render(renderingGroupId: number): void;
  74883. /**
  74884. * In case of occlusion queries, we can render the occlusion bounding box through this method
  74885. * @param mesh Define the mesh to render the occlusion bounding box for
  74886. */
  74887. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  74888. /**
  74889. * Dispose and release the resources attached to this renderer.
  74890. */
  74891. dispose(): void;
  74892. }
  74893. }
  74894. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  74895. import { Nullable } from "babylonjs/types";
  74896. import { Scene } from "babylonjs/scene";
  74897. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  74898. import { Camera } from "babylonjs/Cameras/camera";
  74899. import { ISceneComponent } from "babylonjs/sceneComponent";
  74900. module "babylonjs/scene" {
  74901. interface Scene {
  74902. /** @hidden (Backing field) */
  74903. _depthRenderer: {
  74904. [id: string]: DepthRenderer;
  74905. };
  74906. /**
  74907. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  74908. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  74909. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  74910. * @returns the created depth renderer
  74911. */
  74912. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  74913. /**
  74914. * Disables a depth renderer for a given camera
  74915. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  74916. */
  74917. disableDepthRenderer(camera?: Nullable<Camera>): void;
  74918. }
  74919. }
  74920. /**
  74921. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  74922. * in several rendering techniques.
  74923. */
  74924. export class DepthRendererSceneComponent implements ISceneComponent {
  74925. /**
  74926. * The component name helpfull to identify the component in the list of scene components.
  74927. */
  74928. readonly name: string;
  74929. /**
  74930. * The scene the component belongs to.
  74931. */
  74932. scene: Scene;
  74933. /**
  74934. * Creates a new instance of the component for the given scene
  74935. * @param scene Defines the scene to register the component in
  74936. */
  74937. constructor(scene: Scene);
  74938. /**
  74939. * Registers the component in a given scene
  74940. */
  74941. register(): void;
  74942. /**
  74943. * Rebuilds the elements related to this component in case of
  74944. * context lost for instance.
  74945. */
  74946. rebuild(): void;
  74947. /**
  74948. * Disposes the component and the associated ressources
  74949. */
  74950. dispose(): void;
  74951. private _gatherRenderTargets;
  74952. private _gatherActiveCameraRenderTargets;
  74953. }
  74954. }
  74955. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  74956. import { Nullable } from "babylonjs/types";
  74957. import { Scene } from "babylonjs/scene";
  74958. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  74959. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74960. import { AbstractScene } from "babylonjs/abstractScene";
  74961. module "babylonjs/abstractScene" {
  74962. interface AbstractScene {
  74963. /** @hidden (Backing field) */
  74964. _prePassRenderer: Nullable<PrePassRenderer>;
  74965. /**
  74966. * Gets or Sets the current prepass renderer associated to the scene.
  74967. */
  74968. prePassRenderer: Nullable<PrePassRenderer>;
  74969. /**
  74970. * Enables the prepass and associates it with the scene
  74971. * @returns the PrePassRenderer
  74972. */
  74973. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  74974. /**
  74975. * Disables the prepass associated with the scene
  74976. */
  74977. disablePrePassRenderer(): void;
  74978. }
  74979. }
  74980. /**
  74981. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74982. * in several rendering techniques.
  74983. */
  74984. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  74985. /**
  74986. * The component name helpful to identify the component in the list of scene components.
  74987. */
  74988. readonly name: string;
  74989. /**
  74990. * The scene the component belongs to.
  74991. */
  74992. scene: Scene;
  74993. /**
  74994. * Creates a new instance of the component for the given scene
  74995. * @param scene Defines the scene to register the component in
  74996. */
  74997. constructor(scene: Scene);
  74998. /**
  74999. * Registers the component in a given scene
  75000. */
  75001. register(): void;
  75002. private _beforeCameraDraw;
  75003. private _afterCameraDraw;
  75004. private _beforeClearStage;
  75005. /**
  75006. * Serializes the component data to the specified json object
  75007. * @param serializationObject The object to serialize to
  75008. */
  75009. serialize(serializationObject: any): void;
  75010. /**
  75011. * Adds all the elements from the container to the scene
  75012. * @param container the container holding the elements
  75013. */
  75014. addFromContainer(container: AbstractScene): void;
  75015. /**
  75016. * Removes all the elements in the container from the scene
  75017. * @param container contains the elements to remove
  75018. * @param dispose if the removed element should be disposed (default: false)
  75019. */
  75020. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  75021. /**
  75022. * Rebuilds the elements related to this component in case of
  75023. * context lost for instance.
  75024. */
  75025. rebuild(): void;
  75026. /**
  75027. * Disposes the component and the associated ressources
  75028. */
  75029. dispose(): void;
  75030. }
  75031. }
  75032. declare module "babylonjs/Shaders/outline.fragment" {
  75033. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75034. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  75035. /** @hidden */
  75036. export var outlinePixelShader: {
  75037. name: string;
  75038. shader: string;
  75039. };
  75040. }
  75041. declare module "babylonjs/Shaders/outline.vertex" {
  75042. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75043. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75044. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75045. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75046. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  75047. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75048. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75049. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75050. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  75051. /** @hidden */
  75052. export var outlineVertexShader: {
  75053. name: string;
  75054. shader: string;
  75055. };
  75056. }
  75057. declare module "babylonjs/Rendering/outlineRenderer" {
  75058. import { SubMesh } from "babylonjs/Meshes/subMesh";
  75059. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  75060. import { Scene } from "babylonjs/scene";
  75061. import { ISceneComponent } from "babylonjs/sceneComponent";
  75062. import "babylonjs/Shaders/outline.fragment";
  75063. import "babylonjs/Shaders/outline.vertex";
  75064. module "babylonjs/scene" {
  75065. interface Scene {
  75066. /** @hidden */
  75067. _outlineRenderer: OutlineRenderer;
  75068. /**
  75069. * Gets the outline renderer associated with the scene
  75070. * @returns a OutlineRenderer
  75071. */
  75072. getOutlineRenderer(): OutlineRenderer;
  75073. }
  75074. }
  75075. module "babylonjs/Meshes/abstractMesh" {
  75076. interface AbstractMesh {
  75077. /** @hidden (Backing field) */
  75078. _renderOutline: boolean;
  75079. /**
  75080. * Gets or sets a boolean indicating if the outline must be rendered as well
  75081. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  75082. */
  75083. renderOutline: boolean;
  75084. /** @hidden (Backing field) */
  75085. _renderOverlay: boolean;
  75086. /**
  75087. * Gets or sets a boolean indicating if the overlay must be rendered as well
  75088. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  75089. */
  75090. renderOverlay: boolean;
  75091. }
  75092. }
  75093. /**
  75094. * This class is responsible to draw bothe outline/overlay of meshes.
  75095. * It should not be used directly but through the available method on mesh.
  75096. */
  75097. export class OutlineRenderer implements ISceneComponent {
  75098. /**
  75099. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  75100. */
  75101. private static _StencilReference;
  75102. /**
  75103. * The name of the component. Each component must have a unique name.
  75104. */
  75105. name: string;
  75106. /**
  75107. * The scene the component belongs to.
  75108. */
  75109. scene: Scene;
  75110. /**
  75111. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  75112. */
  75113. zOffset: number;
  75114. private _engine;
  75115. private _effect;
  75116. private _cachedDefines;
  75117. private _savedDepthWrite;
  75118. /**
  75119. * Instantiates a new outline renderer. (There could be only one per scene).
  75120. * @param scene Defines the scene it belongs to
  75121. */
  75122. constructor(scene: Scene);
  75123. /**
  75124. * Register the component to one instance of a scene.
  75125. */
  75126. register(): void;
  75127. /**
  75128. * Rebuilds the elements related to this component in case of
  75129. * context lost for instance.
  75130. */
  75131. rebuild(): void;
  75132. /**
  75133. * Disposes the component and the associated ressources.
  75134. */
  75135. dispose(): void;
  75136. /**
  75137. * Renders the outline in the canvas.
  75138. * @param subMesh Defines the sumesh to render
  75139. * @param batch Defines the batch of meshes in case of instances
  75140. * @param useOverlay Defines if the rendering is for the overlay or the outline
  75141. */
  75142. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  75143. /**
  75144. * Returns whether or not the outline renderer is ready for a given submesh.
  75145. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  75146. * @param subMesh Defines the submesh to check readyness for
  75147. * @param useInstances Defines wheter wee are trying to render instances or not
  75148. * @returns true if ready otherwise false
  75149. */
  75150. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  75151. private _beforeRenderingMesh;
  75152. private _afterRenderingMesh;
  75153. }
  75154. }
  75155. declare module "babylonjs/Rendering/index" {
  75156. export * from "babylonjs/Rendering/boundingBoxRenderer";
  75157. export * from "babylonjs/Rendering/depthRenderer";
  75158. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  75159. export * from "babylonjs/Rendering/edgesRenderer";
  75160. export * from "babylonjs/Rendering/geometryBufferRenderer";
  75161. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75162. export * from "babylonjs/Rendering/prePassRenderer";
  75163. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  75164. export * from "babylonjs/Rendering/outlineRenderer";
  75165. export * from "babylonjs/Rendering/renderingGroup";
  75166. export * from "babylonjs/Rendering/renderingManager";
  75167. export * from "babylonjs/Rendering/utilityLayerRenderer";
  75168. }
  75169. declare module "babylonjs/Sprites/ISprites" {
  75170. /**
  75171. * Defines the basic options interface of a Sprite Frame Source Size.
  75172. */
  75173. export interface ISpriteJSONSpriteSourceSize {
  75174. /**
  75175. * number of the original width of the Frame
  75176. */
  75177. w: number;
  75178. /**
  75179. * number of the original height of the Frame
  75180. */
  75181. h: number;
  75182. }
  75183. /**
  75184. * Defines the basic options interface of a Sprite Frame Data.
  75185. */
  75186. export interface ISpriteJSONSpriteFrameData {
  75187. /**
  75188. * number of the x offset of the Frame
  75189. */
  75190. x: number;
  75191. /**
  75192. * number of the y offset of the Frame
  75193. */
  75194. y: number;
  75195. /**
  75196. * number of the width of the Frame
  75197. */
  75198. w: number;
  75199. /**
  75200. * number of the height of the Frame
  75201. */
  75202. h: number;
  75203. }
  75204. /**
  75205. * Defines the basic options interface of a JSON Sprite.
  75206. */
  75207. export interface ISpriteJSONSprite {
  75208. /**
  75209. * string name of the Frame
  75210. */
  75211. filename: string;
  75212. /**
  75213. * ISpriteJSONSpriteFrame basic object of the frame data
  75214. */
  75215. frame: ISpriteJSONSpriteFrameData;
  75216. /**
  75217. * boolean to flag is the frame was rotated.
  75218. */
  75219. rotated: boolean;
  75220. /**
  75221. * boolean to flag is the frame was trimmed.
  75222. */
  75223. trimmed: boolean;
  75224. /**
  75225. * ISpriteJSONSpriteFrame basic object of the source data
  75226. */
  75227. spriteSourceSize: ISpriteJSONSpriteFrameData;
  75228. /**
  75229. * ISpriteJSONSpriteFrame basic object of the source data
  75230. */
  75231. sourceSize: ISpriteJSONSpriteSourceSize;
  75232. }
  75233. /**
  75234. * Defines the basic options interface of a JSON atlas.
  75235. */
  75236. export interface ISpriteJSONAtlas {
  75237. /**
  75238. * Array of objects that contain the frame data.
  75239. */
  75240. frames: Array<ISpriteJSONSprite>;
  75241. /**
  75242. * object basic object containing the sprite meta data.
  75243. */
  75244. meta?: object;
  75245. }
  75246. }
  75247. declare module "babylonjs/Shaders/spriteMap.fragment" {
  75248. /** @hidden */
  75249. export var spriteMapPixelShader: {
  75250. name: string;
  75251. shader: string;
  75252. };
  75253. }
  75254. declare module "babylonjs/Shaders/spriteMap.vertex" {
  75255. /** @hidden */
  75256. export var spriteMapVertexShader: {
  75257. name: string;
  75258. shader: string;
  75259. };
  75260. }
  75261. declare module "babylonjs/Sprites/spriteMap" {
  75262. import { IDisposable, Scene } from "babylonjs/scene";
  75263. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  75264. import { Texture } from "babylonjs/Materials/Textures/texture";
  75265. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  75266. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  75267. import "babylonjs/Meshes/Builders/planeBuilder";
  75268. import "babylonjs/Shaders/spriteMap.fragment";
  75269. import "babylonjs/Shaders/spriteMap.vertex";
  75270. /**
  75271. * Defines the basic options interface of a SpriteMap
  75272. */
  75273. export interface ISpriteMapOptions {
  75274. /**
  75275. * Vector2 of the number of cells in the grid.
  75276. */
  75277. stageSize?: Vector2;
  75278. /**
  75279. * Vector2 of the size of the output plane in World Units.
  75280. */
  75281. outputSize?: Vector2;
  75282. /**
  75283. * Vector3 of the position of the output plane in World Units.
  75284. */
  75285. outputPosition?: Vector3;
  75286. /**
  75287. * Vector3 of the rotation of the output plane.
  75288. */
  75289. outputRotation?: Vector3;
  75290. /**
  75291. * number of layers that the system will reserve in resources.
  75292. */
  75293. layerCount?: number;
  75294. /**
  75295. * number of max animation frames a single cell will reserve in resources.
  75296. */
  75297. maxAnimationFrames?: number;
  75298. /**
  75299. * number cell index of the base tile when the system compiles.
  75300. */
  75301. baseTile?: number;
  75302. /**
  75303. * boolean flip the sprite after its been repositioned by the framing data.
  75304. */
  75305. flipU?: boolean;
  75306. /**
  75307. * Vector3 scalar of the global RGB values of the SpriteMap.
  75308. */
  75309. colorMultiply?: Vector3;
  75310. }
  75311. /**
  75312. * Defines the IDisposable interface in order to be cleanable from resources.
  75313. */
  75314. export interface ISpriteMap extends IDisposable {
  75315. /**
  75316. * String name of the SpriteMap.
  75317. */
  75318. name: string;
  75319. /**
  75320. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  75321. */
  75322. atlasJSON: ISpriteJSONAtlas;
  75323. /**
  75324. * Texture of the SpriteMap.
  75325. */
  75326. spriteSheet: Texture;
  75327. /**
  75328. * The parameters to initialize the SpriteMap with.
  75329. */
  75330. options: ISpriteMapOptions;
  75331. }
  75332. /**
  75333. * Class used to manage a grid restricted sprite deployment on an Output plane.
  75334. */
  75335. export class SpriteMap implements ISpriteMap {
  75336. /** The Name of the spriteMap */
  75337. name: string;
  75338. /** The JSON file with the frame and meta data */
  75339. atlasJSON: ISpriteJSONAtlas;
  75340. /** The systems Sprite Sheet Texture */
  75341. spriteSheet: Texture;
  75342. /** Arguments passed with the Constructor */
  75343. options: ISpriteMapOptions;
  75344. /** Public Sprite Storage array, parsed from atlasJSON */
  75345. sprites: Array<ISpriteJSONSprite>;
  75346. /** Returns the Number of Sprites in the System */
  75347. get spriteCount(): number;
  75348. /** Returns the Position of Output Plane*/
  75349. get position(): Vector3;
  75350. /** Returns the Position of Output Plane*/
  75351. set position(v: Vector3);
  75352. /** Returns the Rotation of Output Plane*/
  75353. get rotation(): Vector3;
  75354. /** Returns the Rotation of Output Plane*/
  75355. set rotation(v: Vector3);
  75356. /** Sets the AnimationMap*/
  75357. get animationMap(): RawTexture;
  75358. /** Sets the AnimationMap*/
  75359. set animationMap(v: RawTexture);
  75360. /** Scene that the SpriteMap was created in */
  75361. private _scene;
  75362. /** Texture Buffer of Float32 that holds tile frame data*/
  75363. private _frameMap;
  75364. /** Texture Buffers of Float32 that holds tileMap data*/
  75365. private _tileMaps;
  75366. /** Texture Buffer of Float32 that holds Animation Data*/
  75367. private _animationMap;
  75368. /** Custom ShaderMaterial Central to the System*/
  75369. private _material;
  75370. /** Custom ShaderMaterial Central to the System*/
  75371. private _output;
  75372. /** Systems Time Ticker*/
  75373. private _time;
  75374. /**
  75375. * Creates a new SpriteMap
  75376. * @param name defines the SpriteMaps Name
  75377. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  75378. * @param spriteSheet is the Texture that the Sprites are on.
  75379. * @param options a basic deployment configuration
  75380. * @param scene The Scene that the map is deployed on
  75381. */
  75382. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  75383. /**
  75384. * Returns tileID location
  75385. * @returns Vector2 the cell position ID
  75386. */
  75387. getTileID(): Vector2;
  75388. /**
  75389. * Gets the UV location of the mouse over the SpriteMap.
  75390. * @returns Vector2 the UV position of the mouse interaction
  75391. */
  75392. getMousePosition(): Vector2;
  75393. /**
  75394. * Creates the "frame" texture Buffer
  75395. * -------------------------------------
  75396. * Structure of frames
  75397. * "filename": "Falling-Water-2.png",
  75398. * "frame": {"x":69,"y":103,"w":24,"h":32},
  75399. * "rotated": true,
  75400. * "trimmed": true,
  75401. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  75402. * "sourceSize": {"w":32,"h":32}
  75403. * @returns RawTexture of the frameMap
  75404. */
  75405. private _createFrameBuffer;
  75406. /**
  75407. * Creates the tileMap texture Buffer
  75408. * @param buffer normally and array of numbers, or a false to generate from scratch
  75409. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  75410. * @returns RawTexture of the tileMap
  75411. */
  75412. private _createTileBuffer;
  75413. /**
  75414. * Modifies the data of the tileMaps
  75415. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  75416. * @param pos is the iVector2 Coordinates of the Tile
  75417. * @param tile The SpriteIndex of the new Tile
  75418. */
  75419. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  75420. /**
  75421. * Creates the animationMap texture Buffer
  75422. * @param buffer normally and array of numbers, or a false to generate from scratch
  75423. * @returns RawTexture of the animationMap
  75424. */
  75425. private _createTileAnimationBuffer;
  75426. /**
  75427. * Modifies the data of the animationMap
  75428. * @param cellID is the Index of the Sprite
  75429. * @param _frame is the target Animation frame
  75430. * @param toCell is the Target Index of the next frame of the animation
  75431. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  75432. * @param speed is a global scalar of the time variable on the map.
  75433. */
  75434. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  75435. /**
  75436. * Exports the .tilemaps file
  75437. */
  75438. saveTileMaps(): void;
  75439. /**
  75440. * Imports the .tilemaps file
  75441. * @param url of the .tilemaps file
  75442. */
  75443. loadTileMaps(url: string): void;
  75444. /**
  75445. * Release associated resources
  75446. */
  75447. dispose(): void;
  75448. }
  75449. }
  75450. declare module "babylonjs/Sprites/spritePackedManager" {
  75451. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  75452. import { Scene } from "babylonjs/scene";
  75453. /**
  75454. * Class used to manage multiple sprites of different sizes on the same spritesheet
  75455. * @see https://doc.babylonjs.com/babylon101/sprites
  75456. */
  75457. export class SpritePackedManager extends SpriteManager {
  75458. /** defines the packed manager's name */
  75459. name: string;
  75460. /**
  75461. * Creates a new sprite manager from a packed sprite sheet
  75462. * @param name defines the manager's name
  75463. * @param imgUrl defines the sprite sheet url
  75464. * @param capacity defines the maximum allowed number of sprites
  75465. * @param scene defines the hosting scene
  75466. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  75467. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  75468. * @param samplingMode defines the smapling mode to use with spritesheet
  75469. * @param fromPacked set to true; do not alter
  75470. */
  75471. constructor(
  75472. /** defines the packed manager's name */
  75473. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  75474. }
  75475. }
  75476. declare module "babylonjs/Sprites/index" {
  75477. export * from "babylonjs/Sprites/sprite";
  75478. export * from "babylonjs/Sprites/ISprites";
  75479. export * from "babylonjs/Sprites/spriteManager";
  75480. export * from "babylonjs/Sprites/spriteMap";
  75481. export * from "babylonjs/Sprites/spritePackedManager";
  75482. export * from "babylonjs/Sprites/spriteSceneComponent";
  75483. }
  75484. declare module "babylonjs/States/index" {
  75485. export * from "babylonjs/States/alphaCullingState";
  75486. export * from "babylonjs/States/depthCullingState";
  75487. export * from "babylonjs/States/stencilState";
  75488. }
  75489. declare module "babylonjs/Misc/assetsManager" {
  75490. import { Scene } from "babylonjs/scene";
  75491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75492. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  75493. import { Skeleton } from "babylonjs/Bones/skeleton";
  75494. import { Observable } from "babylonjs/Misc/observable";
  75495. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  75496. import { Texture } from "babylonjs/Materials/Textures/texture";
  75497. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  75498. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  75499. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  75500. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  75501. /**
  75502. * Defines the list of states available for a task inside a AssetsManager
  75503. */
  75504. export enum AssetTaskState {
  75505. /**
  75506. * Initialization
  75507. */
  75508. INIT = 0,
  75509. /**
  75510. * Running
  75511. */
  75512. RUNNING = 1,
  75513. /**
  75514. * Done
  75515. */
  75516. DONE = 2,
  75517. /**
  75518. * Error
  75519. */
  75520. ERROR = 3
  75521. }
  75522. /**
  75523. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  75524. */
  75525. export abstract class AbstractAssetTask {
  75526. /**
  75527. * Task name
  75528. */ name: string;
  75529. /**
  75530. * Callback called when the task is successful
  75531. */
  75532. onSuccess: (task: any) => void;
  75533. /**
  75534. * Callback called when the task is not successful
  75535. */
  75536. onError: (task: any, message?: string, exception?: any) => void;
  75537. /**
  75538. * Creates a new AssetsManager
  75539. * @param name defines the name of the task
  75540. */
  75541. constructor(
  75542. /**
  75543. * Task name
  75544. */ name: string);
  75545. private _isCompleted;
  75546. private _taskState;
  75547. private _errorObject;
  75548. /**
  75549. * Get if the task is completed
  75550. */
  75551. get isCompleted(): boolean;
  75552. /**
  75553. * Gets the current state of the task
  75554. */
  75555. get taskState(): AssetTaskState;
  75556. /**
  75557. * Gets the current error object (if task is in error)
  75558. */
  75559. get errorObject(): {
  75560. message?: string;
  75561. exception?: any;
  75562. };
  75563. /**
  75564. * Internal only
  75565. * @hidden
  75566. */
  75567. _setErrorObject(message?: string, exception?: any): void;
  75568. /**
  75569. * Execute the current task
  75570. * @param scene defines the scene where you want your assets to be loaded
  75571. * @param onSuccess is a callback called when the task is successfully executed
  75572. * @param onError is a callback called if an error occurs
  75573. */
  75574. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75575. /**
  75576. * Execute the current task
  75577. * @param scene defines the scene where you want your assets to be loaded
  75578. * @param onSuccess is a callback called when the task is successfully executed
  75579. * @param onError is a callback called if an error occurs
  75580. */
  75581. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75582. /**
  75583. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  75584. * This can be used with failed tasks that have the reason for failure fixed.
  75585. */
  75586. reset(): void;
  75587. private onErrorCallback;
  75588. private onDoneCallback;
  75589. }
  75590. /**
  75591. * Define the interface used by progress events raised during assets loading
  75592. */
  75593. export interface IAssetsProgressEvent {
  75594. /**
  75595. * Defines the number of remaining tasks to process
  75596. */
  75597. remainingCount: number;
  75598. /**
  75599. * Defines the total number of tasks
  75600. */
  75601. totalCount: number;
  75602. /**
  75603. * Defines the task that was just processed
  75604. */
  75605. task: AbstractAssetTask;
  75606. }
  75607. /**
  75608. * Class used to share progress information about assets loading
  75609. */
  75610. export class AssetsProgressEvent implements IAssetsProgressEvent {
  75611. /**
  75612. * Defines the number of remaining tasks to process
  75613. */
  75614. remainingCount: number;
  75615. /**
  75616. * Defines the total number of tasks
  75617. */
  75618. totalCount: number;
  75619. /**
  75620. * Defines the task that was just processed
  75621. */
  75622. task: AbstractAssetTask;
  75623. /**
  75624. * Creates a AssetsProgressEvent
  75625. * @param remainingCount defines the number of remaining tasks to process
  75626. * @param totalCount defines the total number of tasks
  75627. * @param task defines the task that was just processed
  75628. */
  75629. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  75630. }
  75631. /**
  75632. * Define a task used by AssetsManager to load meshes
  75633. */
  75634. export class MeshAssetTask extends AbstractAssetTask {
  75635. /**
  75636. * Defines the name of the task
  75637. */
  75638. name: string;
  75639. /**
  75640. * Defines the list of mesh's names you want to load
  75641. */
  75642. meshesNames: any;
  75643. /**
  75644. * Defines the root url to use as a base to load your meshes and associated resources
  75645. */
  75646. rootUrl: string;
  75647. /**
  75648. * Defines the filename or File of the scene to load from
  75649. */
  75650. sceneFilename: string | File;
  75651. /**
  75652. * Gets the list of loaded meshes
  75653. */
  75654. loadedMeshes: Array<AbstractMesh>;
  75655. /**
  75656. * Gets the list of loaded particle systems
  75657. */
  75658. loadedParticleSystems: Array<IParticleSystem>;
  75659. /**
  75660. * Gets the list of loaded skeletons
  75661. */
  75662. loadedSkeletons: Array<Skeleton>;
  75663. /**
  75664. * Gets the list of loaded animation groups
  75665. */
  75666. loadedAnimationGroups: Array<AnimationGroup>;
  75667. /**
  75668. * Callback called when the task is successful
  75669. */
  75670. onSuccess: (task: MeshAssetTask) => void;
  75671. /**
  75672. * Callback called when the task is successful
  75673. */
  75674. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  75675. /**
  75676. * Creates a new MeshAssetTask
  75677. * @param name defines the name of the task
  75678. * @param meshesNames defines the list of mesh's names you want to load
  75679. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  75680. * @param sceneFilename defines the filename or File of the scene to load from
  75681. */
  75682. constructor(
  75683. /**
  75684. * Defines the name of the task
  75685. */
  75686. name: string,
  75687. /**
  75688. * Defines the list of mesh's names you want to load
  75689. */
  75690. meshesNames: any,
  75691. /**
  75692. * Defines the root url to use as a base to load your meshes and associated resources
  75693. */
  75694. rootUrl: string,
  75695. /**
  75696. * Defines the filename or File of the scene to load from
  75697. */
  75698. sceneFilename: string | File);
  75699. /**
  75700. * Execute the current task
  75701. * @param scene defines the scene where you want your assets to be loaded
  75702. * @param onSuccess is a callback called when the task is successfully executed
  75703. * @param onError is a callback called if an error occurs
  75704. */
  75705. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75706. }
  75707. /**
  75708. * Define a task used by AssetsManager to load text content
  75709. */
  75710. export class TextFileAssetTask extends AbstractAssetTask {
  75711. /**
  75712. * Defines the name of the task
  75713. */
  75714. name: string;
  75715. /**
  75716. * Defines the location of the file to load
  75717. */
  75718. url: string;
  75719. /**
  75720. * Gets the loaded text string
  75721. */
  75722. text: string;
  75723. /**
  75724. * Callback called when the task is successful
  75725. */
  75726. onSuccess: (task: TextFileAssetTask) => void;
  75727. /**
  75728. * Callback called when the task is successful
  75729. */
  75730. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  75731. /**
  75732. * Creates a new TextFileAssetTask object
  75733. * @param name defines the name of the task
  75734. * @param url defines the location of the file to load
  75735. */
  75736. constructor(
  75737. /**
  75738. * Defines the name of the task
  75739. */
  75740. name: string,
  75741. /**
  75742. * Defines the location of the file to load
  75743. */
  75744. url: string);
  75745. /**
  75746. * Execute the current task
  75747. * @param scene defines the scene where you want your assets to be loaded
  75748. * @param onSuccess is a callback called when the task is successfully executed
  75749. * @param onError is a callback called if an error occurs
  75750. */
  75751. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75752. }
  75753. /**
  75754. * Define a task used by AssetsManager to load binary data
  75755. */
  75756. export class BinaryFileAssetTask extends AbstractAssetTask {
  75757. /**
  75758. * Defines the name of the task
  75759. */
  75760. name: string;
  75761. /**
  75762. * Defines the location of the file to load
  75763. */
  75764. url: string;
  75765. /**
  75766. * Gets the lodaded data (as an array buffer)
  75767. */
  75768. data: ArrayBuffer;
  75769. /**
  75770. * Callback called when the task is successful
  75771. */
  75772. onSuccess: (task: BinaryFileAssetTask) => void;
  75773. /**
  75774. * Callback called when the task is successful
  75775. */
  75776. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  75777. /**
  75778. * Creates a new BinaryFileAssetTask object
  75779. * @param name defines the name of the new task
  75780. * @param url defines the location of the file to load
  75781. */
  75782. constructor(
  75783. /**
  75784. * Defines the name of the task
  75785. */
  75786. name: string,
  75787. /**
  75788. * Defines the location of the file to load
  75789. */
  75790. url: string);
  75791. /**
  75792. * Execute the current task
  75793. * @param scene defines the scene where you want your assets to be loaded
  75794. * @param onSuccess is a callback called when the task is successfully executed
  75795. * @param onError is a callback called if an error occurs
  75796. */
  75797. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75798. }
  75799. /**
  75800. * Define a task used by AssetsManager to load images
  75801. */
  75802. export class ImageAssetTask extends AbstractAssetTask {
  75803. /**
  75804. * Defines the name of the task
  75805. */
  75806. name: string;
  75807. /**
  75808. * Defines the location of the image to load
  75809. */
  75810. url: string;
  75811. /**
  75812. * Gets the loaded images
  75813. */
  75814. image: HTMLImageElement;
  75815. /**
  75816. * Callback called when the task is successful
  75817. */
  75818. onSuccess: (task: ImageAssetTask) => void;
  75819. /**
  75820. * Callback called when the task is successful
  75821. */
  75822. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  75823. /**
  75824. * Creates a new ImageAssetTask
  75825. * @param name defines the name of the task
  75826. * @param url defines the location of the image to load
  75827. */
  75828. constructor(
  75829. /**
  75830. * Defines the name of the task
  75831. */
  75832. name: string,
  75833. /**
  75834. * Defines the location of the image to load
  75835. */
  75836. url: string);
  75837. /**
  75838. * Execute the current task
  75839. * @param scene defines the scene where you want your assets to be loaded
  75840. * @param onSuccess is a callback called when the task is successfully executed
  75841. * @param onError is a callback called if an error occurs
  75842. */
  75843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75844. }
  75845. /**
  75846. * Defines the interface used by texture loading tasks
  75847. */
  75848. export interface ITextureAssetTask<TEX extends BaseTexture> {
  75849. /**
  75850. * Gets the loaded texture
  75851. */
  75852. texture: TEX;
  75853. }
  75854. /**
  75855. * Define a task used by AssetsManager to load 2D textures
  75856. */
  75857. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  75858. /**
  75859. * Defines the name of the task
  75860. */
  75861. name: string;
  75862. /**
  75863. * Defines the location of the file to load
  75864. */
  75865. url: string;
  75866. /**
  75867. * Defines if mipmap should not be generated (default is false)
  75868. */
  75869. noMipmap?: boolean | undefined;
  75870. /**
  75871. * Defines if texture must be inverted on Y axis (default is true)
  75872. */
  75873. invertY: boolean;
  75874. /**
  75875. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75876. */
  75877. samplingMode: number;
  75878. /**
  75879. * Gets the loaded texture
  75880. */
  75881. texture: Texture;
  75882. /**
  75883. * Callback called when the task is successful
  75884. */
  75885. onSuccess: (task: TextureAssetTask) => void;
  75886. /**
  75887. * Callback called when the task is successful
  75888. */
  75889. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  75890. /**
  75891. * Creates a new TextureAssetTask object
  75892. * @param name defines the name of the task
  75893. * @param url defines the location of the file to load
  75894. * @param noMipmap defines if mipmap should not be generated (default is false)
  75895. * @param invertY defines if texture must be inverted on Y axis (default is true)
  75896. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75897. */
  75898. constructor(
  75899. /**
  75900. * Defines the name of the task
  75901. */
  75902. name: string,
  75903. /**
  75904. * Defines the location of the file to load
  75905. */
  75906. url: string,
  75907. /**
  75908. * Defines if mipmap should not be generated (default is false)
  75909. */
  75910. noMipmap?: boolean | undefined,
  75911. /**
  75912. * Defines if texture must be inverted on Y axis (default is true)
  75913. */
  75914. invertY?: boolean,
  75915. /**
  75916. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  75917. */
  75918. samplingMode?: number);
  75919. /**
  75920. * Execute the current task
  75921. * @param scene defines the scene where you want your assets to be loaded
  75922. * @param onSuccess is a callback called when the task is successfully executed
  75923. * @param onError is a callback called if an error occurs
  75924. */
  75925. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75926. }
  75927. /**
  75928. * Define a task used by AssetsManager to load cube textures
  75929. */
  75930. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  75931. /**
  75932. * Defines the name of the task
  75933. */
  75934. name: string;
  75935. /**
  75936. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75937. */
  75938. url: string;
  75939. /**
  75940. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75941. */
  75942. extensions?: string[] | undefined;
  75943. /**
  75944. * Defines if mipmaps should not be generated (default is false)
  75945. */
  75946. noMipmap?: boolean | undefined;
  75947. /**
  75948. * Defines the explicit list of files (undefined by default)
  75949. */
  75950. files?: string[] | undefined;
  75951. /**
  75952. * Gets the loaded texture
  75953. */
  75954. texture: CubeTexture;
  75955. /**
  75956. * Callback called when the task is successful
  75957. */
  75958. onSuccess: (task: CubeTextureAssetTask) => void;
  75959. /**
  75960. * Callback called when the task is successful
  75961. */
  75962. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  75963. /**
  75964. * Creates a new CubeTextureAssetTask
  75965. * @param name defines the name of the task
  75966. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75967. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75968. * @param noMipmap defines if mipmaps should not be generated (default is false)
  75969. * @param files defines the explicit list of files (undefined by default)
  75970. */
  75971. constructor(
  75972. /**
  75973. * Defines the name of the task
  75974. */
  75975. name: string,
  75976. /**
  75977. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  75978. */
  75979. url: string,
  75980. /**
  75981. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  75982. */
  75983. extensions?: string[] | undefined,
  75984. /**
  75985. * Defines if mipmaps should not be generated (default is false)
  75986. */
  75987. noMipmap?: boolean | undefined,
  75988. /**
  75989. * Defines the explicit list of files (undefined by default)
  75990. */
  75991. files?: string[] | undefined);
  75992. /**
  75993. * Execute the current task
  75994. * @param scene defines the scene where you want your assets to be loaded
  75995. * @param onSuccess is a callback called when the task is successfully executed
  75996. * @param onError is a callback called if an error occurs
  75997. */
  75998. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  75999. }
  76000. /**
  76001. * Define a task used by AssetsManager to load HDR cube textures
  76002. */
  76003. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  76004. /**
  76005. * Defines the name of the task
  76006. */
  76007. name: string;
  76008. /**
  76009. * Defines the location of the file to load
  76010. */
  76011. url: string;
  76012. /**
  76013. * Defines the desired size (the more it increases the longer the generation will be)
  76014. */
  76015. size: number;
  76016. /**
  76017. * Defines if mipmaps should not be generated (default is false)
  76018. */
  76019. noMipmap: boolean;
  76020. /**
  76021. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76022. */
  76023. generateHarmonics: boolean;
  76024. /**
  76025. * 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)
  76026. */
  76027. gammaSpace: boolean;
  76028. /**
  76029. * Internal Use Only
  76030. */
  76031. reserved: boolean;
  76032. /**
  76033. * Gets the loaded texture
  76034. */
  76035. texture: HDRCubeTexture;
  76036. /**
  76037. * Callback called when the task is successful
  76038. */
  76039. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  76040. /**
  76041. * Callback called when the task is successful
  76042. */
  76043. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  76044. /**
  76045. * Creates a new HDRCubeTextureAssetTask object
  76046. * @param name defines the name of the task
  76047. * @param url defines the location of the file to load
  76048. * @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.
  76049. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76050. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76051. * @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)
  76052. * @param reserved Internal use only
  76053. */
  76054. constructor(
  76055. /**
  76056. * Defines the name of the task
  76057. */
  76058. name: string,
  76059. /**
  76060. * Defines the location of the file to load
  76061. */
  76062. url: string,
  76063. /**
  76064. * Defines the desired size (the more it increases the longer the generation will be)
  76065. */
  76066. size: number,
  76067. /**
  76068. * Defines if mipmaps should not be generated (default is false)
  76069. */
  76070. noMipmap?: boolean,
  76071. /**
  76072. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  76073. */
  76074. generateHarmonics?: boolean,
  76075. /**
  76076. * 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)
  76077. */
  76078. gammaSpace?: boolean,
  76079. /**
  76080. * Internal Use Only
  76081. */
  76082. reserved?: boolean);
  76083. /**
  76084. * Execute the current task
  76085. * @param scene defines the scene where you want your assets to be loaded
  76086. * @param onSuccess is a callback called when the task is successfully executed
  76087. * @param onError is a callback called if an error occurs
  76088. */
  76089. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76090. }
  76091. /**
  76092. * Define a task used by AssetsManager to load Equirectangular cube textures
  76093. */
  76094. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  76095. /**
  76096. * Defines the name of the task
  76097. */
  76098. name: string;
  76099. /**
  76100. * Defines the location of the file to load
  76101. */
  76102. url: string;
  76103. /**
  76104. * Defines the desired size (the more it increases the longer the generation will be)
  76105. */
  76106. size: number;
  76107. /**
  76108. * Defines if mipmaps should not be generated (default is false)
  76109. */
  76110. noMipmap: boolean;
  76111. /**
  76112. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76113. * but the standard material would require them in Gamma space) (default is true)
  76114. */
  76115. gammaSpace: boolean;
  76116. /**
  76117. * Gets the loaded texture
  76118. */
  76119. texture: EquiRectangularCubeTexture;
  76120. /**
  76121. * Callback called when the task is successful
  76122. */
  76123. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  76124. /**
  76125. * Callback called when the task is successful
  76126. */
  76127. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  76128. /**
  76129. * Creates a new EquiRectangularCubeTextureAssetTask object
  76130. * @param name defines the name of the task
  76131. * @param url defines the location of the file to load
  76132. * @param size defines the desired size (the more it increases the longer the generation will be)
  76133. * If the size is omitted this implies you are using a preprocessed cubemap.
  76134. * @param noMipmap defines if mipmaps should not be generated (default is false)
  76135. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  76136. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  76137. * (default is true)
  76138. */
  76139. constructor(
  76140. /**
  76141. * Defines the name of the task
  76142. */
  76143. name: string,
  76144. /**
  76145. * Defines the location of the file to load
  76146. */
  76147. url: string,
  76148. /**
  76149. * Defines the desired size (the more it increases the longer the generation will be)
  76150. */
  76151. size: number,
  76152. /**
  76153. * Defines if mipmaps should not be generated (default is false)
  76154. */
  76155. noMipmap?: boolean,
  76156. /**
  76157. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  76158. * but the standard material would require them in Gamma space) (default is true)
  76159. */
  76160. gammaSpace?: boolean);
  76161. /**
  76162. * Execute the current task
  76163. * @param scene defines the scene where you want your assets to be loaded
  76164. * @param onSuccess is a callback called when the task is successfully executed
  76165. * @param onError is a callback called if an error occurs
  76166. */
  76167. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76168. }
  76169. /**
  76170. * This class can be used to easily import assets into a scene
  76171. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  76172. */
  76173. export class AssetsManager {
  76174. private _scene;
  76175. private _isLoading;
  76176. protected _tasks: AbstractAssetTask[];
  76177. protected _waitingTasksCount: number;
  76178. protected _totalTasksCount: number;
  76179. /**
  76180. * Callback called when all tasks are processed
  76181. */
  76182. onFinish: (tasks: AbstractAssetTask[]) => void;
  76183. /**
  76184. * Callback called when a task is successful
  76185. */
  76186. onTaskSuccess: (task: AbstractAssetTask) => void;
  76187. /**
  76188. * Callback called when a task had an error
  76189. */
  76190. onTaskError: (task: AbstractAssetTask) => void;
  76191. /**
  76192. * Callback called when a task is done (whatever the result is)
  76193. */
  76194. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  76195. /**
  76196. * Observable called when all tasks are processed
  76197. */
  76198. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  76199. /**
  76200. * Observable called when a task had an error
  76201. */
  76202. onTaskErrorObservable: Observable<AbstractAssetTask>;
  76203. /**
  76204. * Observable called when all tasks were executed
  76205. */
  76206. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  76207. /**
  76208. * Observable called when a task is done (whatever the result is)
  76209. */
  76210. onProgressObservable: Observable<IAssetsProgressEvent>;
  76211. /**
  76212. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  76213. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  76214. */
  76215. useDefaultLoadingScreen: boolean;
  76216. /**
  76217. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  76218. * when all assets have been downloaded.
  76219. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  76220. */
  76221. autoHideLoadingUI: boolean;
  76222. /**
  76223. * Creates a new AssetsManager
  76224. * @param scene defines the scene to work on
  76225. */
  76226. constructor(scene: Scene);
  76227. /**
  76228. * Add a MeshAssetTask to the list of active tasks
  76229. * @param taskName defines the name of the new task
  76230. * @param meshesNames defines the name of meshes to load
  76231. * @param rootUrl defines the root url to use to locate files
  76232. * @param sceneFilename defines the filename of the scene file
  76233. * @returns a new MeshAssetTask object
  76234. */
  76235. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  76236. /**
  76237. * Add a TextFileAssetTask to the list of active tasks
  76238. * @param taskName defines the name of the new task
  76239. * @param url defines the url of the file to load
  76240. * @returns a new TextFileAssetTask object
  76241. */
  76242. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  76243. /**
  76244. * Add a BinaryFileAssetTask to the list of active tasks
  76245. * @param taskName defines the name of the new task
  76246. * @param url defines the url of the file to load
  76247. * @returns a new BinaryFileAssetTask object
  76248. */
  76249. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  76250. /**
  76251. * Add a ImageAssetTask to the list of active tasks
  76252. * @param taskName defines the name of the new task
  76253. * @param url defines the url of the file to load
  76254. * @returns a new ImageAssetTask object
  76255. */
  76256. addImageTask(taskName: string, url: string): ImageAssetTask;
  76257. /**
  76258. * Add a TextureAssetTask to the list of active tasks
  76259. * @param taskName defines the name of the new task
  76260. * @param url defines the url of the file to load
  76261. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76262. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  76263. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  76264. * @returns a new TextureAssetTask object
  76265. */
  76266. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  76267. /**
  76268. * Add a CubeTextureAssetTask to the list of active tasks
  76269. * @param taskName defines the name of the new task
  76270. * @param url defines the url of the file to load
  76271. * @param extensions defines the extension to use to load the cube map (can be null)
  76272. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76273. * @param files defines the list of files to load (can be null)
  76274. * @returns a new CubeTextureAssetTask object
  76275. */
  76276. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  76277. /**
  76278. *
  76279. * Add a HDRCubeTextureAssetTask to the list of active tasks
  76280. * @param taskName defines the name of the new task
  76281. * @param url defines the url of the file to load
  76282. * @param size defines the size you want for the cubemap (can be null)
  76283. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76284. * @param generateHarmonics defines if you want to automatically generate (true by default)
  76285. * @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)
  76286. * @param reserved Internal use only
  76287. * @returns a new HDRCubeTextureAssetTask object
  76288. */
  76289. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  76290. /**
  76291. *
  76292. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  76293. * @param taskName defines the name of the new task
  76294. * @param url defines the url of the file to load
  76295. * @param size defines the size you want for the cubemap (can be null)
  76296. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  76297. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  76298. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  76299. * @returns a new EquiRectangularCubeTextureAssetTask object
  76300. */
  76301. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  76302. /**
  76303. * Remove a task from the assets manager.
  76304. * @param task the task to remove
  76305. */
  76306. removeTask(task: AbstractAssetTask): void;
  76307. private _decreaseWaitingTasksCount;
  76308. private _runTask;
  76309. /**
  76310. * Reset the AssetsManager and remove all tasks
  76311. * @return the current instance of the AssetsManager
  76312. */
  76313. reset(): AssetsManager;
  76314. /**
  76315. * Start the loading process
  76316. * @return the current instance of the AssetsManager
  76317. */
  76318. load(): AssetsManager;
  76319. /**
  76320. * Start the loading process as an async operation
  76321. * @return a promise returning the list of failed tasks
  76322. */
  76323. loadAsync(): Promise<void>;
  76324. }
  76325. }
  76326. declare module "babylonjs/Misc/deferred" {
  76327. /**
  76328. * Wrapper class for promise with external resolve and reject.
  76329. */
  76330. export class Deferred<T> {
  76331. /**
  76332. * The promise associated with this deferred object.
  76333. */
  76334. readonly promise: Promise<T>;
  76335. private _resolve;
  76336. private _reject;
  76337. /**
  76338. * The resolve method of the promise associated with this deferred object.
  76339. */
  76340. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  76341. /**
  76342. * The reject method of the promise associated with this deferred object.
  76343. */
  76344. get reject(): (reason?: any) => void;
  76345. /**
  76346. * Constructor for this deferred object.
  76347. */
  76348. constructor();
  76349. }
  76350. }
  76351. declare module "babylonjs/Misc/meshExploder" {
  76352. import { Mesh } from "babylonjs/Meshes/mesh";
  76353. /**
  76354. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  76355. */
  76356. export class MeshExploder {
  76357. private _centerMesh;
  76358. private _meshes;
  76359. private _meshesOrigins;
  76360. private _toCenterVectors;
  76361. private _scaledDirection;
  76362. private _newPosition;
  76363. private _centerPosition;
  76364. /**
  76365. * Explodes meshes from a center mesh.
  76366. * @param meshes The meshes to explode.
  76367. * @param centerMesh The mesh to be center of explosion.
  76368. */
  76369. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  76370. private _setCenterMesh;
  76371. /**
  76372. * Get class name
  76373. * @returns "MeshExploder"
  76374. */
  76375. getClassName(): string;
  76376. /**
  76377. * "Exploded meshes"
  76378. * @returns Array of meshes with the centerMesh at index 0.
  76379. */
  76380. getMeshes(): Array<Mesh>;
  76381. /**
  76382. * Explodes meshes giving a specific direction
  76383. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  76384. */
  76385. explode(direction?: number): void;
  76386. }
  76387. }
  76388. declare module "babylonjs/Misc/filesInput" {
  76389. import { Engine } from "babylonjs/Engines/engine";
  76390. import { Scene } from "babylonjs/scene";
  76391. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  76392. import { Nullable } from "babylonjs/types";
  76393. /**
  76394. * Class used to help managing file picking and drag'n'drop
  76395. */
  76396. export class FilesInput {
  76397. /**
  76398. * List of files ready to be loaded
  76399. */
  76400. static get FilesToLoad(): {
  76401. [key: string]: File;
  76402. };
  76403. /**
  76404. * Callback called when a file is processed
  76405. */
  76406. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  76407. private _engine;
  76408. private _currentScene;
  76409. private _sceneLoadedCallback;
  76410. private _progressCallback;
  76411. private _additionalRenderLoopLogicCallback;
  76412. private _textureLoadingCallback;
  76413. private _startingProcessingFilesCallback;
  76414. private _onReloadCallback;
  76415. private _errorCallback;
  76416. private _elementToMonitor;
  76417. private _sceneFileToLoad;
  76418. private _filesToLoad;
  76419. /**
  76420. * Creates a new FilesInput
  76421. * @param engine defines the rendering engine
  76422. * @param scene defines the hosting scene
  76423. * @param sceneLoadedCallback callback called when scene is loaded
  76424. * @param progressCallback callback called to track progress
  76425. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  76426. * @param textureLoadingCallback callback called when a texture is loading
  76427. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  76428. * @param onReloadCallback callback called when a reload is requested
  76429. * @param errorCallback callback call if an error occurs
  76430. */
  76431. 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>);
  76432. private _dragEnterHandler;
  76433. private _dragOverHandler;
  76434. private _dropHandler;
  76435. /**
  76436. * Calls this function to listen to drag'n'drop events on a specific DOM element
  76437. * @param elementToMonitor defines the DOM element to track
  76438. */
  76439. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  76440. /** Gets the current list of files to load */
  76441. get filesToLoad(): File[];
  76442. /**
  76443. * Release all associated resources
  76444. */
  76445. dispose(): void;
  76446. private renderFunction;
  76447. private drag;
  76448. private drop;
  76449. private _traverseFolder;
  76450. private _processFiles;
  76451. /**
  76452. * Load files from a drop event
  76453. * @param event defines the drop event to use as source
  76454. */
  76455. loadFiles(event: any): void;
  76456. private _processReload;
  76457. /**
  76458. * Reload the current scene from the loaded files
  76459. */
  76460. reload(): void;
  76461. }
  76462. }
  76463. declare module "babylonjs/Misc/HighDynamicRange/index" {
  76464. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  76465. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  76466. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  76467. }
  76468. declare module "babylonjs/Misc/sceneOptimizer" {
  76469. import { Scene, IDisposable } from "babylonjs/scene";
  76470. import { Observable } from "babylonjs/Misc/observable";
  76471. /**
  76472. * Defines the root class used to create scene optimization to use with SceneOptimizer
  76473. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76474. */
  76475. export class SceneOptimization {
  76476. /**
  76477. * Defines the priority of this optimization (0 by default which means first in the list)
  76478. */
  76479. priority: number;
  76480. /**
  76481. * Gets a string describing the action executed by the current optimization
  76482. * @returns description string
  76483. */
  76484. getDescription(): string;
  76485. /**
  76486. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76487. * @param scene defines the current scene where to apply this optimization
  76488. * @param optimizer defines the current optimizer
  76489. * @returns true if everything that can be done was applied
  76490. */
  76491. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76492. /**
  76493. * Creates the SceneOptimization object
  76494. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76495. * @param desc defines the description associated with the optimization
  76496. */
  76497. constructor(
  76498. /**
  76499. * Defines the priority of this optimization (0 by default which means first in the list)
  76500. */
  76501. priority?: number);
  76502. }
  76503. /**
  76504. * Defines an optimization used to reduce the size of render target textures
  76505. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76506. */
  76507. export class TextureOptimization extends SceneOptimization {
  76508. /**
  76509. * Defines the priority of this optimization (0 by default which means first in the list)
  76510. */
  76511. priority: number;
  76512. /**
  76513. * 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
  76514. */
  76515. maximumSize: number;
  76516. /**
  76517. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76518. */
  76519. step: number;
  76520. /**
  76521. * Gets a string describing the action executed by the current optimization
  76522. * @returns description string
  76523. */
  76524. getDescription(): string;
  76525. /**
  76526. * Creates the TextureOptimization object
  76527. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76528. * @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
  76529. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76530. */
  76531. constructor(
  76532. /**
  76533. * Defines the priority of this optimization (0 by default which means first in the list)
  76534. */
  76535. priority?: number,
  76536. /**
  76537. * 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
  76538. */
  76539. maximumSize?: number,
  76540. /**
  76541. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  76542. */
  76543. step?: number);
  76544. /**
  76545. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76546. * @param scene defines the current scene where to apply this optimization
  76547. * @param optimizer defines the current optimizer
  76548. * @returns true if everything that can be done was applied
  76549. */
  76550. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76551. }
  76552. /**
  76553. * Defines an optimization used to increase or decrease the rendering resolution
  76554. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76555. */
  76556. export class HardwareScalingOptimization extends SceneOptimization {
  76557. /**
  76558. * Defines the priority of this optimization (0 by default which means first in the list)
  76559. */
  76560. priority: number;
  76561. /**
  76562. * Defines the maximum scale to use (2 by default)
  76563. */
  76564. maximumScale: number;
  76565. /**
  76566. * Defines the step to use between two passes (0.5 by default)
  76567. */
  76568. step: number;
  76569. private _currentScale;
  76570. private _directionOffset;
  76571. /**
  76572. * Gets a string describing the action executed by the current optimization
  76573. * @return description string
  76574. */
  76575. getDescription(): string;
  76576. /**
  76577. * Creates the HardwareScalingOptimization object
  76578. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76579. * @param maximumScale defines the maximum scale to use (2 by default)
  76580. * @param step defines the step to use between two passes (0.5 by default)
  76581. */
  76582. constructor(
  76583. /**
  76584. * Defines the priority of this optimization (0 by default which means first in the list)
  76585. */
  76586. priority?: number,
  76587. /**
  76588. * Defines the maximum scale to use (2 by default)
  76589. */
  76590. maximumScale?: number,
  76591. /**
  76592. * Defines the step to use between two passes (0.5 by default)
  76593. */
  76594. step?: number);
  76595. /**
  76596. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76597. * @param scene defines the current scene where to apply this optimization
  76598. * @param optimizer defines the current optimizer
  76599. * @returns true if everything that can be done was applied
  76600. */
  76601. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76602. }
  76603. /**
  76604. * Defines an optimization used to remove shadows
  76605. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76606. */
  76607. export class ShadowsOptimization extends SceneOptimization {
  76608. /**
  76609. * Gets a string describing the action executed by the current optimization
  76610. * @return description string
  76611. */
  76612. getDescription(): string;
  76613. /**
  76614. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76615. * @param scene defines the current scene where to apply this optimization
  76616. * @param optimizer defines the current optimizer
  76617. * @returns true if everything that can be done was applied
  76618. */
  76619. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76620. }
  76621. /**
  76622. * Defines an optimization used to turn post-processes off
  76623. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76624. */
  76625. export class PostProcessesOptimization extends SceneOptimization {
  76626. /**
  76627. * Gets a string describing the action executed by the current optimization
  76628. * @return description string
  76629. */
  76630. getDescription(): string;
  76631. /**
  76632. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76633. * @param scene defines the current scene where to apply this optimization
  76634. * @param optimizer defines the current optimizer
  76635. * @returns true if everything that can be done was applied
  76636. */
  76637. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76638. }
  76639. /**
  76640. * Defines an optimization used to turn lens flares off
  76641. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76642. */
  76643. export class LensFlaresOptimization extends SceneOptimization {
  76644. /**
  76645. * Gets a string describing the action executed by the current optimization
  76646. * @return description string
  76647. */
  76648. getDescription(): string;
  76649. /**
  76650. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76651. * @param scene defines the current scene where to apply this optimization
  76652. * @param optimizer defines the current optimizer
  76653. * @returns true if everything that can be done was applied
  76654. */
  76655. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76656. }
  76657. /**
  76658. * Defines an optimization based on user defined callback.
  76659. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76660. */
  76661. export class CustomOptimization extends SceneOptimization {
  76662. /**
  76663. * Callback called to apply the custom optimization.
  76664. */
  76665. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  76666. /**
  76667. * Callback called to get custom description
  76668. */
  76669. onGetDescription: () => string;
  76670. /**
  76671. * Gets a string describing the action executed by the current optimization
  76672. * @returns description string
  76673. */
  76674. getDescription(): string;
  76675. /**
  76676. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76677. * @param scene defines the current scene where to apply this optimization
  76678. * @param optimizer defines the current optimizer
  76679. * @returns true if everything that can be done was applied
  76680. */
  76681. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76682. }
  76683. /**
  76684. * Defines an optimization used to turn particles off
  76685. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76686. */
  76687. export class ParticlesOptimization extends SceneOptimization {
  76688. /**
  76689. * Gets a string describing the action executed by the current optimization
  76690. * @return description string
  76691. */
  76692. getDescription(): string;
  76693. /**
  76694. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76695. * @param scene defines the current scene where to apply this optimization
  76696. * @param optimizer defines the current optimizer
  76697. * @returns true if everything that can be done was applied
  76698. */
  76699. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76700. }
  76701. /**
  76702. * Defines an optimization used to turn render targets off
  76703. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76704. */
  76705. export class RenderTargetsOptimization extends SceneOptimization {
  76706. /**
  76707. * Gets a string describing the action executed by the current optimization
  76708. * @return description string
  76709. */
  76710. getDescription(): string;
  76711. /**
  76712. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76713. * @param scene defines the current scene where to apply this optimization
  76714. * @param optimizer defines the current optimizer
  76715. * @returns true if everything that can be done was applied
  76716. */
  76717. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  76718. }
  76719. /**
  76720. * Defines an optimization used to merge meshes with compatible materials
  76721. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76722. */
  76723. export class MergeMeshesOptimization extends SceneOptimization {
  76724. private static _UpdateSelectionTree;
  76725. /**
  76726. * Gets or sets a boolean which defines if optimization octree has to be updated
  76727. */
  76728. static get UpdateSelectionTree(): boolean;
  76729. /**
  76730. * Gets or sets a boolean which defines if optimization octree has to be updated
  76731. */
  76732. static set UpdateSelectionTree(value: boolean);
  76733. /**
  76734. * Gets a string describing the action executed by the current optimization
  76735. * @return description string
  76736. */
  76737. getDescription(): string;
  76738. private _canBeMerged;
  76739. /**
  76740. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  76741. * @param scene defines the current scene where to apply this optimization
  76742. * @param optimizer defines the current optimizer
  76743. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  76744. * @returns true if everything that can be done was applied
  76745. */
  76746. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  76747. }
  76748. /**
  76749. * Defines a list of options used by SceneOptimizer
  76750. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76751. */
  76752. export class SceneOptimizerOptions {
  76753. /**
  76754. * Defines the target frame rate to reach (60 by default)
  76755. */
  76756. targetFrameRate: number;
  76757. /**
  76758. * Defines the interval between two checkes (2000ms by default)
  76759. */
  76760. trackerDuration: number;
  76761. /**
  76762. * Gets the list of optimizations to apply
  76763. */
  76764. optimizations: SceneOptimization[];
  76765. /**
  76766. * Creates a new list of options used by SceneOptimizer
  76767. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  76768. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  76769. */
  76770. constructor(
  76771. /**
  76772. * Defines the target frame rate to reach (60 by default)
  76773. */
  76774. targetFrameRate?: number,
  76775. /**
  76776. * Defines the interval between two checkes (2000ms by default)
  76777. */
  76778. trackerDuration?: number);
  76779. /**
  76780. * Add a new optimization
  76781. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  76782. * @returns the current SceneOptimizerOptions
  76783. */
  76784. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  76785. /**
  76786. * Add a new custom optimization
  76787. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  76788. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  76789. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  76790. * @returns the current SceneOptimizerOptions
  76791. */
  76792. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  76793. /**
  76794. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  76795. * @param targetFrameRate defines the target frame rate (60 by default)
  76796. * @returns a SceneOptimizerOptions object
  76797. */
  76798. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76799. /**
  76800. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  76801. * @param targetFrameRate defines the target frame rate (60 by default)
  76802. * @returns a SceneOptimizerOptions object
  76803. */
  76804. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76805. /**
  76806. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  76807. * @param targetFrameRate defines the target frame rate (60 by default)
  76808. * @returns a SceneOptimizerOptions object
  76809. */
  76810. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  76811. }
  76812. /**
  76813. * Class used to run optimizations in order to reach a target frame rate
  76814. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  76815. */
  76816. export class SceneOptimizer implements IDisposable {
  76817. private _isRunning;
  76818. private _options;
  76819. private _scene;
  76820. private _currentPriorityLevel;
  76821. private _targetFrameRate;
  76822. private _trackerDuration;
  76823. private _currentFrameRate;
  76824. private _sceneDisposeObserver;
  76825. private _improvementMode;
  76826. /**
  76827. * Defines an observable called when the optimizer reaches the target frame rate
  76828. */
  76829. onSuccessObservable: Observable<SceneOptimizer>;
  76830. /**
  76831. * Defines an observable called when the optimizer enables an optimization
  76832. */
  76833. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  76834. /**
  76835. * Defines an observable called when the optimizer is not able to reach the target frame rate
  76836. */
  76837. onFailureObservable: Observable<SceneOptimizer>;
  76838. /**
  76839. * Gets a boolean indicating if the optimizer is in improvement mode
  76840. */
  76841. get isInImprovementMode(): boolean;
  76842. /**
  76843. * Gets the current priority level (0 at start)
  76844. */
  76845. get currentPriorityLevel(): number;
  76846. /**
  76847. * Gets the current frame rate checked by the SceneOptimizer
  76848. */
  76849. get currentFrameRate(): number;
  76850. /**
  76851. * Gets or sets the current target frame rate (60 by default)
  76852. */
  76853. get targetFrameRate(): number;
  76854. /**
  76855. * Gets or sets the current target frame rate (60 by default)
  76856. */
  76857. set targetFrameRate(value: number);
  76858. /**
  76859. * Gets or sets the current interval between two checks (every 2000ms by default)
  76860. */
  76861. get trackerDuration(): number;
  76862. /**
  76863. * Gets or sets the current interval between two checks (every 2000ms by default)
  76864. */
  76865. set trackerDuration(value: number);
  76866. /**
  76867. * Gets the list of active optimizations
  76868. */
  76869. get optimizations(): SceneOptimization[];
  76870. /**
  76871. * Creates a new SceneOptimizer
  76872. * @param scene defines the scene to work on
  76873. * @param options defines the options to use with the SceneOptimizer
  76874. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  76875. * @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)
  76876. */
  76877. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  76878. /**
  76879. * Stops the current optimizer
  76880. */
  76881. stop(): void;
  76882. /**
  76883. * Reset the optimizer to initial step (current priority level = 0)
  76884. */
  76885. reset(): void;
  76886. /**
  76887. * Start the optimizer. By default it will try to reach a specific framerate
  76888. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  76889. */
  76890. start(): void;
  76891. private _checkCurrentState;
  76892. /**
  76893. * Release all resources
  76894. */
  76895. dispose(): void;
  76896. /**
  76897. * Helper function to create a SceneOptimizer with one single line of code
  76898. * @param scene defines the scene to work on
  76899. * @param options defines the options to use with the SceneOptimizer
  76900. * @param onSuccess defines a callback to call on success
  76901. * @param onFailure defines a callback to call on failure
  76902. * @returns the new SceneOptimizer object
  76903. */
  76904. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  76905. }
  76906. }
  76907. declare module "babylonjs/Misc/sceneSerializer" {
  76908. import { Scene } from "babylonjs/scene";
  76909. /**
  76910. * Class used to serialize a scene into a string
  76911. */
  76912. export class SceneSerializer {
  76913. /**
  76914. * Clear cache used by a previous serialization
  76915. */
  76916. static ClearCache(): void;
  76917. /**
  76918. * Serialize a scene into a JSON compatible object
  76919. * @param scene defines the scene to serialize
  76920. * @returns a JSON compatible object
  76921. */
  76922. static Serialize(scene: Scene): any;
  76923. /**
  76924. * Serialize a mesh into a JSON compatible object
  76925. * @param toSerialize defines the mesh to serialize
  76926. * @param withParents defines if parents must be serialized as well
  76927. * @param withChildren defines if children must be serialized as well
  76928. * @returns a JSON compatible object
  76929. */
  76930. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  76931. }
  76932. }
  76933. declare module "babylonjs/Misc/textureTools" {
  76934. import { Texture } from "babylonjs/Materials/Textures/texture";
  76935. /**
  76936. * Class used to host texture specific utilities
  76937. */
  76938. export class TextureTools {
  76939. /**
  76940. * Uses the GPU to create a copy texture rescaled at a given size
  76941. * @param texture Texture to copy from
  76942. * @param width defines the desired width
  76943. * @param height defines the desired height
  76944. * @param useBilinearMode defines if bilinear mode has to be used
  76945. * @return the generated texture
  76946. */
  76947. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  76948. }
  76949. }
  76950. declare module "babylonjs/Misc/videoRecorder" {
  76951. import { Nullable } from "babylonjs/types";
  76952. import { Engine } from "babylonjs/Engines/engine";
  76953. /**
  76954. * This represents the different options available for the video capture.
  76955. */
  76956. export interface VideoRecorderOptions {
  76957. /** Defines the mime type of the video. */
  76958. mimeType: string;
  76959. /** Defines the FPS the video should be recorded at. */
  76960. fps: number;
  76961. /** Defines the chunk size for the recording data. */
  76962. recordChunckSize: number;
  76963. /** The audio tracks to attach to the recording. */
  76964. audioTracks?: MediaStreamTrack[];
  76965. }
  76966. /**
  76967. * This can help with recording videos from BabylonJS.
  76968. * This is based on the available WebRTC functionalities of the browser.
  76969. *
  76970. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  76971. */
  76972. export class VideoRecorder {
  76973. private static readonly _defaultOptions;
  76974. /**
  76975. * Returns whether or not the VideoRecorder is available in your browser.
  76976. * @param engine Defines the Babylon Engine.
  76977. * @returns true if supported otherwise false.
  76978. */
  76979. static IsSupported(engine: Engine): boolean;
  76980. private readonly _options;
  76981. private _canvas;
  76982. private _mediaRecorder;
  76983. private _recordedChunks;
  76984. private _fileName;
  76985. private _resolve;
  76986. private _reject;
  76987. /**
  76988. * True when a recording is already in progress.
  76989. */
  76990. get isRecording(): boolean;
  76991. /**
  76992. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  76993. * @param engine Defines the BabylonJS Engine you wish to record.
  76994. * @param options Defines options that can be used to customize the capture.
  76995. */
  76996. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  76997. /**
  76998. * Stops the current recording before the default capture timeout passed in the startRecording function.
  76999. */
  77000. stopRecording(): void;
  77001. /**
  77002. * Starts recording the canvas for a max duration specified in parameters.
  77003. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  77004. * If null no automatic download will start and you can rely on the promise to get the data back.
  77005. * @param maxDuration Defines the maximum recording time in seconds.
  77006. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  77007. * @return A promise callback at the end of the recording with the video data in Blob.
  77008. */
  77009. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  77010. /**
  77011. * Releases internal resources used during the recording.
  77012. */
  77013. dispose(): void;
  77014. private _handleDataAvailable;
  77015. private _handleError;
  77016. private _handleStop;
  77017. }
  77018. }
  77019. declare module "babylonjs/Misc/screenshotTools" {
  77020. import { Camera } from "babylonjs/Cameras/camera";
  77021. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  77022. import { Engine } from "babylonjs/Engines/engine";
  77023. /**
  77024. * Class containing a set of static utilities functions for screenshots
  77025. */
  77026. export class ScreenshotTools {
  77027. /**
  77028. * Captures a screenshot of the current rendering
  77029. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77030. * @param engine defines the rendering engine
  77031. * @param camera defines the source camera
  77032. * @param size This parameter can be set to a single number or to an object with the
  77033. * following (optional) properties: precision, width, height. If a single number is passed,
  77034. * it will be used for both width and height. If an object is passed, the screenshot size
  77035. * will be derived from the parameters. The precision property is a multiplier allowing
  77036. * rendering at a higher or lower resolution
  77037. * @param successCallback defines the callback receives a single parameter which contains the
  77038. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77039. * src parameter of an <img> to display it
  77040. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77041. * Check your browser for supported MIME types
  77042. */
  77043. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  77044. /**
  77045. * Captures a screenshot of the current rendering
  77046. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77047. * @param engine defines the rendering engine
  77048. * @param camera defines the source camera
  77049. * @param size This parameter can be set to a single number or to an object with the
  77050. * following (optional) properties: precision, width, height. If a single number is passed,
  77051. * it will be used for both width and height. If an object is passed, the screenshot size
  77052. * will be derived from the parameters. The precision property is a multiplier allowing
  77053. * rendering at a higher or lower resolution
  77054. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  77055. * Check your browser for supported MIME types
  77056. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77057. * to the src parameter of an <img> to display it
  77058. */
  77059. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  77060. /**
  77061. * Generates an image screenshot from the specified camera.
  77062. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77063. * @param engine The engine to use for rendering
  77064. * @param camera The camera to use for rendering
  77065. * @param size This parameter can be set to a single number or to an object with the
  77066. * following (optional) properties: precision, width, height. If a single number is passed,
  77067. * it will be used for both width and height. If an object is passed, the screenshot size
  77068. * will be derived from the parameters. The precision property is a multiplier allowing
  77069. * rendering at a higher or lower resolution
  77070. * @param successCallback The callback receives a single parameter which contains the
  77071. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  77072. * src parameter of an <img> to display it
  77073. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77074. * Check your browser for supported MIME types
  77075. * @param samples Texture samples (default: 1)
  77076. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77077. * @param fileName A name for for the downloaded file.
  77078. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77079. */
  77080. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  77081. /**
  77082. * Generates an image screenshot from the specified camera.
  77083. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  77084. * @param engine The engine to use for rendering
  77085. * @param camera The camera to use for rendering
  77086. * @param size This parameter can be set to a single number or to an object with the
  77087. * following (optional) properties: precision, width, height. If a single number is passed,
  77088. * it will be used for both width and height. If an object is passed, the screenshot size
  77089. * will be derived from the parameters. The precision property is a multiplier allowing
  77090. * rendering at a higher or lower resolution
  77091. * @param mimeType The MIME type of the screenshot image (default: image/png).
  77092. * Check your browser for supported MIME types
  77093. * @param samples Texture samples (default: 1)
  77094. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  77095. * @param fileName A name for for the downloaded file.
  77096. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  77097. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  77098. * to the src parameter of an <img> to display it
  77099. */
  77100. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  77101. /**
  77102. * Gets height and width for screenshot size
  77103. * @private
  77104. */
  77105. private static _getScreenshotSize;
  77106. }
  77107. }
  77108. declare module "babylonjs/Misc/dataReader" {
  77109. /**
  77110. * Interface for a data buffer
  77111. */
  77112. export interface IDataBuffer {
  77113. /**
  77114. * Reads bytes from the data buffer.
  77115. * @param byteOffset The byte offset to read
  77116. * @param byteLength The byte length to read
  77117. * @returns A promise that resolves when the bytes are read
  77118. */
  77119. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  77120. /**
  77121. * The byte length of the buffer.
  77122. */
  77123. readonly byteLength: number;
  77124. }
  77125. /**
  77126. * Utility class for reading from a data buffer
  77127. */
  77128. export class DataReader {
  77129. /**
  77130. * The data buffer associated with this data reader.
  77131. */
  77132. readonly buffer: IDataBuffer;
  77133. /**
  77134. * The current byte offset from the beginning of the data buffer.
  77135. */
  77136. byteOffset: number;
  77137. private _dataView;
  77138. private _dataByteOffset;
  77139. /**
  77140. * Constructor
  77141. * @param buffer The buffer to read
  77142. */
  77143. constructor(buffer: IDataBuffer);
  77144. /**
  77145. * Loads the given byte length.
  77146. * @param byteLength The byte length to load
  77147. * @returns A promise that resolves when the load is complete
  77148. */
  77149. loadAsync(byteLength: number): Promise<void>;
  77150. /**
  77151. * Read a unsigned 32-bit integer from the currently loaded data range.
  77152. * @returns The 32-bit integer read
  77153. */
  77154. readUint32(): number;
  77155. /**
  77156. * Read a byte array from the currently loaded data range.
  77157. * @param byteLength The byte length to read
  77158. * @returns The byte array read
  77159. */
  77160. readUint8Array(byteLength: number): Uint8Array;
  77161. /**
  77162. * Read a string from the currently loaded data range.
  77163. * @param byteLength The byte length to read
  77164. * @returns The string read
  77165. */
  77166. readString(byteLength: number): string;
  77167. /**
  77168. * Skips the given byte length the currently loaded data range.
  77169. * @param byteLength The byte length to skip
  77170. */
  77171. skipBytes(byteLength: number): void;
  77172. }
  77173. }
  77174. declare module "babylonjs/Misc/dataStorage" {
  77175. /**
  77176. * Class for storing data to local storage if available or in-memory storage otherwise
  77177. */
  77178. export class DataStorage {
  77179. private static _Storage;
  77180. private static _GetStorage;
  77181. /**
  77182. * Reads a string from the data storage
  77183. * @param key The key to read
  77184. * @param defaultValue The value if the key doesn't exist
  77185. * @returns The string value
  77186. */
  77187. static ReadString(key: string, defaultValue: string): string;
  77188. /**
  77189. * Writes a string to the data storage
  77190. * @param key The key to write
  77191. * @param value The value to write
  77192. */
  77193. static WriteString(key: string, value: string): void;
  77194. /**
  77195. * Reads a boolean from the data storage
  77196. * @param key The key to read
  77197. * @param defaultValue The value if the key doesn't exist
  77198. * @returns The boolean value
  77199. */
  77200. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  77201. /**
  77202. * Writes a boolean to the data storage
  77203. * @param key The key to write
  77204. * @param value The value to write
  77205. */
  77206. static WriteBoolean(key: string, value: boolean): void;
  77207. /**
  77208. * Reads a number from the data storage
  77209. * @param key The key to read
  77210. * @param defaultValue The value if the key doesn't exist
  77211. * @returns The number value
  77212. */
  77213. static ReadNumber(key: string, defaultValue: number): number;
  77214. /**
  77215. * Writes a number to the data storage
  77216. * @param key The key to write
  77217. * @param value The value to write
  77218. */
  77219. static WriteNumber(key: string, value: number): void;
  77220. }
  77221. }
  77222. declare module "babylonjs/Misc/index" {
  77223. export * from "babylonjs/Misc/andOrNotEvaluator";
  77224. export * from "babylonjs/Misc/assetsManager";
  77225. export * from "babylonjs/Misc/basis";
  77226. export * from "babylonjs/Misc/dds";
  77227. export * from "babylonjs/Misc/decorators";
  77228. export * from "babylonjs/Misc/deferred";
  77229. export * from "babylonjs/Misc/environmentTextureTools";
  77230. export * from "babylonjs/Misc/meshExploder";
  77231. export * from "babylonjs/Misc/filesInput";
  77232. export * from "babylonjs/Misc/HighDynamicRange/index";
  77233. export * from "babylonjs/Misc/khronosTextureContainer";
  77234. export * from "babylonjs/Misc/observable";
  77235. export * from "babylonjs/Misc/performanceMonitor";
  77236. export * from "babylonjs/Misc/promise";
  77237. export * from "babylonjs/Misc/sceneOptimizer";
  77238. export * from "babylonjs/Misc/sceneSerializer";
  77239. export * from "babylonjs/Misc/smartArray";
  77240. export * from "babylonjs/Misc/stringDictionary";
  77241. export * from "babylonjs/Misc/tags";
  77242. export * from "babylonjs/Misc/textureTools";
  77243. export * from "babylonjs/Misc/tga";
  77244. export * from "babylonjs/Misc/tools";
  77245. export * from "babylonjs/Misc/videoRecorder";
  77246. export * from "babylonjs/Misc/virtualJoystick";
  77247. export * from "babylonjs/Misc/workerPool";
  77248. export * from "babylonjs/Misc/logger";
  77249. export * from "babylonjs/Misc/typeStore";
  77250. export * from "babylonjs/Misc/filesInputStore";
  77251. export * from "babylonjs/Misc/deepCopier";
  77252. export * from "babylonjs/Misc/pivotTools";
  77253. export * from "babylonjs/Misc/precisionDate";
  77254. export * from "babylonjs/Misc/screenshotTools";
  77255. export * from "babylonjs/Misc/typeStore";
  77256. export * from "babylonjs/Misc/webRequest";
  77257. export * from "babylonjs/Misc/iInspectable";
  77258. export * from "babylonjs/Misc/brdfTextureTools";
  77259. export * from "babylonjs/Misc/rgbdTextureTools";
  77260. export * from "babylonjs/Misc/gradients";
  77261. export * from "babylonjs/Misc/perfCounter";
  77262. export * from "babylonjs/Misc/fileRequest";
  77263. export * from "babylonjs/Misc/customAnimationFrameRequester";
  77264. export * from "babylonjs/Misc/retryStrategy";
  77265. export * from "babylonjs/Misc/interfaces/screenshotSize";
  77266. export * from "babylonjs/Misc/canvasGenerator";
  77267. export * from "babylonjs/Misc/fileTools";
  77268. export * from "babylonjs/Misc/stringTools";
  77269. export * from "babylonjs/Misc/dataReader";
  77270. export * from "babylonjs/Misc/minMaxReducer";
  77271. export * from "babylonjs/Misc/depthReducer";
  77272. export * from "babylonjs/Misc/dataStorage";
  77273. }
  77274. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  77275. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  77276. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77277. import { Observable } from "babylonjs/Misc/observable";
  77278. import { Matrix } from "babylonjs/Maths/math.vector";
  77279. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77280. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77281. /**
  77282. * An interface for all Hit test features
  77283. */
  77284. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  77285. /**
  77286. * Triggered when new babylon (transformed) hit test results are available
  77287. */
  77288. onHitTestResultObservable: Observable<T[]>;
  77289. }
  77290. /**
  77291. * Options used for hit testing
  77292. */
  77293. export interface IWebXRLegacyHitTestOptions {
  77294. /**
  77295. * Only test when user interacted with the scene. Default - hit test every frame
  77296. */
  77297. testOnPointerDownOnly?: boolean;
  77298. /**
  77299. * The node to use to transform the local results to world coordinates
  77300. */
  77301. worldParentNode?: TransformNode;
  77302. }
  77303. /**
  77304. * Interface defining the babylon result of raycasting/hit-test
  77305. */
  77306. export interface IWebXRLegacyHitResult {
  77307. /**
  77308. * Transformation matrix that can be applied to a node that will put it in the hit point location
  77309. */
  77310. transformationMatrix: Matrix;
  77311. /**
  77312. * The native hit test result
  77313. */
  77314. xrHitResult: XRHitResult | XRHitTestResult;
  77315. }
  77316. /**
  77317. * The currently-working hit-test module.
  77318. * Hit test (or Ray-casting) is used to interact with the real world.
  77319. * For further information read here - https://github.com/immersive-web/hit-test
  77320. */
  77321. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  77322. /**
  77323. * options to use when constructing this feature
  77324. */
  77325. readonly options: IWebXRLegacyHitTestOptions;
  77326. private _direction;
  77327. private _mat;
  77328. private _onSelectEnabled;
  77329. private _origin;
  77330. /**
  77331. * The module's name
  77332. */
  77333. static readonly Name: string;
  77334. /**
  77335. * The (Babylon) version of this module.
  77336. * This is an integer representing the implementation version.
  77337. * This number does not correspond to the WebXR specs version
  77338. */
  77339. static readonly Version: number;
  77340. /**
  77341. * Populated with the last native XR Hit Results
  77342. */
  77343. lastNativeXRHitResults: XRHitResult[];
  77344. /**
  77345. * Triggered when new babylon (transformed) hit test results are available
  77346. */
  77347. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  77348. /**
  77349. * Creates a new instance of the (legacy version) hit test feature
  77350. * @param _xrSessionManager an instance of WebXRSessionManager
  77351. * @param options options to use when constructing this feature
  77352. */
  77353. constructor(_xrSessionManager: WebXRSessionManager,
  77354. /**
  77355. * options to use when constructing this feature
  77356. */
  77357. options?: IWebXRLegacyHitTestOptions);
  77358. /**
  77359. * execute a hit test with an XR Ray
  77360. *
  77361. * @param xrSession a native xrSession that will execute this hit test
  77362. * @param xrRay the ray (position and direction) to use for ray-casting
  77363. * @param referenceSpace native XR reference space to use for the hit-test
  77364. * @param filter filter function that will filter the results
  77365. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77366. */
  77367. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  77368. /**
  77369. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  77370. * @param event the (select) event to use to select with
  77371. * @param referenceSpace the reference space to use for this hit test
  77372. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  77373. */
  77374. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  77375. /**
  77376. * attach this feature
  77377. * Will usually be called by the features manager
  77378. *
  77379. * @returns true if successful.
  77380. */
  77381. attach(): boolean;
  77382. /**
  77383. * detach this feature.
  77384. * Will usually be called by the features manager
  77385. *
  77386. * @returns true if successful.
  77387. */
  77388. detach(): boolean;
  77389. /**
  77390. * Dispose this feature and all of the resources attached
  77391. */
  77392. dispose(): void;
  77393. protected _onXRFrame(frame: XRFrame): void;
  77394. private _onHitTestResults;
  77395. private _onSelect;
  77396. }
  77397. }
  77398. declare module "babylonjs/XR/features/WebXRHitTest" {
  77399. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77400. import { Observable } from "babylonjs/Misc/observable";
  77401. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77402. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77403. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  77404. /**
  77405. * Options used for hit testing (version 2)
  77406. */
  77407. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  77408. /**
  77409. * Do not create a permanent hit test. Will usually be used when only
  77410. * transient inputs are needed.
  77411. */
  77412. disablePermanentHitTest?: boolean;
  77413. /**
  77414. * Enable transient (for example touch-based) hit test inspections
  77415. */
  77416. enableTransientHitTest?: boolean;
  77417. /**
  77418. * Offset ray for the permanent hit test
  77419. */
  77420. offsetRay?: Vector3;
  77421. /**
  77422. * Offset ray for the transient hit test
  77423. */
  77424. transientOffsetRay?: Vector3;
  77425. /**
  77426. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  77427. */
  77428. useReferenceSpace?: boolean;
  77429. }
  77430. /**
  77431. * Interface defining the babylon result of hit-test
  77432. */
  77433. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  77434. /**
  77435. * The input source that generated this hit test (if transient)
  77436. */
  77437. inputSource?: XRInputSource;
  77438. /**
  77439. * Is this a transient hit test
  77440. */
  77441. isTransient?: boolean;
  77442. /**
  77443. * Position of the hit test result
  77444. */
  77445. position: Vector3;
  77446. /**
  77447. * Rotation of the hit test result
  77448. */
  77449. rotationQuaternion: Quaternion;
  77450. /**
  77451. * The native hit test result
  77452. */
  77453. xrHitResult: XRHitTestResult;
  77454. }
  77455. /**
  77456. * The currently-working hit-test module.
  77457. * Hit test (or Ray-casting) is used to interact with the real world.
  77458. * For further information read here - https://github.com/immersive-web/hit-test
  77459. *
  77460. * Tested on chrome (mobile) 80.
  77461. */
  77462. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  77463. /**
  77464. * options to use when constructing this feature
  77465. */
  77466. readonly options: IWebXRHitTestOptions;
  77467. private _tmpMat;
  77468. private _tmpPos;
  77469. private _tmpQuat;
  77470. private _transientXrHitTestSource;
  77471. private _xrHitTestSource;
  77472. private initHitTestSource;
  77473. /**
  77474. * The module's name
  77475. */
  77476. static readonly Name: string;
  77477. /**
  77478. * The (Babylon) version of this module.
  77479. * This is an integer representing the implementation version.
  77480. * This number does not correspond to the WebXR specs version
  77481. */
  77482. static readonly Version: number;
  77483. /**
  77484. * When set to true, each hit test will have its own position/rotation objects
  77485. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  77486. * the developers will clone them or copy them as they see fit.
  77487. */
  77488. autoCloneTransformation: boolean;
  77489. /**
  77490. * Triggered when new babylon (transformed) hit test results are available
  77491. */
  77492. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  77493. /**
  77494. * Use this to temporarily pause hit test checks.
  77495. */
  77496. paused: boolean;
  77497. /**
  77498. * Creates a new instance of the hit test feature
  77499. * @param _xrSessionManager an instance of WebXRSessionManager
  77500. * @param options options to use when constructing this feature
  77501. */
  77502. constructor(_xrSessionManager: WebXRSessionManager,
  77503. /**
  77504. * options to use when constructing this feature
  77505. */
  77506. options?: IWebXRHitTestOptions);
  77507. /**
  77508. * attach this feature
  77509. * Will usually be called by the features manager
  77510. *
  77511. * @returns true if successful.
  77512. */
  77513. attach(): boolean;
  77514. /**
  77515. * detach this feature.
  77516. * Will usually be called by the features manager
  77517. *
  77518. * @returns true if successful.
  77519. */
  77520. detach(): boolean;
  77521. /**
  77522. * Dispose this feature and all of the resources attached
  77523. */
  77524. dispose(): void;
  77525. protected _onXRFrame(frame: XRFrame): void;
  77526. private _processWebXRHitTestResult;
  77527. }
  77528. }
  77529. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  77530. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77531. import { Observable } from "babylonjs/Misc/observable";
  77532. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  77533. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77534. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77535. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  77536. /**
  77537. * Configuration options of the anchor system
  77538. */
  77539. export interface IWebXRAnchorSystemOptions {
  77540. /**
  77541. * a node that will be used to convert local to world coordinates
  77542. */
  77543. worldParentNode?: TransformNode;
  77544. /**
  77545. * If set to true a reference of the created anchors will be kept until the next session starts
  77546. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  77547. */
  77548. doNotRemoveAnchorsOnSessionEnded?: boolean;
  77549. }
  77550. /**
  77551. * A babylon container for an XR Anchor
  77552. */
  77553. export interface IWebXRAnchor {
  77554. /**
  77555. * A babylon-assigned ID for this anchor
  77556. */
  77557. id: number;
  77558. /**
  77559. * Transformation matrix to apply to an object attached to this anchor
  77560. */
  77561. transformationMatrix: Matrix;
  77562. /**
  77563. * The native anchor object
  77564. */
  77565. xrAnchor: XRAnchor;
  77566. /**
  77567. * if defined, this object will be constantly updated by the anchor's position and rotation
  77568. */
  77569. attachedNode?: TransformNode;
  77570. }
  77571. /**
  77572. * An implementation of the anchor system for WebXR.
  77573. * For further information see https://github.com/immersive-web/anchors/
  77574. */
  77575. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  77576. private _options;
  77577. private _lastFrameDetected;
  77578. private _trackedAnchors;
  77579. private _referenceSpaceForFrameAnchors;
  77580. private _futureAnchors;
  77581. /**
  77582. * The module's name
  77583. */
  77584. static readonly Name: string;
  77585. /**
  77586. * The (Babylon) version of this module.
  77587. * This is an integer representing the implementation version.
  77588. * This number does not correspond to the WebXR specs version
  77589. */
  77590. static readonly Version: number;
  77591. /**
  77592. * Observers registered here will be executed when a new anchor was added to the session
  77593. */
  77594. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  77595. /**
  77596. * Observers registered here will be executed when an anchor was removed from the session
  77597. */
  77598. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  77599. /**
  77600. * Observers registered here will be executed when an existing anchor updates
  77601. * This can execute N times every frame
  77602. */
  77603. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  77604. /**
  77605. * Set the reference space to use for anchor creation, when not using a hit test.
  77606. * Will default to the session's reference space if not defined
  77607. */
  77608. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  77609. /**
  77610. * constructs a new anchor system
  77611. * @param _xrSessionManager an instance of WebXRSessionManager
  77612. * @param _options configuration object for this feature
  77613. */
  77614. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  77615. private _tmpVector;
  77616. private _tmpQuaternion;
  77617. private _populateTmpTransformation;
  77618. /**
  77619. * Create a new anchor point using a hit test result at a specific point in the scene
  77620. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77621. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77622. *
  77623. * @param hitTestResult The hit test result to use for this anchor creation
  77624. * @param position an optional position offset for this anchor
  77625. * @param rotationQuaternion an optional rotation offset for this anchor
  77626. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77627. */
  77628. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  77629. /**
  77630. * Add a new anchor at a specific position and rotation
  77631. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  77632. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  77633. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  77634. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  77635. *
  77636. * @param position the position in which to add an anchor
  77637. * @param rotationQuaternion an optional rotation for the anchor transformation
  77638. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  77639. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  77640. */
  77641. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  77642. /**
  77643. * detach this feature.
  77644. * Will usually be called by the features manager
  77645. *
  77646. * @returns true if successful.
  77647. */
  77648. detach(): boolean;
  77649. /**
  77650. * Dispose this feature and all of the resources attached
  77651. */
  77652. dispose(): void;
  77653. protected _onXRFrame(frame: XRFrame): void;
  77654. /**
  77655. * avoiding using Array.find for global support.
  77656. * @param xrAnchor the plane to find in the array
  77657. */
  77658. private _findIndexInAnchorArray;
  77659. private _updateAnchorWithXRFrame;
  77660. private _createAnchorAtTransformation;
  77661. }
  77662. }
  77663. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  77664. import { TransformNode } from "babylonjs/Meshes/transformNode";
  77665. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77666. import { Observable } from "babylonjs/Misc/observable";
  77667. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  77668. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77669. /**
  77670. * Options used in the plane detector module
  77671. */
  77672. export interface IWebXRPlaneDetectorOptions {
  77673. /**
  77674. * The node to use to transform the local results to world coordinates
  77675. */
  77676. worldParentNode?: TransformNode;
  77677. /**
  77678. * If set to true a reference of the created planes will be kept until the next session starts
  77679. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  77680. */
  77681. doNotRemovePlanesOnSessionEnded?: boolean;
  77682. }
  77683. /**
  77684. * A babylon interface for a WebXR plane.
  77685. * A Plane is actually a polygon, built from N points in space
  77686. *
  77687. * Supported in chrome 79, not supported in canary 81 ATM
  77688. */
  77689. export interface IWebXRPlane {
  77690. /**
  77691. * a babylon-assigned ID for this polygon
  77692. */
  77693. id: number;
  77694. /**
  77695. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  77696. */
  77697. polygonDefinition: Array<Vector3>;
  77698. /**
  77699. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  77700. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  77701. */
  77702. transformationMatrix: Matrix;
  77703. /**
  77704. * the native xr-plane object
  77705. */
  77706. xrPlane: XRPlane;
  77707. }
  77708. /**
  77709. * The plane detector is used to detect planes in the real world when in AR
  77710. * For more information see https://github.com/immersive-web/real-world-geometry/
  77711. */
  77712. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  77713. private _options;
  77714. private _detectedPlanes;
  77715. private _enabled;
  77716. private _lastFrameDetected;
  77717. /**
  77718. * The module's name
  77719. */
  77720. static readonly Name: string;
  77721. /**
  77722. * The (Babylon) version of this module.
  77723. * This is an integer representing the implementation version.
  77724. * This number does not correspond to the WebXR specs version
  77725. */
  77726. static readonly Version: number;
  77727. /**
  77728. * Observers registered here will be executed when a new plane was added to the session
  77729. */
  77730. onPlaneAddedObservable: Observable<IWebXRPlane>;
  77731. /**
  77732. * Observers registered here will be executed when a plane is no longer detected in the session
  77733. */
  77734. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  77735. /**
  77736. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  77737. * This can execute N times every frame
  77738. */
  77739. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  77740. /**
  77741. * construct a new Plane Detector
  77742. * @param _xrSessionManager an instance of xr Session manager
  77743. * @param _options configuration to use when constructing this feature
  77744. */
  77745. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  77746. /**
  77747. * detach this feature.
  77748. * Will usually be called by the features manager
  77749. *
  77750. * @returns true if successful.
  77751. */
  77752. detach(): boolean;
  77753. /**
  77754. * Dispose this feature and all of the resources attached
  77755. */
  77756. dispose(): void;
  77757. protected _onXRFrame(frame: XRFrame): void;
  77758. private _init;
  77759. private _updatePlaneWithXRPlane;
  77760. /**
  77761. * avoiding using Array.find for global support.
  77762. * @param xrPlane the plane to find in the array
  77763. */
  77764. private findIndexInPlaneArray;
  77765. }
  77766. }
  77767. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  77768. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77770. import { Observable } from "babylonjs/Misc/observable";
  77771. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77772. /**
  77773. * Options interface for the background remover plugin
  77774. */
  77775. export interface IWebXRBackgroundRemoverOptions {
  77776. /**
  77777. * Further background meshes to disable when entering AR
  77778. */
  77779. backgroundMeshes?: AbstractMesh[];
  77780. /**
  77781. * flags to configure the removal of the environment helper.
  77782. * If not set, the entire background will be removed. If set, flags should be set as well.
  77783. */
  77784. environmentHelperRemovalFlags?: {
  77785. /**
  77786. * Should the skybox be removed (default false)
  77787. */
  77788. skyBox?: boolean;
  77789. /**
  77790. * Should the ground be removed (default false)
  77791. */
  77792. ground?: boolean;
  77793. };
  77794. /**
  77795. * don't disable the environment helper
  77796. */
  77797. ignoreEnvironmentHelper?: boolean;
  77798. }
  77799. /**
  77800. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  77801. */
  77802. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  77803. /**
  77804. * read-only options to be used in this module
  77805. */
  77806. readonly options: IWebXRBackgroundRemoverOptions;
  77807. /**
  77808. * The module's name
  77809. */
  77810. static readonly Name: string;
  77811. /**
  77812. * The (Babylon) version of this module.
  77813. * This is an integer representing the implementation version.
  77814. * This number does not correspond to the WebXR specs version
  77815. */
  77816. static readonly Version: number;
  77817. /**
  77818. * registered observers will be triggered when the background state changes
  77819. */
  77820. onBackgroundStateChangedObservable: Observable<boolean>;
  77821. /**
  77822. * constructs a new background remover module
  77823. * @param _xrSessionManager the session manager for this module
  77824. * @param options read-only options to be used in this module
  77825. */
  77826. constructor(_xrSessionManager: WebXRSessionManager,
  77827. /**
  77828. * read-only options to be used in this module
  77829. */
  77830. options?: IWebXRBackgroundRemoverOptions);
  77831. /**
  77832. * attach this feature
  77833. * Will usually be called by the features manager
  77834. *
  77835. * @returns true if successful.
  77836. */
  77837. attach(): boolean;
  77838. /**
  77839. * detach this feature.
  77840. * Will usually be called by the features manager
  77841. *
  77842. * @returns true if successful.
  77843. */
  77844. detach(): boolean;
  77845. /**
  77846. * Dispose this feature and all of the resources attached
  77847. */
  77848. dispose(): void;
  77849. protected _onXRFrame(_xrFrame: XRFrame): void;
  77850. private _setBackgroundState;
  77851. }
  77852. }
  77853. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  77854. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  77855. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  77856. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  77857. import { WebXRInput } from "babylonjs/XR/webXRInput";
  77858. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  77859. import { Nullable } from "babylonjs/types";
  77860. /**
  77861. * Options for the controller physics feature
  77862. */
  77863. export class IWebXRControllerPhysicsOptions {
  77864. /**
  77865. * Should the headset get its own impostor
  77866. */
  77867. enableHeadsetImpostor?: boolean;
  77868. /**
  77869. * Optional parameters for the headset impostor
  77870. */
  77871. headsetImpostorParams?: {
  77872. /**
  77873. * The type of impostor to create. Default is sphere
  77874. */
  77875. impostorType: number;
  77876. /**
  77877. * the size of the impostor. Defaults to 10cm
  77878. */
  77879. impostorSize?: number | {
  77880. width: number;
  77881. height: number;
  77882. depth: number;
  77883. };
  77884. /**
  77885. * Friction definitions
  77886. */
  77887. friction?: number;
  77888. /**
  77889. * Restitution
  77890. */
  77891. restitution?: number;
  77892. };
  77893. /**
  77894. * The physics properties of the future impostors
  77895. */
  77896. physicsProperties?: {
  77897. /**
  77898. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  77899. * Note that this requires a physics engine that supports mesh impostors!
  77900. */
  77901. useControllerMesh?: boolean;
  77902. /**
  77903. * The type of impostor to create. Default is sphere
  77904. */
  77905. impostorType?: number;
  77906. /**
  77907. * the size of the impostor. Defaults to 10cm
  77908. */
  77909. impostorSize?: number | {
  77910. width: number;
  77911. height: number;
  77912. depth: number;
  77913. };
  77914. /**
  77915. * Friction definitions
  77916. */
  77917. friction?: number;
  77918. /**
  77919. * Restitution
  77920. */
  77921. restitution?: number;
  77922. };
  77923. /**
  77924. * the xr input to use with this pointer selection
  77925. */
  77926. xrInput: WebXRInput;
  77927. }
  77928. /**
  77929. * Add physics impostor to your webxr controllers,
  77930. * including naive calculation of their linear and angular velocity
  77931. */
  77932. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  77933. private readonly _options;
  77934. private _attachController;
  77935. private _controllers;
  77936. private _debugMode;
  77937. private _delta;
  77938. private _headsetImpostor?;
  77939. private _headsetMesh?;
  77940. private _lastTimestamp;
  77941. private _tmpQuaternion;
  77942. private _tmpVector;
  77943. /**
  77944. * The module's name
  77945. */
  77946. static readonly Name: string;
  77947. /**
  77948. * The (Babylon) version of this module.
  77949. * This is an integer representing the implementation version.
  77950. * This number does not correspond to the webxr specs version
  77951. */
  77952. static readonly Version: number;
  77953. /**
  77954. * Construct a new Controller Physics Feature
  77955. * @param _xrSessionManager the corresponding xr session manager
  77956. * @param _options options to create this feature with
  77957. */
  77958. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  77959. /**
  77960. * @hidden
  77961. * enable debugging - will show console outputs and the impostor mesh
  77962. */
  77963. _enablePhysicsDebug(): void;
  77964. /**
  77965. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  77966. * @param xrController the controller to add
  77967. */
  77968. addController(xrController: WebXRInputSource): void;
  77969. /**
  77970. * attach this feature
  77971. * Will usually be called by the features manager
  77972. *
  77973. * @returns true if successful.
  77974. */
  77975. attach(): boolean;
  77976. /**
  77977. * detach this feature.
  77978. * Will usually be called by the features manager
  77979. *
  77980. * @returns true if successful.
  77981. */
  77982. detach(): boolean;
  77983. /**
  77984. * Get the headset impostor, if enabled
  77985. * @returns the impostor
  77986. */
  77987. getHeadsetImpostor(): PhysicsImpostor | undefined;
  77988. /**
  77989. * Get the physics impostor of a specific controller.
  77990. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  77991. * @param controller the controller or the controller id of which to get the impostor
  77992. * @returns the impostor or null
  77993. */
  77994. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  77995. /**
  77996. * Update the physics properties provided in the constructor
  77997. * @param newProperties the new properties object
  77998. */
  77999. setPhysicsProperties(newProperties: {
  78000. impostorType?: number;
  78001. impostorSize?: number | {
  78002. width: number;
  78003. height: number;
  78004. depth: number;
  78005. };
  78006. friction?: number;
  78007. restitution?: number;
  78008. }): void;
  78009. protected _onXRFrame(_xrFrame: any): void;
  78010. private _detachController;
  78011. }
  78012. }
  78013. declare module "babylonjs/XR/features/index" {
  78014. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  78015. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  78016. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  78017. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  78018. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  78019. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  78020. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  78021. export * from "babylonjs/XR/features/WebXRHitTest";
  78022. }
  78023. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  78024. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78026. import { Scene } from "babylonjs/scene";
  78027. /**
  78028. * The motion controller class for all microsoft mixed reality controllers
  78029. */
  78030. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  78031. protected readonly _mapping: {
  78032. defaultButton: {
  78033. valueNodeName: string;
  78034. unpressedNodeName: string;
  78035. pressedNodeName: string;
  78036. };
  78037. defaultAxis: {
  78038. valueNodeName: string;
  78039. minNodeName: string;
  78040. maxNodeName: string;
  78041. };
  78042. buttons: {
  78043. "xr-standard-trigger": {
  78044. rootNodeName: string;
  78045. componentProperty: string;
  78046. states: string[];
  78047. };
  78048. "xr-standard-squeeze": {
  78049. rootNodeName: string;
  78050. componentProperty: string;
  78051. states: string[];
  78052. };
  78053. "xr-standard-touchpad": {
  78054. rootNodeName: string;
  78055. labelAnchorNodeName: string;
  78056. touchPointNodeName: string;
  78057. };
  78058. "xr-standard-thumbstick": {
  78059. rootNodeName: string;
  78060. componentProperty: string;
  78061. states: string[];
  78062. };
  78063. };
  78064. axes: {
  78065. "xr-standard-touchpad": {
  78066. "x-axis": {
  78067. rootNodeName: string;
  78068. };
  78069. "y-axis": {
  78070. rootNodeName: string;
  78071. };
  78072. };
  78073. "xr-standard-thumbstick": {
  78074. "x-axis": {
  78075. rootNodeName: string;
  78076. };
  78077. "y-axis": {
  78078. rootNodeName: string;
  78079. };
  78080. };
  78081. };
  78082. };
  78083. /**
  78084. * The base url used to load the left and right controller models
  78085. */
  78086. static MODEL_BASE_URL: string;
  78087. /**
  78088. * The name of the left controller model file
  78089. */
  78090. static MODEL_LEFT_FILENAME: string;
  78091. /**
  78092. * The name of the right controller model file
  78093. */
  78094. static MODEL_RIGHT_FILENAME: string;
  78095. profileId: string;
  78096. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78097. protected _getFilenameAndPath(): {
  78098. filename: string;
  78099. path: string;
  78100. };
  78101. protected _getModelLoadingConstraints(): boolean;
  78102. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78103. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78104. protected _updateModel(): void;
  78105. }
  78106. }
  78107. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  78108. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78110. import { Scene } from "babylonjs/scene";
  78111. /**
  78112. * The motion controller class for oculus touch (quest, rift).
  78113. * This class supports legacy mapping as well the standard xr mapping
  78114. */
  78115. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  78116. private _forceLegacyControllers;
  78117. private _modelRootNode;
  78118. /**
  78119. * The base url used to load the left and right controller models
  78120. */
  78121. static MODEL_BASE_URL: string;
  78122. /**
  78123. * The name of the left controller model file
  78124. */
  78125. static MODEL_LEFT_FILENAME: string;
  78126. /**
  78127. * The name of the right controller model file
  78128. */
  78129. static MODEL_RIGHT_FILENAME: string;
  78130. /**
  78131. * Base Url for the Quest controller model.
  78132. */
  78133. static QUEST_MODEL_BASE_URL: string;
  78134. profileId: string;
  78135. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  78136. protected _getFilenameAndPath(): {
  78137. filename: string;
  78138. path: string;
  78139. };
  78140. protected _getModelLoadingConstraints(): boolean;
  78141. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78142. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78143. protected _updateModel(): void;
  78144. /**
  78145. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  78146. * between the touch and touch 2.
  78147. */
  78148. private _isQuest;
  78149. }
  78150. }
  78151. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  78152. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78153. import { Scene } from "babylonjs/scene";
  78154. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  78155. /**
  78156. * The motion controller class for the standard HTC-Vive controllers
  78157. */
  78158. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  78159. private _modelRootNode;
  78160. /**
  78161. * The base url used to load the left and right controller models
  78162. */
  78163. static MODEL_BASE_URL: string;
  78164. /**
  78165. * File name for the controller model.
  78166. */
  78167. static MODEL_FILENAME: string;
  78168. profileId: string;
  78169. /**
  78170. * Create a new Vive motion controller object
  78171. * @param scene the scene to use to create this controller
  78172. * @param gamepadObject the corresponding gamepad object
  78173. * @param handedness the handedness of the controller
  78174. */
  78175. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  78176. protected _getFilenameAndPath(): {
  78177. filename: string;
  78178. path: string;
  78179. };
  78180. protected _getModelLoadingConstraints(): boolean;
  78181. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  78182. protected _setRootMesh(meshes: AbstractMesh[]): void;
  78183. protected _updateModel(): void;
  78184. }
  78185. }
  78186. declare module "babylonjs/XR/motionController/index" {
  78187. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  78188. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  78189. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  78190. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  78191. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  78192. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  78193. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  78194. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  78195. }
  78196. declare module "babylonjs/XR/index" {
  78197. export * from "babylonjs/XR/webXRCamera";
  78198. export * from "babylonjs/XR/webXREnterExitUI";
  78199. export * from "babylonjs/XR/webXRExperienceHelper";
  78200. export * from "babylonjs/XR/webXRInput";
  78201. export * from "babylonjs/XR/webXRInputSource";
  78202. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  78203. export * from "babylonjs/XR/webXRTypes";
  78204. export * from "babylonjs/XR/webXRSessionManager";
  78205. export * from "babylonjs/XR/webXRDefaultExperience";
  78206. export * from "babylonjs/XR/webXRFeaturesManager";
  78207. export * from "babylonjs/XR/features/index";
  78208. export * from "babylonjs/XR/motionController/index";
  78209. }
  78210. declare module "babylonjs/index" {
  78211. export * from "babylonjs/abstractScene";
  78212. export * from "babylonjs/Actions/index";
  78213. export * from "babylonjs/Animations/index";
  78214. export * from "babylonjs/assetContainer";
  78215. export * from "babylonjs/Audio/index";
  78216. export * from "babylonjs/Behaviors/index";
  78217. export * from "babylonjs/Bones/index";
  78218. export * from "babylonjs/Cameras/index";
  78219. export * from "babylonjs/Collisions/index";
  78220. export * from "babylonjs/Culling/index";
  78221. export * from "babylonjs/Debug/index";
  78222. export * from "babylonjs/DeviceInput/index";
  78223. export * from "babylonjs/Engines/index";
  78224. export * from "babylonjs/Events/index";
  78225. export * from "babylonjs/Gamepads/index";
  78226. export * from "babylonjs/Gizmos/index";
  78227. export * from "babylonjs/Helpers/index";
  78228. export * from "babylonjs/Instrumentation/index";
  78229. export * from "babylonjs/Layers/index";
  78230. export * from "babylonjs/LensFlares/index";
  78231. export * from "babylonjs/Lights/index";
  78232. export * from "babylonjs/Loading/index";
  78233. export * from "babylonjs/Materials/index";
  78234. export * from "babylonjs/Maths/index";
  78235. export * from "babylonjs/Meshes/index";
  78236. export * from "babylonjs/Morph/index";
  78237. export * from "babylonjs/Navigation/index";
  78238. export * from "babylonjs/node";
  78239. export * from "babylonjs/Offline/index";
  78240. export * from "babylonjs/Particles/index";
  78241. export * from "babylonjs/Physics/index";
  78242. export * from "babylonjs/PostProcesses/index";
  78243. export * from "babylonjs/Probes/index";
  78244. export * from "babylonjs/Rendering/index";
  78245. export * from "babylonjs/scene";
  78246. export * from "babylonjs/sceneComponent";
  78247. export * from "babylonjs/Sprites/index";
  78248. export * from "babylonjs/States/index";
  78249. export * from "babylonjs/Misc/index";
  78250. export * from "babylonjs/XR/index";
  78251. export * from "babylonjs/types";
  78252. }
  78253. declare module "babylonjs/Animations/pathCursor" {
  78254. import { Vector3 } from "babylonjs/Maths/math.vector";
  78255. import { Path2 } from "babylonjs/Maths/math.path";
  78256. /**
  78257. * A cursor which tracks a point on a path
  78258. */
  78259. export class PathCursor {
  78260. private path;
  78261. /**
  78262. * Stores path cursor callbacks for when an onchange event is triggered
  78263. */
  78264. private _onchange;
  78265. /**
  78266. * The value of the path cursor
  78267. */
  78268. value: number;
  78269. /**
  78270. * The animation array of the path cursor
  78271. */
  78272. animations: Animation[];
  78273. /**
  78274. * Initializes the path cursor
  78275. * @param path The path to track
  78276. */
  78277. constructor(path: Path2);
  78278. /**
  78279. * Gets the cursor point on the path
  78280. * @returns A point on the path cursor at the cursor location
  78281. */
  78282. getPoint(): Vector3;
  78283. /**
  78284. * Moves the cursor ahead by the step amount
  78285. * @param step The amount to move the cursor forward
  78286. * @returns This path cursor
  78287. */
  78288. moveAhead(step?: number): PathCursor;
  78289. /**
  78290. * Moves the cursor behind by the step amount
  78291. * @param step The amount to move the cursor back
  78292. * @returns This path cursor
  78293. */
  78294. moveBack(step?: number): PathCursor;
  78295. /**
  78296. * Moves the cursor by the step amount
  78297. * If the step amount is greater than one, an exception is thrown
  78298. * @param step The amount to move the cursor
  78299. * @returns This path cursor
  78300. */
  78301. move(step: number): PathCursor;
  78302. /**
  78303. * Ensures that the value is limited between zero and one
  78304. * @returns This path cursor
  78305. */
  78306. private ensureLimits;
  78307. /**
  78308. * Runs onchange callbacks on change (used by the animation engine)
  78309. * @returns This path cursor
  78310. */
  78311. private raiseOnChange;
  78312. /**
  78313. * Executes a function on change
  78314. * @param f A path cursor onchange callback
  78315. * @returns This path cursor
  78316. */
  78317. onchange(f: (cursor: PathCursor) => void): PathCursor;
  78318. }
  78319. }
  78320. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  78321. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  78322. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  78323. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  78324. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  78325. }
  78326. declare module "babylonjs/Engines/Processors/Expressions/index" {
  78327. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  78328. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  78329. }
  78330. declare module "babylonjs/Engines/Processors/index" {
  78331. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  78332. export * from "babylonjs/Engines/Processors/Expressions/index";
  78333. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  78334. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  78335. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  78336. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  78337. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  78338. export * from "babylonjs/Engines/Processors/shaderProcessor";
  78339. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  78340. }
  78341. declare module "babylonjs/Legacy/legacy" {
  78342. import * as Babylon from "babylonjs/index";
  78343. export * from "babylonjs/index";
  78344. }
  78345. declare module "babylonjs/Shaders/blur.fragment" {
  78346. /** @hidden */
  78347. export var blurPixelShader: {
  78348. name: string;
  78349. shader: string;
  78350. };
  78351. }
  78352. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  78353. /** @hidden */
  78354. export var pointCloudVertexDeclaration: {
  78355. name: string;
  78356. shader: string;
  78357. };
  78358. }
  78359. declare module "babylonjs" {
  78360. export * from "babylonjs/Legacy/legacy";
  78361. }
  78362. declare module BABYLON {
  78363. /** Alias type for value that can be null */
  78364. export type Nullable<T> = T | null;
  78365. /**
  78366. * Alias type for number that are floats
  78367. * @ignorenaming
  78368. */
  78369. export type float = number;
  78370. /**
  78371. * Alias type for number that are doubles.
  78372. * @ignorenaming
  78373. */
  78374. export type double = number;
  78375. /**
  78376. * Alias type for number that are integer
  78377. * @ignorenaming
  78378. */
  78379. export type int = number;
  78380. /** Alias type for number array or Float32Array */
  78381. export type FloatArray = number[] | Float32Array;
  78382. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  78383. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  78384. /**
  78385. * Alias for types that can be used by a Buffer or VertexBuffer.
  78386. */
  78387. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  78388. /**
  78389. * Alias type for primitive types
  78390. * @ignorenaming
  78391. */
  78392. type Primitive = undefined | null | boolean | string | number | Function;
  78393. /**
  78394. * Type modifier to make all the properties of an object Readonly
  78395. */
  78396. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  78397. /**
  78398. * Type modifier to make all the properties of an object Readonly recursively
  78399. */
  78400. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  78401. /**
  78402. * Type modifier to make object properties readonly.
  78403. */
  78404. export type DeepImmutableObject<T> = {
  78405. readonly [K in keyof T]: DeepImmutable<T[K]>;
  78406. };
  78407. /** @hidden */
  78408. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  78409. }
  78410. }
  78411. declare module BABYLON {
  78412. /**
  78413. * A class serves as a medium between the observable and its observers
  78414. */
  78415. export class EventState {
  78416. /**
  78417. * Create a new EventState
  78418. * @param mask defines the mask associated with this state
  78419. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78420. * @param target defines the original target of the state
  78421. * @param currentTarget defines the current target of the state
  78422. */
  78423. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  78424. /**
  78425. * Initialize the current event state
  78426. * @param mask defines the mask associated with this state
  78427. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  78428. * @param target defines the original target of the state
  78429. * @param currentTarget defines the current target of the state
  78430. * @returns the current event state
  78431. */
  78432. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  78433. /**
  78434. * An Observer can set this property to true to prevent subsequent observers of being notified
  78435. */
  78436. skipNextObservers: boolean;
  78437. /**
  78438. * Get the mask value that were used to trigger the event corresponding to this EventState object
  78439. */
  78440. mask: number;
  78441. /**
  78442. * The object that originally notified the event
  78443. */
  78444. target?: any;
  78445. /**
  78446. * The current object in the bubbling phase
  78447. */
  78448. currentTarget?: any;
  78449. /**
  78450. * This will be populated with the return value of the last function that was executed.
  78451. * If it is the first function in the callback chain it will be the event data.
  78452. */
  78453. lastReturnValue?: any;
  78454. }
  78455. /**
  78456. * Represent an Observer registered to a given Observable object.
  78457. */
  78458. export class Observer<T> {
  78459. /**
  78460. * Defines the callback to call when the observer is notified
  78461. */
  78462. callback: (eventData: T, eventState: EventState) => void;
  78463. /**
  78464. * Defines the mask of the observer (used to filter notifications)
  78465. */
  78466. mask: number;
  78467. /**
  78468. * Defines the current scope used to restore the JS context
  78469. */
  78470. scope: any;
  78471. /** @hidden */
  78472. _willBeUnregistered: boolean;
  78473. /**
  78474. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  78475. */
  78476. unregisterOnNextCall: boolean;
  78477. /**
  78478. * Creates a new observer
  78479. * @param callback defines the callback to call when the observer is notified
  78480. * @param mask defines the mask of the observer (used to filter notifications)
  78481. * @param scope defines the current scope used to restore the JS context
  78482. */
  78483. constructor(
  78484. /**
  78485. * Defines the callback to call when the observer is notified
  78486. */
  78487. callback: (eventData: T, eventState: EventState) => void,
  78488. /**
  78489. * Defines the mask of the observer (used to filter notifications)
  78490. */
  78491. mask: number,
  78492. /**
  78493. * Defines the current scope used to restore the JS context
  78494. */
  78495. scope?: any);
  78496. }
  78497. /**
  78498. * Represent a list of observers registered to multiple Observables object.
  78499. */
  78500. export class MultiObserver<T> {
  78501. private _observers;
  78502. private _observables;
  78503. /**
  78504. * Release associated resources
  78505. */
  78506. dispose(): void;
  78507. /**
  78508. * Raise a callback when one of the observable will notify
  78509. * @param observables defines a list of observables to watch
  78510. * @param callback defines the callback to call on notification
  78511. * @param mask defines the mask used to filter notifications
  78512. * @param scope defines the current scope used to restore the JS context
  78513. * @returns the new MultiObserver
  78514. */
  78515. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  78516. }
  78517. /**
  78518. * The Observable class is a simple implementation of the Observable pattern.
  78519. *
  78520. * 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.
  78521. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  78522. * 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).
  78523. * 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.
  78524. */
  78525. export class Observable<T> {
  78526. private _observers;
  78527. private _eventState;
  78528. private _onObserverAdded;
  78529. /**
  78530. * Gets the list of observers
  78531. */
  78532. get observers(): Array<Observer<T>>;
  78533. /**
  78534. * Creates a new observable
  78535. * @param onObserverAdded defines a callback to call when a new observer is added
  78536. */
  78537. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  78538. /**
  78539. * Create a new Observer with the specified callback
  78540. * @param callback the callback that will be executed for that Observer
  78541. * @param mask the mask used to filter observers
  78542. * @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.
  78543. * @param scope optional scope for the callback to be called from
  78544. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  78545. * @returns the new observer created for the callback
  78546. */
  78547. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  78548. /**
  78549. * Create a new Observer with the specified callback and unregisters after the next notification
  78550. * @param callback the callback that will be executed for that Observer
  78551. * @returns the new observer created for the callback
  78552. */
  78553. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  78554. /**
  78555. * Remove an Observer from the Observable object
  78556. * @param observer the instance of the Observer to remove
  78557. * @returns false if it doesn't belong to this Observable
  78558. */
  78559. remove(observer: Nullable<Observer<T>>): boolean;
  78560. /**
  78561. * Remove a callback from the Observable object
  78562. * @param callback the callback to remove
  78563. * @param scope optional scope. If used only the callbacks with this scope will be removed
  78564. * @returns false if it doesn't belong to this Observable
  78565. */
  78566. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  78567. private _deferUnregister;
  78568. private _remove;
  78569. /**
  78570. * Moves the observable to the top of the observer list making it get called first when notified
  78571. * @param observer the observer to move
  78572. */
  78573. makeObserverTopPriority(observer: Observer<T>): void;
  78574. /**
  78575. * Moves the observable to the bottom of the observer list making it get called last when notified
  78576. * @param observer the observer to move
  78577. */
  78578. makeObserverBottomPriority(observer: Observer<T>): void;
  78579. /**
  78580. * Notify all Observers by calling their respective callback with the given data
  78581. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  78582. * @param eventData defines the data to send to all observers
  78583. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  78584. * @param target defines the original target of the state
  78585. * @param currentTarget defines the current target of the state
  78586. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  78587. */
  78588. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  78589. /**
  78590. * Calling this will execute each callback, expecting it to be a promise or return a value.
  78591. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  78592. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  78593. * and it is crucial that all callbacks will be executed.
  78594. * The order of the callbacks is kept, callbacks are not executed parallel.
  78595. *
  78596. * @param eventData The data to be sent to each callback
  78597. * @param mask is used to filter observers defaults to -1
  78598. * @param target defines the callback target (see EventState)
  78599. * @param currentTarget defines he current object in the bubbling phase
  78600. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  78601. */
  78602. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  78603. /**
  78604. * Notify a specific observer
  78605. * @param observer defines the observer to notify
  78606. * @param eventData defines the data to be sent to each callback
  78607. * @param mask is used to filter observers defaults to -1
  78608. */
  78609. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  78610. /**
  78611. * Gets a boolean indicating if the observable has at least one observer
  78612. * @returns true is the Observable has at least one Observer registered
  78613. */
  78614. hasObservers(): boolean;
  78615. /**
  78616. * Clear the list of observers
  78617. */
  78618. clear(): void;
  78619. /**
  78620. * Clone the current observable
  78621. * @returns a new observable
  78622. */
  78623. clone(): Observable<T>;
  78624. /**
  78625. * Does this observable handles observer registered with a given mask
  78626. * @param mask defines the mask to be tested
  78627. * @return whether or not one observer registered with the given mask is handeled
  78628. **/
  78629. hasSpecificMask(mask?: number): boolean;
  78630. }
  78631. }
  78632. declare module BABYLON {
  78633. /**
  78634. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  78635. * Babylon.js
  78636. */
  78637. export class DomManagement {
  78638. /**
  78639. * Checks if the window object exists
  78640. * @returns true if the window object exists
  78641. */
  78642. static IsWindowObjectExist(): boolean;
  78643. /**
  78644. * Checks if the navigator object exists
  78645. * @returns true if the navigator object exists
  78646. */
  78647. static IsNavigatorAvailable(): boolean;
  78648. /**
  78649. * Check if the document object exists
  78650. * @returns true if the document object exists
  78651. */
  78652. static IsDocumentAvailable(): boolean;
  78653. /**
  78654. * Extracts text content from a DOM element hierarchy
  78655. * @param element defines the root element
  78656. * @returns a string
  78657. */
  78658. static GetDOMTextContent(element: HTMLElement): string;
  78659. }
  78660. }
  78661. declare module BABYLON {
  78662. /**
  78663. * Logger used througouht the application to allow configuration of
  78664. * the log level required for the messages.
  78665. */
  78666. export class Logger {
  78667. /**
  78668. * No log
  78669. */
  78670. static readonly NoneLogLevel: number;
  78671. /**
  78672. * Only message logs
  78673. */
  78674. static readonly MessageLogLevel: number;
  78675. /**
  78676. * Only warning logs
  78677. */
  78678. static readonly WarningLogLevel: number;
  78679. /**
  78680. * Only error logs
  78681. */
  78682. static readonly ErrorLogLevel: number;
  78683. /**
  78684. * All logs
  78685. */
  78686. static readonly AllLogLevel: number;
  78687. private static _LogCache;
  78688. /**
  78689. * Gets a value indicating the number of loading errors
  78690. * @ignorenaming
  78691. */
  78692. static errorsCount: number;
  78693. /**
  78694. * Callback called when a new log is added
  78695. */
  78696. static OnNewCacheEntry: (entry: string) => void;
  78697. private static _AddLogEntry;
  78698. private static _FormatMessage;
  78699. private static _LogDisabled;
  78700. private static _LogEnabled;
  78701. private static _WarnDisabled;
  78702. private static _WarnEnabled;
  78703. private static _ErrorDisabled;
  78704. private static _ErrorEnabled;
  78705. /**
  78706. * Log a message to the console
  78707. */
  78708. static Log: (message: string) => void;
  78709. /**
  78710. * Write a warning message to the console
  78711. */
  78712. static Warn: (message: string) => void;
  78713. /**
  78714. * Write an error message to the console
  78715. */
  78716. static Error: (message: string) => void;
  78717. /**
  78718. * Gets current log cache (list of logs)
  78719. */
  78720. static get LogCache(): string;
  78721. /**
  78722. * Clears the log cache
  78723. */
  78724. static ClearLogCache(): void;
  78725. /**
  78726. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  78727. */
  78728. static set LogLevels(level: number);
  78729. }
  78730. }
  78731. declare module BABYLON {
  78732. /** @hidden */
  78733. export class _TypeStore {
  78734. /** @hidden */
  78735. static RegisteredTypes: {
  78736. [key: string]: Object;
  78737. };
  78738. /** @hidden */
  78739. static GetClass(fqdn: string): any;
  78740. }
  78741. }
  78742. declare module BABYLON {
  78743. /**
  78744. * Helper to manipulate strings
  78745. */
  78746. export class StringTools {
  78747. /**
  78748. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  78749. * @param str Source string
  78750. * @param suffix Suffix to search for in the source string
  78751. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78752. */
  78753. static EndsWith(str: string, suffix: string): boolean;
  78754. /**
  78755. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  78756. * @param str Source string
  78757. * @param suffix Suffix to search for in the source string
  78758. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  78759. */
  78760. static StartsWith(str: string, suffix: string): boolean;
  78761. /**
  78762. * Decodes a buffer into a string
  78763. * @param buffer The buffer to decode
  78764. * @returns The decoded string
  78765. */
  78766. static Decode(buffer: Uint8Array | Uint16Array): string;
  78767. /**
  78768. * Encode a buffer to a base64 string
  78769. * @param buffer defines the buffer to encode
  78770. * @returns the encoded string
  78771. */
  78772. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  78773. /**
  78774. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  78775. * @param num the number to convert and pad
  78776. * @param length the expected length of the string
  78777. * @returns the padded string
  78778. */
  78779. static PadNumber(num: number, length: number): string;
  78780. }
  78781. }
  78782. declare module BABYLON {
  78783. /**
  78784. * Class containing a set of static utilities functions for deep copy.
  78785. */
  78786. export class DeepCopier {
  78787. /**
  78788. * Tries to copy an object by duplicating every property
  78789. * @param source defines the source object
  78790. * @param destination defines the target object
  78791. * @param doNotCopyList defines a list of properties to avoid
  78792. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  78793. */
  78794. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  78795. }
  78796. }
  78797. declare module BABYLON {
  78798. /**
  78799. * Class containing a set of static utilities functions for precision date
  78800. */
  78801. export class PrecisionDate {
  78802. /**
  78803. * Gets either window.performance.now() if supported or Date.now() else
  78804. */
  78805. static get Now(): number;
  78806. }
  78807. }
  78808. declare module BABYLON {
  78809. /** @hidden */
  78810. export class _DevTools {
  78811. static WarnImport(name: string): string;
  78812. }
  78813. }
  78814. declare module BABYLON {
  78815. /**
  78816. * Interface used to define the mechanism to get data from the network
  78817. */
  78818. export interface IWebRequest {
  78819. /**
  78820. * Returns client's response url
  78821. */
  78822. responseURL: string;
  78823. /**
  78824. * Returns client's status
  78825. */
  78826. status: number;
  78827. /**
  78828. * Returns client's status as a text
  78829. */
  78830. statusText: string;
  78831. }
  78832. }
  78833. declare module BABYLON {
  78834. /**
  78835. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  78836. */
  78837. export class WebRequest implements IWebRequest {
  78838. private _xhr;
  78839. /**
  78840. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  78841. * i.e. when loading files, where the server/service expects an Authorization header
  78842. */
  78843. static CustomRequestHeaders: {
  78844. [key: string]: string;
  78845. };
  78846. /**
  78847. * Add callback functions in this array to update all the requests before they get sent to the network
  78848. */
  78849. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  78850. private _injectCustomRequestHeaders;
  78851. /**
  78852. * Gets or sets a function to be called when loading progress changes
  78853. */
  78854. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  78855. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  78856. /**
  78857. * Returns client's state
  78858. */
  78859. get readyState(): number;
  78860. /**
  78861. * Returns client's status
  78862. */
  78863. get status(): number;
  78864. /**
  78865. * Returns client's status as a text
  78866. */
  78867. get statusText(): string;
  78868. /**
  78869. * Returns client's response
  78870. */
  78871. get response(): any;
  78872. /**
  78873. * Returns client's response url
  78874. */
  78875. get responseURL(): string;
  78876. /**
  78877. * Returns client's response as text
  78878. */
  78879. get responseText(): string;
  78880. /**
  78881. * Gets or sets the expected response type
  78882. */
  78883. get responseType(): XMLHttpRequestResponseType;
  78884. set responseType(value: XMLHttpRequestResponseType);
  78885. /** @hidden */
  78886. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  78887. /** @hidden */
  78888. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  78889. /**
  78890. * Cancels any network activity
  78891. */
  78892. abort(): void;
  78893. /**
  78894. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  78895. * @param body defines an optional request body
  78896. */
  78897. send(body?: Document | BodyInit | null): void;
  78898. /**
  78899. * Sets the request method, request URL
  78900. * @param method defines the method to use (GET, POST, etc..)
  78901. * @param url defines the url to connect with
  78902. */
  78903. open(method: string, url: string): void;
  78904. /**
  78905. * Sets the value of a request header.
  78906. * @param name The name of the header whose value is to be set
  78907. * @param value The value to set as the body of the header
  78908. */
  78909. setRequestHeader(name: string, value: string): void;
  78910. /**
  78911. * Get the string containing the text of a particular header's value.
  78912. * @param name The name of the header
  78913. * @returns The string containing the text of the given header name
  78914. */
  78915. getResponseHeader(name: string): Nullable<string>;
  78916. }
  78917. }
  78918. declare module BABYLON {
  78919. /**
  78920. * File request interface
  78921. */
  78922. export interface IFileRequest {
  78923. /**
  78924. * Raised when the request is complete (success or error).
  78925. */
  78926. onCompleteObservable: Observable<IFileRequest>;
  78927. /**
  78928. * Aborts the request for a file.
  78929. */
  78930. abort: () => void;
  78931. }
  78932. }
  78933. declare module BABYLON {
  78934. /**
  78935. * Define options used to create a render target texture
  78936. */
  78937. export class RenderTargetCreationOptions {
  78938. /**
  78939. * Specifies is mipmaps must be generated
  78940. */
  78941. generateMipMaps?: boolean;
  78942. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  78943. generateDepthBuffer?: boolean;
  78944. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  78945. generateStencilBuffer?: boolean;
  78946. /** Defines texture type (int by default) */
  78947. type?: number;
  78948. /** Defines sampling mode (trilinear by default) */
  78949. samplingMode?: number;
  78950. /** Defines format (RGBA by default) */
  78951. format?: number;
  78952. }
  78953. }
  78954. declare module BABYLON {
  78955. /** Defines the cross module used constants to avoid circular dependncies */
  78956. export class Constants {
  78957. /** Defines that alpha blending is disabled */
  78958. static readonly ALPHA_DISABLE: number;
  78959. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  78960. static readonly ALPHA_ADD: number;
  78961. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  78962. static readonly ALPHA_COMBINE: number;
  78963. /** Defines that alpha blending is DEST - SRC * DEST */
  78964. static readonly ALPHA_SUBTRACT: number;
  78965. /** Defines that alpha blending is SRC * DEST */
  78966. static readonly ALPHA_MULTIPLY: number;
  78967. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  78968. static readonly ALPHA_MAXIMIZED: number;
  78969. /** Defines that alpha blending is SRC + DEST */
  78970. static readonly ALPHA_ONEONE: number;
  78971. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  78972. static readonly ALPHA_PREMULTIPLIED: number;
  78973. /**
  78974. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  78975. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  78976. */
  78977. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  78978. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  78979. static readonly ALPHA_INTERPOLATE: number;
  78980. /**
  78981. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  78982. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  78983. */
  78984. static readonly ALPHA_SCREENMODE: number;
  78985. /**
  78986. * Defines that alpha blending is SRC + DST
  78987. * Alpha will be set to SRC ALPHA + DST ALPHA
  78988. */
  78989. static readonly ALPHA_ONEONE_ONEONE: number;
  78990. /**
  78991. * Defines that alpha blending is SRC * DST ALPHA + DST
  78992. * Alpha will be set to 0
  78993. */
  78994. static readonly ALPHA_ALPHATOCOLOR: number;
  78995. /**
  78996. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  78997. */
  78998. static readonly ALPHA_REVERSEONEMINUS: number;
  78999. /**
  79000. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  79001. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  79002. */
  79003. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  79004. /**
  79005. * Defines that alpha blending is SRC + DST
  79006. * Alpha will be set to SRC ALPHA
  79007. */
  79008. static readonly ALPHA_ONEONE_ONEZERO: number;
  79009. /**
  79010. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  79011. * Alpha will be set to DST ALPHA
  79012. */
  79013. static readonly ALPHA_EXCLUSION: number;
  79014. /** Defines that alpha blending equation a SUM */
  79015. static readonly ALPHA_EQUATION_ADD: number;
  79016. /** Defines that alpha blending equation a SUBSTRACTION */
  79017. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  79018. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  79019. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  79020. /** Defines that alpha blending equation a MAX operation */
  79021. static readonly ALPHA_EQUATION_MAX: number;
  79022. /** Defines that alpha blending equation a MIN operation */
  79023. static readonly ALPHA_EQUATION_MIN: number;
  79024. /**
  79025. * Defines that alpha blending equation a DARKEN operation:
  79026. * It takes the min of the src and sums the alpha channels.
  79027. */
  79028. static readonly ALPHA_EQUATION_DARKEN: number;
  79029. /** Defines that the ressource is not delayed*/
  79030. static readonly DELAYLOADSTATE_NONE: number;
  79031. /** Defines that the ressource was successfully delay loaded */
  79032. static readonly DELAYLOADSTATE_LOADED: number;
  79033. /** Defines that the ressource is currently delay loading */
  79034. static readonly DELAYLOADSTATE_LOADING: number;
  79035. /** Defines that the ressource is delayed and has not started loading */
  79036. static readonly DELAYLOADSTATE_NOTLOADED: number;
  79037. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  79038. static readonly NEVER: number;
  79039. /** 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 */
  79040. static readonly ALWAYS: number;
  79041. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  79042. static readonly LESS: number;
  79043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  79044. static readonly EQUAL: number;
  79045. /** 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 */
  79046. static readonly LEQUAL: number;
  79047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  79048. static readonly GREATER: number;
  79049. /** 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 */
  79050. static readonly GEQUAL: number;
  79051. /** 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 */
  79052. static readonly NOTEQUAL: number;
  79053. /** Passed to stencilOperation to specify that stencil value must be kept */
  79054. static readonly KEEP: number;
  79055. /** Passed to stencilOperation to specify that stencil value must be replaced */
  79056. static readonly REPLACE: number;
  79057. /** Passed to stencilOperation to specify that stencil value must be incremented */
  79058. static readonly INCR: number;
  79059. /** Passed to stencilOperation to specify that stencil value must be decremented */
  79060. static readonly DECR: number;
  79061. /** Passed to stencilOperation to specify that stencil value must be inverted */
  79062. static readonly INVERT: number;
  79063. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  79064. static readonly INCR_WRAP: number;
  79065. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  79066. static readonly DECR_WRAP: number;
  79067. /** Texture is not repeating outside of 0..1 UVs */
  79068. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  79069. /** Texture is repeating outside of 0..1 UVs */
  79070. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  79071. /** Texture is repeating and mirrored */
  79072. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  79073. /** ALPHA */
  79074. static readonly TEXTUREFORMAT_ALPHA: number;
  79075. /** LUMINANCE */
  79076. static readonly TEXTUREFORMAT_LUMINANCE: number;
  79077. /** LUMINANCE_ALPHA */
  79078. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  79079. /** RGB */
  79080. static readonly TEXTUREFORMAT_RGB: number;
  79081. /** RGBA */
  79082. static readonly TEXTUREFORMAT_RGBA: number;
  79083. /** RED */
  79084. static readonly TEXTUREFORMAT_RED: number;
  79085. /** RED (2nd reference) */
  79086. static readonly TEXTUREFORMAT_R: number;
  79087. /** RG */
  79088. static readonly TEXTUREFORMAT_RG: number;
  79089. /** RED_INTEGER */
  79090. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  79091. /** RED_INTEGER (2nd reference) */
  79092. static readonly TEXTUREFORMAT_R_INTEGER: number;
  79093. /** RG_INTEGER */
  79094. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  79095. /** RGB_INTEGER */
  79096. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  79097. /** RGBA_INTEGER */
  79098. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  79099. /** UNSIGNED_BYTE */
  79100. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  79101. /** UNSIGNED_BYTE (2nd reference) */
  79102. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  79103. /** FLOAT */
  79104. static readonly TEXTURETYPE_FLOAT: number;
  79105. /** HALF_FLOAT */
  79106. static readonly TEXTURETYPE_HALF_FLOAT: number;
  79107. /** BYTE */
  79108. static readonly TEXTURETYPE_BYTE: number;
  79109. /** SHORT */
  79110. static readonly TEXTURETYPE_SHORT: number;
  79111. /** UNSIGNED_SHORT */
  79112. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  79113. /** INT */
  79114. static readonly TEXTURETYPE_INT: number;
  79115. /** UNSIGNED_INT */
  79116. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  79117. /** UNSIGNED_SHORT_4_4_4_4 */
  79118. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  79119. /** UNSIGNED_SHORT_5_5_5_1 */
  79120. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  79121. /** UNSIGNED_SHORT_5_6_5 */
  79122. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  79123. /** UNSIGNED_INT_2_10_10_10_REV */
  79124. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  79125. /** UNSIGNED_INT_24_8 */
  79126. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  79127. /** UNSIGNED_INT_10F_11F_11F_REV */
  79128. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  79129. /** UNSIGNED_INT_5_9_9_9_REV */
  79130. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  79131. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  79132. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  79133. /** nearest is mag = nearest and min = nearest and no mip */
  79134. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  79135. /** mag = nearest and min = nearest and mip = none */
  79136. static readonly TEXTURE_NEAREST_NEAREST: number;
  79137. /** Bilinear is mag = linear and min = linear and no mip */
  79138. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  79139. /** mag = linear and min = linear and mip = none */
  79140. static readonly TEXTURE_LINEAR_LINEAR: number;
  79141. /** Trilinear is mag = linear and min = linear and mip = linear */
  79142. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  79143. /** Trilinear is mag = linear and min = linear and mip = linear */
  79144. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  79145. /** mag = nearest and min = nearest and mip = nearest */
  79146. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  79147. /** mag = nearest and min = linear and mip = nearest */
  79148. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  79149. /** mag = nearest and min = linear and mip = linear */
  79150. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  79151. /** mag = nearest and min = linear and mip = none */
  79152. static readonly TEXTURE_NEAREST_LINEAR: number;
  79153. /** nearest is mag = nearest and min = nearest and mip = linear */
  79154. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  79155. /** mag = linear and min = nearest and mip = nearest */
  79156. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  79157. /** mag = linear and min = nearest and mip = linear */
  79158. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  79159. /** Bilinear is mag = linear and min = linear and mip = nearest */
  79160. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  79161. /** mag = linear and min = nearest and mip = none */
  79162. static readonly TEXTURE_LINEAR_NEAREST: number;
  79163. /** Explicit coordinates mode */
  79164. static readonly TEXTURE_EXPLICIT_MODE: number;
  79165. /** Spherical coordinates mode */
  79166. static readonly TEXTURE_SPHERICAL_MODE: number;
  79167. /** Planar coordinates mode */
  79168. static readonly TEXTURE_PLANAR_MODE: number;
  79169. /** Cubic coordinates mode */
  79170. static readonly TEXTURE_CUBIC_MODE: number;
  79171. /** Projection coordinates mode */
  79172. static readonly TEXTURE_PROJECTION_MODE: number;
  79173. /** Skybox coordinates mode */
  79174. static readonly TEXTURE_SKYBOX_MODE: number;
  79175. /** Inverse Cubic coordinates mode */
  79176. static readonly TEXTURE_INVCUBIC_MODE: number;
  79177. /** Equirectangular coordinates mode */
  79178. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  79179. /** Equirectangular Fixed coordinates mode */
  79180. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  79181. /** Equirectangular Fixed Mirrored coordinates mode */
  79182. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  79183. /** Offline (baking) quality for texture filtering */
  79184. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  79185. /** High quality for texture filtering */
  79186. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  79187. /** Medium quality for texture filtering */
  79188. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  79189. /** Low quality for texture filtering */
  79190. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  79191. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  79192. static readonly SCALEMODE_FLOOR: number;
  79193. /** Defines that texture rescaling will look for the nearest power of 2 size */
  79194. static readonly SCALEMODE_NEAREST: number;
  79195. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  79196. static readonly SCALEMODE_CEILING: number;
  79197. /**
  79198. * The dirty texture flag value
  79199. */
  79200. static readonly MATERIAL_TextureDirtyFlag: number;
  79201. /**
  79202. * The dirty light flag value
  79203. */
  79204. static readonly MATERIAL_LightDirtyFlag: number;
  79205. /**
  79206. * The dirty fresnel flag value
  79207. */
  79208. static readonly MATERIAL_FresnelDirtyFlag: number;
  79209. /**
  79210. * The dirty attribute flag value
  79211. */
  79212. static readonly MATERIAL_AttributesDirtyFlag: number;
  79213. /**
  79214. * The dirty misc flag value
  79215. */
  79216. static readonly MATERIAL_MiscDirtyFlag: number;
  79217. /**
  79218. * The all dirty flag value
  79219. */
  79220. static readonly MATERIAL_AllDirtyFlag: number;
  79221. /**
  79222. * Returns the triangle fill mode
  79223. */
  79224. static readonly MATERIAL_TriangleFillMode: number;
  79225. /**
  79226. * Returns the wireframe mode
  79227. */
  79228. static readonly MATERIAL_WireFrameFillMode: number;
  79229. /**
  79230. * Returns the point fill mode
  79231. */
  79232. static readonly MATERIAL_PointFillMode: number;
  79233. /**
  79234. * Returns the point list draw mode
  79235. */
  79236. static readonly MATERIAL_PointListDrawMode: number;
  79237. /**
  79238. * Returns the line list draw mode
  79239. */
  79240. static readonly MATERIAL_LineListDrawMode: number;
  79241. /**
  79242. * Returns the line loop draw mode
  79243. */
  79244. static readonly MATERIAL_LineLoopDrawMode: number;
  79245. /**
  79246. * Returns the line strip draw mode
  79247. */
  79248. static readonly MATERIAL_LineStripDrawMode: number;
  79249. /**
  79250. * Returns the triangle strip draw mode
  79251. */
  79252. static readonly MATERIAL_TriangleStripDrawMode: number;
  79253. /**
  79254. * Returns the triangle fan draw mode
  79255. */
  79256. static readonly MATERIAL_TriangleFanDrawMode: number;
  79257. /**
  79258. * Stores the clock-wise side orientation
  79259. */
  79260. static readonly MATERIAL_ClockWiseSideOrientation: number;
  79261. /**
  79262. * Stores the counter clock-wise side orientation
  79263. */
  79264. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  79265. /**
  79266. * Nothing
  79267. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79268. */
  79269. static readonly ACTION_NothingTrigger: number;
  79270. /**
  79271. * On pick
  79272. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79273. */
  79274. static readonly ACTION_OnPickTrigger: number;
  79275. /**
  79276. * On left pick
  79277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79278. */
  79279. static readonly ACTION_OnLeftPickTrigger: number;
  79280. /**
  79281. * On right pick
  79282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79283. */
  79284. static readonly ACTION_OnRightPickTrigger: number;
  79285. /**
  79286. * On center pick
  79287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79288. */
  79289. static readonly ACTION_OnCenterPickTrigger: number;
  79290. /**
  79291. * On pick down
  79292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79293. */
  79294. static readonly ACTION_OnPickDownTrigger: number;
  79295. /**
  79296. * On double pick
  79297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79298. */
  79299. static readonly ACTION_OnDoublePickTrigger: number;
  79300. /**
  79301. * On pick up
  79302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79303. */
  79304. static readonly ACTION_OnPickUpTrigger: number;
  79305. /**
  79306. * On pick out.
  79307. * This trigger will only be raised if you also declared a OnPickDown
  79308. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79309. */
  79310. static readonly ACTION_OnPickOutTrigger: number;
  79311. /**
  79312. * On long press
  79313. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79314. */
  79315. static readonly ACTION_OnLongPressTrigger: number;
  79316. /**
  79317. * On pointer over
  79318. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79319. */
  79320. static readonly ACTION_OnPointerOverTrigger: number;
  79321. /**
  79322. * On pointer out
  79323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79324. */
  79325. static readonly ACTION_OnPointerOutTrigger: number;
  79326. /**
  79327. * On every frame
  79328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79329. */
  79330. static readonly ACTION_OnEveryFrameTrigger: number;
  79331. /**
  79332. * On intersection enter
  79333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79334. */
  79335. static readonly ACTION_OnIntersectionEnterTrigger: number;
  79336. /**
  79337. * On intersection exit
  79338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79339. */
  79340. static readonly ACTION_OnIntersectionExitTrigger: number;
  79341. /**
  79342. * On key down
  79343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79344. */
  79345. static readonly ACTION_OnKeyDownTrigger: number;
  79346. /**
  79347. * On key up
  79348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  79349. */
  79350. static readonly ACTION_OnKeyUpTrigger: number;
  79351. /**
  79352. * Billboard mode will only apply to Y axis
  79353. */
  79354. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  79355. /**
  79356. * Billboard mode will apply to all axes
  79357. */
  79358. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  79359. /**
  79360. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  79361. */
  79362. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  79363. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  79364. * Test order :
  79365. * Is the bounding sphere outside the frustum ?
  79366. * If not, are the bounding box vertices outside the frustum ?
  79367. * It not, then the cullable object is in the frustum.
  79368. */
  79369. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  79370. /** Culling strategy : Bounding Sphere Only.
  79371. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  79372. * It's also less accurate than the standard because some not visible objects can still be selected.
  79373. * Test : is the bounding sphere outside the frustum ?
  79374. * If not, then the cullable object is in the frustum.
  79375. */
  79376. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  79377. /** Culling strategy : Optimistic Inclusion.
  79378. * This in an inclusion test first, then the standard exclusion test.
  79379. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  79380. * 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.
  79381. * Anyway, it's as accurate as the standard strategy.
  79382. * Test :
  79383. * Is the cullable object bounding sphere center in the frustum ?
  79384. * If not, apply the default culling strategy.
  79385. */
  79386. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  79387. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  79388. * This in an inclusion test first, then the bounding sphere only exclusion test.
  79389. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  79390. * 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.
  79391. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  79392. * Test :
  79393. * Is the cullable object bounding sphere center in the frustum ?
  79394. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  79395. */
  79396. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  79397. /**
  79398. * No logging while loading
  79399. */
  79400. static readonly SCENELOADER_NO_LOGGING: number;
  79401. /**
  79402. * Minimal logging while loading
  79403. */
  79404. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  79405. /**
  79406. * Summary logging while loading
  79407. */
  79408. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  79409. /**
  79410. * Detailled logging while loading
  79411. */
  79412. static readonly SCENELOADER_DETAILED_LOGGING: number;
  79413. /**
  79414. * Prepass texture index for color
  79415. */
  79416. static readonly PREPASS_COLOR_INDEX: number;
  79417. /**
  79418. * Prepass texture index for irradiance
  79419. */
  79420. static readonly PREPASS_IRRADIANCE_INDEX: number;
  79421. /**
  79422. * Prepass texture index for depth + normal
  79423. */
  79424. static readonly PREPASS_DEPTHNORMAL_INDEX: number;
  79425. /**
  79426. * Prepass texture index for albedo
  79427. */
  79428. static readonly PREPASS_ALBEDO_INDEX: number;
  79429. }
  79430. }
  79431. declare module BABYLON {
  79432. /**
  79433. * This represents the required contract to create a new type of texture loader.
  79434. */
  79435. export interface IInternalTextureLoader {
  79436. /**
  79437. * Defines wether the loader supports cascade loading the different faces.
  79438. */
  79439. supportCascades: boolean;
  79440. /**
  79441. * This returns if the loader support the current file information.
  79442. * @param extension defines the file extension of the file being loaded
  79443. * @param mimeType defines the optional mime type of the file being loaded
  79444. * @returns true if the loader can load the specified file
  79445. */
  79446. canLoad(extension: string, mimeType?: string): boolean;
  79447. /**
  79448. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  79449. * @param data contains the texture data
  79450. * @param texture defines the BabylonJS internal texture
  79451. * @param createPolynomials will be true if polynomials have been requested
  79452. * @param onLoad defines the callback to trigger once the texture is ready
  79453. * @param onError defines the callback to trigger in case of error
  79454. */
  79455. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  79456. /**
  79457. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  79458. * @param data contains the texture data
  79459. * @param texture defines the BabylonJS internal texture
  79460. * @param callback defines the method to call once ready to upload
  79461. */
  79462. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  79463. }
  79464. }
  79465. declare module BABYLON {
  79466. /**
  79467. * Class used to store and describe the pipeline context associated with an effect
  79468. */
  79469. export interface IPipelineContext {
  79470. /**
  79471. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  79472. */
  79473. isAsync: boolean;
  79474. /**
  79475. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  79476. */
  79477. isReady: boolean;
  79478. /** @hidden */
  79479. _getVertexShaderCode(): string | null;
  79480. /** @hidden */
  79481. _getFragmentShaderCode(): string | null;
  79482. /** @hidden */
  79483. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  79484. }
  79485. }
  79486. declare module BABYLON {
  79487. /**
  79488. * Class used to store gfx data (like WebGLBuffer)
  79489. */
  79490. export class DataBuffer {
  79491. /**
  79492. * Gets or sets the number of objects referencing this buffer
  79493. */
  79494. references: number;
  79495. /** Gets or sets the size of the underlying buffer */
  79496. capacity: number;
  79497. /**
  79498. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  79499. */
  79500. is32Bits: boolean;
  79501. /**
  79502. * Gets the underlying buffer
  79503. */
  79504. get underlyingResource(): any;
  79505. }
  79506. }
  79507. declare module BABYLON {
  79508. /** @hidden */
  79509. export interface IShaderProcessor {
  79510. attributeProcessor?: (attribute: string) => string;
  79511. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  79512. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  79513. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  79514. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  79515. lineProcessor?: (line: string, isFragment: boolean) => string;
  79516. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79517. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  79518. }
  79519. }
  79520. declare module BABYLON {
  79521. /** @hidden */
  79522. export interface ProcessingOptions {
  79523. defines: string[];
  79524. indexParameters: any;
  79525. isFragment: boolean;
  79526. shouldUseHighPrecisionShader: boolean;
  79527. supportsUniformBuffers: boolean;
  79528. shadersRepository: string;
  79529. includesShadersStore: {
  79530. [key: string]: string;
  79531. };
  79532. processor?: IShaderProcessor;
  79533. version: string;
  79534. platformName: string;
  79535. lookForClosingBracketForUniformBuffer?: boolean;
  79536. }
  79537. }
  79538. declare module BABYLON {
  79539. /** @hidden */
  79540. export class ShaderCodeNode {
  79541. line: string;
  79542. children: ShaderCodeNode[];
  79543. additionalDefineKey?: string;
  79544. additionalDefineValue?: string;
  79545. isValid(preprocessors: {
  79546. [key: string]: string;
  79547. }): boolean;
  79548. process(preprocessors: {
  79549. [key: string]: string;
  79550. }, options: ProcessingOptions): string;
  79551. }
  79552. }
  79553. declare module BABYLON {
  79554. /** @hidden */
  79555. export class ShaderCodeCursor {
  79556. private _lines;
  79557. lineIndex: number;
  79558. get currentLine(): string;
  79559. get canRead(): boolean;
  79560. set lines(value: string[]);
  79561. }
  79562. }
  79563. declare module BABYLON {
  79564. /** @hidden */
  79565. export class ShaderCodeConditionNode extends ShaderCodeNode {
  79566. process(preprocessors: {
  79567. [key: string]: string;
  79568. }, options: ProcessingOptions): string;
  79569. }
  79570. }
  79571. declare module BABYLON {
  79572. /** @hidden */
  79573. export class ShaderDefineExpression {
  79574. isTrue(preprocessors: {
  79575. [key: string]: string;
  79576. }): boolean;
  79577. private static _OperatorPriority;
  79578. private static _Stack;
  79579. static postfixToInfix(postfix: string[]): string;
  79580. static infixToPostfix(infix: string): string[];
  79581. }
  79582. }
  79583. declare module BABYLON {
  79584. /** @hidden */
  79585. export class ShaderCodeTestNode extends ShaderCodeNode {
  79586. testExpression: ShaderDefineExpression;
  79587. isValid(preprocessors: {
  79588. [key: string]: string;
  79589. }): boolean;
  79590. }
  79591. }
  79592. declare module BABYLON {
  79593. /** @hidden */
  79594. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  79595. define: string;
  79596. not: boolean;
  79597. constructor(define: string, not?: boolean);
  79598. isTrue(preprocessors: {
  79599. [key: string]: string;
  79600. }): boolean;
  79601. }
  79602. }
  79603. declare module BABYLON {
  79604. /** @hidden */
  79605. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  79606. leftOperand: ShaderDefineExpression;
  79607. rightOperand: ShaderDefineExpression;
  79608. isTrue(preprocessors: {
  79609. [key: string]: string;
  79610. }): boolean;
  79611. }
  79612. }
  79613. declare module BABYLON {
  79614. /** @hidden */
  79615. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  79616. leftOperand: ShaderDefineExpression;
  79617. rightOperand: ShaderDefineExpression;
  79618. isTrue(preprocessors: {
  79619. [key: string]: string;
  79620. }): boolean;
  79621. }
  79622. }
  79623. declare module BABYLON {
  79624. /** @hidden */
  79625. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  79626. define: string;
  79627. operand: string;
  79628. testValue: string;
  79629. constructor(define: string, operand: string, testValue: string);
  79630. isTrue(preprocessors: {
  79631. [key: string]: string;
  79632. }): boolean;
  79633. }
  79634. }
  79635. declare module BABYLON {
  79636. /**
  79637. * Class used to enable access to offline support
  79638. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  79639. */
  79640. export interface IOfflineProvider {
  79641. /**
  79642. * Gets a boolean indicating if scene must be saved in the database
  79643. */
  79644. enableSceneOffline: boolean;
  79645. /**
  79646. * Gets a boolean indicating if textures must be saved in the database
  79647. */
  79648. enableTexturesOffline: boolean;
  79649. /**
  79650. * Open the offline support and make it available
  79651. * @param successCallback defines the callback to call on success
  79652. * @param errorCallback defines the callback to call on error
  79653. */
  79654. open(successCallback: () => void, errorCallback: () => void): void;
  79655. /**
  79656. * Loads an image from the offline support
  79657. * @param url defines the url to load from
  79658. * @param image defines the target DOM image
  79659. */
  79660. loadImage(url: string, image: HTMLImageElement): void;
  79661. /**
  79662. * Loads a file from offline support
  79663. * @param url defines the URL to load from
  79664. * @param sceneLoaded defines a callback to call on success
  79665. * @param progressCallBack defines a callback to call when progress changed
  79666. * @param errorCallback defines a callback to call on error
  79667. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  79668. */
  79669. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  79670. }
  79671. }
  79672. declare module BABYLON {
  79673. /**
  79674. * Class used to help managing file picking and drag'n'drop
  79675. * File Storage
  79676. */
  79677. export class FilesInputStore {
  79678. /**
  79679. * List of files ready to be loaded
  79680. */
  79681. static FilesToLoad: {
  79682. [key: string]: File;
  79683. };
  79684. }
  79685. }
  79686. declare module BABYLON {
  79687. /**
  79688. * Class used to define a retry strategy when error happens while loading assets
  79689. */
  79690. export class RetryStrategy {
  79691. /**
  79692. * Function used to defines an exponential back off strategy
  79693. * @param maxRetries defines the maximum number of retries (3 by default)
  79694. * @param baseInterval defines the interval between retries
  79695. * @returns the strategy function to use
  79696. */
  79697. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  79698. }
  79699. }
  79700. declare module BABYLON {
  79701. /**
  79702. * @ignore
  79703. * Application error to support additional information when loading a file
  79704. */
  79705. export abstract class BaseError extends Error {
  79706. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  79707. }
  79708. }
  79709. declare module BABYLON {
  79710. /** @ignore */
  79711. export class LoadFileError extends BaseError {
  79712. request?: WebRequest;
  79713. file?: File;
  79714. /**
  79715. * Creates a new LoadFileError
  79716. * @param message defines the message of the error
  79717. * @param request defines the optional web request
  79718. * @param file defines the optional file
  79719. */
  79720. constructor(message: string, object?: WebRequest | File);
  79721. }
  79722. /** @ignore */
  79723. export class RequestFileError extends BaseError {
  79724. request: WebRequest;
  79725. /**
  79726. * Creates a new LoadFileError
  79727. * @param message defines the message of the error
  79728. * @param request defines the optional web request
  79729. */
  79730. constructor(message: string, request: WebRequest);
  79731. }
  79732. /** @ignore */
  79733. export class ReadFileError extends BaseError {
  79734. file: File;
  79735. /**
  79736. * Creates a new ReadFileError
  79737. * @param message defines the message of the error
  79738. * @param file defines the optional file
  79739. */
  79740. constructor(message: string, file: File);
  79741. }
  79742. /**
  79743. * @hidden
  79744. */
  79745. export class FileTools {
  79746. /**
  79747. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  79748. */
  79749. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  79750. /**
  79751. * Gets or sets the base URL to use to load assets
  79752. */
  79753. static BaseUrl: string;
  79754. /**
  79755. * Default behaviour for cors in the application.
  79756. * It can be a string if the expected behavior is identical in the entire app.
  79757. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  79758. */
  79759. static CorsBehavior: string | ((url: string | string[]) => string);
  79760. /**
  79761. * Gets or sets a function used to pre-process url before using them to load assets
  79762. */
  79763. static PreprocessUrl: (url: string) => string;
  79764. /**
  79765. * Removes unwanted characters from an url
  79766. * @param url defines the url to clean
  79767. * @returns the cleaned url
  79768. */
  79769. private static _CleanUrl;
  79770. /**
  79771. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  79772. * @param url define the url we are trying
  79773. * @param element define the dom element where to configure the cors policy
  79774. */
  79775. static SetCorsBehavior(url: string | string[], element: {
  79776. crossOrigin: string | null;
  79777. }): void;
  79778. /**
  79779. * Loads an image as an HTMLImageElement.
  79780. * @param input url string, ArrayBuffer, or Blob to load
  79781. * @param onLoad callback called when the image successfully loads
  79782. * @param onError callback called when the image fails to load
  79783. * @param offlineProvider offline provider for caching
  79784. * @param mimeType optional mime type
  79785. * @returns the HTMLImageElement of the loaded image
  79786. */
  79787. 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>;
  79788. /**
  79789. * Reads a file from a File object
  79790. * @param file defines the file to load
  79791. * @param onSuccess defines the callback to call when data is loaded
  79792. * @param onProgress defines the callback to call during loading process
  79793. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  79794. * @param onError defines the callback to call when an error occurs
  79795. * @returns a file request object
  79796. */
  79797. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  79798. /**
  79799. * Loads a file from a url
  79800. * @param url url to load
  79801. * @param onSuccess callback called when the file successfully loads
  79802. * @param onProgress callback called while file is loading (if the server supports this mode)
  79803. * @param offlineProvider defines the offline provider for caching
  79804. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79805. * @param onError callback called when the file fails to load
  79806. * @returns a file request object
  79807. */
  79808. 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;
  79809. /**
  79810. * Loads a file
  79811. * @param url url to load
  79812. * @param onSuccess callback called when the file successfully loads
  79813. * @param onProgress callback called while file is loading (if the server supports this mode)
  79814. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79815. * @param onError callback called when the file fails to load
  79816. * @param onOpened callback called when the web request is opened
  79817. * @returns a file request object
  79818. */
  79819. 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;
  79820. /**
  79821. * Checks if the loaded document was accessed via `file:`-Protocol.
  79822. * @returns boolean
  79823. */
  79824. static IsFileURL(): boolean;
  79825. }
  79826. }
  79827. declare module BABYLON {
  79828. /** @hidden */
  79829. export class ShaderProcessor {
  79830. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  79831. private static _ProcessPrecision;
  79832. private static _ExtractOperation;
  79833. private static _BuildSubExpression;
  79834. private static _BuildExpression;
  79835. private static _MoveCursorWithinIf;
  79836. private static _MoveCursor;
  79837. private static _EvaluatePreProcessors;
  79838. private static _PreparePreProcessors;
  79839. private static _ProcessShaderConversion;
  79840. private static _ProcessIncludes;
  79841. /**
  79842. * Loads a file from a url
  79843. * @param url url to load
  79844. * @param onSuccess callback called when the file successfully loads
  79845. * @param onProgress callback called while file is loading (if the server supports this mode)
  79846. * @param offlineProvider defines the offline provider for caching
  79847. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  79848. * @param onError callback called when the file fails to load
  79849. * @returns a file request object
  79850. * @hidden
  79851. */
  79852. 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;
  79853. }
  79854. }
  79855. declare module BABYLON {
  79856. /**
  79857. * @hidden
  79858. */
  79859. export interface IColor4Like {
  79860. r: float;
  79861. g: float;
  79862. b: float;
  79863. a: float;
  79864. }
  79865. /**
  79866. * @hidden
  79867. */
  79868. export interface IColor3Like {
  79869. r: float;
  79870. g: float;
  79871. b: float;
  79872. }
  79873. /**
  79874. * @hidden
  79875. */
  79876. export interface IVector4Like {
  79877. x: float;
  79878. y: float;
  79879. z: float;
  79880. w: float;
  79881. }
  79882. /**
  79883. * @hidden
  79884. */
  79885. export interface IVector3Like {
  79886. x: float;
  79887. y: float;
  79888. z: float;
  79889. }
  79890. /**
  79891. * @hidden
  79892. */
  79893. export interface IVector2Like {
  79894. x: float;
  79895. y: float;
  79896. }
  79897. /**
  79898. * @hidden
  79899. */
  79900. export interface IMatrixLike {
  79901. toArray(): DeepImmutable<Float32Array>;
  79902. updateFlag: int;
  79903. }
  79904. /**
  79905. * @hidden
  79906. */
  79907. export interface IViewportLike {
  79908. x: float;
  79909. y: float;
  79910. width: float;
  79911. height: float;
  79912. }
  79913. /**
  79914. * @hidden
  79915. */
  79916. export interface IPlaneLike {
  79917. normal: IVector3Like;
  79918. d: float;
  79919. normalize(): void;
  79920. }
  79921. }
  79922. declare module BABYLON {
  79923. /**
  79924. * Interface used to define common properties for effect fallbacks
  79925. */
  79926. export interface IEffectFallbacks {
  79927. /**
  79928. * Removes the defines that should be removed when falling back.
  79929. * @param currentDefines defines the current define statements for the shader.
  79930. * @param effect defines the current effect we try to compile
  79931. * @returns The resulting defines with defines of the current rank removed.
  79932. */
  79933. reduce(currentDefines: string, effect: Effect): string;
  79934. /**
  79935. * Removes the fallback from the bound mesh.
  79936. */
  79937. unBindMesh(): void;
  79938. /**
  79939. * Checks to see if more fallbacks are still availible.
  79940. */
  79941. hasMoreFallbacks: boolean;
  79942. }
  79943. }
  79944. declare module BABYLON {
  79945. /**
  79946. * Class used to evalaute queries containing `and` and `or` operators
  79947. */
  79948. export class AndOrNotEvaluator {
  79949. /**
  79950. * Evaluate a query
  79951. * @param query defines the query to evaluate
  79952. * @param evaluateCallback defines the callback used to filter result
  79953. * @returns true if the query matches
  79954. */
  79955. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  79956. private static _HandleParenthesisContent;
  79957. private static _SimplifyNegation;
  79958. }
  79959. }
  79960. declare module BABYLON {
  79961. /**
  79962. * Class used to store custom tags
  79963. */
  79964. export class Tags {
  79965. /**
  79966. * Adds support for tags on the given object
  79967. * @param obj defines the object to use
  79968. */
  79969. static EnableFor(obj: any): void;
  79970. /**
  79971. * Removes tags support
  79972. * @param obj defines the object to use
  79973. */
  79974. static DisableFor(obj: any): void;
  79975. /**
  79976. * Gets a boolean indicating if the given object has tags
  79977. * @param obj defines the object to use
  79978. * @returns a boolean
  79979. */
  79980. static HasTags(obj: any): boolean;
  79981. /**
  79982. * Gets the tags available on a given object
  79983. * @param obj defines the object to use
  79984. * @param asString defines if the tags must be returned as a string instead of an array of strings
  79985. * @returns the tags
  79986. */
  79987. static GetTags(obj: any, asString?: boolean): any;
  79988. /**
  79989. * Adds tags to an object
  79990. * @param obj defines the object to use
  79991. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  79992. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  79993. */
  79994. static AddTagsTo(obj: any, tagsString: string): void;
  79995. /**
  79996. * @hidden
  79997. */
  79998. static _AddTagTo(obj: any, tag: string): void;
  79999. /**
  80000. * Removes specific tags from a specific object
  80001. * @param obj defines the object to use
  80002. * @param tagsString defines the tags to remove
  80003. */
  80004. static RemoveTagsFrom(obj: any, tagsString: string): void;
  80005. /**
  80006. * @hidden
  80007. */
  80008. static _RemoveTagFrom(obj: any, tag: string): void;
  80009. /**
  80010. * Defines if tags hosted on an object match a given query
  80011. * @param obj defines the object to use
  80012. * @param tagsQuery defines the tag query
  80013. * @returns a boolean
  80014. */
  80015. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /**
  80020. * Scalar computation library
  80021. */
  80022. export class Scalar {
  80023. /**
  80024. * Two pi constants convenient for computation.
  80025. */
  80026. static TwoPi: number;
  80027. /**
  80028. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80029. * @param a number
  80030. * @param b number
  80031. * @param epsilon (default = 1.401298E-45)
  80032. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  80033. */
  80034. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80035. /**
  80036. * Returns a string : the upper case translation of the number i to hexadecimal.
  80037. * @param i number
  80038. * @returns the upper case translation of the number i to hexadecimal.
  80039. */
  80040. static ToHex(i: number): string;
  80041. /**
  80042. * Returns -1 if value is negative and +1 is value is positive.
  80043. * @param value the value
  80044. * @returns the value itself if it's equal to zero.
  80045. */
  80046. static Sign(value: number): number;
  80047. /**
  80048. * Returns the value itself if it's between min and max.
  80049. * Returns min if the value is lower than min.
  80050. * Returns max if the value is greater than max.
  80051. * @param value the value to clmap
  80052. * @param min the min value to clamp to (default: 0)
  80053. * @param max the max value to clamp to (default: 1)
  80054. * @returns the clamped value
  80055. */
  80056. static Clamp(value: number, min?: number, max?: number): number;
  80057. /**
  80058. * the log2 of value.
  80059. * @param value the value to compute log2 of
  80060. * @returns the log2 of value.
  80061. */
  80062. static Log2(value: number): number;
  80063. /**
  80064. * Loops the value, so that it is never larger than length and never smaller than 0.
  80065. *
  80066. * This is similar to the modulo operator but it works with floating point numbers.
  80067. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  80068. * With t = 5 and length = 2.5, the result would be 0.0.
  80069. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  80070. * @param value the value
  80071. * @param length the length
  80072. * @returns the looped value
  80073. */
  80074. static Repeat(value: number, length: number): number;
  80075. /**
  80076. * Normalize the value between 0.0 and 1.0 using min and max values
  80077. * @param value value to normalize
  80078. * @param min max to normalize between
  80079. * @param max min to normalize between
  80080. * @returns the normalized value
  80081. */
  80082. static Normalize(value: number, min: number, max: number): number;
  80083. /**
  80084. * Denormalize the value from 0.0 and 1.0 using min and max values
  80085. * @param normalized value to denormalize
  80086. * @param min max to denormalize between
  80087. * @param max min to denormalize between
  80088. * @returns the denormalized value
  80089. */
  80090. static Denormalize(normalized: number, min: number, max: number): number;
  80091. /**
  80092. * Calculates the shortest difference between two given angles given in degrees.
  80093. * @param current current angle in degrees
  80094. * @param target target angle in degrees
  80095. * @returns the delta
  80096. */
  80097. static DeltaAngle(current: number, target: number): number;
  80098. /**
  80099. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  80100. * @param tx value
  80101. * @param length length
  80102. * @returns The returned value will move back and forth between 0 and length
  80103. */
  80104. static PingPong(tx: number, length: number): number;
  80105. /**
  80106. * Interpolates between min and max with smoothing at the limits.
  80107. *
  80108. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  80109. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  80110. * @param from from
  80111. * @param to to
  80112. * @param tx value
  80113. * @returns the smooth stepped value
  80114. */
  80115. static SmoothStep(from: number, to: number, tx: number): number;
  80116. /**
  80117. * Moves a value current towards target.
  80118. *
  80119. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  80120. * Negative values of maxDelta pushes the value away from target.
  80121. * @param current current value
  80122. * @param target target value
  80123. * @param maxDelta max distance to move
  80124. * @returns resulting value
  80125. */
  80126. static MoveTowards(current: number, target: number, maxDelta: number): number;
  80127. /**
  80128. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80129. *
  80130. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  80131. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  80132. * @param current current value
  80133. * @param target target value
  80134. * @param maxDelta max distance to move
  80135. * @returns resulting angle
  80136. */
  80137. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  80138. /**
  80139. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  80140. * @param start start value
  80141. * @param end target value
  80142. * @param amount amount to lerp between
  80143. * @returns the lerped value
  80144. */
  80145. static Lerp(start: number, end: number, amount: number): number;
  80146. /**
  80147. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  80148. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  80149. * @param start start value
  80150. * @param end target value
  80151. * @param amount amount to lerp between
  80152. * @returns the lerped value
  80153. */
  80154. static LerpAngle(start: number, end: number, amount: number): number;
  80155. /**
  80156. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  80157. * @param a start value
  80158. * @param b target value
  80159. * @param value value between a and b
  80160. * @returns the inverseLerp value
  80161. */
  80162. static InverseLerp(a: number, b: number, value: number): number;
  80163. /**
  80164. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  80165. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  80166. * @param value1 spline value
  80167. * @param tangent1 spline value
  80168. * @param value2 spline value
  80169. * @param tangent2 spline value
  80170. * @param amount input value
  80171. * @returns hermite result
  80172. */
  80173. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  80174. /**
  80175. * Returns a random float number between and min and max values
  80176. * @param min min value of random
  80177. * @param max max value of random
  80178. * @returns random value
  80179. */
  80180. static RandomRange(min: number, max: number): number;
  80181. /**
  80182. * This function returns percentage of a number in a given range.
  80183. *
  80184. * RangeToPercent(40,20,60) will return 0.5 (50%)
  80185. * RangeToPercent(34,0,100) will return 0.34 (34%)
  80186. * @param number to convert to percentage
  80187. * @param min min range
  80188. * @param max max range
  80189. * @returns the percentage
  80190. */
  80191. static RangeToPercent(number: number, min: number, max: number): number;
  80192. /**
  80193. * This function returns number that corresponds to the percentage in a given range.
  80194. *
  80195. * PercentToRange(0.34,0,100) will return 34.
  80196. * @param percent to convert to number
  80197. * @param min min range
  80198. * @param max max range
  80199. * @returns the number
  80200. */
  80201. static PercentToRange(percent: number, min: number, max: number): number;
  80202. /**
  80203. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  80204. * @param angle The angle to normalize in radian.
  80205. * @return The converted angle.
  80206. */
  80207. static NormalizeRadians(angle: number): number;
  80208. }
  80209. }
  80210. declare module BABYLON {
  80211. /**
  80212. * Constant used to convert a value to gamma space
  80213. * @ignorenaming
  80214. */
  80215. export const ToGammaSpace: number;
  80216. /**
  80217. * Constant used to convert a value to linear space
  80218. * @ignorenaming
  80219. */
  80220. export const ToLinearSpace = 2.2;
  80221. /**
  80222. * Constant used to define the minimal number value in Babylon.js
  80223. * @ignorenaming
  80224. */
  80225. let Epsilon: number;
  80226. }
  80227. declare module BABYLON {
  80228. /**
  80229. * Class used to represent a viewport on screen
  80230. */
  80231. export class Viewport {
  80232. /** viewport left coordinate */
  80233. x: number;
  80234. /** viewport top coordinate */
  80235. y: number;
  80236. /**viewport width */
  80237. width: number;
  80238. /** viewport height */
  80239. height: number;
  80240. /**
  80241. * Creates a Viewport object located at (x, y) and sized (width, height)
  80242. * @param x defines viewport left coordinate
  80243. * @param y defines viewport top coordinate
  80244. * @param width defines the viewport width
  80245. * @param height defines the viewport height
  80246. */
  80247. constructor(
  80248. /** viewport left coordinate */
  80249. x: number,
  80250. /** viewport top coordinate */
  80251. y: number,
  80252. /**viewport width */
  80253. width: number,
  80254. /** viewport height */
  80255. height: number);
  80256. /**
  80257. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  80258. * @param renderWidth defines the rendering width
  80259. * @param renderHeight defines the rendering height
  80260. * @returns a new Viewport
  80261. */
  80262. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  80263. /**
  80264. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  80265. * @param renderWidth defines the rendering width
  80266. * @param renderHeight defines the rendering height
  80267. * @param ref defines the target viewport
  80268. * @returns the current viewport
  80269. */
  80270. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  80271. /**
  80272. * Returns a new Viewport copied from the current one
  80273. * @returns a new Viewport
  80274. */
  80275. clone(): Viewport;
  80276. }
  80277. }
  80278. declare module BABYLON {
  80279. /**
  80280. * Class containing a set of static utilities functions for arrays.
  80281. */
  80282. export class ArrayTools {
  80283. /**
  80284. * Returns an array of the given size filled with element built from the given constructor and the paramters
  80285. * @param size the number of element to construct and put in the array
  80286. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  80287. * @returns a new array filled with new objects
  80288. */
  80289. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  80290. }
  80291. }
  80292. declare module BABYLON {
  80293. /**
  80294. * Represents a plane by the equation ax + by + cz + d = 0
  80295. */
  80296. export class Plane {
  80297. private static _TmpMatrix;
  80298. /**
  80299. * Normal of the plane (a,b,c)
  80300. */
  80301. normal: Vector3;
  80302. /**
  80303. * d component of the plane
  80304. */
  80305. d: number;
  80306. /**
  80307. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80308. * @param a a component of the plane
  80309. * @param b b component of the plane
  80310. * @param c c component of the plane
  80311. * @param d d component of the plane
  80312. */
  80313. constructor(a: number, b: number, c: number, d: number);
  80314. /**
  80315. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80316. */
  80317. asArray(): number[];
  80318. /**
  80319. * @returns a new plane copied from the current Plane.
  80320. */
  80321. clone(): Plane;
  80322. /**
  80323. * @returns the string "Plane".
  80324. */
  80325. getClassName(): string;
  80326. /**
  80327. * @returns the Plane hash code.
  80328. */
  80329. getHashCode(): number;
  80330. /**
  80331. * Normalize the current Plane in place.
  80332. * @returns the updated Plane.
  80333. */
  80334. normalize(): Plane;
  80335. /**
  80336. * Applies a transformation the plane and returns the result
  80337. * @param transformation the transformation matrix to be applied to the plane
  80338. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80339. */
  80340. transform(transformation: DeepImmutable<Matrix>): Plane;
  80341. /**
  80342. * Compute the dot product between the point and the plane normal
  80343. * @param point point to calculate the dot product with
  80344. * @returns the dot product (float) of the point coordinates and the plane normal.
  80345. */
  80346. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80347. /**
  80348. * Updates the current Plane from the plane defined by the three given points.
  80349. * @param point1 one of the points used to contruct the plane
  80350. * @param point2 one of the points used to contruct the plane
  80351. * @param point3 one of the points used to contruct the plane
  80352. * @returns the updated Plane.
  80353. */
  80354. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80355. /**
  80356. * Checks if the plane is facing a given direction
  80357. * @param direction the direction to check if the plane is facing
  80358. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80359. * @returns True is the vector "direction" is the same side than the plane normal.
  80360. */
  80361. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80362. /**
  80363. * Calculates the distance to a point
  80364. * @param point point to calculate distance to
  80365. * @returns the signed distance (float) from the given point to the Plane.
  80366. */
  80367. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80368. /**
  80369. * Creates a plane from an array
  80370. * @param array the array to create a plane from
  80371. * @returns a new Plane from the given array.
  80372. */
  80373. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80374. /**
  80375. * Creates a plane from three points
  80376. * @param point1 point used to create the plane
  80377. * @param point2 point used to create the plane
  80378. * @param point3 point used to create the plane
  80379. * @returns a new Plane defined by the three given points.
  80380. */
  80381. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80382. /**
  80383. * Creates a plane from an origin point and a normal
  80384. * @param origin origin of the plane to be constructed
  80385. * @param normal normal of the plane to be constructed
  80386. * @returns a new Plane the normal vector to this plane at the given origin point.
  80387. * Note : the vector "normal" is updated because normalized.
  80388. */
  80389. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  80390. /**
  80391. * Calculates the distance from a plane and a point
  80392. * @param origin origin of the plane to be constructed
  80393. * @param normal normal of the plane to be constructed
  80394. * @param point point to calculate distance to
  80395. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80396. */
  80397. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80398. }
  80399. }
  80400. declare module BABYLON {
  80401. /**
  80402. * Class representing a vector containing 2 coordinates
  80403. */
  80404. export class Vector2 {
  80405. /** defines the first coordinate */
  80406. x: number;
  80407. /** defines the second coordinate */
  80408. y: number;
  80409. /**
  80410. * Creates a new Vector2 from the given x and y coordinates
  80411. * @param x defines the first coordinate
  80412. * @param y defines the second coordinate
  80413. */
  80414. constructor(
  80415. /** defines the first coordinate */
  80416. x?: number,
  80417. /** defines the second coordinate */
  80418. y?: number);
  80419. /**
  80420. * Gets a string with the Vector2 coordinates
  80421. * @returns a string with the Vector2 coordinates
  80422. */
  80423. toString(): string;
  80424. /**
  80425. * Gets class name
  80426. * @returns the string "Vector2"
  80427. */
  80428. getClassName(): string;
  80429. /**
  80430. * Gets current vector hash code
  80431. * @returns the Vector2 hash code as a number
  80432. */
  80433. getHashCode(): number;
  80434. /**
  80435. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  80436. * @param array defines the source array
  80437. * @param index defines the offset in source array
  80438. * @returns the current Vector2
  80439. */
  80440. toArray(array: FloatArray, index?: number): Vector2;
  80441. /**
  80442. * Copy the current vector to an array
  80443. * @returns a new array with 2 elements: the Vector2 coordinates.
  80444. */
  80445. asArray(): number[];
  80446. /**
  80447. * Sets the Vector2 coordinates with the given Vector2 coordinates
  80448. * @param source defines the source Vector2
  80449. * @returns the current updated Vector2
  80450. */
  80451. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  80452. /**
  80453. * Sets the Vector2 coordinates with the given floats
  80454. * @param x defines the first coordinate
  80455. * @param y defines the second coordinate
  80456. * @returns the current updated Vector2
  80457. */
  80458. copyFromFloats(x: number, y: number): Vector2;
  80459. /**
  80460. * Sets the Vector2 coordinates with the given floats
  80461. * @param x defines the first coordinate
  80462. * @param y defines the second coordinate
  80463. * @returns the current updated Vector2
  80464. */
  80465. set(x: number, y: number): Vector2;
  80466. /**
  80467. * Add another vector with the current one
  80468. * @param otherVector defines the other vector
  80469. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  80470. */
  80471. add(otherVector: DeepImmutable<Vector2>): Vector2;
  80472. /**
  80473. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  80474. * @param otherVector defines the other vector
  80475. * @param result defines the target vector
  80476. * @returns the unmodified current Vector2
  80477. */
  80478. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80479. /**
  80480. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  80481. * @param otherVector defines the other vector
  80482. * @returns the current updated Vector2
  80483. */
  80484. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80485. /**
  80486. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  80487. * @param otherVector defines the other vector
  80488. * @returns a new Vector2
  80489. */
  80490. addVector3(otherVector: Vector3): Vector2;
  80491. /**
  80492. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  80493. * @param otherVector defines the other vector
  80494. * @returns a new Vector2
  80495. */
  80496. subtract(otherVector: Vector2): Vector2;
  80497. /**
  80498. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  80499. * @param otherVector defines the other vector
  80500. * @param result defines the target vector
  80501. * @returns the unmodified current Vector2
  80502. */
  80503. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80504. /**
  80505. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  80506. * @param otherVector defines the other vector
  80507. * @returns the current updated Vector2
  80508. */
  80509. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80510. /**
  80511. * Multiplies in place the current Vector2 coordinates by the given ones
  80512. * @param otherVector defines the other vector
  80513. * @returns the current updated Vector2
  80514. */
  80515. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80516. /**
  80517. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  80518. * @param otherVector defines the other vector
  80519. * @returns a new Vector2
  80520. */
  80521. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  80522. /**
  80523. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  80524. * @param otherVector defines the other vector
  80525. * @param result defines the target vector
  80526. * @returns the unmodified current Vector2
  80527. */
  80528. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80529. /**
  80530. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  80531. * @param x defines the first coordinate
  80532. * @param y defines the second coordinate
  80533. * @returns a new Vector2
  80534. */
  80535. multiplyByFloats(x: number, y: number): Vector2;
  80536. /**
  80537. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  80538. * @param otherVector defines the other vector
  80539. * @returns a new Vector2
  80540. */
  80541. divide(otherVector: Vector2): Vector2;
  80542. /**
  80543. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  80544. * @param otherVector defines the other vector
  80545. * @param result defines the target vector
  80546. * @returns the unmodified current Vector2
  80547. */
  80548. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  80549. /**
  80550. * Divides the current Vector2 coordinates by the given ones
  80551. * @param otherVector defines the other vector
  80552. * @returns the current updated Vector2
  80553. */
  80554. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  80555. /**
  80556. * Gets a new Vector2 with current Vector2 negated coordinates
  80557. * @returns a new Vector2
  80558. */
  80559. negate(): Vector2;
  80560. /**
  80561. * Negate this vector in place
  80562. * @returns this
  80563. */
  80564. negateInPlace(): Vector2;
  80565. /**
  80566. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  80567. * @param result defines the Vector3 object where to store the result
  80568. * @returns the current Vector2
  80569. */
  80570. negateToRef(result: Vector2): Vector2;
  80571. /**
  80572. * Multiply the Vector2 coordinates by scale
  80573. * @param scale defines the scaling factor
  80574. * @returns the current updated Vector2
  80575. */
  80576. scaleInPlace(scale: number): Vector2;
  80577. /**
  80578. * Returns a new Vector2 scaled by "scale" from the current Vector2
  80579. * @param scale defines the scaling factor
  80580. * @returns a new Vector2
  80581. */
  80582. scale(scale: number): Vector2;
  80583. /**
  80584. * Scale the current Vector2 values by a factor to a given Vector2
  80585. * @param scale defines the scale factor
  80586. * @param result defines the Vector2 object where to store the result
  80587. * @returns the unmodified current Vector2
  80588. */
  80589. scaleToRef(scale: number, result: Vector2): Vector2;
  80590. /**
  80591. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  80592. * @param scale defines the scale factor
  80593. * @param result defines the Vector2 object where to store the result
  80594. * @returns the unmodified current Vector2
  80595. */
  80596. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  80597. /**
  80598. * Gets a boolean if two vectors are equals
  80599. * @param otherVector defines the other vector
  80600. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  80601. */
  80602. equals(otherVector: DeepImmutable<Vector2>): boolean;
  80603. /**
  80604. * Gets a boolean if two vectors are equals (using an epsilon value)
  80605. * @param otherVector defines the other vector
  80606. * @param epsilon defines the minimal distance to consider equality
  80607. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  80608. */
  80609. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  80610. /**
  80611. * Gets a new Vector2 from current Vector2 floored values
  80612. * @returns a new Vector2
  80613. */
  80614. floor(): Vector2;
  80615. /**
  80616. * Gets a new Vector2 from current Vector2 floored values
  80617. * @returns a new Vector2
  80618. */
  80619. fract(): Vector2;
  80620. /**
  80621. * Gets the length of the vector
  80622. * @returns the vector length (float)
  80623. */
  80624. length(): number;
  80625. /**
  80626. * Gets the vector squared length
  80627. * @returns the vector squared length (float)
  80628. */
  80629. lengthSquared(): number;
  80630. /**
  80631. * Normalize the vector
  80632. * @returns the current updated Vector2
  80633. */
  80634. normalize(): Vector2;
  80635. /**
  80636. * Gets a new Vector2 copied from the Vector2
  80637. * @returns a new Vector2
  80638. */
  80639. clone(): Vector2;
  80640. /**
  80641. * Gets a new Vector2(0, 0)
  80642. * @returns a new Vector2
  80643. */
  80644. static Zero(): Vector2;
  80645. /**
  80646. * Gets a new Vector2(1, 1)
  80647. * @returns a new Vector2
  80648. */
  80649. static One(): Vector2;
  80650. /**
  80651. * Gets a new Vector2 set from the given index element of the given array
  80652. * @param array defines the data source
  80653. * @param offset defines the offset in the data source
  80654. * @returns a new Vector2
  80655. */
  80656. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  80657. /**
  80658. * Sets "result" from the given index element of the given array
  80659. * @param array defines the data source
  80660. * @param offset defines the offset in the data source
  80661. * @param result defines the target vector
  80662. */
  80663. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  80664. /**
  80665. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  80666. * @param value1 defines 1st point of control
  80667. * @param value2 defines 2nd point of control
  80668. * @param value3 defines 3rd point of control
  80669. * @param value4 defines 4th point of control
  80670. * @param amount defines the interpolation factor
  80671. * @returns a new Vector2
  80672. */
  80673. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  80674. /**
  80675. * 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".
  80676. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  80677. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  80678. * @param value defines the value to clamp
  80679. * @param min defines the lower limit
  80680. * @param max defines the upper limit
  80681. * @returns a new Vector2
  80682. */
  80683. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  80684. /**
  80685. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  80686. * @param value1 defines the 1st control point
  80687. * @param tangent1 defines the outgoing tangent
  80688. * @param value2 defines the 2nd control point
  80689. * @param tangent2 defines the incoming tangent
  80690. * @param amount defines the interpolation factor
  80691. * @returns a new Vector2
  80692. */
  80693. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  80694. /**
  80695. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  80696. * @param start defines the start vector
  80697. * @param end defines the end vector
  80698. * @param amount defines the interpolation factor
  80699. * @returns a new Vector2
  80700. */
  80701. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  80702. /**
  80703. * Gets the dot product of the vector "left" and the vector "right"
  80704. * @param left defines first vector
  80705. * @param right defines second vector
  80706. * @returns the dot product (float)
  80707. */
  80708. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  80709. /**
  80710. * Returns a new Vector2 equal to the normalized given vector
  80711. * @param vector defines the vector to normalize
  80712. * @returns a new Vector2
  80713. */
  80714. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  80715. /**
  80716. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  80717. * @param left defines 1st vector
  80718. * @param right defines 2nd vector
  80719. * @returns a new Vector2
  80720. */
  80721. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80722. /**
  80723. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  80724. * @param left defines 1st vector
  80725. * @param right defines 2nd vector
  80726. * @returns a new Vector2
  80727. */
  80728. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  80729. /**
  80730. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  80731. * @param vector defines the vector to transform
  80732. * @param transformation defines the matrix to apply
  80733. * @returns a new Vector2
  80734. */
  80735. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  80736. /**
  80737. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  80738. * @param vector defines the vector to transform
  80739. * @param transformation defines the matrix to apply
  80740. * @param result defines the target vector
  80741. */
  80742. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  80743. /**
  80744. * Determines if a given vector is included in a triangle
  80745. * @param p defines the vector to test
  80746. * @param p0 defines 1st triangle point
  80747. * @param p1 defines 2nd triangle point
  80748. * @param p2 defines 3rd triangle point
  80749. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  80750. */
  80751. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  80752. /**
  80753. * Gets the distance between the vectors "value1" and "value2"
  80754. * @param value1 defines first vector
  80755. * @param value2 defines second vector
  80756. * @returns the distance between vectors
  80757. */
  80758. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80759. /**
  80760. * Returns the squared distance between the vectors "value1" and "value2"
  80761. * @param value1 defines first vector
  80762. * @param value2 defines second vector
  80763. * @returns the squared distance between vectors
  80764. */
  80765. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  80766. /**
  80767. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  80768. * @param value1 defines first vector
  80769. * @param value2 defines second vector
  80770. * @returns a new Vector2
  80771. */
  80772. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  80773. /**
  80774. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  80775. * @param p defines the middle point
  80776. * @param segA defines one point of the segment
  80777. * @param segB defines the other point of the segment
  80778. * @returns the shortest distance
  80779. */
  80780. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  80781. }
  80782. /**
  80783. * Class used to store (x,y,z) vector representation
  80784. * A Vector3 is the main object used in 3D geometry
  80785. * It can represent etiher the coordinates of a point the space, either a direction
  80786. * Reminder: js uses a left handed forward facing system
  80787. */
  80788. export class Vector3 {
  80789. private static _UpReadOnly;
  80790. private static _ZeroReadOnly;
  80791. /** @hidden */
  80792. _x: number;
  80793. /** @hidden */
  80794. _y: number;
  80795. /** @hidden */
  80796. _z: number;
  80797. /** @hidden */
  80798. _isDirty: boolean;
  80799. /** Gets or sets the x coordinate */
  80800. get x(): number;
  80801. set x(value: number);
  80802. /** Gets or sets the y coordinate */
  80803. get y(): number;
  80804. set y(value: number);
  80805. /** Gets or sets the z coordinate */
  80806. get z(): number;
  80807. set z(value: number);
  80808. /**
  80809. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  80810. * @param x defines the first coordinates (on X axis)
  80811. * @param y defines the second coordinates (on Y axis)
  80812. * @param z defines the third coordinates (on Z axis)
  80813. */
  80814. constructor(x?: number, y?: number, z?: number);
  80815. /**
  80816. * Creates a string representation of the Vector3
  80817. * @returns a string with the Vector3 coordinates.
  80818. */
  80819. toString(): string;
  80820. /**
  80821. * Gets the class name
  80822. * @returns the string "Vector3"
  80823. */
  80824. getClassName(): string;
  80825. /**
  80826. * Creates the Vector3 hash code
  80827. * @returns a number which tends to be unique between Vector3 instances
  80828. */
  80829. getHashCode(): number;
  80830. /**
  80831. * Creates an array containing three elements : the coordinates of the Vector3
  80832. * @returns a new array of numbers
  80833. */
  80834. asArray(): number[];
  80835. /**
  80836. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  80837. * @param array defines the destination array
  80838. * @param index defines the offset in the destination array
  80839. * @returns the current Vector3
  80840. */
  80841. toArray(array: FloatArray, index?: number): Vector3;
  80842. /**
  80843. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  80844. * @returns a new Quaternion object, computed from the Vector3 coordinates
  80845. */
  80846. toQuaternion(): Quaternion;
  80847. /**
  80848. * Adds the given vector to the current Vector3
  80849. * @param otherVector defines the second operand
  80850. * @returns the current updated Vector3
  80851. */
  80852. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80853. /**
  80854. * Adds the given coordinates to the current Vector3
  80855. * @param x defines the x coordinate of the operand
  80856. * @param y defines the y coordinate of the operand
  80857. * @param z defines the z coordinate of the operand
  80858. * @returns the current updated Vector3
  80859. */
  80860. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  80861. /**
  80862. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  80863. * @param otherVector defines the second operand
  80864. * @returns the resulting Vector3
  80865. */
  80866. add(otherVector: DeepImmutable<Vector3>): Vector3;
  80867. /**
  80868. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  80869. * @param otherVector defines the second operand
  80870. * @param result defines the Vector3 object where to store the result
  80871. * @returns the current Vector3
  80872. */
  80873. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80874. /**
  80875. * Subtract the given vector from the current Vector3
  80876. * @param otherVector defines the second operand
  80877. * @returns the current updated Vector3
  80878. */
  80879. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80880. /**
  80881. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  80882. * @param otherVector defines the second operand
  80883. * @returns the resulting Vector3
  80884. */
  80885. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  80886. /**
  80887. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  80888. * @param otherVector defines the second operand
  80889. * @param result defines the Vector3 object where to store the result
  80890. * @returns the current Vector3
  80891. */
  80892. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  80893. /**
  80894. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  80895. * @param x defines the x coordinate of the operand
  80896. * @param y defines the y coordinate of the operand
  80897. * @param z defines the z coordinate of the operand
  80898. * @returns the resulting Vector3
  80899. */
  80900. subtractFromFloats(x: number, y: number, z: number): Vector3;
  80901. /**
  80902. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  80903. * @param x defines the x coordinate of the operand
  80904. * @param y defines the y coordinate of the operand
  80905. * @param z defines the z coordinate of the operand
  80906. * @param result defines the Vector3 object where to store the result
  80907. * @returns the current Vector3
  80908. */
  80909. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  80910. /**
  80911. * Gets a new Vector3 set with the current Vector3 negated coordinates
  80912. * @returns a new Vector3
  80913. */
  80914. negate(): Vector3;
  80915. /**
  80916. * Negate this vector in place
  80917. * @returns this
  80918. */
  80919. negateInPlace(): Vector3;
  80920. /**
  80921. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  80922. * @param result defines the Vector3 object where to store the result
  80923. * @returns the current Vector3
  80924. */
  80925. negateToRef(result: Vector3): Vector3;
  80926. /**
  80927. * Multiplies the Vector3 coordinates by the float "scale"
  80928. * @param scale defines the multiplier factor
  80929. * @returns the current updated Vector3
  80930. */
  80931. scaleInPlace(scale: number): Vector3;
  80932. /**
  80933. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  80934. * @param scale defines the multiplier factor
  80935. * @returns a new Vector3
  80936. */
  80937. scale(scale: number): Vector3;
  80938. /**
  80939. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  80940. * @param scale defines the multiplier factor
  80941. * @param result defines the Vector3 object where to store the result
  80942. * @returns the current Vector3
  80943. */
  80944. scaleToRef(scale: number, result: Vector3): Vector3;
  80945. /**
  80946. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  80947. * @param scale defines the scale factor
  80948. * @param result defines the Vector3 object where to store the result
  80949. * @returns the unmodified current Vector3
  80950. */
  80951. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  80952. /**
  80953. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80954. * @param origin defines the origin of the projection ray
  80955. * @param plane defines the plane to project to
  80956. * @returns the projected vector3
  80957. */
  80958. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  80959. /**
  80960. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  80961. * @param origin defines the origin of the projection ray
  80962. * @param plane defines the plane to project to
  80963. * @param result defines the Vector3 where to store the result
  80964. */
  80965. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  80966. /**
  80967. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  80968. * @param otherVector defines the second operand
  80969. * @returns true if both vectors are equals
  80970. */
  80971. equals(otherVector: DeepImmutable<Vector3>): boolean;
  80972. /**
  80973. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  80974. * @param otherVector defines the second operand
  80975. * @param epsilon defines the minimal distance to define values as equals
  80976. * @returns true if both vectors are distant less than epsilon
  80977. */
  80978. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  80979. /**
  80980. * Returns true if the current Vector3 coordinates equals the given floats
  80981. * @param x defines the x coordinate of the operand
  80982. * @param y defines the y coordinate of the operand
  80983. * @param z defines the z coordinate of the operand
  80984. * @returns true if both vectors are equals
  80985. */
  80986. equalsToFloats(x: number, y: number, z: number): boolean;
  80987. /**
  80988. * Multiplies the current Vector3 coordinates by the given ones
  80989. * @param otherVector defines the second operand
  80990. * @returns the current updated Vector3
  80991. */
  80992. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  80993. /**
  80994. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  80995. * @param otherVector defines the second operand
  80996. * @returns the new Vector3
  80997. */
  80998. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  80999. /**
  81000. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  81001. * @param otherVector defines the second operand
  81002. * @param result defines the Vector3 object where to store the result
  81003. * @returns the current Vector3
  81004. */
  81005. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81006. /**
  81007. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  81008. * @param x defines the x coordinate of the operand
  81009. * @param y defines the y coordinate of the operand
  81010. * @param z defines the z coordinate of the operand
  81011. * @returns the new Vector3
  81012. */
  81013. multiplyByFloats(x: number, y: number, z: number): Vector3;
  81014. /**
  81015. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  81016. * @param otherVector defines the second operand
  81017. * @returns the new Vector3
  81018. */
  81019. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  81020. /**
  81021. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  81022. * @param otherVector defines the second operand
  81023. * @param result defines the Vector3 object where to store the result
  81024. * @returns the current Vector3
  81025. */
  81026. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  81027. /**
  81028. * Divides the current Vector3 coordinates by the given ones.
  81029. * @param otherVector defines the second operand
  81030. * @returns the current updated Vector3
  81031. */
  81032. divideInPlace(otherVector: Vector3): Vector3;
  81033. /**
  81034. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  81035. * @param other defines the second operand
  81036. * @returns the current updated Vector3
  81037. */
  81038. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81039. /**
  81040. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  81041. * @param other defines the second operand
  81042. * @returns the current updated Vector3
  81043. */
  81044. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  81045. /**
  81046. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  81047. * @param x defines the x coordinate of the operand
  81048. * @param y defines the y coordinate of the operand
  81049. * @param z defines the z coordinate of the operand
  81050. * @returns the current updated Vector3
  81051. */
  81052. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81053. /**
  81054. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  81055. * @param x defines the x coordinate of the operand
  81056. * @param y defines the y coordinate of the operand
  81057. * @param z defines the z coordinate of the operand
  81058. * @returns the current updated Vector3
  81059. */
  81060. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  81061. /**
  81062. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  81063. * Check if is non uniform within a certain amount of decimal places to account for this
  81064. * @param epsilon the amount the values can differ
  81065. * @returns if the the vector is non uniform to a certain number of decimal places
  81066. */
  81067. isNonUniformWithinEpsilon(epsilon: number): boolean;
  81068. /**
  81069. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  81070. */
  81071. get isNonUniform(): boolean;
  81072. /**
  81073. * Gets a new Vector3 from current Vector3 floored values
  81074. * @returns a new Vector3
  81075. */
  81076. floor(): Vector3;
  81077. /**
  81078. * Gets a new Vector3 from current Vector3 floored values
  81079. * @returns a new Vector3
  81080. */
  81081. fract(): Vector3;
  81082. /**
  81083. * Gets the length of the Vector3
  81084. * @returns the length of the Vector3
  81085. */
  81086. length(): number;
  81087. /**
  81088. * Gets the squared length of the Vector3
  81089. * @returns squared length of the Vector3
  81090. */
  81091. lengthSquared(): number;
  81092. /**
  81093. * Normalize the current Vector3.
  81094. * Please note that this is an in place operation.
  81095. * @returns the current updated Vector3
  81096. */
  81097. normalize(): Vector3;
  81098. /**
  81099. * Reorders the x y z properties of the vector in place
  81100. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  81101. * @returns the current updated vector
  81102. */
  81103. reorderInPlace(order: string): this;
  81104. /**
  81105. * Rotates the vector around 0,0,0 by a quaternion
  81106. * @param quaternion the rotation quaternion
  81107. * @param result vector to store the result
  81108. * @returns the resulting vector
  81109. */
  81110. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  81111. /**
  81112. * Rotates a vector around a given point
  81113. * @param quaternion the rotation quaternion
  81114. * @param point the point to rotate around
  81115. * @param result vector to store the result
  81116. * @returns the resulting vector
  81117. */
  81118. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  81119. /**
  81120. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  81121. * The cross product is then orthogonal to both current and "other"
  81122. * @param other defines the right operand
  81123. * @returns the cross product
  81124. */
  81125. cross(other: Vector3): Vector3;
  81126. /**
  81127. * Normalize the current Vector3 with the given input length.
  81128. * Please note that this is an in place operation.
  81129. * @param len the length of the vector
  81130. * @returns the current updated Vector3
  81131. */
  81132. normalizeFromLength(len: number): Vector3;
  81133. /**
  81134. * Normalize the current Vector3 to a new vector
  81135. * @returns the new Vector3
  81136. */
  81137. normalizeToNew(): Vector3;
  81138. /**
  81139. * Normalize the current Vector3 to the reference
  81140. * @param reference define the Vector3 to update
  81141. * @returns the updated Vector3
  81142. */
  81143. normalizeToRef(reference: Vector3): Vector3;
  81144. /**
  81145. * Creates a new Vector3 copied from the current Vector3
  81146. * @returns the new Vector3
  81147. */
  81148. clone(): Vector3;
  81149. /**
  81150. * Copies the given vector coordinates to the current Vector3 ones
  81151. * @param source defines the source Vector3
  81152. * @returns the current updated Vector3
  81153. */
  81154. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  81155. /**
  81156. * Copies the given floats to the current Vector3 coordinates
  81157. * @param x defines the x coordinate of the operand
  81158. * @param y defines the y coordinate of the operand
  81159. * @param z defines the z coordinate of the operand
  81160. * @returns the current updated Vector3
  81161. */
  81162. copyFromFloats(x: number, y: number, z: number): Vector3;
  81163. /**
  81164. * Copies the given floats to the current Vector3 coordinates
  81165. * @param x defines the x coordinate of the operand
  81166. * @param y defines the y coordinate of the operand
  81167. * @param z defines the z coordinate of the operand
  81168. * @returns the current updated Vector3
  81169. */
  81170. set(x: number, y: number, z: number): Vector3;
  81171. /**
  81172. * Copies the given float to the current Vector3 coordinates
  81173. * @param v defines the x, y and z coordinates of the operand
  81174. * @returns the current updated Vector3
  81175. */
  81176. setAll(v: number): Vector3;
  81177. /**
  81178. * Get the clip factor between two vectors
  81179. * @param vector0 defines the first operand
  81180. * @param vector1 defines the second operand
  81181. * @param axis defines the axis to use
  81182. * @param size defines the size along the axis
  81183. * @returns the clip factor
  81184. */
  81185. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  81186. /**
  81187. * Get angle between two vectors
  81188. * @param vector0 angle between vector0 and vector1
  81189. * @param vector1 angle between vector0 and vector1
  81190. * @param normal direction of the normal
  81191. * @return the angle between vector0 and vector1
  81192. */
  81193. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  81194. /**
  81195. * Returns a new Vector3 set from the index "offset" of the given array
  81196. * @param array defines the source array
  81197. * @param offset defines the offset in the source array
  81198. * @returns the new Vector3
  81199. */
  81200. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  81201. /**
  81202. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  81203. * @param array defines the source array
  81204. * @param offset defines the offset in the source array
  81205. * @returns the new Vector3
  81206. * @deprecated Please use FromArray instead.
  81207. */
  81208. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  81209. /**
  81210. * Sets the given vector "result" with the element values from the index "offset" of the given array
  81211. * @param array defines the source array
  81212. * @param offset defines the offset in the source array
  81213. * @param result defines the Vector3 where to store the result
  81214. */
  81215. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  81216. /**
  81217. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  81218. * @param array defines the source array
  81219. * @param offset defines the offset in the source array
  81220. * @param result defines the Vector3 where to store the result
  81221. * @deprecated Please use FromArrayToRef instead.
  81222. */
  81223. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  81224. /**
  81225. * Sets the given vector "result" with the given floats.
  81226. * @param x defines the x coordinate of the source
  81227. * @param y defines the y coordinate of the source
  81228. * @param z defines the z coordinate of the source
  81229. * @param result defines the Vector3 where to store the result
  81230. */
  81231. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  81232. /**
  81233. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  81234. * @returns a new empty Vector3
  81235. */
  81236. static Zero(): Vector3;
  81237. /**
  81238. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  81239. * @returns a new unit Vector3
  81240. */
  81241. static One(): Vector3;
  81242. /**
  81243. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  81244. * @returns a new up Vector3
  81245. */
  81246. static Up(): Vector3;
  81247. /**
  81248. * Gets a up Vector3 that must not be updated
  81249. */
  81250. static get UpReadOnly(): DeepImmutable<Vector3>;
  81251. /**
  81252. * Gets a zero Vector3 that must not be updated
  81253. */
  81254. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  81255. /**
  81256. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  81257. * @returns a new down Vector3
  81258. */
  81259. static Down(): Vector3;
  81260. /**
  81261. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  81262. * @param rightHandedSystem is the scene right-handed (negative z)
  81263. * @returns a new forward Vector3
  81264. */
  81265. static Forward(rightHandedSystem?: boolean): Vector3;
  81266. /**
  81267. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  81268. * @param rightHandedSystem is the scene right-handed (negative-z)
  81269. * @returns a new forward Vector3
  81270. */
  81271. static Backward(rightHandedSystem?: boolean): Vector3;
  81272. /**
  81273. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  81274. * @returns a new right Vector3
  81275. */
  81276. static Right(): Vector3;
  81277. /**
  81278. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  81279. * @returns a new left Vector3
  81280. */
  81281. static Left(): Vector3;
  81282. /**
  81283. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  81284. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81285. * @param vector defines the Vector3 to transform
  81286. * @param transformation defines the transformation matrix
  81287. * @returns the transformed Vector3
  81288. */
  81289. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81290. /**
  81291. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  81292. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  81293. * @param vector defines the Vector3 to transform
  81294. * @param transformation defines the transformation matrix
  81295. * @param result defines the Vector3 where to store the result
  81296. */
  81297. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81298. /**
  81299. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  81300. * This method computes tranformed coordinates only, not transformed direction vectors
  81301. * @param x define the x coordinate of the source vector
  81302. * @param y define the y coordinate of the source vector
  81303. * @param z define the z coordinate of the source vector
  81304. * @param transformation defines the transformation matrix
  81305. * @param result defines the Vector3 where to store the result
  81306. */
  81307. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81308. /**
  81309. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  81310. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81311. * @param vector defines the Vector3 to transform
  81312. * @param transformation defines the transformation matrix
  81313. * @returns the new Vector3
  81314. */
  81315. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  81316. /**
  81317. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  81318. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81319. * @param vector defines the Vector3 to transform
  81320. * @param transformation defines the transformation matrix
  81321. * @param result defines the Vector3 where to store the result
  81322. */
  81323. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81324. /**
  81325. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  81326. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  81327. * @param x define the x coordinate of the source vector
  81328. * @param y define the y coordinate of the source vector
  81329. * @param z define the z coordinate of the source vector
  81330. * @param transformation defines the transformation matrix
  81331. * @param result defines the Vector3 where to store the result
  81332. */
  81333. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  81334. /**
  81335. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  81336. * @param value1 defines the first control point
  81337. * @param value2 defines the second control point
  81338. * @param value3 defines the third control point
  81339. * @param value4 defines the fourth control point
  81340. * @param amount defines the amount on the spline to use
  81341. * @returns the new Vector3
  81342. */
  81343. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  81344. /**
  81345. * 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"
  81346. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81347. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81348. * @param value defines the current value
  81349. * @param min defines the lower range value
  81350. * @param max defines the upper range value
  81351. * @returns the new Vector3
  81352. */
  81353. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  81354. /**
  81355. * 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"
  81356. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  81357. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  81358. * @param value defines the current value
  81359. * @param min defines the lower range value
  81360. * @param max defines the upper range value
  81361. * @param result defines the Vector3 where to store the result
  81362. */
  81363. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  81364. /**
  81365. * Checks if a given vector is inside a specific range
  81366. * @param v defines the vector to test
  81367. * @param min defines the minimum range
  81368. * @param max defines the maximum range
  81369. */
  81370. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  81371. /**
  81372. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  81373. * @param value1 defines the first control point
  81374. * @param tangent1 defines the first tangent vector
  81375. * @param value2 defines the second control point
  81376. * @param tangent2 defines the second tangent vector
  81377. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  81378. * @returns the new Vector3
  81379. */
  81380. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  81381. /**
  81382. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  81383. * @param start defines the start value
  81384. * @param end defines the end value
  81385. * @param amount max defines amount between both (between 0 and 1)
  81386. * @returns the new Vector3
  81387. */
  81388. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  81389. /**
  81390. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  81391. * @param start defines the start value
  81392. * @param end defines the end value
  81393. * @param amount max defines amount between both (between 0 and 1)
  81394. * @param result defines the Vector3 where to store the result
  81395. */
  81396. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  81397. /**
  81398. * Returns the dot product (float) between the vectors "left" and "right"
  81399. * @param left defines the left operand
  81400. * @param right defines the right operand
  81401. * @returns the dot product
  81402. */
  81403. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  81404. /**
  81405. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  81406. * The cross product is then orthogonal to both "left" and "right"
  81407. * @param left defines the left operand
  81408. * @param right defines the right operand
  81409. * @returns the cross product
  81410. */
  81411. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81412. /**
  81413. * Sets the given vector "result" with the cross product of "left" and "right"
  81414. * The cross product is then orthogonal to both "left" and "right"
  81415. * @param left defines the left operand
  81416. * @param right defines the right operand
  81417. * @param result defines the Vector3 where to store the result
  81418. */
  81419. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  81420. /**
  81421. * Returns a new Vector3 as the normalization of the given vector
  81422. * @param vector defines the Vector3 to normalize
  81423. * @returns the new Vector3
  81424. */
  81425. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  81426. /**
  81427. * Sets the given vector "result" with the normalization of the given first vector
  81428. * @param vector defines the Vector3 to normalize
  81429. * @param result defines the Vector3 where to store the result
  81430. */
  81431. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  81432. /**
  81433. * Project a Vector3 onto screen space
  81434. * @param vector defines the Vector3 to project
  81435. * @param world defines the world matrix to use
  81436. * @param transform defines the transform (view x projection) matrix to use
  81437. * @param viewport defines the screen viewport to use
  81438. * @returns the new Vector3
  81439. */
  81440. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  81441. /** @hidden */
  81442. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  81443. /**
  81444. * Unproject from screen space to object space
  81445. * @param source defines the screen space Vector3 to use
  81446. * @param viewportWidth defines the current width of the viewport
  81447. * @param viewportHeight defines the current height of the viewport
  81448. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81449. * @param transform defines the transform (view x projection) matrix to use
  81450. * @returns the new Vector3
  81451. */
  81452. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  81453. /**
  81454. * Unproject from screen space to object space
  81455. * @param source defines the screen space Vector3 to use
  81456. * @param viewportWidth defines the current width of the viewport
  81457. * @param viewportHeight defines the current height of the viewport
  81458. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81459. * @param view defines the view matrix to use
  81460. * @param projection defines the projection matrix to use
  81461. * @returns the new Vector3
  81462. */
  81463. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  81464. /**
  81465. * Unproject from screen space to object space
  81466. * @param source defines the screen space Vector3 to use
  81467. * @param viewportWidth defines the current width of the viewport
  81468. * @param viewportHeight defines the current height of the viewport
  81469. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81470. * @param view defines the view matrix to use
  81471. * @param projection defines the projection matrix to use
  81472. * @param result defines the Vector3 where to store the result
  81473. */
  81474. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81475. /**
  81476. * Unproject from screen space to object space
  81477. * @param sourceX defines the screen space x coordinate to use
  81478. * @param sourceY defines the screen space y coordinate to use
  81479. * @param sourceZ defines the screen space z coordinate to use
  81480. * @param viewportWidth defines the current width of the viewport
  81481. * @param viewportHeight defines the current height of the viewport
  81482. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  81483. * @param view defines the view matrix to use
  81484. * @param projection defines the projection matrix to use
  81485. * @param result defines the Vector3 where to store the result
  81486. */
  81487. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  81488. /**
  81489. * Gets the minimal coordinate values between two Vector3
  81490. * @param left defines the first operand
  81491. * @param right defines the second operand
  81492. * @returns the new Vector3
  81493. */
  81494. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81495. /**
  81496. * Gets the maximal coordinate values between two Vector3
  81497. * @param left defines the first operand
  81498. * @param right defines the second operand
  81499. * @returns the new Vector3
  81500. */
  81501. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  81502. /**
  81503. * Returns the distance between the vectors "value1" and "value2"
  81504. * @param value1 defines the first operand
  81505. * @param value2 defines the second operand
  81506. * @returns the distance
  81507. */
  81508. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81509. /**
  81510. * Returns the squared distance between the vectors "value1" and "value2"
  81511. * @param value1 defines the first operand
  81512. * @param value2 defines the second operand
  81513. * @returns the squared distance
  81514. */
  81515. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  81516. /**
  81517. * Returns a new Vector3 located at the center between "value1" and "value2"
  81518. * @param value1 defines the first operand
  81519. * @param value2 defines the second operand
  81520. * @returns the new Vector3
  81521. */
  81522. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  81523. /**
  81524. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  81525. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  81526. * to something in order to rotate it from its local system to the given target system
  81527. * Note: axis1, axis2 and axis3 are normalized during this operation
  81528. * @param axis1 defines the first axis
  81529. * @param axis2 defines the second axis
  81530. * @param axis3 defines the third axis
  81531. * @returns a new Vector3
  81532. */
  81533. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  81534. /**
  81535. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  81536. * @param axis1 defines the first axis
  81537. * @param axis2 defines the second axis
  81538. * @param axis3 defines the third axis
  81539. * @param ref defines the Vector3 where to store the result
  81540. */
  81541. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  81542. }
  81543. /**
  81544. * Vector4 class created for EulerAngle class conversion to Quaternion
  81545. */
  81546. export class Vector4 {
  81547. /** x value of the vector */
  81548. x: number;
  81549. /** y value of the vector */
  81550. y: number;
  81551. /** z value of the vector */
  81552. z: number;
  81553. /** w value of the vector */
  81554. w: number;
  81555. /**
  81556. * Creates a Vector4 object from the given floats.
  81557. * @param x x value of the vector
  81558. * @param y y value of the vector
  81559. * @param z z value of the vector
  81560. * @param w w value of the vector
  81561. */
  81562. constructor(
  81563. /** x value of the vector */
  81564. x: number,
  81565. /** y value of the vector */
  81566. y: number,
  81567. /** z value of the vector */
  81568. z: number,
  81569. /** w value of the vector */
  81570. w: number);
  81571. /**
  81572. * Returns the string with the Vector4 coordinates.
  81573. * @returns a string containing all the vector values
  81574. */
  81575. toString(): string;
  81576. /**
  81577. * Returns the string "Vector4".
  81578. * @returns "Vector4"
  81579. */
  81580. getClassName(): string;
  81581. /**
  81582. * Returns the Vector4 hash code.
  81583. * @returns a unique hash code
  81584. */
  81585. getHashCode(): number;
  81586. /**
  81587. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  81588. * @returns the resulting array
  81589. */
  81590. asArray(): number[];
  81591. /**
  81592. * Populates the given array from the given index with the Vector4 coordinates.
  81593. * @param array array to populate
  81594. * @param index index of the array to start at (default: 0)
  81595. * @returns the Vector4.
  81596. */
  81597. toArray(array: FloatArray, index?: number): Vector4;
  81598. /**
  81599. * Adds the given vector to the current Vector4.
  81600. * @param otherVector the vector to add
  81601. * @returns the updated Vector4.
  81602. */
  81603. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81604. /**
  81605. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  81606. * @param otherVector the vector to add
  81607. * @returns the resulting vector
  81608. */
  81609. add(otherVector: DeepImmutable<Vector4>): Vector4;
  81610. /**
  81611. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  81612. * @param otherVector the vector to add
  81613. * @param result the vector to store the result
  81614. * @returns the current Vector4.
  81615. */
  81616. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81617. /**
  81618. * Subtract in place the given vector from the current Vector4.
  81619. * @param otherVector the vector to subtract
  81620. * @returns the updated Vector4.
  81621. */
  81622. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81623. /**
  81624. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  81625. * @param otherVector the vector to add
  81626. * @returns the new vector with the result
  81627. */
  81628. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  81629. /**
  81630. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  81631. * @param otherVector the vector to subtract
  81632. * @param result the vector to store the result
  81633. * @returns the current Vector4.
  81634. */
  81635. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81636. /**
  81637. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81638. */
  81639. /**
  81640. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81641. * @param x value to subtract
  81642. * @param y value to subtract
  81643. * @param z value to subtract
  81644. * @param w value to subtract
  81645. * @returns new vector containing the result
  81646. */
  81647. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81648. /**
  81649. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  81650. * @param x value to subtract
  81651. * @param y value to subtract
  81652. * @param z value to subtract
  81653. * @param w value to subtract
  81654. * @param result the vector to store the result in
  81655. * @returns the current Vector4.
  81656. */
  81657. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  81658. /**
  81659. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  81660. * @returns a new vector with the negated values
  81661. */
  81662. negate(): Vector4;
  81663. /**
  81664. * Negate this vector in place
  81665. * @returns this
  81666. */
  81667. negateInPlace(): Vector4;
  81668. /**
  81669. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  81670. * @param result defines the Vector3 object where to store the result
  81671. * @returns the current Vector4
  81672. */
  81673. negateToRef(result: Vector4): Vector4;
  81674. /**
  81675. * Multiplies the current Vector4 coordinates by scale (float).
  81676. * @param scale the number to scale with
  81677. * @returns the updated Vector4.
  81678. */
  81679. scaleInPlace(scale: number): Vector4;
  81680. /**
  81681. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  81682. * @param scale the number to scale with
  81683. * @returns a new vector with the result
  81684. */
  81685. scale(scale: number): Vector4;
  81686. /**
  81687. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  81688. * @param scale the number to scale with
  81689. * @param result a vector to store the result in
  81690. * @returns the current Vector4.
  81691. */
  81692. scaleToRef(scale: number, result: Vector4): Vector4;
  81693. /**
  81694. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  81695. * @param scale defines the scale factor
  81696. * @param result defines the Vector4 object where to store the result
  81697. * @returns the unmodified current Vector4
  81698. */
  81699. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  81700. /**
  81701. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  81702. * @param otherVector the vector to compare against
  81703. * @returns true if they are equal
  81704. */
  81705. equals(otherVector: DeepImmutable<Vector4>): boolean;
  81706. /**
  81707. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  81708. * @param otherVector vector to compare against
  81709. * @param epsilon (Default: very small number)
  81710. * @returns true if they are equal
  81711. */
  81712. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  81713. /**
  81714. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  81715. * @param x x value to compare against
  81716. * @param y y value to compare against
  81717. * @param z z value to compare against
  81718. * @param w w value to compare against
  81719. * @returns true if equal
  81720. */
  81721. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  81722. /**
  81723. * Multiplies in place the current Vector4 by the given one.
  81724. * @param otherVector vector to multiple with
  81725. * @returns the updated Vector4.
  81726. */
  81727. multiplyInPlace(otherVector: Vector4): Vector4;
  81728. /**
  81729. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  81730. * @param otherVector vector to multiple with
  81731. * @returns resulting new vector
  81732. */
  81733. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  81734. /**
  81735. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  81736. * @param otherVector vector to multiple with
  81737. * @param result vector to store the result
  81738. * @returns the current Vector4.
  81739. */
  81740. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81741. /**
  81742. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  81743. * @param x x value multiply with
  81744. * @param y y value multiply with
  81745. * @param z z value multiply with
  81746. * @param w w value multiply with
  81747. * @returns resulting new vector
  81748. */
  81749. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  81750. /**
  81751. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  81752. * @param otherVector vector to devide with
  81753. * @returns resulting new vector
  81754. */
  81755. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  81756. /**
  81757. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  81758. * @param otherVector vector to devide with
  81759. * @param result vector to store the result
  81760. * @returns the current Vector4.
  81761. */
  81762. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  81763. /**
  81764. * Divides the current Vector3 coordinates by the given ones.
  81765. * @param otherVector vector to devide with
  81766. * @returns the updated Vector3.
  81767. */
  81768. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  81769. /**
  81770. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  81771. * @param other defines the second operand
  81772. * @returns the current updated Vector4
  81773. */
  81774. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81775. /**
  81776. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  81777. * @param other defines the second operand
  81778. * @returns the current updated Vector4
  81779. */
  81780. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  81781. /**
  81782. * Gets a new Vector4 from current Vector4 floored values
  81783. * @returns a new Vector4
  81784. */
  81785. floor(): Vector4;
  81786. /**
  81787. * Gets a new Vector4 from current Vector3 floored values
  81788. * @returns a new Vector4
  81789. */
  81790. fract(): Vector4;
  81791. /**
  81792. * Returns the Vector4 length (float).
  81793. * @returns the length
  81794. */
  81795. length(): number;
  81796. /**
  81797. * Returns the Vector4 squared length (float).
  81798. * @returns the length squared
  81799. */
  81800. lengthSquared(): number;
  81801. /**
  81802. * Normalizes in place the Vector4.
  81803. * @returns the updated Vector4.
  81804. */
  81805. normalize(): Vector4;
  81806. /**
  81807. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  81808. * @returns this converted to a new vector3
  81809. */
  81810. toVector3(): Vector3;
  81811. /**
  81812. * Returns a new Vector4 copied from the current one.
  81813. * @returns the new cloned vector
  81814. */
  81815. clone(): Vector4;
  81816. /**
  81817. * Updates the current Vector4 with the given one coordinates.
  81818. * @param source the source vector to copy from
  81819. * @returns the updated Vector4.
  81820. */
  81821. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  81822. /**
  81823. * Updates the current Vector4 coordinates with the given floats.
  81824. * @param x float to copy from
  81825. * @param y float to copy from
  81826. * @param z float to copy from
  81827. * @param w float to copy from
  81828. * @returns the updated Vector4.
  81829. */
  81830. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  81831. /**
  81832. * Updates the current Vector4 coordinates with the given floats.
  81833. * @param x float to set from
  81834. * @param y float to set from
  81835. * @param z float to set from
  81836. * @param w float to set from
  81837. * @returns the updated Vector4.
  81838. */
  81839. set(x: number, y: number, z: number, w: number): Vector4;
  81840. /**
  81841. * Copies the given float to the current Vector3 coordinates
  81842. * @param v defines the x, y, z and w coordinates of the operand
  81843. * @returns the current updated Vector3
  81844. */
  81845. setAll(v: number): Vector4;
  81846. /**
  81847. * Returns a new Vector4 set from the starting index of the given array.
  81848. * @param array the array to pull values from
  81849. * @param offset the offset into the array to start at
  81850. * @returns the new vector
  81851. */
  81852. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  81853. /**
  81854. * Updates the given vector "result" from the starting index of the given array.
  81855. * @param array the array to pull values from
  81856. * @param offset the offset into the array to start at
  81857. * @param result the vector to store the result in
  81858. */
  81859. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  81860. /**
  81861. * Updates the given vector "result" from the starting index of the given Float32Array.
  81862. * @param array the array to pull values from
  81863. * @param offset the offset into the array to start at
  81864. * @param result the vector to store the result in
  81865. */
  81866. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  81867. /**
  81868. * Updates the given vector "result" coordinates from the given floats.
  81869. * @param x float to set from
  81870. * @param y float to set from
  81871. * @param z float to set from
  81872. * @param w float to set from
  81873. * @param result the vector to the floats in
  81874. */
  81875. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  81876. /**
  81877. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  81878. * @returns the new vector
  81879. */
  81880. static Zero(): Vector4;
  81881. /**
  81882. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  81883. * @returns the new vector
  81884. */
  81885. static One(): Vector4;
  81886. /**
  81887. * Returns a new normalized Vector4 from the given one.
  81888. * @param vector the vector to normalize
  81889. * @returns the vector
  81890. */
  81891. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  81892. /**
  81893. * Updates the given vector "result" from the normalization of the given one.
  81894. * @param vector the vector to normalize
  81895. * @param result the vector to store the result in
  81896. */
  81897. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  81898. /**
  81899. * Returns a vector with the minimum values from the left and right vectors
  81900. * @param left left vector to minimize
  81901. * @param right right vector to minimize
  81902. * @returns a new vector with the minimum of the left and right vector values
  81903. */
  81904. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81905. /**
  81906. * Returns a vector with the maximum values from the left and right vectors
  81907. * @param left left vector to maximize
  81908. * @param right right vector to maximize
  81909. * @returns a new vector with the maximum of the left and right vector values
  81910. */
  81911. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  81912. /**
  81913. * Returns the distance (float) between the vectors "value1" and "value2".
  81914. * @param value1 value to calulate the distance between
  81915. * @param value2 value to calulate the distance between
  81916. * @return the distance between the two vectors
  81917. */
  81918. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81919. /**
  81920. * Returns the squared distance (float) between the vectors "value1" and "value2".
  81921. * @param value1 value to calulate the distance between
  81922. * @param value2 value to calulate the distance between
  81923. * @return the distance between the two vectors squared
  81924. */
  81925. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  81926. /**
  81927. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  81928. * @param value1 value to calulate the center between
  81929. * @param value2 value to calulate the center between
  81930. * @return the center between the two vectors
  81931. */
  81932. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  81933. /**
  81934. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  81935. * This methods computes transformed normalized direction vectors only.
  81936. * @param vector the vector to transform
  81937. * @param transformation the transformation matrix to apply
  81938. * @returns the new vector
  81939. */
  81940. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  81941. /**
  81942. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  81943. * This methods computes transformed normalized direction vectors only.
  81944. * @param vector the vector to transform
  81945. * @param transformation the transformation matrix to apply
  81946. * @param result the vector to store the result in
  81947. */
  81948. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81949. /**
  81950. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  81951. * This methods computes transformed normalized direction vectors only.
  81952. * @param x value to transform
  81953. * @param y value to transform
  81954. * @param z value to transform
  81955. * @param w value to transform
  81956. * @param transformation the transformation matrix to apply
  81957. * @param result the vector to store the results in
  81958. */
  81959. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  81960. /**
  81961. * Creates a new Vector4 from a Vector3
  81962. * @param source defines the source data
  81963. * @param w defines the 4th component (default is 0)
  81964. * @returns a new Vector4
  81965. */
  81966. static FromVector3(source: Vector3, w?: number): Vector4;
  81967. }
  81968. /**
  81969. * Class used to store quaternion data
  81970. * @see https://en.wikipedia.org/wiki/Quaternion
  81971. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  81972. */
  81973. export class Quaternion {
  81974. /** @hidden */
  81975. _x: number;
  81976. /** @hidden */
  81977. _y: number;
  81978. /** @hidden */
  81979. _z: number;
  81980. /** @hidden */
  81981. _w: number;
  81982. /** @hidden */
  81983. _isDirty: boolean;
  81984. /** Gets or sets the x coordinate */
  81985. get x(): number;
  81986. set x(value: number);
  81987. /** Gets or sets the y coordinate */
  81988. get y(): number;
  81989. set y(value: number);
  81990. /** Gets or sets the z coordinate */
  81991. get z(): number;
  81992. set z(value: number);
  81993. /** Gets or sets the w coordinate */
  81994. get w(): number;
  81995. set w(value: number);
  81996. /**
  81997. * Creates a new Quaternion from the given floats
  81998. * @param x defines the first component (0 by default)
  81999. * @param y defines the second component (0 by default)
  82000. * @param z defines the third component (0 by default)
  82001. * @param w defines the fourth component (1.0 by default)
  82002. */
  82003. constructor(x?: number, y?: number, z?: number, w?: number);
  82004. /**
  82005. * Gets a string representation for the current quaternion
  82006. * @returns a string with the Quaternion coordinates
  82007. */
  82008. toString(): string;
  82009. /**
  82010. * Gets the class name of the quaternion
  82011. * @returns the string "Quaternion"
  82012. */
  82013. getClassName(): string;
  82014. /**
  82015. * Gets a hash code for this quaternion
  82016. * @returns the quaternion hash code
  82017. */
  82018. getHashCode(): number;
  82019. /**
  82020. * Copy the quaternion to an array
  82021. * @returns a new array populated with 4 elements from the quaternion coordinates
  82022. */
  82023. asArray(): number[];
  82024. /**
  82025. * Check if two quaternions are equals
  82026. * @param otherQuaternion defines the second operand
  82027. * @return true if the current quaternion and the given one coordinates are strictly equals
  82028. */
  82029. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  82030. /**
  82031. * Gets a boolean if two quaternions are equals (using an epsilon value)
  82032. * @param otherQuaternion defines the other quaternion
  82033. * @param epsilon defines the minimal distance to consider equality
  82034. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  82035. */
  82036. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  82037. /**
  82038. * Clone the current quaternion
  82039. * @returns a new quaternion copied from the current one
  82040. */
  82041. clone(): Quaternion;
  82042. /**
  82043. * Copy a quaternion to the current one
  82044. * @param other defines the other quaternion
  82045. * @returns the updated current quaternion
  82046. */
  82047. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  82048. /**
  82049. * Updates the current quaternion with the given float coordinates
  82050. * @param x defines the x coordinate
  82051. * @param y defines the y coordinate
  82052. * @param z defines the z coordinate
  82053. * @param w defines the w coordinate
  82054. * @returns the updated current quaternion
  82055. */
  82056. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  82057. /**
  82058. * Updates the current quaternion from the given float coordinates
  82059. * @param x defines the x coordinate
  82060. * @param y defines the y coordinate
  82061. * @param z defines the z coordinate
  82062. * @param w defines the w coordinate
  82063. * @returns the updated current quaternion
  82064. */
  82065. set(x: number, y: number, z: number, w: number): Quaternion;
  82066. /**
  82067. * Adds two quaternions
  82068. * @param other defines the second operand
  82069. * @returns a new quaternion as the addition result of the given one and the current quaternion
  82070. */
  82071. add(other: DeepImmutable<Quaternion>): Quaternion;
  82072. /**
  82073. * Add a quaternion to the current one
  82074. * @param other defines the quaternion to add
  82075. * @returns the current quaternion
  82076. */
  82077. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  82078. /**
  82079. * Subtract two quaternions
  82080. * @param other defines the second operand
  82081. * @returns a new quaternion as the subtraction result of the given one from the current one
  82082. */
  82083. subtract(other: Quaternion): Quaternion;
  82084. /**
  82085. * Multiplies the current quaternion by a scale factor
  82086. * @param value defines the scale factor
  82087. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  82088. */
  82089. scale(value: number): Quaternion;
  82090. /**
  82091. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  82092. * @param scale defines the scale factor
  82093. * @param result defines the Quaternion object where to store the result
  82094. * @returns the unmodified current quaternion
  82095. */
  82096. scaleToRef(scale: number, result: Quaternion): Quaternion;
  82097. /**
  82098. * Multiplies in place the current quaternion by a scale factor
  82099. * @param value defines the scale factor
  82100. * @returns the current modified quaternion
  82101. */
  82102. scaleInPlace(value: number): Quaternion;
  82103. /**
  82104. * Scale the current quaternion values by a factor and add the result to a given quaternion
  82105. * @param scale defines the scale factor
  82106. * @param result defines the Quaternion object where to store the result
  82107. * @returns the unmodified current quaternion
  82108. */
  82109. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  82110. /**
  82111. * Multiplies two quaternions
  82112. * @param q1 defines the second operand
  82113. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  82114. */
  82115. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  82116. /**
  82117. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  82118. * @param q1 defines the second operand
  82119. * @param result defines the target quaternion
  82120. * @returns the current quaternion
  82121. */
  82122. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  82123. /**
  82124. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  82125. * @param q1 defines the second operand
  82126. * @returns the currentupdated quaternion
  82127. */
  82128. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  82129. /**
  82130. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  82131. * @param ref defines the target quaternion
  82132. * @returns the current quaternion
  82133. */
  82134. conjugateToRef(ref: Quaternion): Quaternion;
  82135. /**
  82136. * Conjugates in place (1-q) the current quaternion
  82137. * @returns the current updated quaternion
  82138. */
  82139. conjugateInPlace(): Quaternion;
  82140. /**
  82141. * Conjugates in place (1-q) the current quaternion
  82142. * @returns a new quaternion
  82143. */
  82144. conjugate(): Quaternion;
  82145. /**
  82146. * Gets length of current quaternion
  82147. * @returns the quaternion length (float)
  82148. */
  82149. length(): number;
  82150. /**
  82151. * Normalize in place the current quaternion
  82152. * @returns the current updated quaternion
  82153. */
  82154. normalize(): Quaternion;
  82155. /**
  82156. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  82157. * @param order is a reserved parameter and is ignore for now
  82158. * @returns a new Vector3 containing the Euler angles
  82159. */
  82160. toEulerAngles(order?: string): Vector3;
  82161. /**
  82162. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  82163. * @param result defines the vector which will be filled with the Euler angles
  82164. * @param order is a reserved parameter and is ignore for now
  82165. * @returns the current unchanged quaternion
  82166. */
  82167. toEulerAnglesToRef(result: Vector3): Quaternion;
  82168. /**
  82169. * Updates the given rotation matrix with the current quaternion values
  82170. * @param result defines the target matrix
  82171. * @returns the current unchanged quaternion
  82172. */
  82173. toRotationMatrix(result: Matrix): Quaternion;
  82174. /**
  82175. * Updates the current quaternion from the given rotation matrix values
  82176. * @param matrix defines the source matrix
  82177. * @returns the current updated quaternion
  82178. */
  82179. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82180. /**
  82181. * Creates a new quaternion from a rotation matrix
  82182. * @param matrix defines the source matrix
  82183. * @returns a new quaternion created from the given rotation matrix values
  82184. */
  82185. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  82186. /**
  82187. * Updates the given quaternion with the given rotation matrix values
  82188. * @param matrix defines the source matrix
  82189. * @param result defines the target quaternion
  82190. */
  82191. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  82192. /**
  82193. * Returns the dot product (float) between the quaternions "left" and "right"
  82194. * @param left defines the left operand
  82195. * @param right defines the right operand
  82196. * @returns the dot product
  82197. */
  82198. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  82199. /**
  82200. * Checks if the two quaternions are close to each other
  82201. * @param quat0 defines the first quaternion to check
  82202. * @param quat1 defines the second quaternion to check
  82203. * @returns true if the two quaternions are close to each other
  82204. */
  82205. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  82206. /**
  82207. * Creates an empty quaternion
  82208. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  82209. */
  82210. static Zero(): Quaternion;
  82211. /**
  82212. * Inverse a given quaternion
  82213. * @param q defines the source quaternion
  82214. * @returns a new quaternion as the inverted current quaternion
  82215. */
  82216. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  82217. /**
  82218. * Inverse a given quaternion
  82219. * @param q defines the source quaternion
  82220. * @param result the quaternion the result will be stored in
  82221. * @returns the result quaternion
  82222. */
  82223. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  82224. /**
  82225. * Creates an identity quaternion
  82226. * @returns the identity quaternion
  82227. */
  82228. static Identity(): Quaternion;
  82229. /**
  82230. * Gets a boolean indicating if the given quaternion is identity
  82231. * @param quaternion defines the quaternion to check
  82232. * @returns true if the quaternion is identity
  82233. */
  82234. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  82235. /**
  82236. * Creates a quaternion from a rotation around an axis
  82237. * @param axis defines the axis to use
  82238. * @param angle defines the angle to use
  82239. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  82240. */
  82241. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  82242. /**
  82243. * Creates a rotation around an axis and stores it into the given quaternion
  82244. * @param axis defines the axis to use
  82245. * @param angle defines the angle to use
  82246. * @param result defines the target quaternion
  82247. * @returns the target quaternion
  82248. */
  82249. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  82250. /**
  82251. * Creates a new quaternion from data stored into an array
  82252. * @param array defines the data source
  82253. * @param offset defines the offset in the source array where the data starts
  82254. * @returns a new quaternion
  82255. */
  82256. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  82257. /**
  82258. * Updates the given quaternion "result" from the starting index of the given array.
  82259. * @param array the array to pull values from
  82260. * @param offset the offset into the array to start at
  82261. * @param result the quaternion to store the result in
  82262. */
  82263. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  82264. /**
  82265. * Create a quaternion from Euler rotation angles
  82266. * @param x Pitch
  82267. * @param y Yaw
  82268. * @param z Roll
  82269. * @returns the new Quaternion
  82270. */
  82271. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  82272. /**
  82273. * Updates a quaternion from Euler rotation angles
  82274. * @param x Pitch
  82275. * @param y Yaw
  82276. * @param z Roll
  82277. * @param result the quaternion to store the result
  82278. * @returns the updated quaternion
  82279. */
  82280. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  82281. /**
  82282. * Create a quaternion from Euler rotation vector
  82283. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82284. * @returns the new Quaternion
  82285. */
  82286. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  82287. /**
  82288. * Updates a quaternion from Euler rotation vector
  82289. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  82290. * @param result the quaternion to store the result
  82291. * @returns the updated quaternion
  82292. */
  82293. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  82294. /**
  82295. * Creates a new quaternion from the given Euler float angles (y, x, z)
  82296. * @param yaw defines the rotation around Y axis
  82297. * @param pitch defines the rotation around X axis
  82298. * @param roll defines the rotation around Z axis
  82299. * @returns the new quaternion
  82300. */
  82301. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  82302. /**
  82303. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  82304. * @param yaw defines the rotation around Y axis
  82305. * @param pitch defines the rotation around X axis
  82306. * @param roll defines the rotation around Z axis
  82307. * @param result defines the target quaternion
  82308. */
  82309. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  82310. /**
  82311. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  82312. * @param alpha defines the rotation around first axis
  82313. * @param beta defines the rotation around second axis
  82314. * @param gamma defines the rotation around third axis
  82315. * @returns the new quaternion
  82316. */
  82317. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  82318. /**
  82319. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  82320. * @param alpha defines the rotation around first axis
  82321. * @param beta defines the rotation around second axis
  82322. * @param gamma defines the rotation around third axis
  82323. * @param result defines the target quaternion
  82324. */
  82325. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  82326. /**
  82327. * 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)
  82328. * @param axis1 defines the first axis
  82329. * @param axis2 defines the second axis
  82330. * @param axis3 defines the third axis
  82331. * @returns the new quaternion
  82332. */
  82333. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  82334. /**
  82335. * 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
  82336. * @param axis1 defines the first axis
  82337. * @param axis2 defines the second axis
  82338. * @param axis3 defines the third axis
  82339. * @param ref defines the target quaternion
  82340. */
  82341. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  82342. /**
  82343. * Interpolates between two quaternions
  82344. * @param left defines first quaternion
  82345. * @param right defines second quaternion
  82346. * @param amount defines the gradient to use
  82347. * @returns the new interpolated quaternion
  82348. */
  82349. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82350. /**
  82351. * Interpolates between two quaternions and stores it into a target quaternion
  82352. * @param left defines first quaternion
  82353. * @param right defines second quaternion
  82354. * @param amount defines the gradient to use
  82355. * @param result defines the target quaternion
  82356. */
  82357. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  82358. /**
  82359. * Interpolate between two quaternions using Hermite interpolation
  82360. * @param value1 defines first quaternion
  82361. * @param tangent1 defines the incoming tangent
  82362. * @param value2 defines second quaternion
  82363. * @param tangent2 defines the outgoing tangent
  82364. * @param amount defines the target quaternion
  82365. * @returns the new interpolated quaternion
  82366. */
  82367. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  82368. }
  82369. /**
  82370. * Class used to store matrix data (4x4)
  82371. */
  82372. export class Matrix {
  82373. private static _updateFlagSeed;
  82374. private static _identityReadOnly;
  82375. private _isIdentity;
  82376. private _isIdentityDirty;
  82377. private _isIdentity3x2;
  82378. private _isIdentity3x2Dirty;
  82379. /**
  82380. * Gets the update flag of the matrix which is an unique number for the matrix.
  82381. * It will be incremented every time the matrix data change.
  82382. * You can use it to speed the comparison between two versions of the same matrix.
  82383. */
  82384. updateFlag: number;
  82385. private readonly _m;
  82386. /**
  82387. * Gets the internal data of the matrix
  82388. */
  82389. get m(): DeepImmutable<Float32Array>;
  82390. /** @hidden */
  82391. _markAsUpdated(): void;
  82392. /** @hidden */
  82393. private _updateIdentityStatus;
  82394. /**
  82395. * Creates an empty matrix (filled with zeros)
  82396. */
  82397. constructor();
  82398. /**
  82399. * Check if the current matrix is identity
  82400. * @returns true is the matrix is the identity matrix
  82401. */
  82402. isIdentity(): boolean;
  82403. /**
  82404. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  82405. * @returns true is the matrix is the identity matrix
  82406. */
  82407. isIdentityAs3x2(): boolean;
  82408. /**
  82409. * Gets the determinant of the matrix
  82410. * @returns the matrix determinant
  82411. */
  82412. determinant(): number;
  82413. /**
  82414. * Returns the matrix as a Float32Array
  82415. * @returns the matrix underlying array
  82416. */
  82417. toArray(): DeepImmutable<Float32Array>;
  82418. /**
  82419. * Returns the matrix as a Float32Array
  82420. * @returns the matrix underlying array.
  82421. */
  82422. asArray(): DeepImmutable<Float32Array>;
  82423. /**
  82424. * Inverts the current matrix in place
  82425. * @returns the current inverted matrix
  82426. */
  82427. invert(): Matrix;
  82428. /**
  82429. * Sets all the matrix elements to zero
  82430. * @returns the current matrix
  82431. */
  82432. reset(): Matrix;
  82433. /**
  82434. * Adds the current matrix with a second one
  82435. * @param other defines the matrix to add
  82436. * @returns a new matrix as the addition of the current matrix and the given one
  82437. */
  82438. add(other: DeepImmutable<Matrix>): Matrix;
  82439. /**
  82440. * Sets the given matrix "result" to the addition of the current matrix and the given one
  82441. * @param other defines the matrix to add
  82442. * @param result defines the target matrix
  82443. * @returns the current matrix
  82444. */
  82445. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82446. /**
  82447. * Adds in place the given matrix to the current matrix
  82448. * @param other defines the second operand
  82449. * @returns the current updated matrix
  82450. */
  82451. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  82452. /**
  82453. * Sets the given matrix to the current inverted Matrix
  82454. * @param other defines the target matrix
  82455. * @returns the unmodified current matrix
  82456. */
  82457. invertToRef(other: Matrix): Matrix;
  82458. /**
  82459. * add a value at the specified position in the current Matrix
  82460. * @param index the index of the value within the matrix. between 0 and 15.
  82461. * @param value the value to be added
  82462. * @returns the current updated matrix
  82463. */
  82464. addAtIndex(index: number, value: number): Matrix;
  82465. /**
  82466. * mutiply the specified position in the current Matrix by a value
  82467. * @param index the index of the value within the matrix. between 0 and 15.
  82468. * @param value the value to be added
  82469. * @returns the current updated matrix
  82470. */
  82471. multiplyAtIndex(index: number, value: number): Matrix;
  82472. /**
  82473. * Inserts the translation vector (using 3 floats) in the current matrix
  82474. * @param x defines the 1st component of the translation
  82475. * @param y defines the 2nd component of the translation
  82476. * @param z defines the 3rd component of the translation
  82477. * @returns the current updated matrix
  82478. */
  82479. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82480. /**
  82481. * Adds the translation vector (using 3 floats) in the current matrix
  82482. * @param x defines the 1st component of the translation
  82483. * @param y defines the 2nd component of the translation
  82484. * @param z defines the 3rd component of the translation
  82485. * @returns the current updated matrix
  82486. */
  82487. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  82488. /**
  82489. * Inserts the translation vector in the current matrix
  82490. * @param vector3 defines the translation to insert
  82491. * @returns the current updated matrix
  82492. */
  82493. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  82494. /**
  82495. * Gets the translation value of the current matrix
  82496. * @returns a new Vector3 as the extracted translation from the matrix
  82497. */
  82498. getTranslation(): Vector3;
  82499. /**
  82500. * Fill a Vector3 with the extracted translation from the matrix
  82501. * @param result defines the Vector3 where to store the translation
  82502. * @returns the current matrix
  82503. */
  82504. getTranslationToRef(result: Vector3): Matrix;
  82505. /**
  82506. * Remove rotation and scaling part from the matrix
  82507. * @returns the updated matrix
  82508. */
  82509. removeRotationAndScaling(): Matrix;
  82510. /**
  82511. * Multiply two matrices
  82512. * @param other defines the second operand
  82513. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  82514. */
  82515. multiply(other: DeepImmutable<Matrix>): Matrix;
  82516. /**
  82517. * Copy the current matrix from the given one
  82518. * @param other defines the source matrix
  82519. * @returns the current updated matrix
  82520. */
  82521. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  82522. /**
  82523. * Populates the given array from the starting index with the current matrix values
  82524. * @param array defines the target array
  82525. * @param offset defines the offset in the target array where to start storing values
  82526. * @returns the current matrix
  82527. */
  82528. copyToArray(array: Float32Array, offset?: number): Matrix;
  82529. /**
  82530. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  82531. * @param other defines the second operand
  82532. * @param result defines the matrix where to store the multiplication
  82533. * @returns the current matrix
  82534. */
  82535. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  82536. /**
  82537. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  82538. * @param other defines the second operand
  82539. * @param result defines the array where to store the multiplication
  82540. * @param offset defines the offset in the target array where to start storing values
  82541. * @returns the current matrix
  82542. */
  82543. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  82544. /**
  82545. * Check equality between this matrix and a second one
  82546. * @param value defines the second matrix to compare
  82547. * @returns true is the current matrix and the given one values are strictly equal
  82548. */
  82549. equals(value: DeepImmutable<Matrix>): boolean;
  82550. /**
  82551. * Clone the current matrix
  82552. * @returns a new matrix from the current matrix
  82553. */
  82554. clone(): Matrix;
  82555. /**
  82556. * Returns the name of the current matrix class
  82557. * @returns the string "Matrix"
  82558. */
  82559. getClassName(): string;
  82560. /**
  82561. * Gets the hash code of the current matrix
  82562. * @returns the hash code
  82563. */
  82564. getHashCode(): number;
  82565. /**
  82566. * Decomposes the current Matrix into a translation, rotation and scaling components
  82567. * @param scale defines the scale vector3 given as a reference to update
  82568. * @param rotation defines the rotation quaternion given as a reference to update
  82569. * @param translation defines the translation vector3 given as a reference to update
  82570. * @returns true if operation was successful
  82571. */
  82572. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  82573. /**
  82574. * Gets specific row of the matrix
  82575. * @param index defines the number of the row to get
  82576. * @returns the index-th row of the current matrix as a new Vector4
  82577. */
  82578. getRow(index: number): Nullable<Vector4>;
  82579. /**
  82580. * Sets the index-th row of the current matrix to the vector4 values
  82581. * @param index defines the number of the row to set
  82582. * @param row defines the target vector4
  82583. * @returns the updated current matrix
  82584. */
  82585. setRow(index: number, row: Vector4): Matrix;
  82586. /**
  82587. * Compute the transpose of the matrix
  82588. * @returns the new transposed matrix
  82589. */
  82590. transpose(): Matrix;
  82591. /**
  82592. * Compute the transpose of the matrix and store it in a given matrix
  82593. * @param result defines the target matrix
  82594. * @returns the current matrix
  82595. */
  82596. transposeToRef(result: Matrix): Matrix;
  82597. /**
  82598. * Sets the index-th row of the current matrix with the given 4 x float values
  82599. * @param index defines the row index
  82600. * @param x defines the x component to set
  82601. * @param y defines the y component to set
  82602. * @param z defines the z component to set
  82603. * @param w defines the w component to set
  82604. * @returns the updated current matrix
  82605. */
  82606. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  82607. /**
  82608. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  82609. * @param scale defines the scale factor
  82610. * @returns a new matrix
  82611. */
  82612. scale(scale: number): Matrix;
  82613. /**
  82614. * Scale the current matrix values by a factor to a given result matrix
  82615. * @param scale defines the scale factor
  82616. * @param result defines the matrix to store the result
  82617. * @returns the current matrix
  82618. */
  82619. scaleToRef(scale: number, result: Matrix): Matrix;
  82620. /**
  82621. * Scale the current matrix values by a factor and add the result to a given matrix
  82622. * @param scale defines the scale factor
  82623. * @param result defines the Matrix to store the result
  82624. * @returns the current matrix
  82625. */
  82626. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  82627. /**
  82628. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  82629. * @param ref matrix to store the result
  82630. */
  82631. toNormalMatrix(ref: Matrix): void;
  82632. /**
  82633. * Gets only rotation part of the current matrix
  82634. * @returns a new matrix sets to the extracted rotation matrix from the current one
  82635. */
  82636. getRotationMatrix(): Matrix;
  82637. /**
  82638. * Extracts the rotation matrix from the current one and sets it as the given "result"
  82639. * @param result defines the target matrix to store data to
  82640. * @returns the current matrix
  82641. */
  82642. getRotationMatrixToRef(result: Matrix): Matrix;
  82643. /**
  82644. * Toggles model matrix from being right handed to left handed in place and vice versa
  82645. */
  82646. toggleModelMatrixHandInPlace(): void;
  82647. /**
  82648. * Toggles projection matrix from being right handed to left handed in place and vice versa
  82649. */
  82650. toggleProjectionMatrixHandInPlace(): void;
  82651. /**
  82652. * Creates a matrix from an array
  82653. * @param array defines the source array
  82654. * @param offset defines an offset in the source array
  82655. * @returns a new Matrix set from the starting index of the given array
  82656. */
  82657. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  82658. /**
  82659. * Copy the content of an array into a given matrix
  82660. * @param array defines the source array
  82661. * @param offset defines an offset in the source array
  82662. * @param result defines the target matrix
  82663. */
  82664. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  82665. /**
  82666. * Stores an array into a matrix after having multiplied each component by a given factor
  82667. * @param array defines the source array
  82668. * @param offset defines the offset in the source array
  82669. * @param scale defines the scaling factor
  82670. * @param result defines the target matrix
  82671. */
  82672. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  82673. /**
  82674. * Gets an identity matrix that must not be updated
  82675. */
  82676. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  82677. /**
  82678. * Stores a list of values (16) inside a given matrix
  82679. * @param initialM11 defines 1st value of 1st row
  82680. * @param initialM12 defines 2nd value of 1st row
  82681. * @param initialM13 defines 3rd value of 1st row
  82682. * @param initialM14 defines 4th value of 1st row
  82683. * @param initialM21 defines 1st value of 2nd row
  82684. * @param initialM22 defines 2nd value of 2nd row
  82685. * @param initialM23 defines 3rd value of 2nd row
  82686. * @param initialM24 defines 4th value of 2nd row
  82687. * @param initialM31 defines 1st value of 3rd row
  82688. * @param initialM32 defines 2nd value of 3rd row
  82689. * @param initialM33 defines 3rd value of 3rd row
  82690. * @param initialM34 defines 4th value of 3rd row
  82691. * @param initialM41 defines 1st value of 4th row
  82692. * @param initialM42 defines 2nd value of 4th row
  82693. * @param initialM43 defines 3rd value of 4th row
  82694. * @param initialM44 defines 4th value of 4th row
  82695. * @param result defines the target matrix
  82696. */
  82697. 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;
  82698. /**
  82699. * Creates new matrix from a list of values (16)
  82700. * @param initialM11 defines 1st value of 1st row
  82701. * @param initialM12 defines 2nd value of 1st row
  82702. * @param initialM13 defines 3rd value of 1st row
  82703. * @param initialM14 defines 4th value of 1st row
  82704. * @param initialM21 defines 1st value of 2nd row
  82705. * @param initialM22 defines 2nd value of 2nd row
  82706. * @param initialM23 defines 3rd value of 2nd row
  82707. * @param initialM24 defines 4th value of 2nd row
  82708. * @param initialM31 defines 1st value of 3rd row
  82709. * @param initialM32 defines 2nd value of 3rd row
  82710. * @param initialM33 defines 3rd value of 3rd row
  82711. * @param initialM34 defines 4th value of 3rd row
  82712. * @param initialM41 defines 1st value of 4th row
  82713. * @param initialM42 defines 2nd value of 4th row
  82714. * @param initialM43 defines 3rd value of 4th row
  82715. * @param initialM44 defines 4th value of 4th row
  82716. * @returns the new matrix
  82717. */
  82718. 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;
  82719. /**
  82720. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82721. * @param scale defines the scale vector3
  82722. * @param rotation defines the rotation quaternion
  82723. * @param translation defines the translation vector3
  82724. * @returns a new matrix
  82725. */
  82726. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  82727. /**
  82728. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  82729. * @param scale defines the scale vector3
  82730. * @param rotation defines the rotation quaternion
  82731. * @param translation defines the translation vector3
  82732. * @param result defines the target matrix
  82733. */
  82734. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  82735. /**
  82736. * Creates a new identity matrix
  82737. * @returns a new identity matrix
  82738. */
  82739. static Identity(): Matrix;
  82740. /**
  82741. * Creates a new identity matrix and stores the result in a given matrix
  82742. * @param result defines the target matrix
  82743. */
  82744. static IdentityToRef(result: Matrix): void;
  82745. /**
  82746. * Creates a new zero matrix
  82747. * @returns a new zero matrix
  82748. */
  82749. static Zero(): Matrix;
  82750. /**
  82751. * Creates a new rotation matrix for "angle" radians around the X axis
  82752. * @param angle defines the angle (in radians) to use
  82753. * @return the new matrix
  82754. */
  82755. static RotationX(angle: number): Matrix;
  82756. /**
  82757. * Creates a new matrix as the invert of a given matrix
  82758. * @param source defines the source matrix
  82759. * @returns the new matrix
  82760. */
  82761. static Invert(source: DeepImmutable<Matrix>): Matrix;
  82762. /**
  82763. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  82764. * @param angle defines the angle (in radians) to use
  82765. * @param result defines the target matrix
  82766. */
  82767. static RotationXToRef(angle: number, result: Matrix): void;
  82768. /**
  82769. * Creates a new rotation matrix for "angle" radians around the Y axis
  82770. * @param angle defines the angle (in radians) to use
  82771. * @return the new matrix
  82772. */
  82773. static RotationY(angle: number): Matrix;
  82774. /**
  82775. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  82776. * @param angle defines the angle (in radians) to use
  82777. * @param result defines the target matrix
  82778. */
  82779. static RotationYToRef(angle: number, result: Matrix): void;
  82780. /**
  82781. * Creates a new rotation matrix for "angle" radians around the Z axis
  82782. * @param angle defines the angle (in radians) to use
  82783. * @return the new matrix
  82784. */
  82785. static RotationZ(angle: number): Matrix;
  82786. /**
  82787. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  82788. * @param angle defines the angle (in radians) to use
  82789. * @param result defines the target matrix
  82790. */
  82791. static RotationZToRef(angle: number, result: Matrix): void;
  82792. /**
  82793. * Creates a new rotation matrix for "angle" radians around the given axis
  82794. * @param axis defines the axis to use
  82795. * @param angle defines the angle (in radians) to use
  82796. * @return the new matrix
  82797. */
  82798. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  82799. /**
  82800. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  82801. * @param axis defines the axis to use
  82802. * @param angle defines the angle (in radians) to use
  82803. * @param result defines the target matrix
  82804. */
  82805. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  82806. /**
  82807. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  82808. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  82809. * @param from defines the vector to align
  82810. * @param to defines the vector to align to
  82811. * @param result defines the target matrix
  82812. */
  82813. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  82814. /**
  82815. * Creates a rotation matrix
  82816. * @param yaw defines the yaw angle in radians (Y axis)
  82817. * @param pitch defines the pitch angle in radians (X axis)
  82818. * @param roll defines the roll angle in radians (X axis)
  82819. * @returns the new rotation matrix
  82820. */
  82821. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  82822. /**
  82823. * Creates a rotation matrix and stores it in a given matrix
  82824. * @param yaw defines the yaw angle in radians (Y axis)
  82825. * @param pitch defines the pitch angle in radians (X axis)
  82826. * @param roll defines the roll angle in radians (X axis)
  82827. * @param result defines the target matrix
  82828. */
  82829. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  82830. /**
  82831. * Creates a scaling matrix
  82832. * @param x defines the scale factor on X axis
  82833. * @param y defines the scale factor on Y axis
  82834. * @param z defines the scale factor on Z axis
  82835. * @returns the new matrix
  82836. */
  82837. static Scaling(x: number, y: number, z: number): Matrix;
  82838. /**
  82839. * Creates a scaling matrix and stores it in a given matrix
  82840. * @param x defines the scale factor on X axis
  82841. * @param y defines the scale factor on Y axis
  82842. * @param z defines the scale factor on Z axis
  82843. * @param result defines the target matrix
  82844. */
  82845. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  82846. /**
  82847. * Creates a translation matrix
  82848. * @param x defines the translation on X axis
  82849. * @param y defines the translation on Y axis
  82850. * @param z defines the translationon Z axis
  82851. * @returns the new matrix
  82852. */
  82853. static Translation(x: number, y: number, z: number): Matrix;
  82854. /**
  82855. * Creates a translation matrix and stores it in a given matrix
  82856. * @param x defines the translation on X axis
  82857. * @param y defines the translation on Y axis
  82858. * @param z defines the translationon Z axis
  82859. * @param result defines the target matrix
  82860. */
  82861. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  82862. /**
  82863. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82864. * @param startValue defines the start value
  82865. * @param endValue defines the end value
  82866. * @param gradient defines the gradient factor
  82867. * @returns the new matrix
  82868. */
  82869. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82870. /**
  82871. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  82872. * @param startValue defines the start value
  82873. * @param endValue defines the end value
  82874. * @param gradient defines the gradient factor
  82875. * @param result defines the Matrix object where to store data
  82876. */
  82877. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82878. /**
  82879. * Builds a new matrix whose values are computed by:
  82880. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82881. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82882. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82883. * @param startValue defines the first matrix
  82884. * @param endValue defines the second matrix
  82885. * @param gradient defines the gradient between the two matrices
  82886. * @returns the new matrix
  82887. */
  82888. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  82889. /**
  82890. * Update a matrix to values which are computed by:
  82891. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  82892. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  82893. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  82894. * @param startValue defines the first matrix
  82895. * @param endValue defines the second matrix
  82896. * @param gradient defines the gradient between the two matrices
  82897. * @param result defines the target matrix
  82898. */
  82899. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  82900. /**
  82901. * 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"
  82902. * This function works in left handed mode
  82903. * @param eye defines the final position of the entity
  82904. * @param target defines where the entity should look at
  82905. * @param up defines the up vector for the entity
  82906. * @returns the new matrix
  82907. */
  82908. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82909. /**
  82910. * 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".
  82911. * This function works in left handed mode
  82912. * @param eye defines the final position of the entity
  82913. * @param target defines where the entity should look at
  82914. * @param up defines the up vector for the entity
  82915. * @param result defines the target matrix
  82916. */
  82917. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82918. /**
  82919. * 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"
  82920. * This function works in right handed mode
  82921. * @param eye defines the final position of the entity
  82922. * @param target defines where the entity should look at
  82923. * @param up defines the up vector for the entity
  82924. * @returns the new matrix
  82925. */
  82926. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  82927. /**
  82928. * 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".
  82929. * This function works in right handed mode
  82930. * @param eye defines the final position of the entity
  82931. * @param target defines where the entity should look at
  82932. * @param up defines the up vector for the entity
  82933. * @param result defines the target matrix
  82934. */
  82935. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  82936. /**
  82937. * Create a left-handed orthographic projection matrix
  82938. * @param width defines the viewport width
  82939. * @param height defines the viewport height
  82940. * @param znear defines the near clip plane
  82941. * @param zfar defines the far clip plane
  82942. * @returns a new matrix as a left-handed orthographic projection matrix
  82943. */
  82944. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  82945. /**
  82946. * Store a left-handed orthographic projection to a given matrix
  82947. * @param width defines the viewport width
  82948. * @param height defines the viewport height
  82949. * @param znear defines the near clip plane
  82950. * @param zfar defines the far clip plane
  82951. * @param result defines the target matrix
  82952. */
  82953. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  82954. /**
  82955. * Create a left-handed orthographic projection matrix
  82956. * @param left defines the viewport left coordinate
  82957. * @param right defines the viewport right coordinate
  82958. * @param bottom defines the viewport bottom coordinate
  82959. * @param top defines the viewport top coordinate
  82960. * @param znear defines the near clip plane
  82961. * @param zfar defines the far clip plane
  82962. * @returns a new matrix as a left-handed orthographic projection matrix
  82963. */
  82964. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82965. /**
  82966. * Stores a left-handed orthographic projection into a given matrix
  82967. * @param left defines the viewport left coordinate
  82968. * @param right defines the viewport right coordinate
  82969. * @param bottom defines the viewport bottom coordinate
  82970. * @param top defines the viewport top coordinate
  82971. * @param znear defines the near clip plane
  82972. * @param zfar defines the far clip plane
  82973. * @param result defines the target matrix
  82974. */
  82975. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82976. /**
  82977. * Creates a right-handed orthographic projection matrix
  82978. * @param left defines the viewport left coordinate
  82979. * @param right defines the viewport right coordinate
  82980. * @param bottom defines the viewport bottom coordinate
  82981. * @param top defines the viewport top coordinate
  82982. * @param znear defines the near clip plane
  82983. * @param zfar defines the far clip plane
  82984. * @returns a new matrix as a right-handed orthographic projection matrix
  82985. */
  82986. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  82987. /**
  82988. * Stores a right-handed orthographic projection into a given matrix
  82989. * @param left defines the viewport left coordinate
  82990. * @param right defines the viewport right coordinate
  82991. * @param bottom defines the viewport bottom coordinate
  82992. * @param top defines the viewport top coordinate
  82993. * @param znear defines the near clip plane
  82994. * @param zfar defines the far clip plane
  82995. * @param result defines the target matrix
  82996. */
  82997. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  82998. /**
  82999. * Creates a left-handed perspective projection matrix
  83000. * @param width defines the viewport width
  83001. * @param height defines the viewport height
  83002. * @param znear defines the near clip plane
  83003. * @param zfar defines the far clip plane
  83004. * @returns a new matrix as a left-handed perspective projection matrix
  83005. */
  83006. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  83007. /**
  83008. * Creates a left-handed perspective projection matrix
  83009. * @param fov defines the horizontal field of view
  83010. * @param aspect defines the aspect ratio
  83011. * @param znear defines the near clip plane
  83012. * @param zfar defines the far clip plane
  83013. * @returns a new matrix as a left-handed perspective projection matrix
  83014. */
  83015. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83016. /**
  83017. * Stores a left-handed perspective projection into a given matrix
  83018. * @param fov defines the horizontal field of view
  83019. * @param aspect defines the aspect ratio
  83020. * @param znear defines the near clip plane
  83021. * @param zfar defines the far clip plane
  83022. * @param result defines the target matrix
  83023. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83024. */
  83025. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83026. /**
  83027. * Stores a left-handed perspective projection into a given matrix with depth reversed
  83028. * @param fov defines the horizontal field of view
  83029. * @param aspect defines the aspect ratio
  83030. * @param znear defines the near clip plane
  83031. * @param zfar not used as infinity is used as far clip
  83032. * @param result defines the target matrix
  83033. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83034. */
  83035. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83036. /**
  83037. * Creates a right-handed perspective projection matrix
  83038. * @param fov defines the horizontal field of view
  83039. * @param aspect defines the aspect ratio
  83040. * @param znear defines the near clip plane
  83041. * @param zfar defines the far clip plane
  83042. * @returns a new matrix as a right-handed perspective projection matrix
  83043. */
  83044. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  83045. /**
  83046. * Stores a right-handed perspective projection into a given matrix
  83047. * @param fov defines the horizontal field of view
  83048. * @param aspect defines the aspect ratio
  83049. * @param znear defines the near clip plane
  83050. * @param zfar defines the far clip plane
  83051. * @param result defines the target matrix
  83052. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83053. */
  83054. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83055. /**
  83056. * Stores a right-handed perspective projection into a given matrix
  83057. * @param fov defines the horizontal field of view
  83058. * @param aspect defines the aspect ratio
  83059. * @param znear defines the near clip plane
  83060. * @param zfar not used as infinity is used as far clip
  83061. * @param result defines the target matrix
  83062. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  83063. */
  83064. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  83065. /**
  83066. * Stores a perspective projection for WebVR info a given matrix
  83067. * @param fov defines the field of view
  83068. * @param znear defines the near clip plane
  83069. * @param zfar defines the far clip plane
  83070. * @param result defines the target matrix
  83071. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  83072. */
  83073. static PerspectiveFovWebVRToRef(fov: {
  83074. upDegrees: number;
  83075. downDegrees: number;
  83076. leftDegrees: number;
  83077. rightDegrees: number;
  83078. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  83079. /**
  83080. * Computes a complete transformation matrix
  83081. * @param viewport defines the viewport to use
  83082. * @param world defines the world matrix
  83083. * @param view defines the view matrix
  83084. * @param projection defines the projection matrix
  83085. * @param zmin defines the near clip plane
  83086. * @param zmax defines the far clip plane
  83087. * @returns the transformation matrix
  83088. */
  83089. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  83090. /**
  83091. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  83092. * @param matrix defines the matrix to use
  83093. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  83094. */
  83095. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  83096. /**
  83097. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  83098. * @param matrix defines the matrix to use
  83099. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  83100. */
  83101. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  83102. /**
  83103. * Compute the transpose of a given matrix
  83104. * @param matrix defines the matrix to transpose
  83105. * @returns the new matrix
  83106. */
  83107. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  83108. /**
  83109. * Compute the transpose of a matrix and store it in a target matrix
  83110. * @param matrix defines the matrix to transpose
  83111. * @param result defines the target matrix
  83112. */
  83113. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  83114. /**
  83115. * Computes a reflection matrix from a plane
  83116. * @param plane defines the reflection plane
  83117. * @returns a new matrix
  83118. */
  83119. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  83120. /**
  83121. * Computes a reflection matrix from a plane
  83122. * @param plane defines the reflection plane
  83123. * @param result defines the target matrix
  83124. */
  83125. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  83126. /**
  83127. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  83128. * @param xaxis defines the value of the 1st axis
  83129. * @param yaxis defines the value of the 2nd axis
  83130. * @param zaxis defines the value of the 3rd axis
  83131. * @param result defines the target matrix
  83132. */
  83133. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  83134. /**
  83135. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  83136. * @param quat defines the quaternion to use
  83137. * @param result defines the target matrix
  83138. */
  83139. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  83140. }
  83141. /**
  83142. * @hidden
  83143. */
  83144. export class TmpVectors {
  83145. static Vector2: Vector2[];
  83146. static Vector3: Vector3[];
  83147. static Vector4: Vector4[];
  83148. static Quaternion: Quaternion[];
  83149. static Matrix: Matrix[];
  83150. }
  83151. }
  83152. declare module BABYLON {
  83153. /**
  83154. * Defines potential orientation for back face culling
  83155. */
  83156. export enum Orientation {
  83157. /**
  83158. * Clockwise
  83159. */
  83160. CW = 0,
  83161. /** Counter clockwise */
  83162. CCW = 1
  83163. }
  83164. /** Class used to represent a Bezier curve */
  83165. export class BezierCurve {
  83166. /**
  83167. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  83168. * @param t defines the time
  83169. * @param x1 defines the left coordinate on X axis
  83170. * @param y1 defines the left coordinate on Y axis
  83171. * @param x2 defines the right coordinate on X axis
  83172. * @param y2 defines the right coordinate on Y axis
  83173. * @returns the interpolated value
  83174. */
  83175. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  83176. }
  83177. /**
  83178. * Defines angle representation
  83179. */
  83180. export class Angle {
  83181. private _radians;
  83182. /**
  83183. * Creates an Angle object of "radians" radians (float).
  83184. * @param radians the angle in radians
  83185. */
  83186. constructor(radians: number);
  83187. /**
  83188. * Get value in degrees
  83189. * @returns the Angle value in degrees (float)
  83190. */
  83191. degrees(): number;
  83192. /**
  83193. * Get value in radians
  83194. * @returns the Angle value in radians (float)
  83195. */
  83196. radians(): number;
  83197. /**
  83198. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  83199. * @param a defines first point as the origin
  83200. * @param b defines point
  83201. * @returns a new Angle
  83202. */
  83203. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  83204. /**
  83205. * Gets a new Angle object from the given float in radians
  83206. * @param radians defines the angle value in radians
  83207. * @returns a new Angle
  83208. */
  83209. static FromRadians(radians: number): Angle;
  83210. /**
  83211. * Gets a new Angle object from the given float in degrees
  83212. * @param degrees defines the angle value in degrees
  83213. * @returns a new Angle
  83214. */
  83215. static FromDegrees(degrees: number): Angle;
  83216. }
  83217. /**
  83218. * This represents an arc in a 2d space.
  83219. */
  83220. export class Arc2 {
  83221. /** Defines the start point of the arc */
  83222. startPoint: Vector2;
  83223. /** Defines the mid point of the arc */
  83224. midPoint: Vector2;
  83225. /** Defines the end point of the arc */
  83226. endPoint: Vector2;
  83227. /**
  83228. * Defines the center point of the arc.
  83229. */
  83230. centerPoint: Vector2;
  83231. /**
  83232. * Defines the radius of the arc.
  83233. */
  83234. radius: number;
  83235. /**
  83236. * Defines the angle of the arc (from mid point to end point).
  83237. */
  83238. angle: Angle;
  83239. /**
  83240. * Defines the start angle of the arc (from start point to middle point).
  83241. */
  83242. startAngle: Angle;
  83243. /**
  83244. * Defines the orientation of the arc (clock wise/counter clock wise).
  83245. */
  83246. orientation: Orientation;
  83247. /**
  83248. * Creates an Arc object from the three given points : start, middle and end.
  83249. * @param startPoint Defines the start point of the arc
  83250. * @param midPoint Defines the midlle point of the arc
  83251. * @param endPoint Defines the end point of the arc
  83252. */
  83253. constructor(
  83254. /** Defines the start point of the arc */
  83255. startPoint: Vector2,
  83256. /** Defines the mid point of the arc */
  83257. midPoint: Vector2,
  83258. /** Defines the end point of the arc */
  83259. endPoint: Vector2);
  83260. }
  83261. /**
  83262. * Represents a 2D path made up of multiple 2D points
  83263. */
  83264. export class Path2 {
  83265. private _points;
  83266. private _length;
  83267. /**
  83268. * If the path start and end point are the same
  83269. */
  83270. closed: boolean;
  83271. /**
  83272. * Creates a Path2 object from the starting 2D coordinates x and y.
  83273. * @param x the starting points x value
  83274. * @param y the starting points y value
  83275. */
  83276. constructor(x: number, y: number);
  83277. /**
  83278. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  83279. * @param x the added points x value
  83280. * @param y the added points y value
  83281. * @returns the updated Path2.
  83282. */
  83283. addLineTo(x: number, y: number): Path2;
  83284. /**
  83285. * 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.
  83286. * @param midX middle point x value
  83287. * @param midY middle point y value
  83288. * @param endX end point x value
  83289. * @param endY end point y value
  83290. * @param numberOfSegments (default: 36)
  83291. * @returns the updated Path2.
  83292. */
  83293. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  83294. /**
  83295. * Closes the Path2.
  83296. * @returns the Path2.
  83297. */
  83298. close(): Path2;
  83299. /**
  83300. * Gets the sum of the distance between each sequential point in the path
  83301. * @returns the Path2 total length (float).
  83302. */
  83303. length(): number;
  83304. /**
  83305. * Gets the points which construct the path
  83306. * @returns the Path2 internal array of points.
  83307. */
  83308. getPoints(): Vector2[];
  83309. /**
  83310. * Retreives the point at the distance aways from the starting point
  83311. * @param normalizedLengthPosition the length along the path to retreive the point from
  83312. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  83313. */
  83314. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  83315. /**
  83316. * Creates a new path starting from an x and y position
  83317. * @param x starting x value
  83318. * @param y starting y value
  83319. * @returns a new Path2 starting at the coordinates (x, y).
  83320. */
  83321. static StartingAt(x: number, y: number): Path2;
  83322. }
  83323. /**
  83324. * Represents a 3D path made up of multiple 3D points
  83325. */
  83326. export class Path3D {
  83327. /**
  83328. * an array of Vector3, the curve axis of the Path3D
  83329. */
  83330. path: Vector3[];
  83331. private _curve;
  83332. private _distances;
  83333. private _tangents;
  83334. private _normals;
  83335. private _binormals;
  83336. private _raw;
  83337. private _alignTangentsWithPath;
  83338. private readonly _pointAtData;
  83339. /**
  83340. * new Path3D(path, normal, raw)
  83341. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  83342. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  83343. * @param path an array of Vector3, the curve axis of the Path3D
  83344. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  83345. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  83346. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  83347. */
  83348. constructor(
  83349. /**
  83350. * an array of Vector3, the curve axis of the Path3D
  83351. */
  83352. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  83353. /**
  83354. * Returns the Path3D array of successive Vector3 designing its curve.
  83355. * @returns the Path3D array of successive Vector3 designing its curve.
  83356. */
  83357. getCurve(): Vector3[];
  83358. /**
  83359. * Returns the Path3D array of successive Vector3 designing its curve.
  83360. * @returns the Path3D array of successive Vector3 designing its curve.
  83361. */
  83362. getPoints(): Vector3[];
  83363. /**
  83364. * @returns the computed length (float) of the path.
  83365. */
  83366. length(): number;
  83367. /**
  83368. * Returns an array populated with tangent vectors on each Path3D curve point.
  83369. * @returns an array populated with tangent vectors on each Path3D curve point.
  83370. */
  83371. getTangents(): Vector3[];
  83372. /**
  83373. * Returns an array populated with normal vectors on each Path3D curve point.
  83374. * @returns an array populated with normal vectors on each Path3D curve point.
  83375. */
  83376. getNormals(): Vector3[];
  83377. /**
  83378. * Returns an array populated with binormal vectors on each Path3D curve point.
  83379. * @returns an array populated with binormal vectors on each Path3D curve point.
  83380. */
  83381. getBinormals(): Vector3[];
  83382. /**
  83383. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  83384. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  83385. */
  83386. getDistances(): number[];
  83387. /**
  83388. * Returns an interpolated point along this path
  83389. * @param position the position of the point along this path, from 0.0 to 1.0
  83390. * @returns a new Vector3 as the point
  83391. */
  83392. getPointAt(position: number): Vector3;
  83393. /**
  83394. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83395. * @param position the position of the point along this path, from 0.0 to 1.0
  83396. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  83397. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  83398. */
  83399. getTangentAt(position: number, interpolated?: boolean): Vector3;
  83400. /**
  83401. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  83402. * @param position the position of the point along this path, from 0.0 to 1.0
  83403. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  83404. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  83405. */
  83406. getNormalAt(position: number, interpolated?: boolean): Vector3;
  83407. /**
  83408. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  83409. * @param position the position of the point along this path, from 0.0 to 1.0
  83410. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  83411. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  83412. */
  83413. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  83414. /**
  83415. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  83416. * @param position the position of the point along this path, from 0.0 to 1.0
  83417. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  83418. */
  83419. getDistanceAt(position: number): number;
  83420. /**
  83421. * Returns the array index of the previous point of an interpolated point along this path
  83422. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83423. * @returns the array index
  83424. */
  83425. getPreviousPointIndexAt(position: number): number;
  83426. /**
  83427. * 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)
  83428. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  83429. * @returns the sub position
  83430. */
  83431. getSubPositionAt(position: number): number;
  83432. /**
  83433. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  83434. * @param target the vector of which to get the closest position to
  83435. * @returns the position of the closest virtual point on this path to the target vector
  83436. */
  83437. getClosestPositionTo(target: Vector3): number;
  83438. /**
  83439. * Returns a sub path (slice) of this path
  83440. * @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
  83441. * @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
  83442. * @returns a sub path (slice) of this path
  83443. */
  83444. slice(start?: number, end?: number): Path3D;
  83445. /**
  83446. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  83447. * @param path path which all values are copied into the curves points
  83448. * @param firstNormal which should be projected onto the curve
  83449. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  83450. * @returns the same object updated.
  83451. */
  83452. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  83453. private _compute;
  83454. private _getFirstNonNullVector;
  83455. private _getLastNonNullVector;
  83456. private _normalVector;
  83457. /**
  83458. * Updates the point at data for an interpolated point along this curve
  83459. * @param position the position of the point along this curve, from 0.0 to 1.0
  83460. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  83461. * @returns the (updated) point at data
  83462. */
  83463. private _updatePointAtData;
  83464. /**
  83465. * Updates the point at data from the specified parameters
  83466. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  83467. * @param point the interpolated point
  83468. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  83469. */
  83470. private _setPointAtData;
  83471. /**
  83472. * Updates the point at interpolation matrix for the tangents, normals and binormals
  83473. */
  83474. private _updateInterpolationMatrix;
  83475. }
  83476. /**
  83477. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83478. * A Curve3 is designed from a series of successive Vector3.
  83479. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  83480. */
  83481. export class Curve3 {
  83482. private _points;
  83483. private _length;
  83484. /**
  83485. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  83486. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  83487. * @param v1 (Vector3) the control point
  83488. * @param v2 (Vector3) the end point of the Quadratic Bezier
  83489. * @param nbPoints (integer) the wanted number of points in the curve
  83490. * @returns the created Curve3
  83491. */
  83492. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83493. /**
  83494. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  83495. * @param v0 (Vector3) the origin point of the Cubic Bezier
  83496. * @param v1 (Vector3) the first control point
  83497. * @param v2 (Vector3) the second control point
  83498. * @param v3 (Vector3) the end point of the Cubic Bezier
  83499. * @param nbPoints (integer) the wanted number of points in the curve
  83500. * @returns the created Curve3
  83501. */
  83502. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83503. /**
  83504. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  83505. * @param p1 (Vector3) the origin point of the Hermite Spline
  83506. * @param t1 (Vector3) the tangent vector at the origin point
  83507. * @param p2 (Vector3) the end point of the Hermite Spline
  83508. * @param t2 (Vector3) the tangent vector at the end point
  83509. * @param nbPoints (integer) the wanted number of points in the curve
  83510. * @returns the created Curve3
  83511. */
  83512. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  83513. /**
  83514. * Returns a Curve3 object along a CatmullRom Spline curve :
  83515. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  83516. * @param nbPoints (integer) the wanted number of points between each curve control points
  83517. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  83518. * @returns the created Curve3
  83519. */
  83520. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  83521. /**
  83522. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  83523. * A Curve3 is designed from a series of successive Vector3.
  83524. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  83525. * @param points points which make up the curve
  83526. */
  83527. constructor(points: Vector3[]);
  83528. /**
  83529. * @returns the Curve3 stored array of successive Vector3
  83530. */
  83531. getPoints(): Vector3[];
  83532. /**
  83533. * @returns the computed length (float) of the curve.
  83534. */
  83535. length(): number;
  83536. /**
  83537. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  83538. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  83539. * curveA and curveB keep unchanged.
  83540. * @param curve the curve to continue from this curve
  83541. * @returns the newly constructed curve
  83542. */
  83543. continue(curve: DeepImmutable<Curve3>): Curve3;
  83544. private _computeLength;
  83545. }
  83546. }
  83547. declare module BABYLON {
  83548. /**
  83549. * This represents the main contract an easing function should follow.
  83550. * Easing functions are used throughout the animation system.
  83551. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83552. */
  83553. export interface IEasingFunction {
  83554. /**
  83555. * Given an input gradient between 0 and 1, this returns the corrseponding value
  83556. * of the easing function.
  83557. * The link below provides some of the most common examples of easing functions.
  83558. * @see https://easings.net/
  83559. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83560. * @returns the corresponding value on the curve defined by the easing function
  83561. */
  83562. ease(gradient: number): number;
  83563. }
  83564. /**
  83565. * Base class used for every default easing function.
  83566. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83567. */
  83568. export class EasingFunction implements IEasingFunction {
  83569. /**
  83570. * Interpolation follows the mathematical formula associated with the easing function.
  83571. */
  83572. static readonly EASINGMODE_EASEIN: number;
  83573. /**
  83574. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  83575. */
  83576. static readonly EASINGMODE_EASEOUT: number;
  83577. /**
  83578. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  83579. */
  83580. static readonly EASINGMODE_EASEINOUT: number;
  83581. private _easingMode;
  83582. /**
  83583. * Sets the easing mode of the current function.
  83584. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  83585. */
  83586. setEasingMode(easingMode: number): void;
  83587. /**
  83588. * Gets the current easing mode.
  83589. * @returns the easing mode
  83590. */
  83591. getEasingMode(): number;
  83592. /**
  83593. * @hidden
  83594. */
  83595. easeInCore(gradient: number): number;
  83596. /**
  83597. * Given an input gradient between 0 and 1, this returns the corresponding value
  83598. * of the easing function.
  83599. * @param gradient Defines the value between 0 and 1 we want the easing value for
  83600. * @returns the corresponding value on the curve defined by the easing function
  83601. */
  83602. ease(gradient: number): number;
  83603. }
  83604. /**
  83605. * Easing function with a circle shape (see link below).
  83606. * @see https://easings.net/#easeInCirc
  83607. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83608. */
  83609. export class CircleEase extends EasingFunction implements IEasingFunction {
  83610. /** @hidden */
  83611. easeInCore(gradient: number): number;
  83612. }
  83613. /**
  83614. * Easing function with a ease back shape (see link below).
  83615. * @see https://easings.net/#easeInBack
  83616. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83617. */
  83618. export class BackEase extends EasingFunction implements IEasingFunction {
  83619. /** Defines the amplitude of the function */
  83620. amplitude: number;
  83621. /**
  83622. * Instantiates a back ease easing
  83623. * @see https://easings.net/#easeInBack
  83624. * @param amplitude Defines the amplitude of the function
  83625. */
  83626. constructor(
  83627. /** Defines the amplitude of the function */
  83628. amplitude?: number);
  83629. /** @hidden */
  83630. easeInCore(gradient: number): number;
  83631. }
  83632. /**
  83633. * Easing function with a bouncing shape (see link below).
  83634. * @see https://easings.net/#easeInBounce
  83635. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83636. */
  83637. export class BounceEase extends EasingFunction implements IEasingFunction {
  83638. /** Defines the number of bounces */
  83639. bounces: number;
  83640. /** Defines the amplitude of the bounce */
  83641. bounciness: number;
  83642. /**
  83643. * Instantiates a bounce easing
  83644. * @see https://easings.net/#easeInBounce
  83645. * @param bounces Defines the number of bounces
  83646. * @param bounciness Defines the amplitude of the bounce
  83647. */
  83648. constructor(
  83649. /** Defines the number of bounces */
  83650. bounces?: number,
  83651. /** Defines the amplitude of the bounce */
  83652. bounciness?: number);
  83653. /** @hidden */
  83654. easeInCore(gradient: number): number;
  83655. }
  83656. /**
  83657. * Easing function with a power of 3 shape (see link below).
  83658. * @see https://easings.net/#easeInCubic
  83659. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83660. */
  83661. export class CubicEase extends EasingFunction implements IEasingFunction {
  83662. /** @hidden */
  83663. easeInCore(gradient: number): number;
  83664. }
  83665. /**
  83666. * Easing function with an elastic shape (see link below).
  83667. * @see https://easings.net/#easeInElastic
  83668. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83669. */
  83670. export class ElasticEase extends EasingFunction implements IEasingFunction {
  83671. /** Defines the number of oscillations*/
  83672. oscillations: number;
  83673. /** Defines the amplitude of the oscillations*/
  83674. springiness: number;
  83675. /**
  83676. * Instantiates an elastic easing function
  83677. * @see https://easings.net/#easeInElastic
  83678. * @param oscillations Defines the number of oscillations
  83679. * @param springiness Defines the amplitude of the oscillations
  83680. */
  83681. constructor(
  83682. /** Defines the number of oscillations*/
  83683. oscillations?: number,
  83684. /** Defines the amplitude of the oscillations*/
  83685. springiness?: number);
  83686. /** @hidden */
  83687. easeInCore(gradient: number): number;
  83688. }
  83689. /**
  83690. * Easing function with an exponential shape (see link below).
  83691. * @see https://easings.net/#easeInExpo
  83692. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83693. */
  83694. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  83695. /** Defines the exponent of the function */
  83696. exponent: number;
  83697. /**
  83698. * Instantiates an exponential easing function
  83699. * @see https://easings.net/#easeInExpo
  83700. * @param exponent Defines the exponent of the function
  83701. */
  83702. constructor(
  83703. /** Defines the exponent of the function */
  83704. exponent?: number);
  83705. /** @hidden */
  83706. easeInCore(gradient: number): number;
  83707. }
  83708. /**
  83709. * Easing function with a power shape (see link below).
  83710. * @see https://easings.net/#easeInQuad
  83711. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83712. */
  83713. export class PowerEase extends EasingFunction implements IEasingFunction {
  83714. /** Defines the power of the function */
  83715. power: number;
  83716. /**
  83717. * Instantiates an power base easing function
  83718. * @see https://easings.net/#easeInQuad
  83719. * @param power Defines the power of the function
  83720. */
  83721. constructor(
  83722. /** Defines the power of the function */
  83723. power?: number);
  83724. /** @hidden */
  83725. easeInCore(gradient: number): number;
  83726. }
  83727. /**
  83728. * Easing function with a power of 2 shape (see link below).
  83729. * @see https://easings.net/#easeInQuad
  83730. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83731. */
  83732. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  83733. /** @hidden */
  83734. easeInCore(gradient: number): number;
  83735. }
  83736. /**
  83737. * Easing function with a power of 4 shape (see link below).
  83738. * @see https://easings.net/#easeInQuart
  83739. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83740. */
  83741. export class QuarticEase extends EasingFunction implements IEasingFunction {
  83742. /** @hidden */
  83743. easeInCore(gradient: number): number;
  83744. }
  83745. /**
  83746. * Easing function with a power of 5 shape (see link below).
  83747. * @see https://easings.net/#easeInQuint
  83748. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83749. */
  83750. export class QuinticEase extends EasingFunction implements IEasingFunction {
  83751. /** @hidden */
  83752. easeInCore(gradient: number): number;
  83753. }
  83754. /**
  83755. * Easing function with a sin shape (see link below).
  83756. * @see https://easings.net/#easeInSine
  83757. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83758. */
  83759. export class SineEase extends EasingFunction implements IEasingFunction {
  83760. /** @hidden */
  83761. easeInCore(gradient: number): number;
  83762. }
  83763. /**
  83764. * Easing function with a bezier shape (see link below).
  83765. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83766. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  83767. */
  83768. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  83769. /** Defines the x component of the start tangent in the bezier curve */
  83770. x1: number;
  83771. /** Defines the y component of the start tangent in the bezier curve */
  83772. y1: number;
  83773. /** Defines the x component of the end tangent in the bezier curve */
  83774. x2: number;
  83775. /** Defines the y component of the end tangent in the bezier curve */
  83776. y2: number;
  83777. /**
  83778. * Instantiates a bezier function
  83779. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  83780. * @param x1 Defines the x component of the start tangent in the bezier curve
  83781. * @param y1 Defines the y component of the start tangent in the bezier curve
  83782. * @param x2 Defines the x component of the end tangent in the bezier curve
  83783. * @param y2 Defines the y component of the end tangent in the bezier curve
  83784. */
  83785. constructor(
  83786. /** Defines the x component of the start tangent in the bezier curve */
  83787. x1?: number,
  83788. /** Defines the y component of the start tangent in the bezier curve */
  83789. y1?: number,
  83790. /** Defines the x component of the end tangent in the bezier curve */
  83791. x2?: number,
  83792. /** Defines the y component of the end tangent in the bezier curve */
  83793. y2?: number);
  83794. /** @hidden */
  83795. easeInCore(gradient: number): number;
  83796. }
  83797. }
  83798. declare module BABYLON {
  83799. /**
  83800. * Class used to hold a RBG color
  83801. */
  83802. export class Color3 {
  83803. /**
  83804. * Defines the red component (between 0 and 1, default is 0)
  83805. */
  83806. r: number;
  83807. /**
  83808. * Defines the green component (between 0 and 1, default is 0)
  83809. */
  83810. g: number;
  83811. /**
  83812. * Defines the blue component (between 0 and 1, default is 0)
  83813. */
  83814. b: number;
  83815. /**
  83816. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  83817. * @param r defines the red component (between 0 and 1, default is 0)
  83818. * @param g defines the green component (between 0 and 1, default is 0)
  83819. * @param b defines the blue component (between 0 and 1, default is 0)
  83820. */
  83821. constructor(
  83822. /**
  83823. * Defines the red component (between 0 and 1, default is 0)
  83824. */
  83825. r?: number,
  83826. /**
  83827. * Defines the green component (between 0 and 1, default is 0)
  83828. */
  83829. g?: number,
  83830. /**
  83831. * Defines the blue component (between 0 and 1, default is 0)
  83832. */
  83833. b?: number);
  83834. /**
  83835. * Creates a string with the Color3 current values
  83836. * @returns the string representation of the Color3 object
  83837. */
  83838. toString(): string;
  83839. /**
  83840. * Returns the string "Color3"
  83841. * @returns "Color3"
  83842. */
  83843. getClassName(): string;
  83844. /**
  83845. * Compute the Color3 hash code
  83846. * @returns an unique number that can be used to hash Color3 objects
  83847. */
  83848. getHashCode(): number;
  83849. /**
  83850. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  83851. * @param array defines the array where to store the r,g,b components
  83852. * @param index defines an optional index in the target array to define where to start storing values
  83853. * @returns the current Color3 object
  83854. */
  83855. toArray(array: FloatArray, index?: number): Color3;
  83856. /**
  83857. * Returns a new Color4 object from the current Color3 and the given alpha
  83858. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  83859. * @returns a new Color4 object
  83860. */
  83861. toColor4(alpha?: number): Color4;
  83862. /**
  83863. * Returns a new array populated with 3 numeric elements : red, green and blue values
  83864. * @returns the new array
  83865. */
  83866. asArray(): number[];
  83867. /**
  83868. * Returns the luminance value
  83869. * @returns a float value
  83870. */
  83871. toLuminance(): number;
  83872. /**
  83873. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  83874. * @param otherColor defines the second operand
  83875. * @returns the new Color3 object
  83876. */
  83877. multiply(otherColor: DeepImmutable<Color3>): Color3;
  83878. /**
  83879. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  83880. * @param otherColor defines the second operand
  83881. * @param result defines the Color3 object where to store the result
  83882. * @returns the current Color3
  83883. */
  83884. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83885. /**
  83886. * Determines equality between Color3 objects
  83887. * @param otherColor defines the second operand
  83888. * @returns true if the rgb values are equal to the given ones
  83889. */
  83890. equals(otherColor: DeepImmutable<Color3>): boolean;
  83891. /**
  83892. * Determines equality between the current Color3 object and a set of r,b,g values
  83893. * @param r defines the red component to check
  83894. * @param g defines the green component to check
  83895. * @param b defines the blue component to check
  83896. * @returns true if the rgb values are equal to the given ones
  83897. */
  83898. equalsFloats(r: number, g: number, b: number): boolean;
  83899. /**
  83900. * Multiplies in place each rgb value by scale
  83901. * @param scale defines the scaling factor
  83902. * @returns the updated Color3
  83903. */
  83904. scale(scale: number): Color3;
  83905. /**
  83906. * Multiplies the rgb values by scale and stores the result into "result"
  83907. * @param scale defines the scaling factor
  83908. * @param result defines the Color3 object where to store the result
  83909. * @returns the unmodified current Color3
  83910. */
  83911. scaleToRef(scale: number, result: Color3): Color3;
  83912. /**
  83913. * Scale the current Color3 values by a factor and add the result to a given Color3
  83914. * @param scale defines the scale factor
  83915. * @param result defines color to store the result into
  83916. * @returns the unmodified current Color3
  83917. */
  83918. scaleAndAddToRef(scale: number, result: Color3): Color3;
  83919. /**
  83920. * Clamps the rgb values by the min and max values and stores the result into "result"
  83921. * @param min defines minimum clamping value (default is 0)
  83922. * @param max defines maximum clamping value (default is 1)
  83923. * @param result defines color to store the result into
  83924. * @returns the original Color3
  83925. */
  83926. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  83927. /**
  83928. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  83929. * @param otherColor defines the second operand
  83930. * @returns the new Color3
  83931. */
  83932. add(otherColor: DeepImmutable<Color3>): Color3;
  83933. /**
  83934. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  83935. * @param otherColor defines the second operand
  83936. * @param result defines Color3 object to store the result into
  83937. * @returns the unmodified current Color3
  83938. */
  83939. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83940. /**
  83941. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  83942. * @param otherColor defines the second operand
  83943. * @returns the new Color3
  83944. */
  83945. subtract(otherColor: DeepImmutable<Color3>): Color3;
  83946. /**
  83947. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  83948. * @param otherColor defines the second operand
  83949. * @param result defines Color3 object to store the result into
  83950. * @returns the unmodified current Color3
  83951. */
  83952. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  83953. /**
  83954. * Copy the current object
  83955. * @returns a new Color3 copied the current one
  83956. */
  83957. clone(): Color3;
  83958. /**
  83959. * Copies the rgb values from the source in the current Color3
  83960. * @param source defines the source Color3 object
  83961. * @returns the updated Color3 object
  83962. */
  83963. copyFrom(source: DeepImmutable<Color3>): Color3;
  83964. /**
  83965. * Updates the Color3 rgb values from the given floats
  83966. * @param r defines the red component to read from
  83967. * @param g defines the green component to read from
  83968. * @param b defines the blue component to read from
  83969. * @returns the current Color3 object
  83970. */
  83971. copyFromFloats(r: number, g: number, b: number): Color3;
  83972. /**
  83973. * Updates the Color3 rgb values from the given floats
  83974. * @param r defines the red component to read from
  83975. * @param g defines the green component to read from
  83976. * @param b defines the blue component to read from
  83977. * @returns the current Color3 object
  83978. */
  83979. set(r: number, g: number, b: number): Color3;
  83980. /**
  83981. * Compute the Color3 hexadecimal code as a string
  83982. * @returns a string containing the hexadecimal representation of the Color3 object
  83983. */
  83984. toHexString(): string;
  83985. /**
  83986. * Computes a new Color3 converted from the current one to linear space
  83987. * @returns a new Color3 object
  83988. */
  83989. toLinearSpace(): Color3;
  83990. /**
  83991. * Converts current color in rgb space to HSV values
  83992. * @returns a new color3 representing the HSV values
  83993. */
  83994. toHSV(): Color3;
  83995. /**
  83996. * Converts current color in rgb space to HSV values
  83997. * @param result defines the Color3 where to store the HSV values
  83998. */
  83999. toHSVToRef(result: Color3): void;
  84000. /**
  84001. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  84002. * @param convertedColor defines the Color3 object where to store the linear space version
  84003. * @returns the unmodified Color3
  84004. */
  84005. toLinearSpaceToRef(convertedColor: Color3): Color3;
  84006. /**
  84007. * Computes a new Color3 converted from the current one to gamma space
  84008. * @returns a new Color3 object
  84009. */
  84010. toGammaSpace(): Color3;
  84011. /**
  84012. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  84013. * @param convertedColor defines the Color3 object where to store the gamma space version
  84014. * @returns the unmodified Color3
  84015. */
  84016. toGammaSpaceToRef(convertedColor: Color3): Color3;
  84017. private static _BlackReadOnly;
  84018. /**
  84019. * Convert Hue, saturation and value to a Color3 (RGB)
  84020. * @param hue defines the hue
  84021. * @param saturation defines the saturation
  84022. * @param value defines the value
  84023. * @param result defines the Color3 where to store the RGB values
  84024. */
  84025. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  84026. /**
  84027. * Creates a new Color3 from the string containing valid hexadecimal values
  84028. * @param hex defines a string containing valid hexadecimal values
  84029. * @returns a new Color3 object
  84030. */
  84031. static FromHexString(hex: string): Color3;
  84032. /**
  84033. * Creates a new Color3 from the starting index of the given array
  84034. * @param array defines the source array
  84035. * @param offset defines an offset in the source array
  84036. * @returns a new Color3 object
  84037. */
  84038. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  84039. /**
  84040. * Creates a new Color3 from integer values (< 256)
  84041. * @param r defines the red component to read from (value between 0 and 255)
  84042. * @param g defines the green component to read from (value between 0 and 255)
  84043. * @param b defines the blue component to read from (value between 0 and 255)
  84044. * @returns a new Color3 object
  84045. */
  84046. static FromInts(r: number, g: number, b: number): Color3;
  84047. /**
  84048. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84049. * @param start defines the start Color3 value
  84050. * @param end defines the end Color3 value
  84051. * @param amount defines the gradient value between start and end
  84052. * @returns a new Color3 object
  84053. */
  84054. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  84055. /**
  84056. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  84057. * @param left defines the start value
  84058. * @param right defines the end value
  84059. * @param amount defines the gradient factor
  84060. * @param result defines the Color3 object where to store the result
  84061. */
  84062. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  84063. /**
  84064. * Returns a Color3 value containing a red color
  84065. * @returns a new Color3 object
  84066. */
  84067. static Red(): Color3;
  84068. /**
  84069. * Returns a Color3 value containing a green color
  84070. * @returns a new Color3 object
  84071. */
  84072. static Green(): Color3;
  84073. /**
  84074. * Returns a Color3 value containing a blue color
  84075. * @returns a new Color3 object
  84076. */
  84077. static Blue(): Color3;
  84078. /**
  84079. * Returns a Color3 value containing a black color
  84080. * @returns a new Color3 object
  84081. */
  84082. static Black(): Color3;
  84083. /**
  84084. * Gets a Color3 value containing a black color that must not be updated
  84085. */
  84086. static get BlackReadOnly(): DeepImmutable<Color3>;
  84087. /**
  84088. * Returns a Color3 value containing a white color
  84089. * @returns a new Color3 object
  84090. */
  84091. static White(): Color3;
  84092. /**
  84093. * Returns a Color3 value containing a purple color
  84094. * @returns a new Color3 object
  84095. */
  84096. static Purple(): Color3;
  84097. /**
  84098. * Returns a Color3 value containing a magenta color
  84099. * @returns a new Color3 object
  84100. */
  84101. static Magenta(): Color3;
  84102. /**
  84103. * Returns a Color3 value containing a yellow color
  84104. * @returns a new Color3 object
  84105. */
  84106. static Yellow(): Color3;
  84107. /**
  84108. * Returns a Color3 value containing a gray color
  84109. * @returns a new Color3 object
  84110. */
  84111. static Gray(): Color3;
  84112. /**
  84113. * Returns a Color3 value containing a teal color
  84114. * @returns a new Color3 object
  84115. */
  84116. static Teal(): Color3;
  84117. /**
  84118. * Returns a Color3 value containing a random color
  84119. * @returns a new Color3 object
  84120. */
  84121. static Random(): Color3;
  84122. }
  84123. /**
  84124. * Class used to hold a RBGA color
  84125. */
  84126. export class Color4 {
  84127. /**
  84128. * Defines the red component (between 0 and 1, default is 0)
  84129. */
  84130. r: number;
  84131. /**
  84132. * Defines the green component (between 0 and 1, default is 0)
  84133. */
  84134. g: number;
  84135. /**
  84136. * Defines the blue component (between 0 and 1, default is 0)
  84137. */
  84138. b: number;
  84139. /**
  84140. * Defines the alpha component (between 0 and 1, default is 1)
  84141. */
  84142. a: number;
  84143. /**
  84144. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  84145. * @param r defines the red component (between 0 and 1, default is 0)
  84146. * @param g defines the green component (between 0 and 1, default is 0)
  84147. * @param b defines the blue component (between 0 and 1, default is 0)
  84148. * @param a defines the alpha component (between 0 and 1, default is 1)
  84149. */
  84150. constructor(
  84151. /**
  84152. * Defines the red component (between 0 and 1, default is 0)
  84153. */
  84154. r?: number,
  84155. /**
  84156. * Defines the green component (between 0 and 1, default is 0)
  84157. */
  84158. g?: number,
  84159. /**
  84160. * Defines the blue component (between 0 and 1, default is 0)
  84161. */
  84162. b?: number,
  84163. /**
  84164. * Defines the alpha component (between 0 and 1, default is 1)
  84165. */
  84166. a?: number);
  84167. /**
  84168. * Adds in place the given Color4 values to the current Color4 object
  84169. * @param right defines the second operand
  84170. * @returns the current updated Color4 object
  84171. */
  84172. addInPlace(right: DeepImmutable<Color4>): Color4;
  84173. /**
  84174. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  84175. * @returns the new array
  84176. */
  84177. asArray(): number[];
  84178. /**
  84179. * Stores from the starting index in the given array the Color4 successive values
  84180. * @param array defines the array where to store the r,g,b components
  84181. * @param index defines an optional index in the target array to define where to start storing values
  84182. * @returns the current Color4 object
  84183. */
  84184. toArray(array: number[], index?: number): Color4;
  84185. /**
  84186. * Determines equality between Color4 objects
  84187. * @param otherColor defines the second operand
  84188. * @returns true if the rgba values are equal to the given ones
  84189. */
  84190. equals(otherColor: DeepImmutable<Color4>): boolean;
  84191. /**
  84192. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  84193. * @param right defines the second operand
  84194. * @returns a new Color4 object
  84195. */
  84196. add(right: DeepImmutable<Color4>): Color4;
  84197. /**
  84198. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  84199. * @param right defines the second operand
  84200. * @returns a new Color4 object
  84201. */
  84202. subtract(right: DeepImmutable<Color4>): Color4;
  84203. /**
  84204. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  84205. * @param right defines the second operand
  84206. * @param result defines the Color4 object where to store the result
  84207. * @returns the current Color4 object
  84208. */
  84209. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  84210. /**
  84211. * Creates a new Color4 with the current Color4 values multiplied by scale
  84212. * @param scale defines the scaling factor to apply
  84213. * @returns a new Color4 object
  84214. */
  84215. scale(scale: number): Color4;
  84216. /**
  84217. * Multiplies the current Color4 values by scale and stores the result in "result"
  84218. * @param scale defines the scaling factor to apply
  84219. * @param result defines the Color4 object where to store the result
  84220. * @returns the current unmodified Color4
  84221. */
  84222. scaleToRef(scale: number, result: Color4): Color4;
  84223. /**
  84224. * Scale the current Color4 values by a factor and add the result to a given Color4
  84225. * @param scale defines the scale factor
  84226. * @param result defines the Color4 object where to store the result
  84227. * @returns the unmodified current Color4
  84228. */
  84229. scaleAndAddToRef(scale: number, result: Color4): Color4;
  84230. /**
  84231. * Clamps the rgb values by the min and max values and stores the result into "result"
  84232. * @param min defines minimum clamping value (default is 0)
  84233. * @param max defines maximum clamping value (default is 1)
  84234. * @param result defines color to store the result into.
  84235. * @returns the cuurent Color4
  84236. */
  84237. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  84238. /**
  84239. * Multipy an Color4 value by another and return a new Color4 object
  84240. * @param color defines the Color4 value to multiply by
  84241. * @returns a new Color4 object
  84242. */
  84243. multiply(color: Color4): Color4;
  84244. /**
  84245. * Multipy a Color4 value by another and push the result in a reference value
  84246. * @param color defines the Color4 value to multiply by
  84247. * @param result defines the Color4 to fill the result in
  84248. * @returns the result Color4
  84249. */
  84250. multiplyToRef(color: Color4, result: Color4): Color4;
  84251. /**
  84252. * Creates a string with the Color4 current values
  84253. * @returns the string representation of the Color4 object
  84254. */
  84255. toString(): string;
  84256. /**
  84257. * Returns the string "Color4"
  84258. * @returns "Color4"
  84259. */
  84260. getClassName(): string;
  84261. /**
  84262. * Compute the Color4 hash code
  84263. * @returns an unique number that can be used to hash Color4 objects
  84264. */
  84265. getHashCode(): number;
  84266. /**
  84267. * Creates a new Color4 copied from the current one
  84268. * @returns a new Color4 object
  84269. */
  84270. clone(): Color4;
  84271. /**
  84272. * Copies the given Color4 values into the current one
  84273. * @param source defines the source Color4 object
  84274. * @returns the current updated Color4 object
  84275. */
  84276. copyFrom(source: Color4): Color4;
  84277. /**
  84278. * Copies the given float values into the current one
  84279. * @param r defines the red component to read from
  84280. * @param g defines the green component to read from
  84281. * @param b defines the blue component to read from
  84282. * @param a defines the alpha component to read from
  84283. * @returns the current updated Color4 object
  84284. */
  84285. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  84286. /**
  84287. * Copies the given float values into the current one
  84288. * @param r defines the red component to read from
  84289. * @param g defines the green component to read from
  84290. * @param b defines the blue component to read from
  84291. * @param a defines the alpha component to read from
  84292. * @returns the current updated Color4 object
  84293. */
  84294. set(r: number, g: number, b: number, a: number): Color4;
  84295. /**
  84296. * Compute the Color4 hexadecimal code as a string
  84297. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  84298. * @returns a string containing the hexadecimal representation of the Color4 object
  84299. */
  84300. toHexString(returnAsColor3?: boolean): string;
  84301. /**
  84302. * Computes a new Color4 converted from the current one to linear space
  84303. * @returns a new Color4 object
  84304. */
  84305. toLinearSpace(): Color4;
  84306. /**
  84307. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  84308. * @param convertedColor defines the Color4 object where to store the linear space version
  84309. * @returns the unmodified Color4
  84310. */
  84311. toLinearSpaceToRef(convertedColor: Color4): Color4;
  84312. /**
  84313. * Computes a new Color4 converted from the current one to gamma space
  84314. * @returns a new Color4 object
  84315. */
  84316. toGammaSpace(): Color4;
  84317. /**
  84318. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  84319. * @param convertedColor defines the Color4 object where to store the gamma space version
  84320. * @returns the unmodified Color4
  84321. */
  84322. toGammaSpaceToRef(convertedColor: Color4): Color4;
  84323. /**
  84324. * Creates a new Color4 from the string containing valid hexadecimal values
  84325. * @param hex defines a string containing valid hexadecimal values
  84326. * @returns a new Color4 object
  84327. */
  84328. static FromHexString(hex: string): Color4;
  84329. /**
  84330. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84331. * @param left defines the start value
  84332. * @param right defines the end value
  84333. * @param amount defines the gradient factor
  84334. * @returns a new Color4 object
  84335. */
  84336. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  84337. /**
  84338. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  84339. * @param left defines the start value
  84340. * @param right defines the end value
  84341. * @param amount defines the gradient factor
  84342. * @param result defines the Color4 object where to store data
  84343. */
  84344. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  84345. /**
  84346. * Creates a new Color4 from a Color3 and an alpha value
  84347. * @param color3 defines the source Color3 to read from
  84348. * @param alpha defines the alpha component (1.0 by default)
  84349. * @returns a new Color4 object
  84350. */
  84351. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  84352. /**
  84353. * Creates a new Color4 from the starting index element of the given array
  84354. * @param array defines the source array to read from
  84355. * @param offset defines the offset in the source array
  84356. * @returns a new Color4 object
  84357. */
  84358. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  84359. /**
  84360. * Creates a new Color3 from integer values (< 256)
  84361. * @param r defines the red component to read from (value between 0 and 255)
  84362. * @param g defines the green component to read from (value between 0 and 255)
  84363. * @param b defines the blue component to read from (value between 0 and 255)
  84364. * @param a defines the alpha component to read from (value between 0 and 255)
  84365. * @returns a new Color3 object
  84366. */
  84367. static FromInts(r: number, g: number, b: number, a: number): Color4;
  84368. /**
  84369. * Check the content of a given array and convert it to an array containing RGBA data
  84370. * If the original array was already containing count * 4 values then it is returned directly
  84371. * @param colors defines the array to check
  84372. * @param count defines the number of RGBA data to expect
  84373. * @returns an array containing count * 4 values (RGBA)
  84374. */
  84375. static CheckColors4(colors: number[], count: number): number[];
  84376. }
  84377. /**
  84378. * @hidden
  84379. */
  84380. export class TmpColors {
  84381. static Color3: Color3[];
  84382. static Color4: Color4[];
  84383. }
  84384. }
  84385. declare module BABYLON {
  84386. /**
  84387. * Defines an interface which represents an animation key frame
  84388. */
  84389. export interface IAnimationKey {
  84390. /**
  84391. * Frame of the key frame
  84392. */
  84393. frame: number;
  84394. /**
  84395. * Value at the specifies key frame
  84396. */
  84397. value: any;
  84398. /**
  84399. * The input tangent for the cubic hermite spline
  84400. */
  84401. inTangent?: any;
  84402. /**
  84403. * The output tangent for the cubic hermite spline
  84404. */
  84405. outTangent?: any;
  84406. /**
  84407. * The animation interpolation type
  84408. */
  84409. interpolation?: AnimationKeyInterpolation;
  84410. }
  84411. /**
  84412. * Enum for the animation key frame interpolation type
  84413. */
  84414. export enum AnimationKeyInterpolation {
  84415. /**
  84416. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  84417. */
  84418. STEP = 1
  84419. }
  84420. }
  84421. declare module BABYLON {
  84422. /**
  84423. * Represents the range of an animation
  84424. */
  84425. export class AnimationRange {
  84426. /**The name of the animation range**/
  84427. name: string;
  84428. /**The starting frame of the animation */
  84429. from: number;
  84430. /**The ending frame of the animation*/
  84431. to: number;
  84432. /**
  84433. * Initializes the range of an animation
  84434. * @param name The name of the animation range
  84435. * @param from The starting frame of the animation
  84436. * @param to The ending frame of the animation
  84437. */
  84438. constructor(
  84439. /**The name of the animation range**/
  84440. name: string,
  84441. /**The starting frame of the animation */
  84442. from: number,
  84443. /**The ending frame of the animation*/
  84444. to: number);
  84445. /**
  84446. * Makes a copy of the animation range
  84447. * @returns A copy of the animation range
  84448. */
  84449. clone(): AnimationRange;
  84450. }
  84451. }
  84452. declare module BABYLON {
  84453. /**
  84454. * Composed of a frame, and an action function
  84455. */
  84456. export class AnimationEvent {
  84457. /** The frame for which the event is triggered **/
  84458. frame: number;
  84459. /** The event to perform when triggered **/
  84460. action: (currentFrame: number) => void;
  84461. /** Specifies if the event should be triggered only once**/
  84462. onlyOnce?: boolean | undefined;
  84463. /**
  84464. * Specifies if the animation event is done
  84465. */
  84466. isDone: boolean;
  84467. /**
  84468. * Initializes the animation event
  84469. * @param frame The frame for which the event is triggered
  84470. * @param action The event to perform when triggered
  84471. * @param onlyOnce Specifies if the event should be triggered only once
  84472. */
  84473. constructor(
  84474. /** The frame for which the event is triggered **/
  84475. frame: number,
  84476. /** The event to perform when triggered **/
  84477. action: (currentFrame: number) => void,
  84478. /** Specifies if the event should be triggered only once**/
  84479. onlyOnce?: boolean | undefined);
  84480. /** @hidden */
  84481. _clone(): AnimationEvent;
  84482. }
  84483. }
  84484. declare module BABYLON {
  84485. /**
  84486. * Interface used to define a behavior
  84487. */
  84488. export interface Behavior<T> {
  84489. /** gets or sets behavior's name */
  84490. name: string;
  84491. /**
  84492. * Function called when the behavior needs to be initialized (after attaching it to a target)
  84493. */
  84494. init(): void;
  84495. /**
  84496. * Called when the behavior is attached to a target
  84497. * @param target defines the target where the behavior is attached to
  84498. */
  84499. attach(target: T): void;
  84500. /**
  84501. * Called when the behavior is detached from its target
  84502. */
  84503. detach(): void;
  84504. }
  84505. /**
  84506. * Interface implemented by classes supporting behaviors
  84507. */
  84508. export interface IBehaviorAware<T> {
  84509. /**
  84510. * Attach a behavior
  84511. * @param behavior defines the behavior to attach
  84512. * @returns the current host
  84513. */
  84514. addBehavior(behavior: Behavior<T>): T;
  84515. /**
  84516. * Remove a behavior from the current object
  84517. * @param behavior defines the behavior to detach
  84518. * @returns the current host
  84519. */
  84520. removeBehavior(behavior: Behavior<T>): T;
  84521. /**
  84522. * Gets a behavior using its name to search
  84523. * @param name defines the name to search
  84524. * @returns the behavior or null if not found
  84525. */
  84526. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  84527. }
  84528. }
  84529. declare module BABYLON {
  84530. /**
  84531. * Defines an array and its length.
  84532. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  84533. */
  84534. export interface ISmartArrayLike<T> {
  84535. /**
  84536. * The data of the array.
  84537. */
  84538. data: Array<T>;
  84539. /**
  84540. * The active length of the array.
  84541. */
  84542. length: number;
  84543. }
  84544. /**
  84545. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84546. */
  84547. export class SmartArray<T> implements ISmartArrayLike<T> {
  84548. /**
  84549. * The full set of data from the array.
  84550. */
  84551. data: Array<T>;
  84552. /**
  84553. * The active length of the array.
  84554. */
  84555. length: number;
  84556. protected _id: number;
  84557. /**
  84558. * Instantiates a Smart Array.
  84559. * @param capacity defines the default capacity of the array.
  84560. */
  84561. constructor(capacity: number);
  84562. /**
  84563. * Pushes a value at the end of the active data.
  84564. * @param value defines the object to push in the array.
  84565. */
  84566. push(value: T): void;
  84567. /**
  84568. * Iterates over the active data and apply the lambda to them.
  84569. * @param func defines the action to apply on each value.
  84570. */
  84571. forEach(func: (content: T) => void): void;
  84572. /**
  84573. * Sorts the full sets of data.
  84574. * @param compareFn defines the comparison function to apply.
  84575. */
  84576. sort(compareFn: (a: T, b: T) => number): void;
  84577. /**
  84578. * Resets the active data to an empty array.
  84579. */
  84580. reset(): void;
  84581. /**
  84582. * Releases all the data from the array as well as the array.
  84583. */
  84584. dispose(): void;
  84585. /**
  84586. * Concats the active data with a given array.
  84587. * @param array defines the data to concatenate with.
  84588. */
  84589. concat(array: any): void;
  84590. /**
  84591. * Returns the position of a value in the active data.
  84592. * @param value defines the value to find the index for
  84593. * @returns the index if found in the active data otherwise -1
  84594. */
  84595. indexOf(value: T): number;
  84596. /**
  84597. * Returns whether an element is part of the active data.
  84598. * @param value defines the value to look for
  84599. * @returns true if found in the active data otherwise false
  84600. */
  84601. contains(value: T): boolean;
  84602. private static _GlobalId;
  84603. }
  84604. /**
  84605. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  84606. * The data in this array can only be present once
  84607. */
  84608. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  84609. private _duplicateId;
  84610. /**
  84611. * Pushes a value at the end of the active data.
  84612. * THIS DOES NOT PREVENT DUPPLICATE DATA
  84613. * @param value defines the object to push in the array.
  84614. */
  84615. push(value: T): void;
  84616. /**
  84617. * Pushes a value at the end of the active data.
  84618. * If the data is already present, it won t be added again
  84619. * @param value defines the object to push in the array.
  84620. * @returns true if added false if it was already present
  84621. */
  84622. pushNoDuplicate(value: T): boolean;
  84623. /**
  84624. * Resets the active data to an empty array.
  84625. */
  84626. reset(): void;
  84627. /**
  84628. * Concats the active data with a given array.
  84629. * This ensures no dupplicate will be present in the result.
  84630. * @param array defines the data to concatenate with.
  84631. */
  84632. concatWithNoDuplicate(array: any): void;
  84633. }
  84634. }
  84635. declare module BABYLON {
  84636. /**
  84637. * @ignore
  84638. * This is a list of all the different input types that are available in the application.
  84639. * Fo instance: ArcRotateCameraGamepadInput...
  84640. */
  84641. export var CameraInputTypes: {};
  84642. /**
  84643. * This is the contract to implement in order to create a new input class.
  84644. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  84645. */
  84646. export interface ICameraInput<TCamera extends Camera> {
  84647. /**
  84648. * Defines the camera the input is attached to.
  84649. */
  84650. camera: Nullable<TCamera>;
  84651. /**
  84652. * Gets the class name of the current intput.
  84653. * @returns the class name
  84654. */
  84655. getClassName(): string;
  84656. /**
  84657. * Get the friendly name associated with the input class.
  84658. * @returns the input friendly name
  84659. */
  84660. getSimpleName(): string;
  84661. /**
  84662. * Attach the input controls to a specific dom element to get the input from.
  84663. * @param element Defines the element the controls should be listened from
  84664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84665. */
  84666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  84667. /**
  84668. * Detach the current controls from the specified dom element.
  84669. * @param element Defines the element to stop listening the inputs from
  84670. */
  84671. detachControl(element: Nullable<HTMLElement>): void;
  84672. /**
  84673. * Update the current camera state depending on the inputs that have been used this frame.
  84674. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84675. */
  84676. checkInputs?: () => void;
  84677. }
  84678. /**
  84679. * Represents a map of input types to input instance or input index to input instance.
  84680. */
  84681. export interface CameraInputsMap<TCamera extends Camera> {
  84682. /**
  84683. * Accessor to the input by input type.
  84684. */
  84685. [name: string]: ICameraInput<TCamera>;
  84686. /**
  84687. * Accessor to the input by input index.
  84688. */
  84689. [idx: number]: ICameraInput<TCamera>;
  84690. }
  84691. /**
  84692. * This represents the input manager used within a camera.
  84693. * It helps dealing with all the different kind of input attached to a camera.
  84694. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84695. */
  84696. export class CameraInputsManager<TCamera extends Camera> {
  84697. /**
  84698. * Defines the list of inputs attahed to the camera.
  84699. */
  84700. attached: CameraInputsMap<TCamera>;
  84701. /**
  84702. * Defines the dom element the camera is collecting inputs from.
  84703. * This is null if the controls have not been attached.
  84704. */
  84705. attachedElement: Nullable<HTMLElement>;
  84706. /**
  84707. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84708. */
  84709. noPreventDefault: boolean;
  84710. /**
  84711. * Defined the camera the input manager belongs to.
  84712. */
  84713. camera: TCamera;
  84714. /**
  84715. * Update the current camera state depending on the inputs that have been used this frame.
  84716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  84717. */
  84718. checkInputs: () => void;
  84719. /**
  84720. * Instantiate a new Camera Input Manager.
  84721. * @param camera Defines the camera the input manager blongs to
  84722. */
  84723. constructor(camera: TCamera);
  84724. /**
  84725. * Add an input method to a camera
  84726. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  84727. * @param input camera input method
  84728. */
  84729. add(input: ICameraInput<TCamera>): void;
  84730. /**
  84731. * Remove a specific input method from a camera
  84732. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  84733. * @param inputToRemove camera input method
  84734. */
  84735. remove(inputToRemove: ICameraInput<TCamera>): void;
  84736. /**
  84737. * Remove a specific input type from a camera
  84738. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  84739. * @param inputType the type of the input to remove
  84740. */
  84741. removeByType(inputType: string): void;
  84742. private _addCheckInputs;
  84743. /**
  84744. * Attach the input controls to the currently attached dom element to listen the events from.
  84745. * @param input Defines the input to attach
  84746. */
  84747. attachInput(input: ICameraInput<TCamera>): void;
  84748. /**
  84749. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  84750. * @param element Defines the dom element to collect the events from
  84751. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  84752. */
  84753. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  84754. /**
  84755. * Detach the current manager inputs controls from a specific dom element.
  84756. * @param element Defines the dom element to collect the events from
  84757. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  84758. */
  84759. detachElement(element: HTMLElement, disconnect?: boolean): void;
  84760. /**
  84761. * Rebuild the dynamic inputCheck function from the current list of
  84762. * defined inputs in the manager.
  84763. */
  84764. rebuildInputCheck(): void;
  84765. /**
  84766. * Remove all attached input methods from a camera
  84767. */
  84768. clear(): void;
  84769. /**
  84770. * Serialize the current input manager attached to a camera.
  84771. * This ensures than once parsed,
  84772. * the input associated to the camera will be identical to the current ones
  84773. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  84774. */
  84775. serialize(serializedCamera: any): void;
  84776. /**
  84777. * Parses an input manager serialized JSON to restore the previous list of inputs
  84778. * and states associated to a camera.
  84779. * @param parsedCamera Defines the JSON to parse
  84780. */
  84781. parse(parsedCamera: any): void;
  84782. }
  84783. }
  84784. declare module BABYLON {
  84785. /**
  84786. * Class used to store data that will be store in GPU memory
  84787. */
  84788. export class Buffer {
  84789. private _engine;
  84790. private _buffer;
  84791. /** @hidden */
  84792. _data: Nullable<DataArray>;
  84793. private _updatable;
  84794. private _instanced;
  84795. private _divisor;
  84796. /**
  84797. * Gets the byte stride.
  84798. */
  84799. readonly byteStride: number;
  84800. /**
  84801. * Constructor
  84802. * @param engine the engine
  84803. * @param data the data to use for this buffer
  84804. * @param updatable whether the data is updatable
  84805. * @param stride the stride (optional)
  84806. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84807. * @param instanced whether the buffer is instanced (optional)
  84808. * @param useBytes set to true if the stride in in bytes (optional)
  84809. * @param divisor sets an optional divisor for instances (1 by default)
  84810. */
  84811. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  84812. /**
  84813. * Create a new VertexBuffer based on the current buffer
  84814. * @param kind defines the vertex buffer kind (position, normal, etc.)
  84815. * @param offset defines offset in the buffer (0 by default)
  84816. * @param size defines the size in floats of attributes (position is 3 for instance)
  84817. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  84818. * @param instanced defines if the vertex buffer contains indexed data
  84819. * @param useBytes defines if the offset and stride are in bytes *
  84820. * @param divisor sets an optional divisor for instances (1 by default)
  84821. * @returns the new vertex buffer
  84822. */
  84823. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  84824. /**
  84825. * Gets a boolean indicating if the Buffer is updatable?
  84826. * @returns true if the buffer is updatable
  84827. */
  84828. isUpdatable(): boolean;
  84829. /**
  84830. * Gets current buffer's data
  84831. * @returns a DataArray or null
  84832. */
  84833. getData(): Nullable<DataArray>;
  84834. /**
  84835. * Gets underlying native buffer
  84836. * @returns underlying native buffer
  84837. */
  84838. getBuffer(): Nullable<DataBuffer>;
  84839. /**
  84840. * Gets the stride in float32 units (i.e. byte stride / 4).
  84841. * May not be an integer if the byte stride is not divisible by 4.
  84842. * @returns the stride in float32 units
  84843. * @deprecated Please use byteStride instead.
  84844. */
  84845. getStrideSize(): number;
  84846. /**
  84847. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  84848. * @param data defines the data to store
  84849. */
  84850. create(data?: Nullable<DataArray>): void;
  84851. /** @hidden */
  84852. _rebuild(): void;
  84853. /**
  84854. * Update current buffer data
  84855. * @param data defines the data to store
  84856. */
  84857. update(data: DataArray): void;
  84858. /**
  84859. * Updates the data directly.
  84860. * @param data the new data
  84861. * @param offset the new offset
  84862. * @param vertexCount the vertex count (optional)
  84863. * @param useBytes set to true if the offset is in bytes
  84864. */
  84865. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  84866. /**
  84867. * Release all resources
  84868. */
  84869. dispose(): void;
  84870. }
  84871. /**
  84872. * Specialized buffer used to store vertex data
  84873. */
  84874. export class VertexBuffer {
  84875. /** @hidden */
  84876. _buffer: Buffer;
  84877. private _kind;
  84878. private _size;
  84879. private _ownsBuffer;
  84880. private _instanced;
  84881. private _instanceDivisor;
  84882. /**
  84883. * The byte type.
  84884. */
  84885. static readonly BYTE: number;
  84886. /**
  84887. * The unsigned byte type.
  84888. */
  84889. static readonly UNSIGNED_BYTE: number;
  84890. /**
  84891. * The short type.
  84892. */
  84893. static readonly SHORT: number;
  84894. /**
  84895. * The unsigned short type.
  84896. */
  84897. static readonly UNSIGNED_SHORT: number;
  84898. /**
  84899. * The integer type.
  84900. */
  84901. static readonly INT: number;
  84902. /**
  84903. * The unsigned integer type.
  84904. */
  84905. static readonly UNSIGNED_INT: number;
  84906. /**
  84907. * The float type.
  84908. */
  84909. static readonly FLOAT: number;
  84910. /**
  84911. * Gets or sets the instance divisor when in instanced mode
  84912. */
  84913. get instanceDivisor(): number;
  84914. set instanceDivisor(value: number);
  84915. /**
  84916. * Gets the byte stride.
  84917. */
  84918. readonly byteStride: number;
  84919. /**
  84920. * Gets the byte offset.
  84921. */
  84922. readonly byteOffset: number;
  84923. /**
  84924. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  84925. */
  84926. readonly normalized: boolean;
  84927. /**
  84928. * Gets the data type of each component in the array.
  84929. */
  84930. readonly type: number;
  84931. /**
  84932. * Constructor
  84933. * @param engine the engine
  84934. * @param data the data to use for this vertex buffer
  84935. * @param kind the vertex buffer kind
  84936. * @param updatable whether the data is updatable
  84937. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  84938. * @param stride the stride (optional)
  84939. * @param instanced whether the buffer is instanced (optional)
  84940. * @param offset the offset of the data (optional)
  84941. * @param size the number of components (optional)
  84942. * @param type the type of the component (optional)
  84943. * @param normalized whether the data contains normalized data (optional)
  84944. * @param useBytes set to true if stride and offset are in bytes (optional)
  84945. * @param divisor defines the instance divisor to use (1 by default)
  84946. */
  84947. 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);
  84948. /** @hidden */
  84949. _rebuild(): void;
  84950. /**
  84951. * Returns the kind of the VertexBuffer (string)
  84952. * @returns a string
  84953. */
  84954. getKind(): string;
  84955. /**
  84956. * Gets a boolean indicating if the VertexBuffer is updatable?
  84957. * @returns true if the buffer is updatable
  84958. */
  84959. isUpdatable(): boolean;
  84960. /**
  84961. * Gets current buffer's data
  84962. * @returns a DataArray or null
  84963. */
  84964. getData(): Nullable<DataArray>;
  84965. /**
  84966. * Gets underlying native buffer
  84967. * @returns underlying native buffer
  84968. */
  84969. getBuffer(): Nullable<DataBuffer>;
  84970. /**
  84971. * Gets the stride in float32 units (i.e. byte stride / 4).
  84972. * May not be an integer if the byte stride is not divisible by 4.
  84973. * @returns the stride in float32 units
  84974. * @deprecated Please use byteStride instead.
  84975. */
  84976. getStrideSize(): number;
  84977. /**
  84978. * Returns the offset as a multiple of the type byte length.
  84979. * @returns the offset in bytes
  84980. * @deprecated Please use byteOffset instead.
  84981. */
  84982. getOffset(): number;
  84983. /**
  84984. * Returns the number of components per vertex attribute (integer)
  84985. * @returns the size in float
  84986. */
  84987. getSize(): number;
  84988. /**
  84989. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  84990. * @returns true if this buffer is instanced
  84991. */
  84992. getIsInstanced(): boolean;
  84993. /**
  84994. * Returns the instancing divisor, zero for non-instanced (integer).
  84995. * @returns a number
  84996. */
  84997. getInstanceDivisor(): number;
  84998. /**
  84999. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  85000. * @param data defines the data to store
  85001. */
  85002. create(data?: DataArray): void;
  85003. /**
  85004. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  85005. * This function will create a new buffer if the current one is not updatable
  85006. * @param data defines the data to store
  85007. */
  85008. update(data: DataArray): void;
  85009. /**
  85010. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  85011. * Returns the directly updated WebGLBuffer.
  85012. * @param data the new data
  85013. * @param offset the new offset
  85014. * @param useBytes set to true if the offset is in bytes
  85015. */
  85016. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  85017. /**
  85018. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  85019. */
  85020. dispose(): void;
  85021. /**
  85022. * Enumerates each value of this vertex buffer as numbers.
  85023. * @param count the number of values to enumerate
  85024. * @param callback the callback function called for each value
  85025. */
  85026. forEach(count: number, callback: (value: number, index: number) => void): void;
  85027. /**
  85028. * Positions
  85029. */
  85030. static readonly PositionKind: string;
  85031. /**
  85032. * Normals
  85033. */
  85034. static readonly NormalKind: string;
  85035. /**
  85036. * Tangents
  85037. */
  85038. static readonly TangentKind: string;
  85039. /**
  85040. * Texture coordinates
  85041. */
  85042. static readonly UVKind: string;
  85043. /**
  85044. * Texture coordinates 2
  85045. */
  85046. static readonly UV2Kind: string;
  85047. /**
  85048. * Texture coordinates 3
  85049. */
  85050. static readonly UV3Kind: string;
  85051. /**
  85052. * Texture coordinates 4
  85053. */
  85054. static readonly UV4Kind: string;
  85055. /**
  85056. * Texture coordinates 5
  85057. */
  85058. static readonly UV5Kind: string;
  85059. /**
  85060. * Texture coordinates 6
  85061. */
  85062. static readonly UV6Kind: string;
  85063. /**
  85064. * Colors
  85065. */
  85066. static readonly ColorKind: string;
  85067. /**
  85068. * Matrix indices (for bones)
  85069. */
  85070. static readonly MatricesIndicesKind: string;
  85071. /**
  85072. * Matrix weights (for bones)
  85073. */
  85074. static readonly MatricesWeightsKind: string;
  85075. /**
  85076. * Additional matrix indices (for bones)
  85077. */
  85078. static readonly MatricesIndicesExtraKind: string;
  85079. /**
  85080. * Additional matrix weights (for bones)
  85081. */
  85082. static readonly MatricesWeightsExtraKind: string;
  85083. /**
  85084. * Deduces the stride given a kind.
  85085. * @param kind The kind string to deduce
  85086. * @returns The deduced stride
  85087. */
  85088. static DeduceStride(kind: string): number;
  85089. /**
  85090. * Gets the byte length of the given type.
  85091. * @param type the type
  85092. * @returns the number of bytes
  85093. */
  85094. static GetTypeByteLength(type: number): number;
  85095. /**
  85096. * Enumerates each value of the given parameters as numbers.
  85097. * @param data the data to enumerate
  85098. * @param byteOffset the byte offset of the data
  85099. * @param byteStride the byte stride of the data
  85100. * @param componentCount the number of components per element
  85101. * @param componentType the type of the component
  85102. * @param count the number of values to enumerate
  85103. * @param normalized whether the data is normalized
  85104. * @param callback the callback function called for each value
  85105. */
  85106. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  85107. private static _GetFloatValue;
  85108. }
  85109. }
  85110. declare module BABYLON {
  85111. /**
  85112. * @hidden
  85113. */
  85114. export class IntersectionInfo {
  85115. bu: Nullable<number>;
  85116. bv: Nullable<number>;
  85117. distance: number;
  85118. faceId: number;
  85119. subMeshId: number;
  85120. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  85121. }
  85122. }
  85123. declare module BABYLON {
  85124. /**
  85125. * Class used to store bounding sphere information
  85126. */
  85127. export class BoundingSphere {
  85128. /**
  85129. * Gets the center of the bounding sphere in local space
  85130. */
  85131. readonly center: Vector3;
  85132. /**
  85133. * Radius of the bounding sphere in local space
  85134. */
  85135. radius: number;
  85136. /**
  85137. * Gets the center of the bounding sphere in world space
  85138. */
  85139. readonly centerWorld: Vector3;
  85140. /**
  85141. * Radius of the bounding sphere in world space
  85142. */
  85143. radiusWorld: number;
  85144. /**
  85145. * Gets the minimum vector in local space
  85146. */
  85147. readonly minimum: Vector3;
  85148. /**
  85149. * Gets the maximum vector in local space
  85150. */
  85151. readonly maximum: Vector3;
  85152. private _worldMatrix;
  85153. private static readonly TmpVector3;
  85154. /**
  85155. * Creates a new bounding sphere
  85156. * @param min defines the minimum vector (in local space)
  85157. * @param max defines the maximum vector (in local space)
  85158. * @param worldMatrix defines the new world matrix
  85159. */
  85160. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85161. /**
  85162. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  85163. * @param min defines the new minimum vector (in local space)
  85164. * @param max defines the new maximum vector (in local space)
  85165. * @param worldMatrix defines the new world matrix
  85166. */
  85167. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85168. /**
  85169. * Scale the current bounding sphere by applying a scale factor
  85170. * @param factor defines the scale factor to apply
  85171. * @returns the current bounding box
  85172. */
  85173. scale(factor: number): BoundingSphere;
  85174. /**
  85175. * Gets the world matrix of the bounding box
  85176. * @returns a matrix
  85177. */
  85178. getWorldMatrix(): DeepImmutable<Matrix>;
  85179. /** @hidden */
  85180. _update(worldMatrix: DeepImmutable<Matrix>): void;
  85181. /**
  85182. * Tests if the bounding sphere is intersecting the frustum planes
  85183. * @param frustumPlanes defines the frustum planes to test
  85184. * @returns true if there is an intersection
  85185. */
  85186. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85187. /**
  85188. * Tests if the bounding sphere center is in between the frustum planes.
  85189. * Used for optimistic fast inclusion.
  85190. * @param frustumPlanes defines the frustum planes to test
  85191. * @returns true if the sphere center is in between the frustum planes
  85192. */
  85193. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85194. /**
  85195. * Tests if a point is inside the bounding sphere
  85196. * @param point defines the point to test
  85197. * @returns true if the point is inside the bounding sphere
  85198. */
  85199. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85200. /**
  85201. * Checks if two sphere intersct
  85202. * @param sphere0 sphere 0
  85203. * @param sphere1 sphere 1
  85204. * @returns true if the speres intersect
  85205. */
  85206. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  85207. }
  85208. }
  85209. declare module BABYLON {
  85210. /**
  85211. * Class used to store bounding box information
  85212. */
  85213. export class BoundingBox implements ICullable {
  85214. /**
  85215. * Gets the 8 vectors representing the bounding box in local space
  85216. */
  85217. readonly vectors: Vector3[];
  85218. /**
  85219. * Gets the center of the bounding box in local space
  85220. */
  85221. readonly center: Vector3;
  85222. /**
  85223. * Gets the center of the bounding box in world space
  85224. */
  85225. readonly centerWorld: Vector3;
  85226. /**
  85227. * Gets the extend size in local space
  85228. */
  85229. readonly extendSize: Vector3;
  85230. /**
  85231. * Gets the extend size in world space
  85232. */
  85233. readonly extendSizeWorld: Vector3;
  85234. /**
  85235. * Gets the OBB (object bounding box) directions
  85236. */
  85237. readonly directions: Vector3[];
  85238. /**
  85239. * Gets the 8 vectors representing the bounding box in world space
  85240. */
  85241. readonly vectorsWorld: Vector3[];
  85242. /**
  85243. * Gets the minimum vector in world space
  85244. */
  85245. readonly minimumWorld: Vector3;
  85246. /**
  85247. * Gets the maximum vector in world space
  85248. */
  85249. readonly maximumWorld: Vector3;
  85250. /**
  85251. * Gets the minimum vector in local space
  85252. */
  85253. readonly minimum: Vector3;
  85254. /**
  85255. * Gets the maximum vector in local space
  85256. */
  85257. readonly maximum: Vector3;
  85258. private _worldMatrix;
  85259. private static readonly TmpVector3;
  85260. /**
  85261. * @hidden
  85262. */
  85263. _tag: number;
  85264. /**
  85265. * Creates a new bounding box
  85266. * @param min defines the minimum vector (in local space)
  85267. * @param max defines the maximum vector (in local space)
  85268. * @param worldMatrix defines the new world matrix
  85269. */
  85270. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85271. /**
  85272. * Recreates the entire bounding box from scratch as if we call the constructor in place
  85273. * @param min defines the new minimum vector (in local space)
  85274. * @param max defines the new maximum vector (in local space)
  85275. * @param worldMatrix defines the new world matrix
  85276. */
  85277. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85278. /**
  85279. * Scale the current bounding box by applying a scale factor
  85280. * @param factor defines the scale factor to apply
  85281. * @returns the current bounding box
  85282. */
  85283. scale(factor: number): BoundingBox;
  85284. /**
  85285. * Gets the world matrix of the bounding box
  85286. * @returns a matrix
  85287. */
  85288. getWorldMatrix(): DeepImmutable<Matrix>;
  85289. /** @hidden */
  85290. _update(world: DeepImmutable<Matrix>): void;
  85291. /**
  85292. * Tests if the bounding box is intersecting the frustum planes
  85293. * @param frustumPlanes defines the frustum planes to test
  85294. * @returns true if there is an intersection
  85295. */
  85296. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85297. /**
  85298. * Tests if the bounding box is entirely inside the frustum planes
  85299. * @param frustumPlanes defines the frustum planes to test
  85300. * @returns true if there is an inclusion
  85301. */
  85302. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85303. /**
  85304. * Tests if a point is inside the bounding box
  85305. * @param point defines the point to test
  85306. * @returns true if the point is inside the bounding box
  85307. */
  85308. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85309. /**
  85310. * Tests if the bounding box intersects with a bounding sphere
  85311. * @param sphere defines the sphere to test
  85312. * @returns true if there is an intersection
  85313. */
  85314. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  85315. /**
  85316. * Tests if the bounding box intersects with a box defined by a min and max vectors
  85317. * @param min defines the min vector to use
  85318. * @param max defines the max vector to use
  85319. * @returns true if there is an intersection
  85320. */
  85321. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  85322. /**
  85323. * Tests if two bounding boxes are intersections
  85324. * @param box0 defines the first box to test
  85325. * @param box1 defines the second box to test
  85326. * @returns true if there is an intersection
  85327. */
  85328. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  85329. /**
  85330. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  85331. * @param minPoint defines the minimum vector of the bounding box
  85332. * @param maxPoint defines the maximum vector of the bounding box
  85333. * @param sphereCenter defines the sphere center
  85334. * @param sphereRadius defines the sphere radius
  85335. * @returns true if there is an intersection
  85336. */
  85337. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  85338. /**
  85339. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  85340. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85341. * @param frustumPlanes defines the frustum planes to test
  85342. * @return true if there is an inclusion
  85343. */
  85344. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85345. /**
  85346. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  85347. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  85348. * @param frustumPlanes defines the frustum planes to test
  85349. * @return true if there is an intersection
  85350. */
  85351. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85352. }
  85353. }
  85354. declare module BABYLON {
  85355. /** @hidden */
  85356. export class Collider {
  85357. /** Define if a collision was found */
  85358. collisionFound: boolean;
  85359. /**
  85360. * Define last intersection point in local space
  85361. */
  85362. intersectionPoint: Vector3;
  85363. /**
  85364. * Define last collided mesh
  85365. */
  85366. collidedMesh: Nullable<AbstractMesh>;
  85367. private _collisionPoint;
  85368. private _planeIntersectionPoint;
  85369. private _tempVector;
  85370. private _tempVector2;
  85371. private _tempVector3;
  85372. private _tempVector4;
  85373. private _edge;
  85374. private _baseToVertex;
  85375. private _destinationPoint;
  85376. private _slidePlaneNormal;
  85377. private _displacementVector;
  85378. /** @hidden */
  85379. _radius: Vector3;
  85380. /** @hidden */
  85381. _retry: number;
  85382. private _velocity;
  85383. private _basePoint;
  85384. private _epsilon;
  85385. /** @hidden */
  85386. _velocityWorldLength: number;
  85387. /** @hidden */
  85388. _basePointWorld: Vector3;
  85389. private _velocityWorld;
  85390. private _normalizedVelocity;
  85391. /** @hidden */
  85392. _initialVelocity: Vector3;
  85393. /** @hidden */
  85394. _initialPosition: Vector3;
  85395. private _nearestDistance;
  85396. private _collisionMask;
  85397. get collisionMask(): number;
  85398. set collisionMask(mask: number);
  85399. /**
  85400. * Gets the plane normal used to compute the sliding response (in local space)
  85401. */
  85402. get slidePlaneNormal(): Vector3;
  85403. /** @hidden */
  85404. _initialize(source: Vector3, dir: Vector3, e: number): void;
  85405. /** @hidden */
  85406. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  85407. /** @hidden */
  85408. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  85409. /** @hidden */
  85410. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85411. /** @hidden */
  85412. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  85413. /** @hidden */
  85414. _getResponse(pos: Vector3, vel: Vector3): void;
  85415. }
  85416. }
  85417. declare module BABYLON {
  85418. /**
  85419. * Interface for cullable objects
  85420. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  85421. */
  85422. export interface ICullable {
  85423. /**
  85424. * Checks if the object or part of the object is in the frustum
  85425. * @param frustumPlanes Camera near/planes
  85426. * @returns true if the object is in frustum otherwise false
  85427. */
  85428. isInFrustum(frustumPlanes: Plane[]): boolean;
  85429. /**
  85430. * Checks if a cullable object (mesh...) is in the camera frustum
  85431. * Unlike isInFrustum this cheks the full bounding box
  85432. * @param frustumPlanes Camera near/planes
  85433. * @returns true if the object is in frustum otherwise false
  85434. */
  85435. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  85436. }
  85437. /**
  85438. * Info for a bounding data of a mesh
  85439. */
  85440. export class BoundingInfo implements ICullable {
  85441. /**
  85442. * Bounding box for the mesh
  85443. */
  85444. readonly boundingBox: BoundingBox;
  85445. /**
  85446. * Bounding sphere for the mesh
  85447. */
  85448. readonly boundingSphere: BoundingSphere;
  85449. private _isLocked;
  85450. private static readonly TmpVector3;
  85451. /**
  85452. * Constructs bounding info
  85453. * @param minimum min vector of the bounding box/sphere
  85454. * @param maximum max vector of the bounding box/sphere
  85455. * @param worldMatrix defines the new world matrix
  85456. */
  85457. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  85458. /**
  85459. * Recreates the entire bounding info from scratch as if we call the constructor in place
  85460. * @param min defines the new minimum vector (in local space)
  85461. * @param max defines the new maximum vector (in local space)
  85462. * @param worldMatrix defines the new world matrix
  85463. */
  85464. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  85465. /**
  85466. * min vector of the bounding box/sphere
  85467. */
  85468. get minimum(): Vector3;
  85469. /**
  85470. * max vector of the bounding box/sphere
  85471. */
  85472. get maximum(): Vector3;
  85473. /**
  85474. * If the info is locked and won't be updated to avoid perf overhead
  85475. */
  85476. get isLocked(): boolean;
  85477. set isLocked(value: boolean);
  85478. /**
  85479. * Updates the bounding sphere and box
  85480. * @param world world matrix to be used to update
  85481. */
  85482. update(world: DeepImmutable<Matrix>): void;
  85483. /**
  85484. * Recreate the bounding info to be centered around a specific point given a specific extend.
  85485. * @param center New center of the bounding info
  85486. * @param extend New extend of the bounding info
  85487. * @returns the current bounding info
  85488. */
  85489. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  85490. /**
  85491. * Scale the current bounding info by applying a scale factor
  85492. * @param factor defines the scale factor to apply
  85493. * @returns the current bounding info
  85494. */
  85495. scale(factor: number): BoundingInfo;
  85496. /**
  85497. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  85498. * @param frustumPlanes defines the frustum to test
  85499. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  85500. * @returns true if the bounding info is in the frustum planes
  85501. */
  85502. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  85503. /**
  85504. * Gets the world distance between the min and max points of the bounding box
  85505. */
  85506. get diagonalLength(): number;
  85507. /**
  85508. * Checks if a cullable object (mesh...) is in the camera frustum
  85509. * Unlike isInFrustum this cheks the full bounding box
  85510. * @param frustumPlanes Camera near/planes
  85511. * @returns true if the object is in frustum otherwise false
  85512. */
  85513. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  85514. /** @hidden */
  85515. _checkCollision(collider: Collider): boolean;
  85516. /**
  85517. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  85518. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85519. * @param point the point to check intersection with
  85520. * @returns if the point intersects
  85521. */
  85522. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  85523. /**
  85524. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  85525. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  85526. * @param boundingInfo the bounding info to check intersection with
  85527. * @param precise if the intersection should be done using OBB
  85528. * @returns if the bounding info intersects
  85529. */
  85530. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  85531. }
  85532. }
  85533. declare module BABYLON {
  85534. /**
  85535. * Extracts minimum and maximum values from a list of indexed positions
  85536. * @param positions defines the positions to use
  85537. * @param indices defines the indices to the positions
  85538. * @param indexStart defines the start index
  85539. * @param indexCount defines the end index
  85540. * @param bias defines bias value to add to the result
  85541. * @return minimum and maximum values
  85542. */
  85543. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  85544. minimum: Vector3;
  85545. maximum: Vector3;
  85546. };
  85547. /**
  85548. * Extracts minimum and maximum values from a list of positions
  85549. * @param positions defines the positions to use
  85550. * @param start defines the start index in the positions array
  85551. * @param count defines the number of positions to handle
  85552. * @param bias defines bias value to add to the result
  85553. * @param stride defines the stride size to use (distance between two positions in the positions array)
  85554. * @return minimum and maximum values
  85555. */
  85556. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  85557. minimum: Vector3;
  85558. maximum: Vector3;
  85559. };
  85560. }
  85561. declare module BABYLON {
  85562. /** @hidden */
  85563. export class WebGLDataBuffer extends DataBuffer {
  85564. private _buffer;
  85565. constructor(resource: WebGLBuffer);
  85566. get underlyingResource(): any;
  85567. }
  85568. }
  85569. declare module BABYLON {
  85570. /** @hidden */
  85571. export class WebGLPipelineContext implements IPipelineContext {
  85572. engine: ThinEngine;
  85573. program: Nullable<WebGLProgram>;
  85574. context?: WebGLRenderingContext;
  85575. vertexShader?: WebGLShader;
  85576. fragmentShader?: WebGLShader;
  85577. isParallelCompiled: boolean;
  85578. onCompiled?: () => void;
  85579. transformFeedback?: WebGLTransformFeedback | null;
  85580. vertexCompilationError: Nullable<string>;
  85581. fragmentCompilationError: Nullable<string>;
  85582. programLinkError: Nullable<string>;
  85583. programValidationError: Nullable<string>;
  85584. get isAsync(): boolean;
  85585. get isReady(): boolean;
  85586. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  85587. _getVertexShaderCode(): string | null;
  85588. _getFragmentShaderCode(): string | null;
  85589. }
  85590. }
  85591. declare module BABYLON {
  85592. interface ThinEngine {
  85593. /**
  85594. * Create an uniform buffer
  85595. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85596. * @param elements defines the content of the uniform buffer
  85597. * @returns the webGL uniform buffer
  85598. */
  85599. createUniformBuffer(elements: FloatArray): DataBuffer;
  85600. /**
  85601. * Create a dynamic uniform buffer
  85602. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85603. * @param elements defines the content of the uniform buffer
  85604. * @returns the webGL uniform buffer
  85605. */
  85606. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  85607. /**
  85608. * Update an existing uniform buffer
  85609. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  85610. * @param uniformBuffer defines the target uniform buffer
  85611. * @param elements defines the content to update
  85612. * @param offset defines the offset in the uniform buffer where update should start
  85613. * @param count defines the size of the data to update
  85614. */
  85615. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  85616. /**
  85617. * Bind an uniform buffer to the current webGL context
  85618. * @param buffer defines the buffer to bind
  85619. */
  85620. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  85621. /**
  85622. * Bind a buffer to the current webGL context at a given location
  85623. * @param buffer defines the buffer to bind
  85624. * @param location defines the index where to bind the buffer
  85625. */
  85626. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  85627. /**
  85628. * Bind a specific block at a given index in a specific shader program
  85629. * @param pipelineContext defines the pipeline context to use
  85630. * @param blockName defines the block name
  85631. * @param index defines the index where to bind the block
  85632. */
  85633. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  85634. }
  85635. }
  85636. declare module BABYLON {
  85637. /**
  85638. * Uniform buffer objects.
  85639. *
  85640. * Handles blocks of uniform on the GPU.
  85641. *
  85642. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85643. *
  85644. * For more information, please refer to :
  85645. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85646. */
  85647. export class UniformBuffer {
  85648. private _engine;
  85649. private _buffer;
  85650. private _data;
  85651. private _bufferData;
  85652. private _dynamic?;
  85653. private _uniformLocations;
  85654. private _uniformSizes;
  85655. private _uniformLocationPointer;
  85656. private _needSync;
  85657. private _noUBO;
  85658. private _currentEffect;
  85659. /** @hidden */
  85660. _alreadyBound: boolean;
  85661. private static _MAX_UNIFORM_SIZE;
  85662. private static _tempBuffer;
  85663. /**
  85664. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85665. * This is dynamic to allow compat with webgl 1 and 2.
  85666. * You will need to pass the name of the uniform as well as the value.
  85667. */
  85668. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85669. /**
  85670. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85671. * This is dynamic to allow compat with webgl 1 and 2.
  85672. * You will need to pass the name of the uniform as well as the value.
  85673. */
  85674. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85675. /**
  85676. * Lambda to Update a single float in a uniform buffer.
  85677. * This is dynamic to allow compat with webgl 1 and 2.
  85678. * You will need to pass the name of the uniform as well as the value.
  85679. */
  85680. updateFloat: (name: string, x: number) => void;
  85681. /**
  85682. * Lambda to Update a vec2 of float in a uniform buffer.
  85683. * This is dynamic to allow compat with webgl 1 and 2.
  85684. * You will need to pass the name of the uniform as well as the value.
  85685. */
  85686. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85687. /**
  85688. * Lambda to Update a vec3 of float in a uniform buffer.
  85689. * This is dynamic to allow compat with webgl 1 and 2.
  85690. * You will need to pass the name of the uniform as well as the value.
  85691. */
  85692. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85693. /**
  85694. * Lambda to Update a vec4 of float in a uniform buffer.
  85695. * This is dynamic to allow compat with webgl 1 and 2.
  85696. * You will need to pass the name of the uniform as well as the value.
  85697. */
  85698. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85699. /**
  85700. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85701. * This is dynamic to allow compat with webgl 1 and 2.
  85702. * You will need to pass the name of the uniform as well as the value.
  85703. */
  85704. updateMatrix: (name: string, mat: Matrix) => void;
  85705. /**
  85706. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85707. * This is dynamic to allow compat with webgl 1 and 2.
  85708. * You will need to pass the name of the uniform as well as the value.
  85709. */
  85710. updateVector3: (name: string, vector: Vector3) => void;
  85711. /**
  85712. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85713. * This is dynamic to allow compat with webgl 1 and 2.
  85714. * You will need to pass the name of the uniform as well as the value.
  85715. */
  85716. updateVector4: (name: string, vector: Vector4) => void;
  85717. /**
  85718. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85719. * This is dynamic to allow compat with webgl 1 and 2.
  85720. * You will need to pass the name of the uniform as well as the value.
  85721. */
  85722. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85723. /**
  85724. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85725. * This is dynamic to allow compat with webgl 1 and 2.
  85726. * You will need to pass the name of the uniform as well as the value.
  85727. */
  85728. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85729. /**
  85730. * Instantiates a new Uniform buffer objects.
  85731. *
  85732. * Handles blocks of uniform on the GPU.
  85733. *
  85734. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85735. *
  85736. * For more information, please refer to :
  85737. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85738. * @param engine Define the engine the buffer is associated with
  85739. * @param data Define the data contained in the buffer
  85740. * @param dynamic Define if the buffer is updatable
  85741. */
  85742. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85743. /**
  85744. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85745. * or just falling back on setUniformXXX calls.
  85746. */
  85747. get useUbo(): boolean;
  85748. /**
  85749. * Indicates if the WebGL underlying uniform buffer is in sync
  85750. * with the javascript cache data.
  85751. */
  85752. get isSync(): boolean;
  85753. /**
  85754. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85755. * Also, a dynamic UniformBuffer will disable cache verification and always
  85756. * update the underlying WebGL uniform buffer to the GPU.
  85757. * @returns if Dynamic, otherwise false
  85758. */
  85759. isDynamic(): boolean;
  85760. /**
  85761. * The data cache on JS side.
  85762. * @returns the underlying data as a float array
  85763. */
  85764. getData(): Float32Array;
  85765. /**
  85766. * The underlying WebGL Uniform buffer.
  85767. * @returns the webgl buffer
  85768. */
  85769. getBuffer(): Nullable<DataBuffer>;
  85770. /**
  85771. * std140 layout specifies how to align data within an UBO structure.
  85772. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85773. * for specs.
  85774. */
  85775. private _fillAlignment;
  85776. /**
  85777. * Adds an uniform in the buffer.
  85778. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85779. * for the layout to be correct !
  85780. * @param name Name of the uniform, as used in the uniform block in the shader.
  85781. * @param size Data size, or data directly.
  85782. */
  85783. addUniform(name: string, size: number | number[]): void;
  85784. /**
  85785. * Adds a Matrix 4x4 to the uniform buffer.
  85786. * @param name Name of the uniform, as used in the uniform block in the shader.
  85787. * @param mat A 4x4 matrix.
  85788. */
  85789. addMatrix(name: string, mat: Matrix): void;
  85790. /**
  85791. * Adds a vec2 to the uniform buffer.
  85792. * @param name Name of the uniform, as used in the uniform block in the shader.
  85793. * @param x Define the x component value of the vec2
  85794. * @param y Define the y component value of the vec2
  85795. */
  85796. addFloat2(name: string, x: number, y: number): void;
  85797. /**
  85798. * Adds a vec3 to the uniform buffer.
  85799. * @param name Name of the uniform, as used in the uniform block in the shader.
  85800. * @param x Define the x component value of the vec3
  85801. * @param y Define the y component value of the vec3
  85802. * @param z Define the z component value of the vec3
  85803. */
  85804. addFloat3(name: string, x: number, y: number, z: number): void;
  85805. /**
  85806. * Adds a vec3 to the uniform buffer.
  85807. * @param name Name of the uniform, as used in the uniform block in the shader.
  85808. * @param color Define the vec3 from a Color
  85809. */
  85810. addColor3(name: string, color: Color3): void;
  85811. /**
  85812. * Adds a vec4 to the uniform buffer.
  85813. * @param name Name of the uniform, as used in the uniform block in the shader.
  85814. * @param color Define the rgb components from a Color
  85815. * @param alpha Define the a component of the vec4
  85816. */
  85817. addColor4(name: string, color: Color3, alpha: number): void;
  85818. /**
  85819. * Adds a vec3 to the uniform buffer.
  85820. * @param name Name of the uniform, as used in the uniform block in the shader.
  85821. * @param vector Define the vec3 components from a Vector
  85822. */
  85823. addVector3(name: string, vector: Vector3): void;
  85824. /**
  85825. * Adds a Matrix 3x3 to the uniform buffer.
  85826. * @param name Name of the uniform, as used in the uniform block in the shader.
  85827. */
  85828. addMatrix3x3(name: string): void;
  85829. /**
  85830. * Adds a Matrix 2x2 to the uniform buffer.
  85831. * @param name Name of the uniform, as used in the uniform block in the shader.
  85832. */
  85833. addMatrix2x2(name: string): void;
  85834. /**
  85835. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85836. */
  85837. create(): void;
  85838. /** @hidden */
  85839. _rebuild(): void;
  85840. /**
  85841. * Updates the WebGL Uniform Buffer on the GPU.
  85842. * If the `dynamic` flag is set to true, no cache comparison is done.
  85843. * Otherwise, the buffer will be updated only if the cache differs.
  85844. */
  85845. update(): void;
  85846. /**
  85847. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85848. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85849. * @param data Define the flattened data
  85850. * @param size Define the size of the data.
  85851. */
  85852. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85853. private _valueCache;
  85854. private _cacheMatrix;
  85855. private _updateMatrix3x3ForUniform;
  85856. private _updateMatrix3x3ForEffect;
  85857. private _updateMatrix2x2ForEffect;
  85858. private _updateMatrix2x2ForUniform;
  85859. private _updateFloatForEffect;
  85860. private _updateFloatForUniform;
  85861. private _updateFloat2ForEffect;
  85862. private _updateFloat2ForUniform;
  85863. private _updateFloat3ForEffect;
  85864. private _updateFloat3ForUniform;
  85865. private _updateFloat4ForEffect;
  85866. private _updateFloat4ForUniform;
  85867. private _updateMatrixForEffect;
  85868. private _updateMatrixForUniform;
  85869. private _updateVector3ForEffect;
  85870. private _updateVector3ForUniform;
  85871. private _updateVector4ForEffect;
  85872. private _updateVector4ForUniform;
  85873. private _updateColor3ForEffect;
  85874. private _updateColor3ForUniform;
  85875. private _updateColor4ForEffect;
  85876. private _updateColor4ForUniform;
  85877. /**
  85878. * Sets a sampler uniform on the effect.
  85879. * @param name Define the name of the sampler.
  85880. * @param texture Define the texture to set in the sampler
  85881. */
  85882. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85883. /**
  85884. * Directly updates the value of the uniform in the cache AND on the GPU.
  85885. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85886. * @param data Define the flattened data
  85887. */
  85888. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85889. /**
  85890. * Binds this uniform buffer to an effect.
  85891. * @param effect Define the effect to bind the buffer to
  85892. * @param name Name of the uniform block in the shader.
  85893. */
  85894. bindToEffect(effect: Effect, name: string): void;
  85895. /**
  85896. * Disposes the uniform buffer.
  85897. */
  85898. dispose(): void;
  85899. }
  85900. }
  85901. declare module BABYLON {
  85902. /**
  85903. * Enum that determines the text-wrapping mode to use.
  85904. */
  85905. export enum InspectableType {
  85906. /**
  85907. * Checkbox for booleans
  85908. */
  85909. Checkbox = 0,
  85910. /**
  85911. * Sliders for numbers
  85912. */
  85913. Slider = 1,
  85914. /**
  85915. * Vector3
  85916. */
  85917. Vector3 = 2,
  85918. /**
  85919. * Quaternions
  85920. */
  85921. Quaternion = 3,
  85922. /**
  85923. * Color3
  85924. */
  85925. Color3 = 4,
  85926. /**
  85927. * String
  85928. */
  85929. String = 5
  85930. }
  85931. /**
  85932. * Interface used to define custom inspectable properties.
  85933. * This interface is used by the inspector to display custom property grids
  85934. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  85935. */
  85936. export interface IInspectable {
  85937. /**
  85938. * Gets the label to display
  85939. */
  85940. label: string;
  85941. /**
  85942. * Gets the name of the property to edit
  85943. */
  85944. propertyName: string;
  85945. /**
  85946. * Gets the type of the editor to use
  85947. */
  85948. type: InspectableType;
  85949. /**
  85950. * Gets the minimum value of the property when using in "slider" mode
  85951. */
  85952. min?: number;
  85953. /**
  85954. * Gets the maximum value of the property when using in "slider" mode
  85955. */
  85956. max?: number;
  85957. /**
  85958. * Gets the setp to use when using in "slider" mode
  85959. */
  85960. step?: number;
  85961. }
  85962. }
  85963. declare module BABYLON {
  85964. /**
  85965. * Class used to provide helper for timing
  85966. */
  85967. export class TimingTools {
  85968. /**
  85969. * Polyfill for setImmediate
  85970. * @param action defines the action to execute after the current execution block
  85971. */
  85972. static SetImmediate(action: () => void): void;
  85973. }
  85974. }
  85975. declare module BABYLON {
  85976. /**
  85977. * Class used to enable instatition of objects by class name
  85978. */
  85979. export class InstantiationTools {
  85980. /**
  85981. * Use this object to register external classes like custom textures or material
  85982. * to allow the laoders to instantiate them
  85983. */
  85984. static RegisteredExternalClasses: {
  85985. [key: string]: Object;
  85986. };
  85987. /**
  85988. * Tries to instantiate a new object from a given class name
  85989. * @param className defines the class name to instantiate
  85990. * @returns the new object or null if the system was not able to do the instantiation
  85991. */
  85992. static Instantiate(className: string): any;
  85993. }
  85994. }
  85995. declare module BABYLON {
  85996. /**
  85997. * Define options used to create a depth texture
  85998. */
  85999. export class DepthTextureCreationOptions {
  86000. /** Specifies whether or not a stencil should be allocated in the texture */
  86001. generateStencil?: boolean;
  86002. /** Specifies whether or not bilinear filtering is enable on the texture */
  86003. bilinearFiltering?: boolean;
  86004. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86005. comparisonFunction?: number;
  86006. /** Specifies if the created texture is a cube texture */
  86007. isCube?: boolean;
  86008. }
  86009. }
  86010. declare module BABYLON {
  86011. interface ThinEngine {
  86012. /**
  86013. * Creates a depth stencil cube texture.
  86014. * This is only available in WebGL 2.
  86015. * @param size The size of face edge in the cube texture.
  86016. * @param options The options defining the cube texture.
  86017. * @returns The cube texture
  86018. */
  86019. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  86020. /**
  86021. * Creates a cube texture
  86022. * @param rootUrl defines the url where the files to load is located
  86023. * @param scene defines the current scene
  86024. * @param files defines the list of files to load (1 per face)
  86025. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86026. * @param onLoad defines an optional callback raised when the texture is loaded
  86027. * @param onError defines an optional callback raised if there is an issue to load the texture
  86028. * @param format defines the format of the data
  86029. * @param forcedExtension defines the extension to use to pick the right loader
  86030. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86031. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86032. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86033. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  86034. * @returns the cube texture as an InternalTexture
  86035. */
  86036. 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;
  86037. /**
  86038. * Creates a cube texture
  86039. * @param rootUrl defines the url where the files to load is located
  86040. * @param scene defines the current scene
  86041. * @param files defines the list of files to load (1 per face)
  86042. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86043. * @param onLoad defines an optional callback raised when the texture is loaded
  86044. * @param onError defines an optional callback raised if there is an issue to load the texture
  86045. * @param format defines the format of the data
  86046. * @param forcedExtension defines the extension to use to pick the right loader
  86047. * @returns the cube texture as an InternalTexture
  86048. */
  86049. 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;
  86050. /**
  86051. * Creates a cube texture
  86052. * @param rootUrl defines the url where the files to load is located
  86053. * @param scene defines the current scene
  86054. * @param files defines the list of files to load (1 per face)
  86055. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  86056. * @param onLoad defines an optional callback raised when the texture is loaded
  86057. * @param onError defines an optional callback raised if there is an issue to load the texture
  86058. * @param format defines the format of the data
  86059. * @param forcedExtension defines the extension to use to pick the right loader
  86060. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  86061. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86062. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86063. * @returns the cube texture as an InternalTexture
  86064. */
  86065. 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;
  86066. /** @hidden */
  86067. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  86068. /** @hidden */
  86069. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  86070. /** @hidden */
  86071. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86072. /** @hidden */
  86073. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  86074. /**
  86075. * @hidden
  86076. */
  86077. _setCubeMapTextureParams(loadMipmap: boolean): void;
  86078. }
  86079. }
  86080. declare module BABYLON {
  86081. /**
  86082. * Class for creating a cube texture
  86083. */
  86084. export class CubeTexture extends BaseTexture {
  86085. private _delayedOnLoad;
  86086. /**
  86087. * Observable triggered once the texture has been loaded.
  86088. */
  86089. onLoadObservable: Observable<CubeTexture>;
  86090. /**
  86091. * The url of the texture
  86092. */
  86093. url: string;
  86094. /**
  86095. * Gets or sets the center of the bounding box associated with the cube texture.
  86096. * It must define where the camera used to render the texture was set
  86097. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86098. */
  86099. boundingBoxPosition: Vector3;
  86100. private _boundingBoxSize;
  86101. /**
  86102. * Gets or sets the size of the bounding box associated with the cube texture
  86103. * When defined, the cubemap will switch to local mode
  86104. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86105. * @example https://www.babylonjs-playground.com/#RNASML
  86106. */
  86107. set boundingBoxSize(value: Vector3);
  86108. /**
  86109. * Returns the bounding box size
  86110. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  86111. */
  86112. get boundingBoxSize(): Vector3;
  86113. protected _rotationY: number;
  86114. /**
  86115. * Sets texture matrix rotation angle around Y axis in radians.
  86116. */
  86117. set rotationY(value: number);
  86118. /**
  86119. * Gets texture matrix rotation angle around Y axis radians.
  86120. */
  86121. get rotationY(): number;
  86122. /**
  86123. * Are mip maps generated for this texture or not.
  86124. */
  86125. get noMipmap(): boolean;
  86126. private _noMipmap;
  86127. private _files;
  86128. protected _forcedExtension: Nullable<string>;
  86129. private _extensions;
  86130. private _textureMatrix;
  86131. private _format;
  86132. private _createPolynomials;
  86133. /**
  86134. * Creates a cube texture from an array of image urls
  86135. * @param files defines an array of image urls
  86136. * @param scene defines the hosting scene
  86137. * @param noMipmap specifies if mip maps are not used
  86138. * @returns a cube texture
  86139. */
  86140. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  86141. /**
  86142. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  86143. * @param url defines the url of the prefiltered texture
  86144. * @param scene defines the scene the texture is attached to
  86145. * @param forcedExtension defines the extension of the file if different from the url
  86146. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86147. * @return the prefiltered texture
  86148. */
  86149. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  86150. /**
  86151. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  86152. * as prefiltered data.
  86153. * @param rootUrl defines the url of the texture or the root name of the six images
  86154. * @param null defines the scene or engine the texture is attached to
  86155. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  86156. * @param noMipmap defines if mipmaps should be created or not
  86157. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  86158. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  86159. * @param onError defines a callback triggered in case of error during load
  86160. * @param format defines the internal format to use for the texture once loaded
  86161. * @param prefiltered defines whether or not the texture is created from prefiltered data
  86162. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  86163. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  86164. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  86165. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  86166. * @return the cube texture
  86167. */
  86168. 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);
  86169. /**
  86170. * Get the current class name of the texture useful for serialization or dynamic coding.
  86171. * @returns "CubeTexture"
  86172. */
  86173. getClassName(): string;
  86174. /**
  86175. * Update the url (and optional buffer) of this texture if url was null during construction.
  86176. * @param url the url of the texture
  86177. * @param forcedExtension defines the extension to use
  86178. * @param onLoad callback called when the texture is loaded (defaults to null)
  86179. * @param prefiltered Defines whether the updated texture is prefiltered or not
  86180. */
  86181. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  86182. /**
  86183. * Delays loading of the cube texture
  86184. * @param forcedExtension defines the extension to use
  86185. */
  86186. delayLoad(forcedExtension?: string): void;
  86187. /**
  86188. * Returns the reflection texture matrix
  86189. * @returns the reflection texture matrix
  86190. */
  86191. getReflectionTextureMatrix(): Matrix;
  86192. /**
  86193. * Sets the reflection texture matrix
  86194. * @param value Reflection texture matrix
  86195. */
  86196. setReflectionTextureMatrix(value: Matrix): void;
  86197. /**
  86198. * Parses text to create a cube texture
  86199. * @param parsedTexture define the serialized text to read from
  86200. * @param scene defines the hosting scene
  86201. * @param rootUrl defines the root url of the cube texture
  86202. * @returns a cube texture
  86203. */
  86204. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  86205. /**
  86206. * Makes a clone, or deep copy, of the cube texture
  86207. * @returns a new cube texture
  86208. */
  86209. clone(): CubeTexture;
  86210. }
  86211. }
  86212. declare module BABYLON {
  86213. /**
  86214. * Manages the defines for the Material
  86215. */
  86216. export class MaterialDefines {
  86217. /** @hidden */
  86218. protected _keys: string[];
  86219. private _isDirty;
  86220. /** @hidden */
  86221. _renderId: number;
  86222. /** @hidden */
  86223. _areLightsDirty: boolean;
  86224. /** @hidden */
  86225. _areLightsDisposed: boolean;
  86226. /** @hidden */
  86227. _areAttributesDirty: boolean;
  86228. /** @hidden */
  86229. _areTexturesDirty: boolean;
  86230. /** @hidden */
  86231. _areFresnelDirty: boolean;
  86232. /** @hidden */
  86233. _areMiscDirty: boolean;
  86234. /** @hidden */
  86235. _areImageProcessingDirty: boolean;
  86236. /** @hidden */
  86237. _normals: boolean;
  86238. /** @hidden */
  86239. _uvs: boolean;
  86240. /** @hidden */
  86241. _needNormals: boolean;
  86242. /** @hidden */
  86243. _needUVs: boolean;
  86244. [id: string]: any;
  86245. /**
  86246. * Specifies if the material needs to be re-calculated
  86247. */
  86248. get isDirty(): boolean;
  86249. /**
  86250. * Marks the material to indicate that it has been re-calculated
  86251. */
  86252. markAsProcessed(): void;
  86253. /**
  86254. * Marks the material to indicate that it needs to be re-calculated
  86255. */
  86256. markAsUnprocessed(): void;
  86257. /**
  86258. * Marks the material to indicate all of its defines need to be re-calculated
  86259. */
  86260. markAllAsDirty(): void;
  86261. /**
  86262. * Marks the material to indicate that image processing needs to be re-calculated
  86263. */
  86264. markAsImageProcessingDirty(): void;
  86265. /**
  86266. * Marks the material to indicate the lights need to be re-calculated
  86267. * @param disposed Defines whether the light is dirty due to dispose or not
  86268. */
  86269. markAsLightDirty(disposed?: boolean): void;
  86270. /**
  86271. * Marks the attribute state as changed
  86272. */
  86273. markAsAttributesDirty(): void;
  86274. /**
  86275. * Marks the texture state as changed
  86276. */
  86277. markAsTexturesDirty(): void;
  86278. /**
  86279. * Marks the fresnel state as changed
  86280. */
  86281. markAsFresnelDirty(): void;
  86282. /**
  86283. * Marks the misc state as changed
  86284. */
  86285. markAsMiscDirty(): void;
  86286. /**
  86287. * Rebuilds the material defines
  86288. */
  86289. rebuild(): void;
  86290. /**
  86291. * Specifies if two material defines are equal
  86292. * @param other - A material define instance to compare to
  86293. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  86294. */
  86295. isEqual(other: MaterialDefines): boolean;
  86296. /**
  86297. * Clones this instance's defines to another instance
  86298. * @param other - material defines to clone values to
  86299. */
  86300. cloneTo(other: MaterialDefines): void;
  86301. /**
  86302. * Resets the material define values
  86303. */
  86304. reset(): void;
  86305. /**
  86306. * Converts the material define values to a string
  86307. * @returns - String of material define information
  86308. */
  86309. toString(): string;
  86310. }
  86311. }
  86312. declare module BABYLON {
  86313. /**
  86314. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  86315. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  86316. * 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;
  86317. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  86318. */
  86319. export class ColorCurves {
  86320. private _dirty;
  86321. private _tempColor;
  86322. private _globalCurve;
  86323. private _highlightsCurve;
  86324. private _midtonesCurve;
  86325. private _shadowsCurve;
  86326. private _positiveCurve;
  86327. private _negativeCurve;
  86328. private _globalHue;
  86329. private _globalDensity;
  86330. private _globalSaturation;
  86331. private _globalExposure;
  86332. /**
  86333. * Gets the global Hue value.
  86334. * 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).
  86335. */
  86336. get globalHue(): number;
  86337. /**
  86338. * Sets the global Hue value.
  86339. * 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).
  86340. */
  86341. set globalHue(value: number);
  86342. /**
  86343. * Gets the global Density value.
  86344. * 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.
  86345. * Values less than zero provide a filter of opposite hue.
  86346. */
  86347. get globalDensity(): number;
  86348. /**
  86349. * Sets the global Density value.
  86350. * 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.
  86351. * Values less than zero provide a filter of opposite hue.
  86352. */
  86353. set globalDensity(value: number);
  86354. /**
  86355. * Gets the global Saturation value.
  86356. * 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.
  86357. */
  86358. get globalSaturation(): number;
  86359. /**
  86360. * Sets the global Saturation value.
  86361. * 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.
  86362. */
  86363. set globalSaturation(value: number);
  86364. /**
  86365. * Gets the global Exposure value.
  86366. * 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.
  86367. */
  86368. get globalExposure(): number;
  86369. /**
  86370. * Sets the global Exposure value.
  86371. * 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.
  86372. */
  86373. set globalExposure(value: number);
  86374. private _highlightsHue;
  86375. private _highlightsDensity;
  86376. private _highlightsSaturation;
  86377. private _highlightsExposure;
  86378. /**
  86379. * Gets the highlights Hue value.
  86380. * 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).
  86381. */
  86382. get highlightsHue(): number;
  86383. /**
  86384. * Sets the highlights Hue value.
  86385. * 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).
  86386. */
  86387. set highlightsHue(value: number);
  86388. /**
  86389. * Gets the highlights Density value.
  86390. * 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.
  86391. * Values less than zero provide a filter of opposite hue.
  86392. */
  86393. get highlightsDensity(): number;
  86394. /**
  86395. * Sets the highlights Density value.
  86396. * 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.
  86397. * Values less than zero provide a filter of opposite hue.
  86398. */
  86399. set highlightsDensity(value: number);
  86400. /**
  86401. * Gets the highlights Saturation value.
  86402. * 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.
  86403. */
  86404. get highlightsSaturation(): number;
  86405. /**
  86406. * Sets the highlights Saturation value.
  86407. * 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.
  86408. */
  86409. set highlightsSaturation(value: number);
  86410. /**
  86411. * Gets the highlights Exposure value.
  86412. * 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.
  86413. */
  86414. get highlightsExposure(): number;
  86415. /**
  86416. * Sets the highlights Exposure value.
  86417. * 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.
  86418. */
  86419. set highlightsExposure(value: number);
  86420. private _midtonesHue;
  86421. private _midtonesDensity;
  86422. private _midtonesSaturation;
  86423. private _midtonesExposure;
  86424. /**
  86425. * Gets the midtones Hue value.
  86426. * 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).
  86427. */
  86428. get midtonesHue(): number;
  86429. /**
  86430. * Sets the midtones Hue value.
  86431. * 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).
  86432. */
  86433. set midtonesHue(value: number);
  86434. /**
  86435. * Gets the midtones Density value.
  86436. * 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.
  86437. * Values less than zero provide a filter of opposite hue.
  86438. */
  86439. get midtonesDensity(): number;
  86440. /**
  86441. * Sets the midtones Density value.
  86442. * 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.
  86443. * Values less than zero provide a filter of opposite hue.
  86444. */
  86445. set midtonesDensity(value: number);
  86446. /**
  86447. * Gets the midtones Saturation value.
  86448. * 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.
  86449. */
  86450. get midtonesSaturation(): number;
  86451. /**
  86452. * Sets the midtones Saturation value.
  86453. * 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.
  86454. */
  86455. set midtonesSaturation(value: number);
  86456. /**
  86457. * Gets the midtones Exposure value.
  86458. * 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.
  86459. */
  86460. get midtonesExposure(): number;
  86461. /**
  86462. * Sets the midtones Exposure value.
  86463. * 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.
  86464. */
  86465. set midtonesExposure(value: number);
  86466. private _shadowsHue;
  86467. private _shadowsDensity;
  86468. private _shadowsSaturation;
  86469. private _shadowsExposure;
  86470. /**
  86471. * Gets the shadows Hue value.
  86472. * 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).
  86473. */
  86474. get shadowsHue(): number;
  86475. /**
  86476. * Sets the shadows Hue value.
  86477. * 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).
  86478. */
  86479. set shadowsHue(value: number);
  86480. /**
  86481. * Gets the shadows Density value.
  86482. * 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.
  86483. * Values less than zero provide a filter of opposite hue.
  86484. */
  86485. get shadowsDensity(): number;
  86486. /**
  86487. * Sets the shadows Density value.
  86488. * 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.
  86489. * Values less than zero provide a filter of opposite hue.
  86490. */
  86491. set shadowsDensity(value: number);
  86492. /**
  86493. * Gets the shadows Saturation value.
  86494. * 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.
  86495. */
  86496. get shadowsSaturation(): number;
  86497. /**
  86498. * Sets the shadows Saturation value.
  86499. * 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.
  86500. */
  86501. set shadowsSaturation(value: number);
  86502. /**
  86503. * Gets the shadows Exposure value.
  86504. * 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.
  86505. */
  86506. get shadowsExposure(): number;
  86507. /**
  86508. * Sets the shadows Exposure value.
  86509. * 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.
  86510. */
  86511. set shadowsExposure(value: number);
  86512. /**
  86513. * Returns the class name
  86514. * @returns The class name
  86515. */
  86516. getClassName(): string;
  86517. /**
  86518. * Binds the color curves to the shader.
  86519. * @param colorCurves The color curve to bind
  86520. * @param effect The effect to bind to
  86521. * @param positiveUniform The positive uniform shader parameter
  86522. * @param neutralUniform The neutral uniform shader parameter
  86523. * @param negativeUniform The negative uniform shader parameter
  86524. */
  86525. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  86526. /**
  86527. * Prepare the list of uniforms associated with the ColorCurves effects.
  86528. * @param uniformsList The list of uniforms used in the effect
  86529. */
  86530. static PrepareUniforms(uniformsList: string[]): void;
  86531. /**
  86532. * Returns color grading data based on a hue, density, saturation and exposure value.
  86533. * @param filterHue The hue of the color filter.
  86534. * @param filterDensity The density of the color filter.
  86535. * @param saturation The saturation.
  86536. * @param exposure The exposure.
  86537. * @param result The result data container.
  86538. */
  86539. private getColorGradingDataToRef;
  86540. /**
  86541. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  86542. * @param value The input slider value in range [-100,100].
  86543. * @returns Adjusted value.
  86544. */
  86545. private static applyColorGradingSliderNonlinear;
  86546. /**
  86547. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  86548. * @param hue The hue (H) input.
  86549. * @param saturation The saturation (S) input.
  86550. * @param brightness The brightness (B) input.
  86551. * @result An RGBA color represented as Vector4.
  86552. */
  86553. private static fromHSBToRef;
  86554. /**
  86555. * Returns a value clamped between min and max
  86556. * @param value The value to clamp
  86557. * @param min The minimum of value
  86558. * @param max The maximum of value
  86559. * @returns The clamped value.
  86560. */
  86561. private static clamp;
  86562. /**
  86563. * Clones the current color curve instance.
  86564. * @return The cloned curves
  86565. */
  86566. clone(): ColorCurves;
  86567. /**
  86568. * Serializes the current color curve instance to a json representation.
  86569. * @return a JSON representation
  86570. */
  86571. serialize(): any;
  86572. /**
  86573. * Parses the color curve from a json representation.
  86574. * @param source the JSON source to parse
  86575. * @return The parsed curves
  86576. */
  86577. static Parse(source: any): ColorCurves;
  86578. }
  86579. }
  86580. declare module BABYLON {
  86581. /**
  86582. * Interface to follow in your material defines to integrate easily the
  86583. * Image proccessing functions.
  86584. * @hidden
  86585. */
  86586. export interface IImageProcessingConfigurationDefines {
  86587. IMAGEPROCESSING: boolean;
  86588. VIGNETTE: boolean;
  86589. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86590. VIGNETTEBLENDMODEOPAQUE: boolean;
  86591. TONEMAPPING: boolean;
  86592. TONEMAPPING_ACES: boolean;
  86593. CONTRAST: boolean;
  86594. EXPOSURE: boolean;
  86595. COLORCURVES: boolean;
  86596. COLORGRADING: boolean;
  86597. COLORGRADING3D: boolean;
  86598. SAMPLER3DGREENDEPTH: boolean;
  86599. SAMPLER3DBGRMAP: boolean;
  86600. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86601. }
  86602. /**
  86603. * @hidden
  86604. */
  86605. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  86606. IMAGEPROCESSING: boolean;
  86607. VIGNETTE: boolean;
  86608. VIGNETTEBLENDMODEMULTIPLY: boolean;
  86609. VIGNETTEBLENDMODEOPAQUE: boolean;
  86610. TONEMAPPING: boolean;
  86611. TONEMAPPING_ACES: boolean;
  86612. CONTRAST: boolean;
  86613. COLORCURVES: boolean;
  86614. COLORGRADING: boolean;
  86615. COLORGRADING3D: boolean;
  86616. SAMPLER3DGREENDEPTH: boolean;
  86617. SAMPLER3DBGRMAP: boolean;
  86618. IMAGEPROCESSINGPOSTPROCESS: boolean;
  86619. EXPOSURE: boolean;
  86620. constructor();
  86621. }
  86622. /**
  86623. * This groups together the common properties used for image processing either in direct forward pass
  86624. * or through post processing effect depending on the use of the image processing pipeline in your scene
  86625. * or not.
  86626. */
  86627. export class ImageProcessingConfiguration {
  86628. /**
  86629. * Default tone mapping applied in BabylonJS.
  86630. */
  86631. static readonly TONEMAPPING_STANDARD: number;
  86632. /**
  86633. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  86634. * to other engines rendering to increase portability.
  86635. */
  86636. static readonly TONEMAPPING_ACES: number;
  86637. /**
  86638. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  86639. */
  86640. colorCurves: Nullable<ColorCurves>;
  86641. private _colorCurvesEnabled;
  86642. /**
  86643. * Gets wether the color curves effect is enabled.
  86644. */
  86645. get colorCurvesEnabled(): boolean;
  86646. /**
  86647. * Sets wether the color curves effect is enabled.
  86648. */
  86649. set colorCurvesEnabled(value: boolean);
  86650. private _colorGradingTexture;
  86651. /**
  86652. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86653. */
  86654. get colorGradingTexture(): Nullable<BaseTexture>;
  86655. /**
  86656. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  86657. */
  86658. set colorGradingTexture(value: Nullable<BaseTexture>);
  86659. private _colorGradingEnabled;
  86660. /**
  86661. * Gets wether the color grading effect is enabled.
  86662. */
  86663. get colorGradingEnabled(): boolean;
  86664. /**
  86665. * Sets wether the color grading effect is enabled.
  86666. */
  86667. set colorGradingEnabled(value: boolean);
  86668. private _colorGradingWithGreenDepth;
  86669. /**
  86670. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  86671. */
  86672. get colorGradingWithGreenDepth(): boolean;
  86673. /**
  86674. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  86675. */
  86676. set colorGradingWithGreenDepth(value: boolean);
  86677. private _colorGradingBGR;
  86678. /**
  86679. * Gets wether the color grading texture contains BGR values.
  86680. */
  86681. get colorGradingBGR(): boolean;
  86682. /**
  86683. * Sets wether the color grading texture contains BGR values.
  86684. */
  86685. set colorGradingBGR(value: boolean);
  86686. /** @hidden */
  86687. _exposure: number;
  86688. /**
  86689. * Gets the Exposure used in the effect.
  86690. */
  86691. get exposure(): number;
  86692. /**
  86693. * Sets the Exposure used in the effect.
  86694. */
  86695. set exposure(value: number);
  86696. private _toneMappingEnabled;
  86697. /**
  86698. * Gets wether the tone mapping effect is enabled.
  86699. */
  86700. get toneMappingEnabled(): boolean;
  86701. /**
  86702. * Sets wether the tone mapping effect is enabled.
  86703. */
  86704. set toneMappingEnabled(value: boolean);
  86705. private _toneMappingType;
  86706. /**
  86707. * Gets the type of tone mapping effect.
  86708. */
  86709. get toneMappingType(): number;
  86710. /**
  86711. * Sets the type of tone mapping effect used in BabylonJS.
  86712. */
  86713. set toneMappingType(value: number);
  86714. protected _contrast: number;
  86715. /**
  86716. * Gets the contrast used in the effect.
  86717. */
  86718. get contrast(): number;
  86719. /**
  86720. * Sets the contrast used in the effect.
  86721. */
  86722. set contrast(value: number);
  86723. /**
  86724. * Vignette stretch size.
  86725. */
  86726. vignetteStretch: number;
  86727. /**
  86728. * Vignette centre X Offset.
  86729. */
  86730. vignetteCentreX: number;
  86731. /**
  86732. * Vignette centre Y Offset.
  86733. */
  86734. vignetteCentreY: number;
  86735. /**
  86736. * Vignette weight or intensity of the vignette effect.
  86737. */
  86738. vignetteWeight: number;
  86739. /**
  86740. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  86741. * if vignetteEnabled is set to true.
  86742. */
  86743. vignetteColor: Color4;
  86744. /**
  86745. * Camera field of view used by the Vignette effect.
  86746. */
  86747. vignetteCameraFov: number;
  86748. private _vignetteBlendMode;
  86749. /**
  86750. * Gets the vignette blend mode allowing different kind of effect.
  86751. */
  86752. get vignetteBlendMode(): number;
  86753. /**
  86754. * Sets the vignette blend mode allowing different kind of effect.
  86755. */
  86756. set vignetteBlendMode(value: number);
  86757. private _vignetteEnabled;
  86758. /**
  86759. * Gets wether the vignette effect is enabled.
  86760. */
  86761. get vignetteEnabled(): boolean;
  86762. /**
  86763. * Sets wether the vignette effect is enabled.
  86764. */
  86765. set vignetteEnabled(value: boolean);
  86766. private _applyByPostProcess;
  86767. /**
  86768. * Gets wether the image processing is applied through a post process or not.
  86769. */
  86770. get applyByPostProcess(): boolean;
  86771. /**
  86772. * Sets wether the image processing is applied through a post process or not.
  86773. */
  86774. set applyByPostProcess(value: boolean);
  86775. private _isEnabled;
  86776. /**
  86777. * Gets wether the image processing is enabled or not.
  86778. */
  86779. get isEnabled(): boolean;
  86780. /**
  86781. * Sets wether the image processing is enabled or not.
  86782. */
  86783. set isEnabled(value: boolean);
  86784. /**
  86785. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  86786. */
  86787. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  86788. /**
  86789. * Method called each time the image processing information changes requires to recompile the effect.
  86790. */
  86791. protected _updateParameters(): void;
  86792. /**
  86793. * Gets the current class name.
  86794. * @return "ImageProcessingConfiguration"
  86795. */
  86796. getClassName(): string;
  86797. /**
  86798. * Prepare the list of uniforms associated with the Image Processing effects.
  86799. * @param uniforms The list of uniforms used in the effect
  86800. * @param defines the list of defines currently in use
  86801. */
  86802. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  86803. /**
  86804. * Prepare the list of samplers associated with the Image Processing effects.
  86805. * @param samplersList The list of uniforms used in the effect
  86806. * @param defines the list of defines currently in use
  86807. */
  86808. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  86809. /**
  86810. * Prepare the list of defines associated to the shader.
  86811. * @param defines the list of defines to complete
  86812. * @param forPostProcess Define if we are currently in post process mode or not
  86813. */
  86814. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  86815. /**
  86816. * Returns true if all the image processing information are ready.
  86817. * @returns True if ready, otherwise, false
  86818. */
  86819. isReady(): boolean;
  86820. /**
  86821. * Binds the image processing to the shader.
  86822. * @param effect The effect to bind to
  86823. * @param overrideAspectRatio Override the aspect ratio of the effect
  86824. */
  86825. bind(effect: Effect, overrideAspectRatio?: number): void;
  86826. /**
  86827. * Clones the current image processing instance.
  86828. * @return The cloned image processing
  86829. */
  86830. clone(): ImageProcessingConfiguration;
  86831. /**
  86832. * Serializes the current image processing instance to a json representation.
  86833. * @return a JSON representation
  86834. */
  86835. serialize(): any;
  86836. /**
  86837. * Parses the image processing from a json representation.
  86838. * @param source the JSON source to parse
  86839. * @return The parsed image processing
  86840. */
  86841. static Parse(source: any): ImageProcessingConfiguration;
  86842. private static _VIGNETTEMODE_MULTIPLY;
  86843. private static _VIGNETTEMODE_OPAQUE;
  86844. /**
  86845. * Used to apply the vignette as a mix with the pixel color.
  86846. */
  86847. static get VIGNETTEMODE_MULTIPLY(): number;
  86848. /**
  86849. * Used to apply the vignette as a replacement of the pixel color.
  86850. */
  86851. static get VIGNETTEMODE_OPAQUE(): number;
  86852. }
  86853. }
  86854. declare module BABYLON {
  86855. /** @hidden */
  86856. export var postprocessVertexShader: {
  86857. name: string;
  86858. shader: string;
  86859. };
  86860. }
  86861. declare module BABYLON {
  86862. interface ThinEngine {
  86863. /**
  86864. * Creates a new render target texture
  86865. * @param size defines the size of the texture
  86866. * @param options defines the options used to create the texture
  86867. * @returns a new render target texture stored in an InternalTexture
  86868. */
  86869. createRenderTargetTexture(size: number | {
  86870. width: number;
  86871. height: number;
  86872. layers?: number;
  86873. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  86874. /**
  86875. * Creates a depth stencil texture.
  86876. * This is only available in WebGL 2 or with the depth texture extension available.
  86877. * @param size The size of face edge in the texture.
  86878. * @param options The options defining the texture.
  86879. * @returns The texture
  86880. */
  86881. createDepthStencilTexture(size: number | {
  86882. width: number;
  86883. height: number;
  86884. layers?: number;
  86885. }, options: DepthTextureCreationOptions): InternalTexture;
  86886. /** @hidden */
  86887. _createDepthStencilTexture(size: number | {
  86888. width: number;
  86889. height: number;
  86890. layers?: number;
  86891. }, options: DepthTextureCreationOptions): InternalTexture;
  86892. }
  86893. }
  86894. declare module BABYLON {
  86895. /**
  86896. * Defines the kind of connection point for node based material
  86897. */
  86898. export enum NodeMaterialBlockConnectionPointTypes {
  86899. /** Float */
  86900. Float = 1,
  86901. /** Int */
  86902. Int = 2,
  86903. /** Vector2 */
  86904. Vector2 = 4,
  86905. /** Vector3 */
  86906. Vector3 = 8,
  86907. /** Vector4 */
  86908. Vector4 = 16,
  86909. /** Color3 */
  86910. Color3 = 32,
  86911. /** Color4 */
  86912. Color4 = 64,
  86913. /** Matrix */
  86914. Matrix = 128,
  86915. /** Custom object */
  86916. Object = 256,
  86917. /** Detect type based on connection */
  86918. AutoDetect = 1024,
  86919. /** Output type that will be defined by input type */
  86920. BasedOnInput = 2048
  86921. }
  86922. }
  86923. declare module BABYLON {
  86924. /**
  86925. * Enum used to define the target of a block
  86926. */
  86927. export enum NodeMaterialBlockTargets {
  86928. /** Vertex shader */
  86929. Vertex = 1,
  86930. /** Fragment shader */
  86931. Fragment = 2,
  86932. /** Neutral */
  86933. Neutral = 4,
  86934. /** Vertex and Fragment */
  86935. VertexAndFragment = 3
  86936. }
  86937. }
  86938. declare module BABYLON {
  86939. /**
  86940. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  86941. */
  86942. export enum NodeMaterialBlockConnectionPointMode {
  86943. /** Value is an uniform */
  86944. Uniform = 0,
  86945. /** Value is a mesh attribute */
  86946. Attribute = 1,
  86947. /** Value is a varying between vertex and fragment shaders */
  86948. Varying = 2,
  86949. /** Mode is undefined */
  86950. Undefined = 3
  86951. }
  86952. }
  86953. declare module BABYLON {
  86954. /**
  86955. * Enum used to define system values e.g. values automatically provided by the system
  86956. */
  86957. export enum NodeMaterialSystemValues {
  86958. /** World */
  86959. World = 1,
  86960. /** View */
  86961. View = 2,
  86962. /** Projection */
  86963. Projection = 3,
  86964. /** ViewProjection */
  86965. ViewProjection = 4,
  86966. /** WorldView */
  86967. WorldView = 5,
  86968. /** WorldViewProjection */
  86969. WorldViewProjection = 6,
  86970. /** CameraPosition */
  86971. CameraPosition = 7,
  86972. /** Fog Color */
  86973. FogColor = 8,
  86974. /** Delta time */
  86975. DeltaTime = 9
  86976. }
  86977. }
  86978. declare module BABYLON {
  86979. /** Defines supported spaces */
  86980. export enum Space {
  86981. /** Local (object) space */
  86982. LOCAL = 0,
  86983. /** World space */
  86984. WORLD = 1,
  86985. /** Bone space */
  86986. BONE = 2
  86987. }
  86988. /** Defines the 3 main axes */
  86989. export class Axis {
  86990. /** X axis */
  86991. static X: Vector3;
  86992. /** Y axis */
  86993. static Y: Vector3;
  86994. /** Z axis */
  86995. static Z: Vector3;
  86996. }
  86997. }
  86998. declare module BABYLON {
  86999. /**
  87000. * Represents a camera frustum
  87001. */
  87002. export class Frustum {
  87003. /**
  87004. * Gets the planes representing the frustum
  87005. * @param transform matrix to be applied to the returned planes
  87006. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  87007. */
  87008. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  87009. /**
  87010. * Gets the near frustum plane transformed by the transform matrix
  87011. * @param transform transformation matrix to be applied to the resulting frustum plane
  87012. * @param frustumPlane the resuling frustum plane
  87013. */
  87014. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87015. /**
  87016. * Gets the far frustum plane transformed by the transform matrix
  87017. * @param transform transformation matrix to be applied to the resulting frustum plane
  87018. * @param frustumPlane the resuling frustum plane
  87019. */
  87020. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87021. /**
  87022. * Gets the left frustum plane transformed by the transform matrix
  87023. * @param transform transformation matrix to be applied to the resulting frustum plane
  87024. * @param frustumPlane the resuling frustum plane
  87025. */
  87026. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87027. /**
  87028. * Gets the right frustum plane transformed by the transform matrix
  87029. * @param transform transformation matrix to be applied to the resulting frustum plane
  87030. * @param frustumPlane the resuling frustum plane
  87031. */
  87032. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87033. /**
  87034. * Gets the top frustum plane transformed by the transform matrix
  87035. * @param transform transformation matrix to be applied to the resulting frustum plane
  87036. * @param frustumPlane the resuling frustum plane
  87037. */
  87038. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87039. /**
  87040. * Gets the bottom frustum plane transformed by the transform matrix
  87041. * @param transform transformation matrix to be applied to the resulting frustum plane
  87042. * @param frustumPlane the resuling frustum plane
  87043. */
  87044. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  87045. /**
  87046. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  87047. * @param transform transformation matrix to be applied to the resulting frustum planes
  87048. * @param frustumPlanes the resuling frustum planes
  87049. */
  87050. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  87051. }
  87052. }
  87053. declare module BABYLON {
  87054. /**
  87055. * Interface for the size containing width and height
  87056. */
  87057. export interface ISize {
  87058. /**
  87059. * Width
  87060. */
  87061. width: number;
  87062. /**
  87063. * Heighht
  87064. */
  87065. height: number;
  87066. }
  87067. /**
  87068. * Size containing widht and height
  87069. */
  87070. export class Size implements ISize {
  87071. /**
  87072. * Width
  87073. */
  87074. width: number;
  87075. /**
  87076. * Height
  87077. */
  87078. height: number;
  87079. /**
  87080. * Creates a Size object from the given width and height (floats).
  87081. * @param width width of the new size
  87082. * @param height height of the new size
  87083. */
  87084. constructor(width: number, height: number);
  87085. /**
  87086. * Returns a string with the Size width and height
  87087. * @returns a string with the Size width and height
  87088. */
  87089. toString(): string;
  87090. /**
  87091. * "Size"
  87092. * @returns the string "Size"
  87093. */
  87094. getClassName(): string;
  87095. /**
  87096. * Returns the Size hash code.
  87097. * @returns a hash code for a unique width and height
  87098. */
  87099. getHashCode(): number;
  87100. /**
  87101. * Updates the current size from the given one.
  87102. * @param src the given size
  87103. */
  87104. copyFrom(src: Size): void;
  87105. /**
  87106. * Updates in place the current Size from the given floats.
  87107. * @param width width of the new size
  87108. * @param height height of the new size
  87109. * @returns the updated Size.
  87110. */
  87111. copyFromFloats(width: number, height: number): Size;
  87112. /**
  87113. * Updates in place the current Size from the given floats.
  87114. * @param width width to set
  87115. * @param height height to set
  87116. * @returns the updated Size.
  87117. */
  87118. set(width: number, height: number): Size;
  87119. /**
  87120. * Multiplies the width and height by numbers
  87121. * @param w factor to multiple the width by
  87122. * @param h factor to multiple the height by
  87123. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  87124. */
  87125. multiplyByFloats(w: number, h: number): Size;
  87126. /**
  87127. * Clones the size
  87128. * @returns a new Size copied from the given one.
  87129. */
  87130. clone(): Size;
  87131. /**
  87132. * True if the current Size and the given one width and height are strictly equal.
  87133. * @param other the other size to compare against
  87134. * @returns True if the current Size and the given one width and height are strictly equal.
  87135. */
  87136. equals(other: Size): boolean;
  87137. /**
  87138. * The surface of the Size : width * height (float).
  87139. */
  87140. get surface(): number;
  87141. /**
  87142. * Create a new size of zero
  87143. * @returns a new Size set to (0.0, 0.0)
  87144. */
  87145. static Zero(): Size;
  87146. /**
  87147. * Sums the width and height of two sizes
  87148. * @param otherSize size to add to this size
  87149. * @returns a new Size set as the addition result of the current Size and the given one.
  87150. */
  87151. add(otherSize: Size): Size;
  87152. /**
  87153. * Subtracts the width and height of two
  87154. * @param otherSize size to subtract to this size
  87155. * @returns a new Size set as the subtraction result of the given one from the current Size.
  87156. */
  87157. subtract(otherSize: Size): Size;
  87158. /**
  87159. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  87160. * @param start starting size to lerp between
  87161. * @param end end size to lerp between
  87162. * @param amount amount to lerp between the start and end values
  87163. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  87164. */
  87165. static Lerp(start: Size, end: Size, amount: number): Size;
  87166. }
  87167. }
  87168. declare module BABYLON {
  87169. /**
  87170. * Contains position and normal vectors for a vertex
  87171. */
  87172. export class PositionNormalVertex {
  87173. /** the position of the vertex (defaut: 0,0,0) */
  87174. position: Vector3;
  87175. /** the normal of the vertex (defaut: 0,1,0) */
  87176. normal: Vector3;
  87177. /**
  87178. * Creates a PositionNormalVertex
  87179. * @param position the position of the vertex (defaut: 0,0,0)
  87180. * @param normal the normal of the vertex (defaut: 0,1,0)
  87181. */
  87182. constructor(
  87183. /** the position of the vertex (defaut: 0,0,0) */
  87184. position?: Vector3,
  87185. /** the normal of the vertex (defaut: 0,1,0) */
  87186. normal?: Vector3);
  87187. /**
  87188. * Clones the PositionNormalVertex
  87189. * @returns the cloned PositionNormalVertex
  87190. */
  87191. clone(): PositionNormalVertex;
  87192. }
  87193. /**
  87194. * Contains position, normal and uv vectors for a vertex
  87195. */
  87196. export class PositionNormalTextureVertex {
  87197. /** the position of the vertex (defaut: 0,0,0) */
  87198. position: Vector3;
  87199. /** the normal of the vertex (defaut: 0,1,0) */
  87200. normal: Vector3;
  87201. /** the uv of the vertex (default: 0,0) */
  87202. uv: Vector2;
  87203. /**
  87204. * Creates a PositionNormalTextureVertex
  87205. * @param position the position of the vertex (defaut: 0,0,0)
  87206. * @param normal the normal of the vertex (defaut: 0,1,0)
  87207. * @param uv the uv of the vertex (default: 0,0)
  87208. */
  87209. constructor(
  87210. /** the position of the vertex (defaut: 0,0,0) */
  87211. position?: Vector3,
  87212. /** the normal of the vertex (defaut: 0,1,0) */
  87213. normal?: Vector3,
  87214. /** the uv of the vertex (default: 0,0) */
  87215. uv?: Vector2);
  87216. /**
  87217. * Clones the PositionNormalTextureVertex
  87218. * @returns the cloned PositionNormalTextureVertex
  87219. */
  87220. clone(): PositionNormalTextureVertex;
  87221. }
  87222. }
  87223. declare module BABYLON {
  87224. /**
  87225. * Enum defining the type of animations supported by InputBlock
  87226. */
  87227. export enum AnimatedInputBlockTypes {
  87228. /** No animation */
  87229. None = 0,
  87230. /** Time based animation. Will only work for floats */
  87231. Time = 1
  87232. }
  87233. }
  87234. declare module BABYLON {
  87235. /**
  87236. * Interface describing all the common properties and methods a shadow light needs to implement.
  87237. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  87238. * as well as binding the different shadow properties to the effects.
  87239. */
  87240. export interface IShadowLight extends Light {
  87241. /**
  87242. * The light id in the scene (used in scene.findLighById for instance)
  87243. */
  87244. id: string;
  87245. /**
  87246. * The position the shdow will be casted from.
  87247. */
  87248. position: Vector3;
  87249. /**
  87250. * In 2d mode (needCube being false), the direction used to cast the shadow.
  87251. */
  87252. direction: Vector3;
  87253. /**
  87254. * The transformed position. Position of the light in world space taking parenting in account.
  87255. */
  87256. transformedPosition: Vector3;
  87257. /**
  87258. * The transformed direction. Direction of the light in world space taking parenting in account.
  87259. */
  87260. transformedDirection: Vector3;
  87261. /**
  87262. * The friendly name of the light in the scene.
  87263. */
  87264. name: string;
  87265. /**
  87266. * Defines the shadow projection clipping minimum z value.
  87267. */
  87268. shadowMinZ: number;
  87269. /**
  87270. * Defines the shadow projection clipping maximum z value.
  87271. */
  87272. shadowMaxZ: number;
  87273. /**
  87274. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87275. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87276. */
  87277. computeTransformedInformation(): boolean;
  87278. /**
  87279. * Gets the scene the light belongs to.
  87280. * @returns The scene
  87281. */
  87282. getScene(): Scene;
  87283. /**
  87284. * Callback defining a custom Projection Matrix Builder.
  87285. * This can be used to override the default projection matrix computation.
  87286. */
  87287. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87288. /**
  87289. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87290. * @param matrix The materix to updated with the projection information
  87291. * @param viewMatrix The transform matrix of the light
  87292. * @param renderList The list of mesh to render in the map
  87293. * @returns The current light
  87294. */
  87295. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87296. /**
  87297. * Gets the current depth scale used in ESM.
  87298. * @returns The scale
  87299. */
  87300. getDepthScale(): number;
  87301. /**
  87302. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87303. * @returns true if a cube texture needs to be use
  87304. */
  87305. needCube(): boolean;
  87306. /**
  87307. * Detects if the projection matrix requires to be recomputed this frame.
  87308. * @returns true if it requires to be recomputed otherwise, false.
  87309. */
  87310. needProjectionMatrixCompute(): boolean;
  87311. /**
  87312. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87313. */
  87314. forceProjectionMatrixCompute(): void;
  87315. /**
  87316. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87317. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87318. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87319. */
  87320. getShadowDirection(faceIndex?: number): Vector3;
  87321. /**
  87322. * Gets the minZ used for shadow according to both the scene and the light.
  87323. * @param activeCamera The camera we are returning the min for
  87324. * @returns the depth min z
  87325. */
  87326. getDepthMinZ(activeCamera: Camera): number;
  87327. /**
  87328. * Gets the maxZ used for shadow according to both the scene and the light.
  87329. * @param activeCamera The camera we are returning the max for
  87330. * @returns the depth max z
  87331. */
  87332. getDepthMaxZ(activeCamera: Camera): number;
  87333. }
  87334. /**
  87335. * Base implementation IShadowLight
  87336. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  87337. */
  87338. export abstract class ShadowLight extends Light implements IShadowLight {
  87339. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  87340. protected _position: Vector3;
  87341. protected _setPosition(value: Vector3): void;
  87342. /**
  87343. * Sets the position the shadow will be casted from. Also use as the light position for both
  87344. * point and spot lights.
  87345. */
  87346. get position(): Vector3;
  87347. /**
  87348. * Sets the position the shadow will be casted from. Also use as the light position for both
  87349. * point and spot lights.
  87350. */
  87351. set position(value: Vector3);
  87352. protected _direction: Vector3;
  87353. protected _setDirection(value: Vector3): void;
  87354. /**
  87355. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  87356. * Also use as the light direction on spot and directional lights.
  87357. */
  87358. get direction(): Vector3;
  87359. /**
  87360. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  87361. * Also use as the light direction on spot and directional lights.
  87362. */
  87363. set direction(value: Vector3);
  87364. protected _shadowMinZ: number;
  87365. /**
  87366. * Gets the shadow projection clipping minimum z value.
  87367. */
  87368. get shadowMinZ(): number;
  87369. /**
  87370. * Sets the shadow projection clipping minimum z value.
  87371. */
  87372. set shadowMinZ(value: number);
  87373. protected _shadowMaxZ: number;
  87374. /**
  87375. * Sets the shadow projection clipping maximum z value.
  87376. */
  87377. get shadowMaxZ(): number;
  87378. /**
  87379. * Gets the shadow projection clipping maximum z value.
  87380. */
  87381. set shadowMaxZ(value: number);
  87382. /**
  87383. * Callback defining a custom Projection Matrix Builder.
  87384. * This can be used to override the default projection matrix computation.
  87385. */
  87386. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  87387. /**
  87388. * The transformed position. Position of the light in world space taking parenting in account.
  87389. */
  87390. transformedPosition: Vector3;
  87391. /**
  87392. * The transformed direction. Direction of the light in world space taking parenting in account.
  87393. */
  87394. transformedDirection: Vector3;
  87395. private _needProjectionMatrixCompute;
  87396. /**
  87397. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  87398. * @returns true if the information has been computed, false if it does not need to (no parenting)
  87399. */
  87400. computeTransformedInformation(): boolean;
  87401. /**
  87402. * Return the depth scale used for the shadow map.
  87403. * @returns the depth scale.
  87404. */
  87405. getDepthScale(): number;
  87406. /**
  87407. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  87408. * @param faceIndex The index of the face we are computed the direction to generate shadow
  87409. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  87410. */
  87411. getShadowDirection(faceIndex?: number): Vector3;
  87412. /**
  87413. * Returns the ShadowLight absolute position in the World.
  87414. * @returns the position vector in world space
  87415. */
  87416. getAbsolutePosition(): Vector3;
  87417. /**
  87418. * Sets the ShadowLight direction toward the passed target.
  87419. * @param target The point to target in local space
  87420. * @returns the updated ShadowLight direction
  87421. */
  87422. setDirectionToTarget(target: Vector3): Vector3;
  87423. /**
  87424. * Returns the light rotation in euler definition.
  87425. * @returns the x y z rotation in local space.
  87426. */
  87427. getRotation(): Vector3;
  87428. /**
  87429. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  87430. * @returns true if a cube texture needs to be use
  87431. */
  87432. needCube(): boolean;
  87433. /**
  87434. * Detects if the projection matrix requires to be recomputed this frame.
  87435. * @returns true if it requires to be recomputed otherwise, false.
  87436. */
  87437. needProjectionMatrixCompute(): boolean;
  87438. /**
  87439. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  87440. */
  87441. forceProjectionMatrixCompute(): void;
  87442. /** @hidden */
  87443. _initCache(): void;
  87444. /** @hidden */
  87445. _isSynchronized(): boolean;
  87446. /**
  87447. * Computes the world matrix of the node
  87448. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87449. * @returns the world matrix
  87450. */
  87451. computeWorldMatrix(force?: boolean): Matrix;
  87452. /**
  87453. * Gets the minZ used for shadow according to both the scene and the light.
  87454. * @param activeCamera The camera we are returning the min for
  87455. * @returns the depth min z
  87456. */
  87457. getDepthMinZ(activeCamera: Camera): number;
  87458. /**
  87459. * Gets the maxZ used for shadow according to both the scene and the light.
  87460. * @param activeCamera The camera we are returning the max for
  87461. * @returns the depth max z
  87462. */
  87463. getDepthMaxZ(activeCamera: Camera): number;
  87464. /**
  87465. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  87466. * @param matrix The materix to updated with the projection information
  87467. * @param viewMatrix The transform matrix of the light
  87468. * @param renderList The list of mesh to render in the map
  87469. * @returns The current light
  87470. */
  87471. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  87472. }
  87473. }
  87474. declare module BABYLON {
  87475. /** @hidden */
  87476. export var packingFunctions: {
  87477. name: string;
  87478. shader: string;
  87479. };
  87480. }
  87481. declare module BABYLON {
  87482. /** @hidden */
  87483. export var bayerDitherFunctions: {
  87484. name: string;
  87485. shader: string;
  87486. };
  87487. }
  87488. declare module BABYLON {
  87489. /** @hidden */
  87490. export var shadowMapFragmentDeclaration: {
  87491. name: string;
  87492. shader: string;
  87493. };
  87494. }
  87495. declare module BABYLON {
  87496. /** @hidden */
  87497. export var clipPlaneFragmentDeclaration: {
  87498. name: string;
  87499. shader: string;
  87500. };
  87501. }
  87502. declare module BABYLON {
  87503. /** @hidden */
  87504. export var clipPlaneFragment: {
  87505. name: string;
  87506. shader: string;
  87507. };
  87508. }
  87509. declare module BABYLON {
  87510. /** @hidden */
  87511. export var shadowMapFragment: {
  87512. name: string;
  87513. shader: string;
  87514. };
  87515. }
  87516. declare module BABYLON {
  87517. /** @hidden */
  87518. export var shadowMapPixelShader: {
  87519. name: string;
  87520. shader: string;
  87521. };
  87522. }
  87523. declare module BABYLON {
  87524. /** @hidden */
  87525. export var bonesDeclaration: {
  87526. name: string;
  87527. shader: string;
  87528. };
  87529. }
  87530. declare module BABYLON {
  87531. /** @hidden */
  87532. export var morphTargetsVertexGlobalDeclaration: {
  87533. name: string;
  87534. shader: string;
  87535. };
  87536. }
  87537. declare module BABYLON {
  87538. /** @hidden */
  87539. export var morphTargetsVertexDeclaration: {
  87540. name: string;
  87541. shader: string;
  87542. };
  87543. }
  87544. declare module BABYLON {
  87545. /** @hidden */
  87546. export var instancesDeclaration: {
  87547. name: string;
  87548. shader: string;
  87549. };
  87550. }
  87551. declare module BABYLON {
  87552. /** @hidden */
  87553. export var helperFunctions: {
  87554. name: string;
  87555. shader: string;
  87556. };
  87557. }
  87558. declare module BABYLON {
  87559. /** @hidden */
  87560. export var shadowMapVertexDeclaration: {
  87561. name: string;
  87562. shader: string;
  87563. };
  87564. }
  87565. declare module BABYLON {
  87566. /** @hidden */
  87567. export var clipPlaneVertexDeclaration: {
  87568. name: string;
  87569. shader: string;
  87570. };
  87571. }
  87572. declare module BABYLON {
  87573. /** @hidden */
  87574. export var morphTargetsVertex: {
  87575. name: string;
  87576. shader: string;
  87577. };
  87578. }
  87579. declare module BABYLON {
  87580. /** @hidden */
  87581. export var instancesVertex: {
  87582. name: string;
  87583. shader: string;
  87584. };
  87585. }
  87586. declare module BABYLON {
  87587. /** @hidden */
  87588. export var bonesVertex: {
  87589. name: string;
  87590. shader: string;
  87591. };
  87592. }
  87593. declare module BABYLON {
  87594. /** @hidden */
  87595. export var shadowMapVertexNormalBias: {
  87596. name: string;
  87597. shader: string;
  87598. };
  87599. }
  87600. declare module BABYLON {
  87601. /** @hidden */
  87602. export var shadowMapVertexMetric: {
  87603. name: string;
  87604. shader: string;
  87605. };
  87606. }
  87607. declare module BABYLON {
  87608. /** @hidden */
  87609. export var clipPlaneVertex: {
  87610. name: string;
  87611. shader: string;
  87612. };
  87613. }
  87614. declare module BABYLON {
  87615. /** @hidden */
  87616. export var shadowMapVertexShader: {
  87617. name: string;
  87618. shader: string;
  87619. };
  87620. }
  87621. declare module BABYLON {
  87622. /** @hidden */
  87623. export var depthBoxBlurPixelShader: {
  87624. name: string;
  87625. shader: string;
  87626. };
  87627. }
  87628. declare module BABYLON {
  87629. /** @hidden */
  87630. export var shadowMapFragmentSoftTransparentShadow: {
  87631. name: string;
  87632. shader: string;
  87633. };
  87634. }
  87635. declare module BABYLON {
  87636. /**
  87637. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  87638. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  87639. */
  87640. export class EffectFallbacks implements IEffectFallbacks {
  87641. private _defines;
  87642. private _currentRank;
  87643. private _maxRank;
  87644. private _mesh;
  87645. /**
  87646. * Removes the fallback from the bound mesh.
  87647. */
  87648. unBindMesh(): void;
  87649. /**
  87650. * Adds a fallback on the specified property.
  87651. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87652. * @param define The name of the define in the shader
  87653. */
  87654. addFallback(rank: number, define: string): void;
  87655. /**
  87656. * Sets the mesh to use CPU skinning when needing to fallback.
  87657. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  87658. * @param mesh The mesh to use the fallbacks.
  87659. */
  87660. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  87661. /**
  87662. * Checks to see if more fallbacks are still availible.
  87663. */
  87664. get hasMoreFallbacks(): boolean;
  87665. /**
  87666. * Removes the defines that should be removed when falling back.
  87667. * @param currentDefines defines the current define statements for the shader.
  87668. * @param effect defines the current effect we try to compile
  87669. * @returns The resulting defines with defines of the current rank removed.
  87670. */
  87671. reduce(currentDefines: string, effect: Effect): string;
  87672. }
  87673. }
  87674. declare module BABYLON {
  87675. /**
  87676. * Interface used to define Action
  87677. */
  87678. export interface IAction {
  87679. /**
  87680. * Trigger for the action
  87681. */
  87682. trigger: number;
  87683. /** Options of the trigger */
  87684. triggerOptions: any;
  87685. /**
  87686. * Gets the trigger parameters
  87687. * @returns the trigger parameters
  87688. */
  87689. getTriggerParameter(): any;
  87690. /**
  87691. * Internal only - executes current action event
  87692. * @hidden
  87693. */
  87694. _executeCurrent(evt?: ActionEvent): void;
  87695. /**
  87696. * Serialize placeholder for child classes
  87697. * @param parent of child
  87698. * @returns the serialized object
  87699. */
  87700. serialize(parent: any): any;
  87701. /**
  87702. * Internal only
  87703. * @hidden
  87704. */
  87705. _prepare(): void;
  87706. /**
  87707. * Internal only - manager for action
  87708. * @hidden
  87709. */
  87710. _actionManager: AbstractActionManager;
  87711. /**
  87712. * Adds action to chain of actions, may be a DoNothingAction
  87713. * @param action defines the next action to execute
  87714. * @returns The action passed in
  87715. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87716. */
  87717. then(action: IAction): IAction;
  87718. }
  87719. /**
  87720. * The action to be carried out following a trigger
  87721. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  87722. */
  87723. export class Action implements IAction {
  87724. /** the trigger, with or without parameters, for the action */
  87725. triggerOptions: any;
  87726. /**
  87727. * Trigger for the action
  87728. */
  87729. trigger: number;
  87730. /**
  87731. * Internal only - manager for action
  87732. * @hidden
  87733. */
  87734. _actionManager: ActionManager;
  87735. private _nextActiveAction;
  87736. private _child;
  87737. private _condition?;
  87738. private _triggerParameter;
  87739. /**
  87740. * An event triggered prior to action being executed.
  87741. */
  87742. onBeforeExecuteObservable: Observable<Action>;
  87743. /**
  87744. * Creates a new Action
  87745. * @param triggerOptions the trigger, with or without parameters, for the action
  87746. * @param condition an optional determinant of action
  87747. */
  87748. constructor(
  87749. /** the trigger, with or without parameters, for the action */
  87750. triggerOptions: any, condition?: Condition);
  87751. /**
  87752. * Internal only
  87753. * @hidden
  87754. */
  87755. _prepare(): void;
  87756. /**
  87757. * Gets the trigger parameters
  87758. * @returns the trigger parameters
  87759. */
  87760. getTriggerParameter(): any;
  87761. /**
  87762. * Internal only - executes current action event
  87763. * @hidden
  87764. */
  87765. _executeCurrent(evt?: ActionEvent): void;
  87766. /**
  87767. * Execute placeholder for child classes
  87768. * @param evt optional action event
  87769. */
  87770. execute(evt?: ActionEvent): void;
  87771. /**
  87772. * Skips to next active action
  87773. */
  87774. skipToNextActiveAction(): void;
  87775. /**
  87776. * Adds action to chain of actions, may be a DoNothingAction
  87777. * @param action defines the next action to execute
  87778. * @returns The action passed in
  87779. * @see https://www.babylonjs-playground.com/#1T30HR#0
  87780. */
  87781. then(action: Action): Action;
  87782. /**
  87783. * Internal only
  87784. * @hidden
  87785. */
  87786. _getProperty(propertyPath: string): string;
  87787. /**
  87788. * Internal only
  87789. * @hidden
  87790. */
  87791. _getEffectiveTarget(target: any, propertyPath: string): any;
  87792. /**
  87793. * Serialize placeholder for child classes
  87794. * @param parent of child
  87795. * @returns the serialized object
  87796. */
  87797. serialize(parent: any): any;
  87798. /**
  87799. * Internal only called by serialize
  87800. * @hidden
  87801. */
  87802. protected _serialize(serializedAction: any, parent?: any): any;
  87803. /**
  87804. * Internal only
  87805. * @hidden
  87806. */
  87807. static _SerializeValueAsString: (value: any) => string;
  87808. /**
  87809. * Internal only
  87810. * @hidden
  87811. */
  87812. static _GetTargetProperty: (target: Scene | Node) => {
  87813. name: string;
  87814. targetType: string;
  87815. value: string;
  87816. };
  87817. }
  87818. }
  87819. declare module BABYLON {
  87820. /**
  87821. * A Condition applied to an Action
  87822. */
  87823. export class Condition {
  87824. /**
  87825. * Internal only - manager for action
  87826. * @hidden
  87827. */
  87828. _actionManager: ActionManager;
  87829. /**
  87830. * Internal only
  87831. * @hidden
  87832. */
  87833. _evaluationId: number;
  87834. /**
  87835. * Internal only
  87836. * @hidden
  87837. */
  87838. _currentResult: boolean;
  87839. /**
  87840. * Creates a new Condition
  87841. * @param actionManager the manager of the action the condition is applied to
  87842. */
  87843. constructor(actionManager: ActionManager);
  87844. /**
  87845. * Check if the current condition is valid
  87846. * @returns a boolean
  87847. */
  87848. isValid(): boolean;
  87849. /**
  87850. * Internal only
  87851. * @hidden
  87852. */
  87853. _getProperty(propertyPath: string): string;
  87854. /**
  87855. * Internal only
  87856. * @hidden
  87857. */
  87858. _getEffectiveTarget(target: any, propertyPath: string): any;
  87859. /**
  87860. * Serialize placeholder for child classes
  87861. * @returns the serialized object
  87862. */
  87863. serialize(): any;
  87864. /**
  87865. * Internal only
  87866. * @hidden
  87867. */
  87868. protected _serialize(serializedCondition: any): any;
  87869. }
  87870. /**
  87871. * Defines specific conditional operators as extensions of Condition
  87872. */
  87873. export class ValueCondition extends Condition {
  87874. /** path to specify the property of the target the conditional operator uses */
  87875. propertyPath: string;
  87876. /** the value compared by the conditional operator against the current value of the property */
  87877. value: any;
  87878. /** the conditional operator, default ValueCondition.IsEqual */
  87879. operator: number;
  87880. /**
  87881. * Internal only
  87882. * @hidden
  87883. */
  87884. private static _IsEqual;
  87885. /**
  87886. * Internal only
  87887. * @hidden
  87888. */
  87889. private static _IsDifferent;
  87890. /**
  87891. * Internal only
  87892. * @hidden
  87893. */
  87894. private static _IsGreater;
  87895. /**
  87896. * Internal only
  87897. * @hidden
  87898. */
  87899. private static _IsLesser;
  87900. /**
  87901. * returns the number for IsEqual
  87902. */
  87903. static get IsEqual(): number;
  87904. /**
  87905. * Returns the number for IsDifferent
  87906. */
  87907. static get IsDifferent(): number;
  87908. /**
  87909. * Returns the number for IsGreater
  87910. */
  87911. static get IsGreater(): number;
  87912. /**
  87913. * Returns the number for IsLesser
  87914. */
  87915. static get IsLesser(): number;
  87916. /**
  87917. * Internal only The action manager for the condition
  87918. * @hidden
  87919. */
  87920. _actionManager: ActionManager;
  87921. /**
  87922. * Internal only
  87923. * @hidden
  87924. */
  87925. private _target;
  87926. /**
  87927. * Internal only
  87928. * @hidden
  87929. */
  87930. private _effectiveTarget;
  87931. /**
  87932. * Internal only
  87933. * @hidden
  87934. */
  87935. private _property;
  87936. /**
  87937. * Creates a new ValueCondition
  87938. * @param actionManager manager for the action the condition applies to
  87939. * @param target for the action
  87940. * @param propertyPath path to specify the property of the target the conditional operator uses
  87941. * @param value the value compared by the conditional operator against the current value of the property
  87942. * @param operator the conditional operator, default ValueCondition.IsEqual
  87943. */
  87944. constructor(actionManager: ActionManager, target: any,
  87945. /** path to specify the property of the target the conditional operator uses */
  87946. propertyPath: string,
  87947. /** the value compared by the conditional operator against the current value of the property */
  87948. value: any,
  87949. /** the conditional operator, default ValueCondition.IsEqual */
  87950. operator?: number);
  87951. /**
  87952. * Compares the given value with the property value for the specified conditional operator
  87953. * @returns the result of the comparison
  87954. */
  87955. isValid(): boolean;
  87956. /**
  87957. * Serialize the ValueCondition into a JSON compatible object
  87958. * @returns serialization object
  87959. */
  87960. serialize(): any;
  87961. /**
  87962. * Gets the name of the conditional operator for the ValueCondition
  87963. * @param operator the conditional operator
  87964. * @returns the name
  87965. */
  87966. static GetOperatorName(operator: number): string;
  87967. }
  87968. /**
  87969. * Defines a predicate condition as an extension of Condition
  87970. */
  87971. export class PredicateCondition extends Condition {
  87972. /** defines the predicate function used to validate the condition */
  87973. predicate: () => boolean;
  87974. /**
  87975. * Internal only - manager for action
  87976. * @hidden
  87977. */
  87978. _actionManager: ActionManager;
  87979. /**
  87980. * Creates a new PredicateCondition
  87981. * @param actionManager manager for the action the condition applies to
  87982. * @param predicate defines the predicate function used to validate the condition
  87983. */
  87984. constructor(actionManager: ActionManager,
  87985. /** defines the predicate function used to validate the condition */
  87986. predicate: () => boolean);
  87987. /**
  87988. * @returns the validity of the predicate condition
  87989. */
  87990. isValid(): boolean;
  87991. }
  87992. /**
  87993. * Defines a state condition as an extension of Condition
  87994. */
  87995. export class StateCondition extends Condition {
  87996. /** Value to compare with target state */
  87997. value: string;
  87998. /**
  87999. * Internal only - manager for action
  88000. * @hidden
  88001. */
  88002. _actionManager: ActionManager;
  88003. /**
  88004. * Internal only
  88005. * @hidden
  88006. */
  88007. private _target;
  88008. /**
  88009. * Creates a new StateCondition
  88010. * @param actionManager manager for the action the condition applies to
  88011. * @param target of the condition
  88012. * @param value to compare with target state
  88013. */
  88014. constructor(actionManager: ActionManager, target: any,
  88015. /** Value to compare with target state */
  88016. value: string);
  88017. /**
  88018. * Gets a boolean indicating if the current condition is met
  88019. * @returns the validity of the state
  88020. */
  88021. isValid(): boolean;
  88022. /**
  88023. * Serialize the StateCondition into a JSON compatible object
  88024. * @returns serialization object
  88025. */
  88026. serialize(): any;
  88027. }
  88028. }
  88029. declare module BABYLON {
  88030. /**
  88031. * This defines an action responsible to toggle a boolean once triggered.
  88032. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88033. */
  88034. export class SwitchBooleanAction extends Action {
  88035. /**
  88036. * The path to the boolean property in the target object
  88037. */
  88038. propertyPath: string;
  88039. private _target;
  88040. private _effectiveTarget;
  88041. private _property;
  88042. /**
  88043. * Instantiate the action
  88044. * @param triggerOptions defines the trigger options
  88045. * @param target defines the object containing the boolean
  88046. * @param propertyPath defines the path to the boolean property in the target object
  88047. * @param condition defines the trigger related conditions
  88048. */
  88049. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  88050. /** @hidden */
  88051. _prepare(): void;
  88052. /**
  88053. * Execute the action toggle the boolean value.
  88054. */
  88055. execute(): void;
  88056. /**
  88057. * Serializes the actions and its related information.
  88058. * @param parent defines the object to serialize in
  88059. * @returns the serialized object
  88060. */
  88061. serialize(parent: any): any;
  88062. }
  88063. /**
  88064. * This defines an action responsible to set a the state field of the target
  88065. * to a desired value once triggered.
  88066. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88067. */
  88068. export class SetStateAction extends Action {
  88069. /**
  88070. * The value to store in the state field.
  88071. */
  88072. value: string;
  88073. private _target;
  88074. /**
  88075. * Instantiate the action
  88076. * @param triggerOptions defines the trigger options
  88077. * @param target defines the object containing the state property
  88078. * @param value defines the value to store in the state field
  88079. * @param condition defines the trigger related conditions
  88080. */
  88081. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  88082. /**
  88083. * Execute the action and store the value on the target state property.
  88084. */
  88085. execute(): void;
  88086. /**
  88087. * Serializes the actions and its related information.
  88088. * @param parent defines the object to serialize in
  88089. * @returns the serialized object
  88090. */
  88091. serialize(parent: any): any;
  88092. }
  88093. /**
  88094. * This defines an action responsible to set a property of the target
  88095. * to a desired value once triggered.
  88096. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88097. */
  88098. export class SetValueAction extends Action {
  88099. /**
  88100. * The path of the property to set in the target.
  88101. */
  88102. propertyPath: string;
  88103. /**
  88104. * The value to set in the property
  88105. */
  88106. value: any;
  88107. private _target;
  88108. private _effectiveTarget;
  88109. private _property;
  88110. /**
  88111. * Instantiate the action
  88112. * @param triggerOptions defines the trigger options
  88113. * @param target defines the object containing the property
  88114. * @param propertyPath defines the path of the property to set in the target
  88115. * @param value defines the value to set in the property
  88116. * @param condition defines the trigger related conditions
  88117. */
  88118. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88119. /** @hidden */
  88120. _prepare(): void;
  88121. /**
  88122. * Execute the action and set the targetted property to the desired value.
  88123. */
  88124. execute(): void;
  88125. /**
  88126. * Serializes the actions and its related information.
  88127. * @param parent defines the object to serialize in
  88128. * @returns the serialized object
  88129. */
  88130. serialize(parent: any): any;
  88131. }
  88132. /**
  88133. * This defines an action responsible to increment the target value
  88134. * to a desired value once triggered.
  88135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88136. */
  88137. export class IncrementValueAction extends Action {
  88138. /**
  88139. * The path of the property to increment in the target.
  88140. */
  88141. propertyPath: string;
  88142. /**
  88143. * The value we should increment the property by.
  88144. */
  88145. value: any;
  88146. private _target;
  88147. private _effectiveTarget;
  88148. private _property;
  88149. /**
  88150. * Instantiate the action
  88151. * @param triggerOptions defines the trigger options
  88152. * @param target defines the object containing the property
  88153. * @param propertyPath defines the path of the property to increment in the target
  88154. * @param value defines the value value we should increment the property by
  88155. * @param condition defines the trigger related conditions
  88156. */
  88157. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  88158. /** @hidden */
  88159. _prepare(): void;
  88160. /**
  88161. * Execute the action and increment the target of the value amount.
  88162. */
  88163. execute(): void;
  88164. /**
  88165. * Serializes the actions and its related information.
  88166. * @param parent defines the object to serialize in
  88167. * @returns the serialized object
  88168. */
  88169. serialize(parent: any): any;
  88170. }
  88171. /**
  88172. * This defines an action responsible to start an animation once triggered.
  88173. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88174. */
  88175. export class PlayAnimationAction extends Action {
  88176. /**
  88177. * Where the animation should start (animation frame)
  88178. */
  88179. from: number;
  88180. /**
  88181. * Where the animation should stop (animation frame)
  88182. */
  88183. to: number;
  88184. /**
  88185. * Define if the animation should loop or stop after the first play.
  88186. */
  88187. loop?: boolean;
  88188. private _target;
  88189. /**
  88190. * Instantiate the action
  88191. * @param triggerOptions defines the trigger options
  88192. * @param target defines the target animation or animation name
  88193. * @param from defines from where the animation should start (animation frame)
  88194. * @param end defines where the animation should stop (animation frame)
  88195. * @param loop defines if the animation should loop or stop after the first play
  88196. * @param condition defines the trigger related conditions
  88197. */
  88198. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  88199. /** @hidden */
  88200. _prepare(): void;
  88201. /**
  88202. * Execute the action and play the animation.
  88203. */
  88204. execute(): void;
  88205. /**
  88206. * Serializes the actions and its related information.
  88207. * @param parent defines the object to serialize in
  88208. * @returns the serialized object
  88209. */
  88210. serialize(parent: any): any;
  88211. }
  88212. /**
  88213. * This defines an action responsible to stop an animation once triggered.
  88214. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88215. */
  88216. export class StopAnimationAction extends Action {
  88217. private _target;
  88218. /**
  88219. * Instantiate the action
  88220. * @param triggerOptions defines the trigger options
  88221. * @param target defines the target animation or animation name
  88222. * @param condition defines the trigger related conditions
  88223. */
  88224. constructor(triggerOptions: any, target: any, condition?: Condition);
  88225. /** @hidden */
  88226. _prepare(): void;
  88227. /**
  88228. * Execute the action and stop the animation.
  88229. */
  88230. execute(): void;
  88231. /**
  88232. * Serializes the actions and its related information.
  88233. * @param parent defines the object to serialize in
  88234. * @returns the serialized object
  88235. */
  88236. serialize(parent: any): any;
  88237. }
  88238. /**
  88239. * This defines an action responsible that does nothing once triggered.
  88240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88241. */
  88242. export class DoNothingAction extends Action {
  88243. /**
  88244. * Instantiate the action
  88245. * @param triggerOptions defines the trigger options
  88246. * @param condition defines the trigger related conditions
  88247. */
  88248. constructor(triggerOptions?: any, condition?: Condition);
  88249. /**
  88250. * Execute the action and do nothing.
  88251. */
  88252. execute(): void;
  88253. /**
  88254. * Serializes the actions and its related information.
  88255. * @param parent defines the object to serialize in
  88256. * @returns the serialized object
  88257. */
  88258. serialize(parent: any): any;
  88259. }
  88260. /**
  88261. * This defines an action responsible to trigger several actions once triggered.
  88262. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88263. */
  88264. export class CombineAction extends Action {
  88265. /**
  88266. * The list of aggregated animations to run.
  88267. */
  88268. children: Action[];
  88269. /**
  88270. * Instantiate the action
  88271. * @param triggerOptions defines the trigger options
  88272. * @param children defines the list of aggregated animations to run
  88273. * @param condition defines the trigger related conditions
  88274. */
  88275. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  88276. /** @hidden */
  88277. _prepare(): void;
  88278. /**
  88279. * Execute the action and executes all the aggregated actions.
  88280. */
  88281. execute(evt: ActionEvent): void;
  88282. /**
  88283. * Serializes the actions and its related information.
  88284. * @param parent defines the object to serialize in
  88285. * @returns the serialized object
  88286. */
  88287. serialize(parent: any): any;
  88288. }
  88289. /**
  88290. * This defines an action responsible to run code (external event) once triggered.
  88291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88292. */
  88293. export class ExecuteCodeAction extends Action {
  88294. /**
  88295. * The callback function to run.
  88296. */
  88297. func: (evt: ActionEvent) => void;
  88298. /**
  88299. * Instantiate the action
  88300. * @param triggerOptions defines the trigger options
  88301. * @param func defines the callback function to run
  88302. * @param condition defines the trigger related conditions
  88303. */
  88304. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  88305. /**
  88306. * Execute the action and run the attached code.
  88307. */
  88308. execute(evt: ActionEvent): void;
  88309. }
  88310. /**
  88311. * This defines an action responsible to set the parent property of the target once triggered.
  88312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88313. */
  88314. export class SetParentAction extends Action {
  88315. private _parent;
  88316. private _target;
  88317. /**
  88318. * Instantiate the action
  88319. * @param triggerOptions defines the trigger options
  88320. * @param target defines the target containing the parent property
  88321. * @param parent defines from where the animation should start (animation frame)
  88322. * @param condition defines the trigger related conditions
  88323. */
  88324. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  88325. /** @hidden */
  88326. _prepare(): void;
  88327. /**
  88328. * Execute the action and set the parent property.
  88329. */
  88330. execute(): void;
  88331. /**
  88332. * Serializes the actions and its related information.
  88333. * @param parent defines the object to serialize in
  88334. * @returns the serialized object
  88335. */
  88336. serialize(parent: any): any;
  88337. }
  88338. }
  88339. declare module BABYLON {
  88340. /**
  88341. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  88342. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  88343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  88344. */
  88345. export class ActionManager extends AbstractActionManager {
  88346. /**
  88347. * Nothing
  88348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88349. */
  88350. static readonly NothingTrigger: number;
  88351. /**
  88352. * On pick
  88353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88354. */
  88355. static readonly OnPickTrigger: number;
  88356. /**
  88357. * On left pick
  88358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88359. */
  88360. static readonly OnLeftPickTrigger: number;
  88361. /**
  88362. * On right pick
  88363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88364. */
  88365. static readonly OnRightPickTrigger: number;
  88366. /**
  88367. * On center pick
  88368. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88369. */
  88370. static readonly OnCenterPickTrigger: number;
  88371. /**
  88372. * On pick down
  88373. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88374. */
  88375. static readonly OnPickDownTrigger: number;
  88376. /**
  88377. * On double pick
  88378. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88379. */
  88380. static readonly OnDoublePickTrigger: number;
  88381. /**
  88382. * On pick up
  88383. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88384. */
  88385. static readonly OnPickUpTrigger: number;
  88386. /**
  88387. * On pick out.
  88388. * This trigger will only be raised if you also declared a OnPickDown
  88389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88390. */
  88391. static readonly OnPickOutTrigger: number;
  88392. /**
  88393. * On long press
  88394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88395. */
  88396. static readonly OnLongPressTrigger: number;
  88397. /**
  88398. * On pointer over
  88399. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88400. */
  88401. static readonly OnPointerOverTrigger: number;
  88402. /**
  88403. * On pointer out
  88404. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88405. */
  88406. static readonly OnPointerOutTrigger: number;
  88407. /**
  88408. * On every frame
  88409. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88410. */
  88411. static readonly OnEveryFrameTrigger: number;
  88412. /**
  88413. * On intersection enter
  88414. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88415. */
  88416. static readonly OnIntersectionEnterTrigger: number;
  88417. /**
  88418. * On intersection exit
  88419. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88420. */
  88421. static readonly OnIntersectionExitTrigger: number;
  88422. /**
  88423. * On key down
  88424. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88425. */
  88426. static readonly OnKeyDownTrigger: number;
  88427. /**
  88428. * On key up
  88429. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  88430. */
  88431. static readonly OnKeyUpTrigger: number;
  88432. private _scene;
  88433. /**
  88434. * Creates a new action manager
  88435. * @param scene defines the hosting scene
  88436. */
  88437. constructor(scene: Scene);
  88438. /**
  88439. * Releases all associated resources
  88440. */
  88441. dispose(): void;
  88442. /**
  88443. * Gets hosting scene
  88444. * @returns the hosting scene
  88445. */
  88446. getScene(): Scene;
  88447. /**
  88448. * Does this action manager handles actions of any of the given triggers
  88449. * @param triggers defines the triggers to be tested
  88450. * @return a boolean indicating whether one (or more) of the triggers is handled
  88451. */
  88452. hasSpecificTriggers(triggers: number[]): boolean;
  88453. /**
  88454. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  88455. * speed.
  88456. * @param triggerA defines the trigger to be tested
  88457. * @param triggerB defines the trigger to be tested
  88458. * @return a boolean indicating whether one (or more) of the triggers is handled
  88459. */
  88460. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  88461. /**
  88462. * Does this action manager handles actions of a given trigger
  88463. * @param trigger defines the trigger to be tested
  88464. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  88465. * @return whether the trigger is handled
  88466. */
  88467. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  88468. /**
  88469. * Does this action manager has pointer triggers
  88470. */
  88471. get hasPointerTriggers(): boolean;
  88472. /**
  88473. * Does this action manager has pick triggers
  88474. */
  88475. get hasPickTriggers(): boolean;
  88476. /**
  88477. * Registers an action to this action manager
  88478. * @param action defines the action to be registered
  88479. * @return the action amended (prepared) after registration
  88480. */
  88481. registerAction(action: IAction): Nullable<IAction>;
  88482. /**
  88483. * Unregisters an action to this action manager
  88484. * @param action defines the action to be unregistered
  88485. * @return a boolean indicating whether the action has been unregistered
  88486. */
  88487. unregisterAction(action: IAction): Boolean;
  88488. /**
  88489. * Process a specific trigger
  88490. * @param trigger defines the trigger to process
  88491. * @param evt defines the event details to be processed
  88492. */
  88493. processTrigger(trigger: number, evt?: IActionEvent): void;
  88494. /** @hidden */
  88495. _getEffectiveTarget(target: any, propertyPath: string): any;
  88496. /** @hidden */
  88497. _getProperty(propertyPath: string): string;
  88498. /**
  88499. * Serialize this manager to a JSON object
  88500. * @param name defines the property name to store this manager
  88501. * @returns a JSON representation of this manager
  88502. */
  88503. serialize(name: string): any;
  88504. /**
  88505. * Creates a new ActionManager from a JSON data
  88506. * @param parsedActions defines the JSON data to read from
  88507. * @param object defines the hosting mesh
  88508. * @param scene defines the hosting scene
  88509. */
  88510. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  88511. /**
  88512. * Get a trigger name by index
  88513. * @param trigger defines the trigger index
  88514. * @returns a trigger name
  88515. */
  88516. static GetTriggerName(trigger: number): string;
  88517. }
  88518. }
  88519. declare module BABYLON {
  88520. /**
  88521. * Class used to represent a sprite
  88522. * @see https://doc.babylonjs.com/babylon101/sprites
  88523. */
  88524. export class Sprite implements IAnimatable {
  88525. /** defines the name */
  88526. name: string;
  88527. /** Gets or sets the current world position */
  88528. position: Vector3;
  88529. /** Gets or sets the main color */
  88530. color: Color4;
  88531. /** Gets or sets the width */
  88532. width: number;
  88533. /** Gets or sets the height */
  88534. height: number;
  88535. /** Gets or sets rotation angle */
  88536. angle: number;
  88537. /** Gets or sets the cell index in the sprite sheet */
  88538. cellIndex: number;
  88539. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  88540. cellRef: string;
  88541. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  88542. invertU: boolean;
  88543. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  88544. invertV: boolean;
  88545. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  88546. disposeWhenFinishedAnimating: boolean;
  88547. /** Gets the list of attached animations */
  88548. animations: Nullable<Array<Animation>>;
  88549. /** Gets or sets a boolean indicating if the sprite can be picked */
  88550. isPickable: boolean;
  88551. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  88552. useAlphaForPicking: boolean;
  88553. /** @hidden */
  88554. _xOffset: number;
  88555. /** @hidden */
  88556. _yOffset: number;
  88557. /** @hidden */
  88558. _xSize: number;
  88559. /** @hidden */
  88560. _ySize: number;
  88561. /**
  88562. * Gets or sets the associated action manager
  88563. */
  88564. actionManager: Nullable<ActionManager>;
  88565. /**
  88566. * An event triggered when the control has been disposed
  88567. */
  88568. onDisposeObservable: Observable<Sprite>;
  88569. private _animationStarted;
  88570. private _loopAnimation;
  88571. private _fromIndex;
  88572. private _toIndex;
  88573. private _delay;
  88574. private _direction;
  88575. private _manager;
  88576. private _time;
  88577. private _onAnimationEnd;
  88578. /**
  88579. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  88580. */
  88581. isVisible: boolean;
  88582. /**
  88583. * Gets or sets the sprite size
  88584. */
  88585. get size(): number;
  88586. set size(value: number);
  88587. /**
  88588. * Returns a boolean indicating if the animation is started
  88589. */
  88590. get animationStarted(): boolean;
  88591. /**
  88592. * Gets or sets the unique id of the sprite
  88593. */
  88594. uniqueId: number;
  88595. /**
  88596. * Gets the manager of this sprite
  88597. */
  88598. get manager(): ISpriteManager;
  88599. /**
  88600. * Creates a new Sprite
  88601. * @param name defines the name
  88602. * @param manager defines the manager
  88603. */
  88604. constructor(
  88605. /** defines the name */
  88606. name: string, manager: ISpriteManager);
  88607. /**
  88608. * Returns the string "Sprite"
  88609. * @returns "Sprite"
  88610. */
  88611. getClassName(): string;
  88612. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  88613. get fromIndex(): number;
  88614. set fromIndex(value: number);
  88615. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  88616. get toIndex(): number;
  88617. set toIndex(value: number);
  88618. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  88619. get loopAnimation(): boolean;
  88620. set loopAnimation(value: boolean);
  88621. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  88622. get delay(): number;
  88623. set delay(value: number);
  88624. /**
  88625. * Starts an animation
  88626. * @param from defines the initial key
  88627. * @param to defines the end key
  88628. * @param loop defines if the animation must loop
  88629. * @param delay defines the start delay (in ms)
  88630. * @param onAnimationEnd defines a callback to call when animation ends
  88631. */
  88632. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  88633. /** Stops current animation (if any) */
  88634. stopAnimation(): void;
  88635. /** @hidden */
  88636. _animate(deltaTime: number): void;
  88637. /** Release associated resources */
  88638. dispose(): void;
  88639. /**
  88640. * Serializes the sprite to a JSON object
  88641. * @returns the JSON object
  88642. */
  88643. serialize(): any;
  88644. /**
  88645. * Parses a JSON object to create a new sprite
  88646. * @param parsedSprite The JSON object to parse
  88647. * @param manager defines the hosting manager
  88648. * @returns the new sprite
  88649. */
  88650. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  88651. }
  88652. }
  88653. declare module BABYLON {
  88654. /**
  88655. * Information about the result of picking within a scene
  88656. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  88657. */
  88658. export class PickingInfo {
  88659. /** @hidden */
  88660. _pickingUnavailable: boolean;
  88661. /**
  88662. * If the pick collided with an object
  88663. */
  88664. hit: boolean;
  88665. /**
  88666. * Distance away where the pick collided
  88667. */
  88668. distance: number;
  88669. /**
  88670. * The location of pick collision
  88671. */
  88672. pickedPoint: Nullable<Vector3>;
  88673. /**
  88674. * The mesh corresponding the the pick collision
  88675. */
  88676. pickedMesh: Nullable<AbstractMesh>;
  88677. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  88678. bu: number;
  88679. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  88680. bv: number;
  88681. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88682. faceId: number;
  88683. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  88684. subMeshFaceId: number;
  88685. /** Id of the the submesh that was picked */
  88686. subMeshId: number;
  88687. /** If a sprite was picked, this will be the sprite the pick collided with */
  88688. pickedSprite: Nullable<Sprite>;
  88689. /**
  88690. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  88691. */
  88692. originMesh: Nullable<AbstractMesh>;
  88693. /**
  88694. * The ray that was used to perform the picking.
  88695. */
  88696. ray: Nullable<Ray>;
  88697. /**
  88698. * Gets the normal correspodning to the face the pick collided with
  88699. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  88700. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  88701. * @returns The normal correspodning to the face the pick collided with
  88702. */
  88703. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  88704. /**
  88705. * Gets the texture coordinates of where the pick occured
  88706. * @returns the vector containing the coordnates of the texture
  88707. */
  88708. getTextureCoordinates(): Nullable<Vector2>;
  88709. }
  88710. }
  88711. declare module BABYLON {
  88712. /**
  88713. * Class representing a ray with position and direction
  88714. */
  88715. export class Ray {
  88716. /** origin point */
  88717. origin: Vector3;
  88718. /** direction */
  88719. direction: Vector3;
  88720. /** length of the ray */
  88721. length: number;
  88722. private static readonly TmpVector3;
  88723. private _tmpRay;
  88724. /**
  88725. * Creates a new ray
  88726. * @param origin origin point
  88727. * @param direction direction
  88728. * @param length length of the ray
  88729. */
  88730. constructor(
  88731. /** origin point */
  88732. origin: Vector3,
  88733. /** direction */
  88734. direction: Vector3,
  88735. /** length of the ray */
  88736. length?: number);
  88737. /**
  88738. * Checks if the ray intersects a box
  88739. * This does not account for the ray lenght by design to improve perfs.
  88740. * @param minimum bound of the box
  88741. * @param maximum bound of the box
  88742. * @param intersectionTreshold extra extend to be added to the box in all direction
  88743. * @returns if the box was hit
  88744. */
  88745. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  88746. /**
  88747. * Checks if the ray intersects a box
  88748. * This does not account for the ray lenght by design to improve perfs.
  88749. * @param box the bounding box to check
  88750. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  88751. * @returns if the box was hit
  88752. */
  88753. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  88754. /**
  88755. * If the ray hits a sphere
  88756. * @param sphere the bounding sphere to check
  88757. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  88758. * @returns true if it hits the sphere
  88759. */
  88760. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  88761. /**
  88762. * If the ray hits a triange
  88763. * @param vertex0 triangle vertex
  88764. * @param vertex1 triangle vertex
  88765. * @param vertex2 triangle vertex
  88766. * @returns intersection information if hit
  88767. */
  88768. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  88769. /**
  88770. * Checks if ray intersects a plane
  88771. * @param plane the plane to check
  88772. * @returns the distance away it was hit
  88773. */
  88774. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  88775. /**
  88776. * Calculate the intercept of a ray on a given axis
  88777. * @param axis to check 'x' | 'y' | 'z'
  88778. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  88779. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  88780. */
  88781. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  88782. /**
  88783. * Checks if ray intersects a mesh
  88784. * @param mesh the mesh to check
  88785. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88786. * @returns picking info of the intersecton
  88787. */
  88788. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  88789. /**
  88790. * Checks if ray intersects a mesh
  88791. * @param meshes the meshes to check
  88792. * @param fastCheck defines if the first intersection will be used (and not the closest)
  88793. * @param results array to store result in
  88794. * @returns Array of picking infos
  88795. */
  88796. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  88797. private _comparePickingInfo;
  88798. private static smallnum;
  88799. private static rayl;
  88800. /**
  88801. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  88802. * @param sega the first point of the segment to test the intersection against
  88803. * @param segb the second point of the segment to test the intersection against
  88804. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  88805. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  88806. */
  88807. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  88808. /**
  88809. * Update the ray from viewport position
  88810. * @param x position
  88811. * @param y y position
  88812. * @param viewportWidth viewport width
  88813. * @param viewportHeight viewport height
  88814. * @param world world matrix
  88815. * @param view view matrix
  88816. * @param projection projection matrix
  88817. * @returns this ray updated
  88818. */
  88819. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88820. /**
  88821. * Creates a ray with origin and direction of 0,0,0
  88822. * @returns the new ray
  88823. */
  88824. static Zero(): Ray;
  88825. /**
  88826. * Creates a new ray from screen space and viewport
  88827. * @param x position
  88828. * @param y y position
  88829. * @param viewportWidth viewport width
  88830. * @param viewportHeight viewport height
  88831. * @param world world matrix
  88832. * @param view view matrix
  88833. * @param projection projection matrix
  88834. * @returns new ray
  88835. */
  88836. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  88837. /**
  88838. * 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
  88839. * transformed to the given world matrix.
  88840. * @param origin The origin point
  88841. * @param end The end point
  88842. * @param world a matrix to transform the ray to. Default is the identity matrix.
  88843. * @returns the new ray
  88844. */
  88845. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  88846. /**
  88847. * Transforms a ray by a matrix
  88848. * @param ray ray to transform
  88849. * @param matrix matrix to apply
  88850. * @returns the resulting new ray
  88851. */
  88852. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  88853. /**
  88854. * Transforms a ray by a matrix
  88855. * @param ray ray to transform
  88856. * @param matrix matrix to apply
  88857. * @param result ray to store result in
  88858. */
  88859. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  88860. /**
  88861. * Unproject a ray from screen space to object space
  88862. * @param sourceX defines the screen space x coordinate to use
  88863. * @param sourceY defines the screen space y coordinate to use
  88864. * @param viewportWidth defines the current width of the viewport
  88865. * @param viewportHeight defines the current height of the viewport
  88866. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  88867. * @param view defines the view matrix to use
  88868. * @param projection defines the projection matrix to use
  88869. */
  88870. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  88871. }
  88872. /**
  88873. * Type used to define predicate used to select faces when a mesh intersection is detected
  88874. */
  88875. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  88876. interface Scene {
  88877. /** @hidden */
  88878. _tempPickingRay: Nullable<Ray>;
  88879. /** @hidden */
  88880. _cachedRayForTransform: Ray;
  88881. /** @hidden */
  88882. _pickWithRayInverseMatrix: Matrix;
  88883. /** @hidden */
  88884. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  88885. /** @hidden */
  88886. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  88887. }
  88888. }
  88889. declare module BABYLON {
  88890. /**
  88891. * Groups all the scene component constants in one place to ease maintenance.
  88892. * @hidden
  88893. */
  88894. export class SceneComponentConstants {
  88895. static readonly NAME_EFFECTLAYER: string;
  88896. static readonly NAME_LAYER: string;
  88897. static readonly NAME_LENSFLARESYSTEM: string;
  88898. static readonly NAME_BOUNDINGBOXRENDERER: string;
  88899. static readonly NAME_PARTICLESYSTEM: string;
  88900. static readonly NAME_GAMEPAD: string;
  88901. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  88902. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  88903. static readonly NAME_PREPASSRENDERER: string;
  88904. static readonly NAME_DEPTHRENDERER: string;
  88905. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  88906. static readonly NAME_SPRITE: string;
  88907. static readonly NAME_OUTLINERENDERER: string;
  88908. static readonly NAME_PROCEDURALTEXTURE: string;
  88909. static readonly NAME_SHADOWGENERATOR: string;
  88910. static readonly NAME_OCTREE: string;
  88911. static readonly NAME_PHYSICSENGINE: string;
  88912. static readonly NAME_AUDIO: string;
  88913. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  88914. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88915. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  88916. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  88917. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  88918. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  88919. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  88920. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  88921. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  88922. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  88923. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  88924. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  88925. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  88926. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  88927. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  88928. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  88929. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  88930. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  88931. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  88932. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  88933. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  88934. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  88935. static readonly STEP_AFTERRENDER_AUDIO: number;
  88936. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  88937. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  88938. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  88939. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  88940. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  88941. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  88942. static readonly STEP_POINTERMOVE_SPRITE: number;
  88943. static readonly STEP_POINTERDOWN_SPRITE: number;
  88944. static readonly STEP_POINTERUP_SPRITE: number;
  88945. }
  88946. /**
  88947. * This represents a scene component.
  88948. *
  88949. * This is used to decouple the dependency the scene is having on the different workloads like
  88950. * layers, post processes...
  88951. */
  88952. export interface ISceneComponent {
  88953. /**
  88954. * The name of the component. Each component must have a unique name.
  88955. */
  88956. name: string;
  88957. /**
  88958. * The scene the component belongs to.
  88959. */
  88960. scene: Scene;
  88961. /**
  88962. * Register the component to one instance of a scene.
  88963. */
  88964. register(): void;
  88965. /**
  88966. * Rebuilds the elements related to this component in case of
  88967. * context lost for instance.
  88968. */
  88969. rebuild(): void;
  88970. /**
  88971. * Disposes the component and the associated ressources.
  88972. */
  88973. dispose(): void;
  88974. }
  88975. /**
  88976. * This represents a SERIALIZABLE scene component.
  88977. *
  88978. * This extends Scene Component to add Serialization methods on top.
  88979. */
  88980. export interface ISceneSerializableComponent extends ISceneComponent {
  88981. /**
  88982. * Adds all the elements from the container to the scene
  88983. * @param container the container holding the elements
  88984. */
  88985. addFromContainer(container: AbstractScene): void;
  88986. /**
  88987. * Removes all the elements in the container from the scene
  88988. * @param container contains the elements to remove
  88989. * @param dispose if the removed element should be disposed (default: false)
  88990. */
  88991. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  88992. /**
  88993. * Serializes the component data to the specified json object
  88994. * @param serializationObject The object to serialize to
  88995. */
  88996. serialize(serializationObject: any): void;
  88997. }
  88998. /**
  88999. * Strong typing of a Mesh related stage step action
  89000. */
  89001. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  89002. /**
  89003. * Strong typing of a Evaluate Sub Mesh related stage step action
  89004. */
  89005. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  89006. /**
  89007. * Strong typing of a Active Mesh related stage step action
  89008. */
  89009. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  89010. /**
  89011. * Strong typing of a Camera related stage step action
  89012. */
  89013. export type CameraStageAction = (camera: Camera) => void;
  89014. /**
  89015. * Strong typing of a Camera Frame buffer related stage step action
  89016. */
  89017. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  89018. /**
  89019. * Strong typing of a Render Target related stage step action
  89020. */
  89021. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  89022. /**
  89023. * Strong typing of a RenderingGroup related stage step action
  89024. */
  89025. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  89026. /**
  89027. * Strong typing of a Mesh Render related stage step action
  89028. */
  89029. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  89030. /**
  89031. * Strong typing of a simple stage step action
  89032. */
  89033. export type SimpleStageAction = () => void;
  89034. /**
  89035. * Strong typing of a render target action.
  89036. */
  89037. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  89038. /**
  89039. * Strong typing of a pointer move action.
  89040. */
  89041. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  89042. /**
  89043. * Strong typing of a pointer up/down action.
  89044. */
  89045. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  89046. /**
  89047. * Representation of a stage in the scene (Basically a list of ordered steps)
  89048. * @hidden
  89049. */
  89050. export class Stage<T extends Function> extends Array<{
  89051. index: number;
  89052. component: ISceneComponent;
  89053. action: T;
  89054. }> {
  89055. /**
  89056. * Hide ctor from the rest of the world.
  89057. * @param items The items to add.
  89058. */
  89059. private constructor();
  89060. /**
  89061. * Creates a new Stage.
  89062. * @returns A new instance of a Stage
  89063. */
  89064. static Create<T extends Function>(): Stage<T>;
  89065. /**
  89066. * Registers a step in an ordered way in the targeted stage.
  89067. * @param index Defines the position to register the step in
  89068. * @param component Defines the component attached to the step
  89069. * @param action Defines the action to launch during the step
  89070. */
  89071. registerStep(index: number, component: ISceneComponent, action: T): void;
  89072. /**
  89073. * Clears all the steps from the stage.
  89074. */
  89075. clear(): void;
  89076. }
  89077. }
  89078. declare module BABYLON {
  89079. interface Scene {
  89080. /** @hidden */
  89081. _pointerOverSprite: Nullable<Sprite>;
  89082. /** @hidden */
  89083. _pickedDownSprite: Nullable<Sprite>;
  89084. /** @hidden */
  89085. _tempSpritePickingRay: Nullable<Ray>;
  89086. /**
  89087. * All of the sprite managers added to this scene
  89088. * @see https://doc.babylonjs.com/babylon101/sprites
  89089. */
  89090. spriteManagers: Array<ISpriteManager>;
  89091. /**
  89092. * An event triggered when sprites rendering is about to start
  89093. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89094. */
  89095. onBeforeSpritesRenderingObservable: Observable<Scene>;
  89096. /**
  89097. * An event triggered when sprites rendering is done
  89098. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  89099. */
  89100. onAfterSpritesRenderingObservable: Observable<Scene>;
  89101. /** @hidden */
  89102. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89103. /** Launch a ray to try to pick a sprite in the scene
  89104. * @param x position on screen
  89105. * @param y position on screen
  89106. * @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
  89107. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89108. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89109. * @returns a PickingInfo
  89110. */
  89111. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89112. /** Use the given ray to pick a sprite in the scene
  89113. * @param ray The ray (in world space) to use to pick meshes
  89114. * @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
  89115. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89116. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89117. * @returns a PickingInfo
  89118. */
  89119. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  89120. /** @hidden */
  89121. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89122. /** Launch a ray to try to pick sprites in the scene
  89123. * @param x position on screen
  89124. * @param y position on screen
  89125. * @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
  89126. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  89127. * @returns a PickingInfo array
  89128. */
  89129. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89130. /** Use the given ray to pick sprites in the scene
  89131. * @param ray The ray (in world space) to use to pick meshes
  89132. * @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
  89133. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  89134. * @returns a PickingInfo array
  89135. */
  89136. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  89137. /**
  89138. * Force the sprite under the pointer
  89139. * @param sprite defines the sprite to use
  89140. */
  89141. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  89142. /**
  89143. * Gets the sprite under the pointer
  89144. * @returns a Sprite or null if no sprite is under the pointer
  89145. */
  89146. getPointerOverSprite(): Nullable<Sprite>;
  89147. }
  89148. /**
  89149. * Defines the sprite scene component responsible to manage sprites
  89150. * in a given scene.
  89151. */
  89152. export class SpriteSceneComponent implements ISceneComponent {
  89153. /**
  89154. * The component name helpfull to identify the component in the list of scene components.
  89155. */
  89156. readonly name: string;
  89157. /**
  89158. * The scene the component belongs to.
  89159. */
  89160. scene: Scene;
  89161. /** @hidden */
  89162. private _spritePredicate;
  89163. /**
  89164. * Creates a new instance of the component for the given scene
  89165. * @param scene Defines the scene to register the component in
  89166. */
  89167. constructor(scene: Scene);
  89168. /**
  89169. * Registers the component in a given scene
  89170. */
  89171. register(): void;
  89172. /**
  89173. * Rebuilds the elements related to this component in case of
  89174. * context lost for instance.
  89175. */
  89176. rebuild(): void;
  89177. /**
  89178. * Disposes the component and the associated ressources.
  89179. */
  89180. dispose(): void;
  89181. private _pickSpriteButKeepRay;
  89182. private _pointerMove;
  89183. private _pointerDown;
  89184. private _pointerUp;
  89185. }
  89186. }
  89187. declare module BABYLON {
  89188. /** @hidden */
  89189. export var fogFragmentDeclaration: {
  89190. name: string;
  89191. shader: string;
  89192. };
  89193. }
  89194. declare module BABYLON {
  89195. /** @hidden */
  89196. export var fogFragment: {
  89197. name: string;
  89198. shader: string;
  89199. };
  89200. }
  89201. declare module BABYLON {
  89202. /** @hidden */
  89203. export var spritesPixelShader: {
  89204. name: string;
  89205. shader: string;
  89206. };
  89207. }
  89208. declare module BABYLON {
  89209. /** @hidden */
  89210. export var fogVertexDeclaration: {
  89211. name: string;
  89212. shader: string;
  89213. };
  89214. }
  89215. declare module BABYLON {
  89216. /** @hidden */
  89217. export var spritesVertexShader: {
  89218. name: string;
  89219. shader: string;
  89220. };
  89221. }
  89222. declare module BABYLON {
  89223. /**
  89224. * Defines the minimum interface to fullfil in order to be a sprite manager.
  89225. */
  89226. export interface ISpriteManager extends IDisposable {
  89227. /**
  89228. * Gets manager's name
  89229. */
  89230. name: string;
  89231. /**
  89232. * Restricts the camera to viewing objects with the same layerMask.
  89233. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  89234. */
  89235. layerMask: number;
  89236. /**
  89237. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  89238. */
  89239. isPickable: boolean;
  89240. /**
  89241. * Gets the hosting scene
  89242. */
  89243. scene: Scene;
  89244. /**
  89245. * Specifies the rendering group id for this mesh (0 by default)
  89246. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  89247. */
  89248. renderingGroupId: number;
  89249. /**
  89250. * Defines the list of sprites managed by the manager.
  89251. */
  89252. sprites: Array<Sprite>;
  89253. /**
  89254. * Gets or sets the spritesheet texture
  89255. */
  89256. texture: Texture;
  89257. /** Defines the default width of a cell in the spritesheet */
  89258. cellWidth: number;
  89259. /** Defines the default height of a cell in the spritesheet */
  89260. cellHeight: number;
  89261. /**
  89262. * Tests the intersection of a sprite with a specific ray.
  89263. * @param ray The ray we are sending to test the collision
  89264. * @param camera The camera space we are sending rays in
  89265. * @param predicate A predicate allowing excluding sprites from the list of object to test
  89266. * @param fastCheck defines if the first intersection will be used (and not the closest)
  89267. * @returns picking info or null.
  89268. */
  89269. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89270. /**
  89271. * Intersects the sprites with a ray
  89272. * @param ray defines the ray to intersect with
  89273. * @param camera defines the current active camera
  89274. * @param predicate defines a predicate used to select candidate sprites
  89275. * @returns null if no hit or a PickingInfo array
  89276. */
  89277. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89278. /**
  89279. * Renders the list of sprites on screen.
  89280. */
  89281. render(): void;
  89282. }
  89283. /**
  89284. * Class used to manage multiple sprites on the same spritesheet
  89285. * @see https://doc.babylonjs.com/babylon101/sprites
  89286. */
  89287. export class SpriteManager implements ISpriteManager {
  89288. /** defines the manager's name */
  89289. name: string;
  89290. /** Define the Url to load snippets */
  89291. static SnippetUrl: string;
  89292. /** Snippet ID if the manager was created from the snippet server */
  89293. snippetId: string;
  89294. /** Gets the list of sprites */
  89295. sprites: Sprite[];
  89296. /** Gets or sets the rendering group id (0 by default) */
  89297. renderingGroupId: number;
  89298. /** Gets or sets camera layer mask */
  89299. layerMask: number;
  89300. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  89301. fogEnabled: boolean;
  89302. /** Gets or sets a boolean indicating if the sprites are pickable */
  89303. isPickable: boolean;
  89304. /** Defines the default width of a cell in the spritesheet */
  89305. cellWidth: number;
  89306. /** Defines the default height of a cell in the spritesheet */
  89307. cellHeight: number;
  89308. /** Associative array from JSON sprite data file */
  89309. private _cellData;
  89310. /** Array of sprite names from JSON sprite data file */
  89311. private _spriteMap;
  89312. /** True when packed cell data from JSON file is ready*/
  89313. private _packedAndReady;
  89314. private _textureContent;
  89315. /**
  89316. * An event triggered when the manager is disposed.
  89317. */
  89318. onDisposeObservable: Observable<SpriteManager>;
  89319. private _onDisposeObserver;
  89320. /**
  89321. * Callback called when the manager is disposed
  89322. */
  89323. set onDispose(callback: () => void);
  89324. private _capacity;
  89325. private _fromPacked;
  89326. private _spriteTexture;
  89327. private _epsilon;
  89328. private _scene;
  89329. private _vertexData;
  89330. private _buffer;
  89331. private _vertexBuffers;
  89332. private _indexBuffer;
  89333. private _effectBase;
  89334. private _effectFog;
  89335. /**
  89336. * Gets or sets the unique id of the sprite
  89337. */
  89338. uniqueId: number;
  89339. /**
  89340. * Gets the array of sprites
  89341. */
  89342. get children(): Sprite[];
  89343. /**
  89344. * Gets the hosting scene
  89345. */
  89346. get scene(): Scene;
  89347. /**
  89348. * Gets the capacity of the manager
  89349. */
  89350. get capacity(): number;
  89351. /**
  89352. * Gets or sets the spritesheet texture
  89353. */
  89354. get texture(): Texture;
  89355. set texture(value: Texture);
  89356. private _blendMode;
  89357. /**
  89358. * Blend mode use to render the particle, it can be any of
  89359. * the static Constants.ALPHA_x properties provided in this class.
  89360. * Default value is Constants.ALPHA_COMBINE
  89361. */
  89362. get blendMode(): number;
  89363. set blendMode(blendMode: number);
  89364. /** Disables writing to the depth buffer when rendering the sprites.
  89365. * It can be handy to disable depth writing when using textures without alpha channel
  89366. * and setting some specific blend modes.
  89367. */
  89368. disableDepthWrite: boolean;
  89369. /**
  89370. * Creates a new sprite manager
  89371. * @param name defines the manager's name
  89372. * @param imgUrl defines the sprite sheet url
  89373. * @param capacity defines the maximum allowed number of sprites
  89374. * @param cellSize defines the size of a sprite cell
  89375. * @param scene defines the hosting scene
  89376. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  89377. * @param samplingMode defines the smapling mode to use with spritesheet
  89378. * @param fromPacked set to false; do not alter
  89379. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  89380. */
  89381. constructor(
  89382. /** defines the manager's name */
  89383. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  89384. /**
  89385. * Returns the string "SpriteManager"
  89386. * @returns "SpriteManager"
  89387. */
  89388. getClassName(): string;
  89389. private _makePacked;
  89390. private _appendSpriteVertex;
  89391. private _checkTextureAlpha;
  89392. /**
  89393. * Intersects the sprites with a ray
  89394. * @param ray defines the ray to intersect with
  89395. * @param camera defines the current active camera
  89396. * @param predicate defines a predicate used to select candidate sprites
  89397. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  89398. * @returns null if no hit or a PickingInfo
  89399. */
  89400. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  89401. /**
  89402. * Intersects the sprites with a ray
  89403. * @param ray defines the ray to intersect with
  89404. * @param camera defines the current active camera
  89405. * @param predicate defines a predicate used to select candidate sprites
  89406. * @returns null if no hit or a PickingInfo array
  89407. */
  89408. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  89409. /**
  89410. * Render all child sprites
  89411. */
  89412. render(): void;
  89413. /**
  89414. * Release associated resources
  89415. */
  89416. dispose(): void;
  89417. /**
  89418. * Serializes the sprite manager to a JSON object
  89419. * @param serializeTexture defines if the texture must be serialized as well
  89420. * @returns the JSON object
  89421. */
  89422. serialize(serializeTexture?: boolean): any;
  89423. /**
  89424. * Parses a JSON object to create a new sprite manager.
  89425. * @param parsedManager The JSON object to parse
  89426. * @param scene The scene to create the sprite managerin
  89427. * @param rootUrl The root url to use to load external dependencies like texture
  89428. * @returns the new sprite manager
  89429. */
  89430. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  89431. /**
  89432. * Creates a sprite manager from a snippet saved in a remote file
  89433. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  89434. * @param url defines the url to load from
  89435. * @param scene defines the hosting scene
  89436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89437. * @returns a promise that will resolve to the new sprite manager
  89438. */
  89439. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89440. /**
  89441. * Creates a sprite manager from a snippet saved by the sprite editor
  89442. * @param snippetId defines the snippet to load
  89443. * @param scene defines the hosting scene
  89444. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  89445. * @returns a promise that will resolve to the new sprite manager
  89446. */
  89447. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  89448. }
  89449. }
  89450. declare module BABYLON {
  89451. /** Interface used by value gradients (color, factor, ...) */
  89452. export interface IValueGradient {
  89453. /**
  89454. * Gets or sets the gradient value (between 0 and 1)
  89455. */
  89456. gradient: number;
  89457. }
  89458. /** Class used to store color4 gradient */
  89459. export class ColorGradient implements IValueGradient {
  89460. /**
  89461. * Gets or sets the gradient value (between 0 and 1)
  89462. */
  89463. gradient: number;
  89464. /**
  89465. * Gets or sets first associated color
  89466. */
  89467. color1: Color4;
  89468. /**
  89469. * Gets or sets second associated color
  89470. */
  89471. color2?: Color4 | undefined;
  89472. /**
  89473. * Creates a new color4 gradient
  89474. * @param gradient gets or sets the gradient value (between 0 and 1)
  89475. * @param color1 gets or sets first associated color
  89476. * @param color2 gets or sets first second color
  89477. */
  89478. constructor(
  89479. /**
  89480. * Gets or sets the gradient value (between 0 and 1)
  89481. */
  89482. gradient: number,
  89483. /**
  89484. * Gets or sets first associated color
  89485. */
  89486. color1: Color4,
  89487. /**
  89488. * Gets or sets second associated color
  89489. */
  89490. color2?: Color4 | undefined);
  89491. /**
  89492. * Will get a color picked randomly between color1 and color2.
  89493. * If color2 is undefined then color1 will be used
  89494. * @param result defines the target Color4 to store the result in
  89495. */
  89496. getColorToRef(result: Color4): void;
  89497. }
  89498. /** Class used to store color 3 gradient */
  89499. export class Color3Gradient implements IValueGradient {
  89500. /**
  89501. * Gets or sets the gradient value (between 0 and 1)
  89502. */
  89503. gradient: number;
  89504. /**
  89505. * Gets or sets the associated color
  89506. */
  89507. color: Color3;
  89508. /**
  89509. * Creates a new color3 gradient
  89510. * @param gradient gets or sets the gradient value (between 0 and 1)
  89511. * @param color gets or sets associated color
  89512. */
  89513. constructor(
  89514. /**
  89515. * Gets or sets the gradient value (between 0 and 1)
  89516. */
  89517. gradient: number,
  89518. /**
  89519. * Gets or sets the associated color
  89520. */
  89521. color: Color3);
  89522. }
  89523. /** Class used to store factor gradient */
  89524. export class FactorGradient implements IValueGradient {
  89525. /**
  89526. * Gets or sets the gradient value (between 0 and 1)
  89527. */
  89528. gradient: number;
  89529. /**
  89530. * Gets or sets first associated factor
  89531. */
  89532. factor1: number;
  89533. /**
  89534. * Gets or sets second associated factor
  89535. */
  89536. factor2?: number | undefined;
  89537. /**
  89538. * Creates a new factor gradient
  89539. * @param gradient gets or sets the gradient value (between 0 and 1)
  89540. * @param factor1 gets or sets first associated factor
  89541. * @param factor2 gets or sets second associated factor
  89542. */
  89543. constructor(
  89544. /**
  89545. * Gets or sets the gradient value (between 0 and 1)
  89546. */
  89547. gradient: number,
  89548. /**
  89549. * Gets or sets first associated factor
  89550. */
  89551. factor1: number,
  89552. /**
  89553. * Gets or sets second associated factor
  89554. */
  89555. factor2?: number | undefined);
  89556. /**
  89557. * Will get a number picked randomly between factor1 and factor2.
  89558. * If factor2 is undefined then factor1 will be used
  89559. * @returns the picked number
  89560. */
  89561. getFactor(): number;
  89562. }
  89563. /**
  89564. * Helper used to simplify some generic gradient tasks
  89565. */
  89566. export class GradientHelper {
  89567. /**
  89568. * Gets the current gradient from an array of IValueGradient
  89569. * @param ratio defines the current ratio to get
  89570. * @param gradients defines the array of IValueGradient
  89571. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  89572. */
  89573. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  89574. }
  89575. }
  89576. declare module BABYLON {
  89577. interface ThinEngine {
  89578. /**
  89579. * Creates a raw texture
  89580. * @param data defines the data to store in the texture
  89581. * @param width defines the width of the texture
  89582. * @param height defines the height of the texture
  89583. * @param format defines the format of the data
  89584. * @param generateMipMaps defines if the engine should generate the mip levels
  89585. * @param invertY defines if data must be stored with Y axis inverted
  89586. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  89587. * @param compression defines the compression used (null by default)
  89588. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89589. * @returns the raw texture inside an InternalTexture
  89590. */
  89591. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  89592. /**
  89593. * Update a raw texture
  89594. * @param texture defines the texture to update
  89595. * @param data defines the data to store in the texture
  89596. * @param format defines the format of the data
  89597. * @param invertY defines if data must be stored with Y axis inverted
  89598. */
  89599. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89600. /**
  89601. * Update a raw texture
  89602. * @param texture defines the texture to update
  89603. * @param data defines the data to store in the texture
  89604. * @param format defines the format of the data
  89605. * @param invertY defines if data must be stored with Y axis inverted
  89606. * @param compression defines the compression used (null by default)
  89607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89608. */
  89609. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  89610. /**
  89611. * Creates a new raw cube texture
  89612. * @param data defines the array of data to use to create each face
  89613. * @param size defines the size of the textures
  89614. * @param format defines the format of the data
  89615. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89616. * @param generateMipMaps defines if the engine should generate the mip levels
  89617. * @param invertY defines if data must be stored with Y axis inverted
  89618. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89619. * @param compression defines the compression used (null by default)
  89620. * @returns the cube texture as an InternalTexture
  89621. */
  89622. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  89623. /**
  89624. * Update a raw cube texture
  89625. * @param texture defines the texture to udpdate
  89626. * @param data defines the data to store
  89627. * @param format defines the data format
  89628. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89629. * @param invertY defines if data must be stored with Y axis inverted
  89630. */
  89631. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  89632. /**
  89633. * Update a raw cube texture
  89634. * @param texture defines the texture to udpdate
  89635. * @param data defines the data to store
  89636. * @param format defines the data format
  89637. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89638. * @param invertY defines if data must be stored with Y axis inverted
  89639. * @param compression defines the compression used (null by default)
  89640. */
  89641. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  89642. /**
  89643. * Update a raw cube texture
  89644. * @param texture defines the texture to udpdate
  89645. * @param data defines the data to store
  89646. * @param format defines the data format
  89647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  89648. * @param invertY defines if data must be stored with Y axis inverted
  89649. * @param compression defines the compression used (null by default)
  89650. * @param level defines which level of the texture to update
  89651. */
  89652. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  89653. /**
  89654. * Creates a new raw cube texture from a specified url
  89655. * @param url defines the url where the data is located
  89656. * @param scene defines the current scene
  89657. * @param size defines the size of the textures
  89658. * @param format defines the format of the data
  89659. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89660. * @param noMipmap defines if the engine should avoid generating the mip levels
  89661. * @param callback defines a callback used to extract texture data from loaded data
  89662. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89663. * @param onLoad defines a callback called when texture is loaded
  89664. * @param onError defines a callback called if there is an error
  89665. * @returns the cube texture as an InternalTexture
  89666. */
  89667. 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;
  89668. /**
  89669. * Creates a new raw cube texture from a specified url
  89670. * @param url defines the url where the data is located
  89671. * @param scene defines the current scene
  89672. * @param size defines the size of the textures
  89673. * @param format defines the format of the data
  89674. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  89675. * @param noMipmap defines if the engine should avoid generating the mip levels
  89676. * @param callback defines a callback used to extract texture data from loaded data
  89677. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  89678. * @param onLoad defines a callback called when texture is loaded
  89679. * @param onError defines a callback called if there is an error
  89680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89681. * @param invertY defines if data must be stored with Y axis inverted
  89682. * @returns the cube texture as an InternalTexture
  89683. */
  89684. 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;
  89685. /**
  89686. * Creates a new raw 3D texture
  89687. * @param data defines the data used to create the texture
  89688. * @param width defines the width of the texture
  89689. * @param height defines the height of the texture
  89690. * @param depth defines the depth of the texture
  89691. * @param format defines the format of the texture
  89692. * @param generateMipMaps defines if the engine must generate mip levels
  89693. * @param invertY defines if data must be stored with Y axis inverted
  89694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89695. * @param compression defines the compressed used (can be null)
  89696. * @param textureType defines the compressed used (can be null)
  89697. * @returns a new raw 3D texture (stored in an InternalTexture)
  89698. */
  89699. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89700. /**
  89701. * Update a raw 3D texture
  89702. * @param texture defines the texture to update
  89703. * @param data defines the data to store
  89704. * @param format defines the data format
  89705. * @param invertY defines if data must be stored with Y axis inverted
  89706. */
  89707. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89708. /**
  89709. * Update a raw 3D texture
  89710. * @param texture defines the texture to update
  89711. * @param data defines the data to store
  89712. * @param format defines the data format
  89713. * @param invertY defines if data must be stored with Y axis inverted
  89714. * @param compression defines the used compression (can be null)
  89715. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89716. */
  89717. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89718. /**
  89719. * Creates a new raw 2D array texture
  89720. * @param data defines the data used to create the texture
  89721. * @param width defines the width of the texture
  89722. * @param height defines the height of the texture
  89723. * @param depth defines the number of layers of the texture
  89724. * @param format defines the format of the texture
  89725. * @param generateMipMaps defines if the engine must generate mip levels
  89726. * @param invertY defines if data must be stored with Y axis inverted
  89727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  89728. * @param compression defines the compressed used (can be null)
  89729. * @param textureType defines the compressed used (can be null)
  89730. * @returns a new raw 2D array texture (stored in an InternalTexture)
  89731. */
  89732. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  89733. /**
  89734. * Update a raw 2D array texture
  89735. * @param texture defines the texture to update
  89736. * @param data defines the data to store
  89737. * @param format defines the data format
  89738. * @param invertY defines if data must be stored with Y axis inverted
  89739. */
  89740. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  89741. /**
  89742. * Update a raw 2D array texture
  89743. * @param texture defines the texture to update
  89744. * @param data defines the data to store
  89745. * @param format defines the data format
  89746. * @param invertY defines if data must be stored with Y axis inverted
  89747. * @param compression defines the used compression (can be null)
  89748. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  89749. */
  89750. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  89751. }
  89752. }
  89753. declare module BABYLON {
  89754. /**
  89755. * Raw texture can help creating a texture directly from an array of data.
  89756. * This can be super useful if you either get the data from an uncompressed source or
  89757. * if you wish to create your texture pixel by pixel.
  89758. */
  89759. export class RawTexture extends Texture {
  89760. /**
  89761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89762. */
  89763. format: number;
  89764. /**
  89765. * Instantiates a new RawTexture.
  89766. * Raw texture can help creating a texture directly from an array of data.
  89767. * This can be super useful if you either get the data from an uncompressed source or
  89768. * if you wish to create your texture pixel by pixel.
  89769. * @param data define the array of data to use to create the texture
  89770. * @param width define the width of the texture
  89771. * @param height define the height of the texture
  89772. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89773. * @param scene define the scene the texture belongs to
  89774. * @param generateMipMaps define whether mip maps should be generated or not
  89775. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89776. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89777. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89778. */
  89779. constructor(data: ArrayBufferView, width: number, height: number,
  89780. /**
  89781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  89782. */
  89783. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  89784. /**
  89785. * Updates the texture underlying data.
  89786. * @param data Define the new data of the texture
  89787. */
  89788. update(data: ArrayBufferView): void;
  89789. /**
  89790. * Creates a luminance texture from some data.
  89791. * @param data Define the texture data
  89792. * @param width Define the width of the texture
  89793. * @param height Define the height of the texture
  89794. * @param scene Define the scene the texture belongs to
  89795. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89796. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89797. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89798. * @returns the luminance texture
  89799. */
  89800. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89801. /**
  89802. * Creates a luminance alpha texture from some data.
  89803. * @param data Define the texture data
  89804. * @param width Define the width of the texture
  89805. * @param height Define the height of the texture
  89806. * @param scene Define the scene the texture belongs to
  89807. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89808. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89809. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89810. * @returns the luminance alpha texture
  89811. */
  89812. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89813. /**
  89814. * Creates an alpha texture from some data.
  89815. * @param data Define the texture data
  89816. * @param width Define the width of the texture
  89817. * @param height Define the height of the texture
  89818. * @param scene Define the scene the texture belongs to
  89819. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89820. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89821. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89822. * @returns the alpha texture
  89823. */
  89824. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  89825. /**
  89826. * Creates a RGB texture from some data.
  89827. * @param data Define the texture data
  89828. * @param width Define the width of the texture
  89829. * @param height Define the height of the texture
  89830. * @param scene Define the scene the texture belongs to
  89831. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89832. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89833. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89834. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89835. * @returns the RGB alpha texture
  89836. */
  89837. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89838. /**
  89839. * Creates a RGBA texture from some data.
  89840. * @param data Define the texture data
  89841. * @param width Define the width of the texture
  89842. * @param height Define the height of the texture
  89843. * @param scene Define the scene the texture belongs to
  89844. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89845. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89846. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89847. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89848. * @returns the RGBA texture
  89849. */
  89850. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89851. /**
  89852. * Creates a R texture from some data.
  89853. * @param data Define the texture data
  89854. * @param width Define the width of the texture
  89855. * @param height Define the height of the texture
  89856. * @param scene Define the scene the texture belongs to
  89857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  89858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  89859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  89860. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  89861. * @returns the R texture
  89862. */
  89863. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  89864. }
  89865. }
  89866. declare module BABYLON {
  89867. interface AbstractScene {
  89868. /**
  89869. * The list of procedural textures added to the scene
  89870. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89871. */
  89872. proceduralTextures: Array<ProceduralTexture>;
  89873. }
  89874. /**
  89875. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  89876. * in a given scene.
  89877. */
  89878. export class ProceduralTextureSceneComponent implements ISceneComponent {
  89879. /**
  89880. * The component name helpfull to identify the component in the list of scene components.
  89881. */
  89882. readonly name: string;
  89883. /**
  89884. * The scene the component belongs to.
  89885. */
  89886. scene: Scene;
  89887. /**
  89888. * Creates a new instance of the component for the given scene
  89889. * @param scene Defines the scene to register the component in
  89890. */
  89891. constructor(scene: Scene);
  89892. /**
  89893. * Registers the component in a given scene
  89894. */
  89895. register(): void;
  89896. /**
  89897. * Rebuilds the elements related to this component in case of
  89898. * context lost for instance.
  89899. */
  89900. rebuild(): void;
  89901. /**
  89902. * Disposes the component and the associated ressources.
  89903. */
  89904. dispose(): void;
  89905. private _beforeClear;
  89906. }
  89907. }
  89908. declare module BABYLON {
  89909. interface ThinEngine {
  89910. /**
  89911. * Creates a new render target cube texture
  89912. * @param size defines the size of the texture
  89913. * @param options defines the options used to create the texture
  89914. * @returns a new render target cube texture stored in an InternalTexture
  89915. */
  89916. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  89917. }
  89918. }
  89919. declare module BABYLON {
  89920. /** @hidden */
  89921. export var proceduralVertexShader: {
  89922. name: string;
  89923. shader: string;
  89924. };
  89925. }
  89926. declare module BABYLON {
  89927. /**
  89928. * 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.
  89929. * This is the base class of any Procedural texture and contains most of the shareable code.
  89930. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89931. */
  89932. export class ProceduralTexture extends Texture {
  89933. isCube: boolean;
  89934. /**
  89935. * Define if the texture is enabled or not (disabled texture will not render)
  89936. */
  89937. isEnabled: boolean;
  89938. /**
  89939. * Define if the texture must be cleared before rendering (default is true)
  89940. */
  89941. autoClear: boolean;
  89942. /**
  89943. * Callback called when the texture is generated
  89944. */
  89945. onGenerated: () => void;
  89946. /**
  89947. * Event raised when the texture is generated
  89948. */
  89949. onGeneratedObservable: Observable<ProceduralTexture>;
  89950. /** @hidden */
  89951. _generateMipMaps: boolean;
  89952. /** @hidden **/
  89953. _effect: Effect;
  89954. /** @hidden */
  89955. _textures: {
  89956. [key: string]: Texture;
  89957. };
  89958. /** @hidden */
  89959. protected _fallbackTexture: Nullable<Texture>;
  89960. private _size;
  89961. private _currentRefreshId;
  89962. private _frameId;
  89963. private _refreshRate;
  89964. private _vertexBuffers;
  89965. private _indexBuffer;
  89966. private _uniforms;
  89967. private _samplers;
  89968. private _fragment;
  89969. private _floats;
  89970. private _ints;
  89971. private _floatsArrays;
  89972. private _colors3;
  89973. private _colors4;
  89974. private _vectors2;
  89975. private _vectors3;
  89976. private _matrices;
  89977. private _fallbackTextureUsed;
  89978. private _fullEngine;
  89979. private _cachedDefines;
  89980. private _contentUpdateId;
  89981. private _contentData;
  89982. /**
  89983. * Instantiates a new procedural texture.
  89984. * 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.
  89985. * This is the base class of any Procedural texture and contains most of the shareable code.
  89986. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  89987. * @param name Define the name of the texture
  89988. * @param size Define the size of the texture to create
  89989. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  89990. * @param scene Define the scene the texture belongs to
  89991. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  89992. * @param generateMipMaps Define if the texture should creates mip maps or not
  89993. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  89994. */
  89995. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  89996. /**
  89997. * The effect that is created when initializing the post process.
  89998. * @returns The created effect corresponding the the postprocess.
  89999. */
  90000. getEffect(): Effect;
  90001. /**
  90002. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  90003. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  90004. */
  90005. getContent(): Nullable<ArrayBufferView>;
  90006. private _createIndexBuffer;
  90007. /** @hidden */
  90008. _rebuild(): void;
  90009. /**
  90010. * Resets the texture in order to recreate its associated resources.
  90011. * This can be called in case of context loss
  90012. */
  90013. reset(): void;
  90014. protected _getDefines(): string;
  90015. /**
  90016. * Is the texture ready to be used ? (rendered at least once)
  90017. * @returns true if ready, otherwise, false.
  90018. */
  90019. isReady(): boolean;
  90020. /**
  90021. * Resets the refresh counter of the texture and start bak from scratch.
  90022. * Could be useful to regenerate the texture if it is setup to render only once.
  90023. */
  90024. resetRefreshCounter(): void;
  90025. /**
  90026. * Set the fragment shader to use in order to render the texture.
  90027. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  90028. */
  90029. setFragment(fragment: any): void;
  90030. /**
  90031. * Define the refresh rate of the texture or the rendering frequency.
  90032. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  90033. */
  90034. get refreshRate(): number;
  90035. set refreshRate(value: number);
  90036. /** @hidden */
  90037. _shouldRender(): boolean;
  90038. /**
  90039. * Get the size the texture is rendering at.
  90040. * @returns the size (texture is always squared)
  90041. */
  90042. getRenderSize(): number;
  90043. /**
  90044. * Resize the texture to new value.
  90045. * @param size Define the new size the texture should have
  90046. * @param generateMipMaps Define whether the new texture should create mip maps
  90047. */
  90048. resize(size: number, generateMipMaps: boolean): void;
  90049. private _checkUniform;
  90050. /**
  90051. * Set a texture in the shader program used to render.
  90052. * @param name Define the name of the uniform samplers as defined in the shader
  90053. * @param texture Define the texture to bind to this sampler
  90054. * @return the texture itself allowing "fluent" like uniform updates
  90055. */
  90056. setTexture(name: string, texture: Texture): ProceduralTexture;
  90057. /**
  90058. * Set a float in the shader.
  90059. * @param name Define the name of the uniform as defined in the shader
  90060. * @param value Define the value to give to the uniform
  90061. * @return the texture itself allowing "fluent" like uniform updates
  90062. */
  90063. setFloat(name: string, value: number): ProceduralTexture;
  90064. /**
  90065. * Set a int in the shader.
  90066. * @param name Define the name of the uniform as defined in the shader
  90067. * @param value Define the value to give to the uniform
  90068. * @return the texture itself allowing "fluent" like uniform updates
  90069. */
  90070. setInt(name: string, value: number): ProceduralTexture;
  90071. /**
  90072. * Set an array of floats in the shader.
  90073. * @param name Define the name of the uniform as defined in the shader
  90074. * @param value Define the value to give to the uniform
  90075. * @return the texture itself allowing "fluent" like uniform updates
  90076. */
  90077. setFloats(name: string, value: number[]): ProceduralTexture;
  90078. /**
  90079. * Set a vec3 in the shader from a Color3.
  90080. * @param name Define the name of the uniform as defined in the shader
  90081. * @param value Define the value to give to the uniform
  90082. * @return the texture itself allowing "fluent" like uniform updates
  90083. */
  90084. setColor3(name: string, value: Color3): ProceduralTexture;
  90085. /**
  90086. * Set a vec4 in the shader from a Color4.
  90087. * @param name Define the name of the uniform as defined in the shader
  90088. * @param value Define the value to give to the uniform
  90089. * @return the texture itself allowing "fluent" like uniform updates
  90090. */
  90091. setColor4(name: string, value: Color4): ProceduralTexture;
  90092. /**
  90093. * Set a vec2 in the shader from a Vector2.
  90094. * @param name Define the name of the uniform as defined in the shader
  90095. * @param value Define the value to give to the uniform
  90096. * @return the texture itself allowing "fluent" like uniform updates
  90097. */
  90098. setVector2(name: string, value: Vector2): ProceduralTexture;
  90099. /**
  90100. * Set a vec3 in the shader from a Vector3.
  90101. * @param name Define the name of the uniform as defined in the shader
  90102. * @param value Define the value to give to the uniform
  90103. * @return the texture itself allowing "fluent" like uniform updates
  90104. */
  90105. setVector3(name: string, value: Vector3): ProceduralTexture;
  90106. /**
  90107. * Set a mat4 in the shader from a MAtrix.
  90108. * @param name Define the name of the uniform as defined in the shader
  90109. * @param value Define the value to give to the uniform
  90110. * @return the texture itself allowing "fluent" like uniform updates
  90111. */
  90112. setMatrix(name: string, value: Matrix): ProceduralTexture;
  90113. /**
  90114. * Render the texture to its associated render target.
  90115. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  90116. */
  90117. render(useCameraPostProcess?: boolean): void;
  90118. /**
  90119. * Clone the texture.
  90120. * @returns the cloned texture
  90121. */
  90122. clone(): ProceduralTexture;
  90123. /**
  90124. * Dispose the texture and release its asoociated resources.
  90125. */
  90126. dispose(): void;
  90127. }
  90128. }
  90129. declare module BABYLON {
  90130. /**
  90131. * This represents the base class for particle system in Babylon.
  90132. * 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.
  90133. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90134. * @example https://doc.babylonjs.com/babylon101/particles
  90135. */
  90136. export class BaseParticleSystem {
  90137. /**
  90138. * Source color is added to the destination color without alpha affecting the result
  90139. */
  90140. static BLENDMODE_ONEONE: number;
  90141. /**
  90142. * Blend current color and particle color using particle’s alpha
  90143. */
  90144. static BLENDMODE_STANDARD: number;
  90145. /**
  90146. * Add current color and particle color multiplied by particle’s alpha
  90147. */
  90148. static BLENDMODE_ADD: number;
  90149. /**
  90150. * Multiply current color with particle color
  90151. */
  90152. static BLENDMODE_MULTIPLY: number;
  90153. /**
  90154. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  90155. */
  90156. static BLENDMODE_MULTIPLYADD: number;
  90157. /**
  90158. * List of animations used by the particle system.
  90159. */
  90160. animations: Animation[];
  90161. /**
  90162. * Gets or sets the unique id of the particle system
  90163. */
  90164. uniqueId: number;
  90165. /**
  90166. * The id of the Particle system.
  90167. */
  90168. id: string;
  90169. /**
  90170. * The friendly name of the Particle system.
  90171. */
  90172. name: string;
  90173. /**
  90174. * Snippet ID if the particle system was created from the snippet server
  90175. */
  90176. snippetId: string;
  90177. /**
  90178. * The rendering group used by the Particle system to chose when to render.
  90179. */
  90180. renderingGroupId: number;
  90181. /**
  90182. * The emitter represents the Mesh or position we are attaching the particle system to.
  90183. */
  90184. emitter: Nullable<AbstractMesh | Vector3>;
  90185. /**
  90186. * The maximum number of particles to emit per frame
  90187. */
  90188. emitRate: number;
  90189. /**
  90190. * If you want to launch only a few particles at once, that can be done, as well.
  90191. */
  90192. manualEmitCount: number;
  90193. /**
  90194. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  90195. */
  90196. updateSpeed: number;
  90197. /**
  90198. * The amount of time the particle system is running (depends of the overall update speed).
  90199. */
  90200. targetStopDuration: number;
  90201. /**
  90202. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  90203. */
  90204. disposeOnStop: boolean;
  90205. /**
  90206. * Minimum power of emitting particles.
  90207. */
  90208. minEmitPower: number;
  90209. /**
  90210. * Maximum power of emitting particles.
  90211. */
  90212. maxEmitPower: number;
  90213. /**
  90214. * Minimum life time of emitting particles.
  90215. */
  90216. minLifeTime: number;
  90217. /**
  90218. * Maximum life time of emitting particles.
  90219. */
  90220. maxLifeTime: number;
  90221. /**
  90222. * Minimum Size of emitting particles.
  90223. */
  90224. minSize: number;
  90225. /**
  90226. * Maximum Size of emitting particles.
  90227. */
  90228. maxSize: number;
  90229. /**
  90230. * Minimum scale of emitting particles on X axis.
  90231. */
  90232. minScaleX: number;
  90233. /**
  90234. * Maximum scale of emitting particles on X axis.
  90235. */
  90236. maxScaleX: number;
  90237. /**
  90238. * Minimum scale of emitting particles on Y axis.
  90239. */
  90240. minScaleY: number;
  90241. /**
  90242. * Maximum scale of emitting particles on Y axis.
  90243. */
  90244. maxScaleY: number;
  90245. /**
  90246. * Gets or sets the minimal initial rotation in radians.
  90247. */
  90248. minInitialRotation: number;
  90249. /**
  90250. * Gets or sets the maximal initial rotation in radians.
  90251. */
  90252. maxInitialRotation: number;
  90253. /**
  90254. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  90255. */
  90256. minAngularSpeed: number;
  90257. /**
  90258. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  90259. */
  90260. maxAngularSpeed: number;
  90261. /**
  90262. * The texture used to render each particle. (this can be a spritesheet)
  90263. */
  90264. particleTexture: Nullable<Texture>;
  90265. /**
  90266. * The layer mask we are rendering the particles through.
  90267. */
  90268. layerMask: number;
  90269. /**
  90270. * This can help using your own shader to render the particle system.
  90271. * The according effect will be created
  90272. */
  90273. customShader: any;
  90274. /**
  90275. * By default particle system starts as soon as they are created. This prevents the
  90276. * automatic start to happen and let you decide when to start emitting particles.
  90277. */
  90278. preventAutoStart: boolean;
  90279. private _noiseTexture;
  90280. /**
  90281. * Gets or sets a texture used to add random noise to particle positions
  90282. */
  90283. get noiseTexture(): Nullable<ProceduralTexture>;
  90284. set noiseTexture(value: Nullable<ProceduralTexture>);
  90285. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  90286. noiseStrength: Vector3;
  90287. /**
  90288. * Callback triggered when the particle animation is ending.
  90289. */
  90290. onAnimationEnd: Nullable<() => void>;
  90291. /**
  90292. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  90293. */
  90294. blendMode: number;
  90295. /**
  90296. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  90297. * to override the particles.
  90298. */
  90299. forceDepthWrite: boolean;
  90300. /** 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 */
  90301. preWarmCycles: number;
  90302. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  90303. preWarmStepOffset: number;
  90304. /**
  90305. * 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)
  90306. */
  90307. spriteCellChangeSpeed: number;
  90308. /**
  90309. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  90310. */
  90311. startSpriteCellID: number;
  90312. /**
  90313. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  90314. */
  90315. endSpriteCellID: number;
  90316. /**
  90317. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  90318. */
  90319. spriteCellWidth: number;
  90320. /**
  90321. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  90322. */
  90323. spriteCellHeight: number;
  90324. /**
  90325. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  90326. */
  90327. spriteRandomStartCell: boolean;
  90328. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  90329. translationPivot: Vector2;
  90330. /** @hidden */
  90331. protected _isAnimationSheetEnabled: boolean;
  90332. /**
  90333. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  90334. */
  90335. beginAnimationOnStart: boolean;
  90336. /**
  90337. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  90338. */
  90339. beginAnimationFrom: number;
  90340. /**
  90341. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  90342. */
  90343. beginAnimationTo: number;
  90344. /**
  90345. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  90346. */
  90347. beginAnimationLoop: boolean;
  90348. /**
  90349. * Gets or sets a world offset applied to all particles
  90350. */
  90351. worldOffset: Vector3;
  90352. /**
  90353. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  90354. */
  90355. get isAnimationSheetEnabled(): boolean;
  90356. set isAnimationSheetEnabled(value: boolean);
  90357. /**
  90358. * Get hosting scene
  90359. * @returns the scene
  90360. */
  90361. getScene(): Scene;
  90362. /**
  90363. * You can use gravity if you want to give an orientation to your particles.
  90364. */
  90365. gravity: Vector3;
  90366. protected _colorGradients: Nullable<Array<ColorGradient>>;
  90367. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  90368. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  90369. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  90370. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  90371. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  90372. protected _dragGradients: Nullable<Array<FactorGradient>>;
  90373. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  90374. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  90375. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  90376. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  90377. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  90378. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  90379. /**
  90380. * Defines the delay in milliseconds before starting the system (0 by default)
  90381. */
  90382. startDelay: number;
  90383. /**
  90384. * Gets the current list of drag gradients.
  90385. * You must use addDragGradient and removeDragGradient to udpate this list
  90386. * @returns the list of drag gradients
  90387. */
  90388. getDragGradients(): Nullable<Array<FactorGradient>>;
  90389. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  90390. limitVelocityDamping: number;
  90391. /**
  90392. * Gets the current list of limit velocity gradients.
  90393. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  90394. * @returns the list of limit velocity gradients
  90395. */
  90396. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  90397. /**
  90398. * Gets the current list of color gradients.
  90399. * You must use addColorGradient and removeColorGradient to udpate this list
  90400. * @returns the list of color gradients
  90401. */
  90402. getColorGradients(): Nullable<Array<ColorGradient>>;
  90403. /**
  90404. * Gets the current list of size gradients.
  90405. * You must use addSizeGradient and removeSizeGradient to udpate this list
  90406. * @returns the list of size gradients
  90407. */
  90408. getSizeGradients(): Nullable<Array<FactorGradient>>;
  90409. /**
  90410. * Gets the current list of color remap gradients.
  90411. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  90412. * @returns the list of color remap gradients
  90413. */
  90414. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  90415. /**
  90416. * Gets the current list of alpha remap gradients.
  90417. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  90418. * @returns the list of alpha remap gradients
  90419. */
  90420. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  90421. /**
  90422. * Gets the current list of life time gradients.
  90423. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  90424. * @returns the list of life time gradients
  90425. */
  90426. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  90427. /**
  90428. * Gets the current list of angular speed gradients.
  90429. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  90430. * @returns the list of angular speed gradients
  90431. */
  90432. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  90433. /**
  90434. * Gets the current list of velocity gradients.
  90435. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  90436. * @returns the list of velocity gradients
  90437. */
  90438. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  90439. /**
  90440. * Gets the current list of start size gradients.
  90441. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  90442. * @returns the list of start size gradients
  90443. */
  90444. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  90445. /**
  90446. * Gets the current list of emit rate gradients.
  90447. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  90448. * @returns the list of emit rate gradients
  90449. */
  90450. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  90451. /**
  90452. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90453. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90454. */
  90455. get direction1(): Vector3;
  90456. set direction1(value: Vector3);
  90457. /**
  90458. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  90459. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90460. */
  90461. get direction2(): Vector3;
  90462. set direction2(value: Vector3);
  90463. /**
  90464. * 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.
  90465. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90466. */
  90467. get minEmitBox(): Vector3;
  90468. set minEmitBox(value: Vector3);
  90469. /**
  90470. * 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.
  90471. * This only works when particleEmitterTyps is a BoxParticleEmitter
  90472. */
  90473. get maxEmitBox(): Vector3;
  90474. set maxEmitBox(value: Vector3);
  90475. /**
  90476. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90477. */
  90478. color1: Color4;
  90479. /**
  90480. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  90481. */
  90482. color2: Color4;
  90483. /**
  90484. * Color the particle will have at the end of its lifetime
  90485. */
  90486. colorDead: Color4;
  90487. /**
  90488. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  90489. */
  90490. textureMask: Color4;
  90491. /**
  90492. * The particle emitter type defines the emitter used by the particle system.
  90493. * It can be for example box, sphere, or cone...
  90494. */
  90495. particleEmitterType: IParticleEmitterType;
  90496. /** @hidden */
  90497. _isSubEmitter: boolean;
  90498. /**
  90499. * Gets or sets the billboard mode to use when isBillboardBased = true.
  90500. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  90501. */
  90502. billboardMode: number;
  90503. protected _isBillboardBased: boolean;
  90504. /**
  90505. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  90506. */
  90507. get isBillboardBased(): boolean;
  90508. set isBillboardBased(value: boolean);
  90509. /**
  90510. * The scene the particle system belongs to.
  90511. */
  90512. protected _scene: Scene;
  90513. /**
  90514. * Local cache of defines for image processing.
  90515. */
  90516. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  90517. /**
  90518. * Default configuration related to image processing available in the standard Material.
  90519. */
  90520. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  90521. /**
  90522. * Gets the image processing configuration used either in this material.
  90523. */
  90524. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  90525. /**
  90526. * Sets the Default image processing configuration used either in the this material.
  90527. *
  90528. * If sets to null, the scene one is in use.
  90529. */
  90530. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  90531. /**
  90532. * Attaches a new image processing configuration to the Standard Material.
  90533. * @param configuration
  90534. */
  90535. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  90536. /** @hidden */
  90537. protected _reset(): void;
  90538. /** @hidden */
  90539. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  90540. /**
  90541. * Instantiates a particle system.
  90542. * 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.
  90543. * @param name The name of the particle system
  90544. */
  90545. constructor(name: string);
  90546. /**
  90547. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  90548. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90549. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90550. * @returns the emitter
  90551. */
  90552. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  90553. /**
  90554. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  90555. * @param radius The radius of the hemisphere to emit from
  90556. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90557. * @returns the emitter
  90558. */
  90559. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  90560. /**
  90561. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  90562. * @param radius The radius of the sphere to emit from
  90563. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  90564. * @returns the emitter
  90565. */
  90566. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  90567. /**
  90568. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  90569. * @param radius The radius of the sphere to emit from
  90570. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  90571. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  90572. * @returns the emitter
  90573. */
  90574. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  90575. /**
  90576. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  90577. * @param radius The radius of the emission cylinder
  90578. * @param height The height of the emission cylinder
  90579. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  90580. * @param directionRandomizer How much to randomize the particle direction [0-1]
  90581. * @returns the emitter
  90582. */
  90583. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  90584. /**
  90585. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  90586. * @param radius The radius of the cylinder to emit from
  90587. * @param height The height of the emission cylinder
  90588. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  90589. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  90590. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  90591. * @returns the emitter
  90592. */
  90593. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  90594. /**
  90595. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  90596. * @param radius The radius of the cone to emit from
  90597. * @param angle The base angle of the cone
  90598. * @returns the emitter
  90599. */
  90600. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  90601. /**
  90602. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  90603. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  90604. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  90605. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90606. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  90607. * @returns the emitter
  90608. */
  90609. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  90610. }
  90611. }
  90612. declare module BABYLON {
  90613. /**
  90614. * Type of sub emitter
  90615. */
  90616. export enum SubEmitterType {
  90617. /**
  90618. * Attached to the particle over it's lifetime
  90619. */
  90620. ATTACHED = 0,
  90621. /**
  90622. * Created when the particle dies
  90623. */
  90624. END = 1
  90625. }
  90626. /**
  90627. * Sub emitter class used to emit particles from an existing particle
  90628. */
  90629. export class SubEmitter {
  90630. /**
  90631. * the particle system to be used by the sub emitter
  90632. */
  90633. particleSystem: ParticleSystem;
  90634. /**
  90635. * Type of the submitter (Default: END)
  90636. */
  90637. type: SubEmitterType;
  90638. /**
  90639. * 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)
  90640. * Note: This only is supported when using an emitter of type Mesh
  90641. */
  90642. inheritDirection: boolean;
  90643. /**
  90644. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  90645. */
  90646. inheritedVelocityAmount: number;
  90647. /**
  90648. * Creates a sub emitter
  90649. * @param particleSystem the particle system to be used by the sub emitter
  90650. */
  90651. constructor(
  90652. /**
  90653. * the particle system to be used by the sub emitter
  90654. */
  90655. particleSystem: ParticleSystem);
  90656. /**
  90657. * Clones the sub emitter
  90658. * @returns the cloned sub emitter
  90659. */
  90660. clone(): SubEmitter;
  90661. /**
  90662. * Serialize current object to a JSON object
  90663. * @returns the serialized object
  90664. */
  90665. serialize(): any;
  90666. /** @hidden */
  90667. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  90668. /**
  90669. * Creates a new SubEmitter from a serialized JSON version
  90670. * @param serializationObject defines the JSON object to read from
  90671. * @param scene defines the hosting scene
  90672. * @param rootUrl defines the rootUrl for data loading
  90673. * @returns a new SubEmitter
  90674. */
  90675. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  90676. /** Release associated resources */
  90677. dispose(): void;
  90678. }
  90679. }
  90680. declare module BABYLON {
  90681. /** @hidden */
  90682. export var imageProcessingDeclaration: {
  90683. name: string;
  90684. shader: string;
  90685. };
  90686. }
  90687. declare module BABYLON {
  90688. /** @hidden */
  90689. export var imageProcessingFunctions: {
  90690. name: string;
  90691. shader: string;
  90692. };
  90693. }
  90694. declare module BABYLON {
  90695. /** @hidden */
  90696. export var particlesPixelShader: {
  90697. name: string;
  90698. shader: string;
  90699. };
  90700. }
  90701. declare module BABYLON {
  90702. /** @hidden */
  90703. export var particlesVertexShader: {
  90704. name: string;
  90705. shader: string;
  90706. };
  90707. }
  90708. declare module BABYLON {
  90709. /**
  90710. * This represents a particle system in Babylon.
  90711. * 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.
  90712. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  90713. * @example https://doc.babylonjs.com/babylon101/particles
  90714. */
  90715. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  90716. /**
  90717. * Billboard mode will only apply to Y axis
  90718. */
  90719. static readonly BILLBOARDMODE_Y: number;
  90720. /**
  90721. * Billboard mode will apply to all axes
  90722. */
  90723. static readonly BILLBOARDMODE_ALL: number;
  90724. /**
  90725. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  90726. */
  90727. static readonly BILLBOARDMODE_STRETCHED: number;
  90728. /**
  90729. * This function can be defined to provide custom update for active particles.
  90730. * This function will be called instead of regular update (age, position, color, etc.).
  90731. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  90732. */
  90733. updateFunction: (particles: Particle[]) => void;
  90734. private _emitterWorldMatrix;
  90735. /**
  90736. * This function can be defined to specify initial direction for every new particle.
  90737. * It by default use the emitterType defined function
  90738. */
  90739. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90740. /**
  90741. * This function can be defined to specify initial position for every new particle.
  90742. * It by default use the emitterType defined function
  90743. */
  90744. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  90745. /**
  90746. * @hidden
  90747. */
  90748. _inheritedVelocityOffset: Vector3;
  90749. /**
  90750. * An event triggered when the system is disposed
  90751. */
  90752. onDisposeObservable: Observable<IParticleSystem>;
  90753. private _onDisposeObserver;
  90754. /**
  90755. * Sets a callback that will be triggered when the system is disposed
  90756. */
  90757. set onDispose(callback: () => void);
  90758. private _particles;
  90759. private _epsilon;
  90760. private _capacity;
  90761. private _stockParticles;
  90762. private _newPartsExcess;
  90763. private _vertexData;
  90764. private _vertexBuffer;
  90765. private _vertexBuffers;
  90766. private _spriteBuffer;
  90767. private _indexBuffer;
  90768. private _effect;
  90769. private _customEffect;
  90770. private _cachedDefines;
  90771. private _scaledColorStep;
  90772. private _colorDiff;
  90773. private _scaledDirection;
  90774. private _scaledGravity;
  90775. private _currentRenderId;
  90776. private _alive;
  90777. private _useInstancing;
  90778. private _started;
  90779. private _stopped;
  90780. private _actualFrame;
  90781. private _scaledUpdateSpeed;
  90782. private _vertexBufferSize;
  90783. /** @hidden */
  90784. _currentEmitRateGradient: Nullable<FactorGradient>;
  90785. /** @hidden */
  90786. _currentEmitRate1: number;
  90787. /** @hidden */
  90788. _currentEmitRate2: number;
  90789. /** @hidden */
  90790. _currentStartSizeGradient: Nullable<FactorGradient>;
  90791. /** @hidden */
  90792. _currentStartSize1: number;
  90793. /** @hidden */
  90794. _currentStartSize2: number;
  90795. private readonly _rawTextureWidth;
  90796. private _rampGradientsTexture;
  90797. private _useRampGradients;
  90798. /** Gets or sets a boolean indicating that ramp gradients must be used
  90799. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  90800. */
  90801. get useRampGradients(): boolean;
  90802. set useRampGradients(value: boolean);
  90803. /**
  90804. * 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.
  90805. * 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: [])
  90806. */
  90807. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  90808. private _subEmitters;
  90809. /**
  90810. * @hidden
  90811. * If the particle systems emitter should be disposed when the particle system is disposed
  90812. */
  90813. _disposeEmitterOnDispose: boolean;
  90814. /**
  90815. * The current active Sub-systems, this property is used by the root particle system only.
  90816. */
  90817. activeSubSystems: Array<ParticleSystem>;
  90818. /**
  90819. * Specifies if the particles are updated in emitter local space or world space
  90820. */
  90821. isLocal: boolean;
  90822. private _rootParticleSystem;
  90823. /**
  90824. * Gets the current list of active particles
  90825. */
  90826. get particles(): Particle[];
  90827. /**
  90828. * Gets the number of particles active at the same time.
  90829. * @returns The number of active particles.
  90830. */
  90831. getActiveCount(): number;
  90832. /**
  90833. * Returns the string "ParticleSystem"
  90834. * @returns a string containing the class name
  90835. */
  90836. getClassName(): string;
  90837. /**
  90838. * Gets a boolean indicating that the system is stopping
  90839. * @returns true if the system is currently stopping
  90840. */
  90841. isStopping(): boolean;
  90842. /**
  90843. * Gets the custom effect used to render the particles
  90844. * @param blendMode Blend mode for which the effect should be retrieved
  90845. * @returns The effect
  90846. */
  90847. getCustomEffect(blendMode?: number): Nullable<Effect>;
  90848. /**
  90849. * Sets the custom effect used to render the particles
  90850. * @param effect The effect to set
  90851. * @param blendMode Blend mode for which the effect should be set
  90852. */
  90853. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  90854. /** @hidden */
  90855. private _onBeforeDrawParticlesObservable;
  90856. /**
  90857. * Observable that will be called just before the particles are drawn
  90858. */
  90859. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  90860. /**
  90861. * Gets the name of the particle vertex shader
  90862. */
  90863. get vertexShaderName(): string;
  90864. /**
  90865. * Instantiates a particle system.
  90866. * 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.
  90867. * @param name The name of the particle system
  90868. * @param capacity The max number of particles alive at the same time
  90869. * @param scene The scene the particle system belongs to
  90870. * @param customEffect a custom effect used to change the way particles are rendered by default
  90871. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  90872. * @param epsilon Offset used to render the particles
  90873. */
  90874. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  90875. private _addFactorGradient;
  90876. private _removeFactorGradient;
  90877. /**
  90878. * Adds a new life time gradient
  90879. * @param gradient defines the gradient to use (between 0 and 1)
  90880. * @param factor defines the life time factor to affect to the specified gradient
  90881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90882. * @returns the current particle system
  90883. */
  90884. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90885. /**
  90886. * Remove a specific life time gradient
  90887. * @param gradient defines the gradient to remove
  90888. * @returns the current particle system
  90889. */
  90890. removeLifeTimeGradient(gradient: number): IParticleSystem;
  90891. /**
  90892. * Adds a new size gradient
  90893. * @param gradient defines the gradient to use (between 0 and 1)
  90894. * @param factor defines the size factor to affect to the specified gradient
  90895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90896. * @returns the current particle system
  90897. */
  90898. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90899. /**
  90900. * Remove a specific size gradient
  90901. * @param gradient defines the gradient to remove
  90902. * @returns the current particle system
  90903. */
  90904. removeSizeGradient(gradient: number): IParticleSystem;
  90905. /**
  90906. * Adds a new color remap gradient
  90907. * @param gradient defines the gradient to use (between 0 and 1)
  90908. * @param min defines the color remap minimal range
  90909. * @param max defines the color remap maximal range
  90910. * @returns the current particle system
  90911. */
  90912. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90913. /**
  90914. * Remove a specific color remap gradient
  90915. * @param gradient defines the gradient to remove
  90916. * @returns the current particle system
  90917. */
  90918. removeColorRemapGradient(gradient: number): IParticleSystem;
  90919. /**
  90920. * Adds a new alpha remap gradient
  90921. * @param gradient defines the gradient to use (between 0 and 1)
  90922. * @param min defines the alpha remap minimal range
  90923. * @param max defines the alpha remap maximal range
  90924. * @returns the current particle system
  90925. */
  90926. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  90927. /**
  90928. * Remove a specific alpha remap gradient
  90929. * @param gradient defines the gradient to remove
  90930. * @returns the current particle system
  90931. */
  90932. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  90933. /**
  90934. * Adds a new angular speed gradient
  90935. * @param gradient defines the gradient to use (between 0 and 1)
  90936. * @param factor defines the angular speed to affect to the specified gradient
  90937. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90938. * @returns the current particle system
  90939. */
  90940. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90941. /**
  90942. * Remove a specific angular speed gradient
  90943. * @param gradient defines the gradient to remove
  90944. * @returns the current particle system
  90945. */
  90946. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  90947. /**
  90948. * Adds a new velocity gradient
  90949. * @param gradient defines the gradient to use (between 0 and 1)
  90950. * @param factor defines the velocity to affect to the specified gradient
  90951. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90952. * @returns the current particle system
  90953. */
  90954. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90955. /**
  90956. * Remove a specific velocity gradient
  90957. * @param gradient defines the gradient to remove
  90958. * @returns the current particle system
  90959. */
  90960. removeVelocityGradient(gradient: number): IParticleSystem;
  90961. /**
  90962. * Adds a new limit velocity gradient
  90963. * @param gradient defines the gradient to use (between 0 and 1)
  90964. * @param factor defines the limit velocity value to affect to the specified gradient
  90965. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90966. * @returns the current particle system
  90967. */
  90968. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90969. /**
  90970. * Remove a specific limit velocity gradient
  90971. * @param gradient defines the gradient to remove
  90972. * @returns the current particle system
  90973. */
  90974. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  90975. /**
  90976. * Adds a new drag gradient
  90977. * @param gradient defines the gradient to use (between 0 and 1)
  90978. * @param factor defines the drag value to affect to the specified gradient
  90979. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90980. * @returns the current particle system
  90981. */
  90982. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90983. /**
  90984. * Remove a specific drag gradient
  90985. * @param gradient defines the gradient to remove
  90986. * @returns the current particle system
  90987. */
  90988. removeDragGradient(gradient: number): IParticleSystem;
  90989. /**
  90990. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  90991. * @param gradient defines the gradient to use (between 0 and 1)
  90992. * @param factor defines the emit rate value to affect to the specified gradient
  90993. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  90994. * @returns the current particle system
  90995. */
  90996. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  90997. /**
  90998. * Remove a specific emit rate gradient
  90999. * @param gradient defines the gradient to remove
  91000. * @returns the current particle system
  91001. */
  91002. removeEmitRateGradient(gradient: number): IParticleSystem;
  91003. /**
  91004. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  91005. * @param gradient defines the gradient to use (between 0 and 1)
  91006. * @param factor defines the start size value to affect to the specified gradient
  91007. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  91008. * @returns the current particle system
  91009. */
  91010. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  91011. /**
  91012. * Remove a specific start size gradient
  91013. * @param gradient defines the gradient to remove
  91014. * @returns the current particle system
  91015. */
  91016. removeStartSizeGradient(gradient: number): IParticleSystem;
  91017. private _createRampGradientTexture;
  91018. /**
  91019. * Gets the current list of ramp gradients.
  91020. * You must use addRampGradient and removeRampGradient to udpate this list
  91021. * @returns the list of ramp gradients
  91022. */
  91023. getRampGradients(): Nullable<Array<Color3Gradient>>;
  91024. /** Force the system to rebuild all gradients that need to be resync */
  91025. forceRefreshGradients(): void;
  91026. private _syncRampGradientTexture;
  91027. /**
  91028. * Adds a new ramp gradient used to remap particle colors
  91029. * @param gradient defines the gradient to use (between 0 and 1)
  91030. * @param color defines the color to affect to the specified gradient
  91031. * @returns the current particle system
  91032. */
  91033. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  91034. /**
  91035. * Remove a specific ramp gradient
  91036. * @param gradient defines the gradient to remove
  91037. * @returns the current particle system
  91038. */
  91039. removeRampGradient(gradient: number): ParticleSystem;
  91040. /**
  91041. * Adds a new color gradient
  91042. * @param gradient defines the gradient to use (between 0 and 1)
  91043. * @param color1 defines the color to affect to the specified gradient
  91044. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  91045. * @returns this particle system
  91046. */
  91047. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  91048. /**
  91049. * Remove a specific color gradient
  91050. * @param gradient defines the gradient to remove
  91051. * @returns this particle system
  91052. */
  91053. removeColorGradient(gradient: number): IParticleSystem;
  91054. private _fetchR;
  91055. protected _reset(): void;
  91056. private _resetEffect;
  91057. private _createVertexBuffers;
  91058. private _createIndexBuffer;
  91059. /**
  91060. * Gets the maximum number of particles active at the same time.
  91061. * @returns The max number of active particles.
  91062. */
  91063. getCapacity(): number;
  91064. /**
  91065. * Gets whether there are still active particles in the system.
  91066. * @returns True if it is alive, otherwise false.
  91067. */
  91068. isAlive(): boolean;
  91069. /**
  91070. * Gets if the system has been started. (Note: this will still be true after stop is called)
  91071. * @returns True if it has been started, otherwise false.
  91072. */
  91073. isStarted(): boolean;
  91074. private _prepareSubEmitterInternalArray;
  91075. /**
  91076. * Starts the particle system and begins to emit
  91077. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  91078. */
  91079. start(delay?: number): void;
  91080. /**
  91081. * Stops the particle system.
  91082. * @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.
  91083. */
  91084. stop(stopSubEmitters?: boolean): void;
  91085. /**
  91086. * Remove all active particles
  91087. */
  91088. reset(): void;
  91089. /**
  91090. * @hidden (for internal use only)
  91091. */
  91092. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  91093. /**
  91094. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  91095. * Its lifetime will start back at 0.
  91096. */
  91097. recycleParticle: (particle: Particle) => void;
  91098. private _stopSubEmitters;
  91099. private _createParticle;
  91100. private _removeFromRoot;
  91101. private _emitFromParticle;
  91102. private _update;
  91103. /** @hidden */
  91104. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  91105. /** @hidden */
  91106. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  91107. /**
  91108. * Fill the defines array according to the current settings of the particle system
  91109. * @param defines Array to be updated
  91110. * @param blendMode blend mode to take into account when updating the array
  91111. */
  91112. fillDefines(defines: Array<string>, blendMode: number): void;
  91113. /**
  91114. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  91115. * @param uniforms Uniforms array to fill
  91116. * @param attributes Attributes array to fill
  91117. * @param samplers Samplers array to fill
  91118. */
  91119. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  91120. /** @hidden */
  91121. private _getEffect;
  91122. /**
  91123. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  91124. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  91125. */
  91126. animate(preWarmOnly?: boolean): void;
  91127. private _appendParticleVertices;
  91128. /**
  91129. * Rebuilds the particle system.
  91130. */
  91131. rebuild(): void;
  91132. /**
  91133. * Is this system ready to be used/rendered
  91134. * @return true if the system is ready
  91135. */
  91136. isReady(): boolean;
  91137. private _render;
  91138. /**
  91139. * Renders the particle system in its current state.
  91140. * @returns the current number of particles
  91141. */
  91142. render(): number;
  91143. /**
  91144. * Disposes the particle system and free the associated resources
  91145. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  91146. */
  91147. dispose(disposeTexture?: boolean): void;
  91148. /**
  91149. * Clones the particle system.
  91150. * @param name The name of the cloned object
  91151. * @param newEmitter The new emitter to use
  91152. * @returns the cloned particle system
  91153. */
  91154. clone(name: string, newEmitter: any): ParticleSystem;
  91155. /**
  91156. * Serializes the particle system to a JSON object
  91157. * @param serializeTexture defines if the texture must be serialized as well
  91158. * @returns the JSON object
  91159. */
  91160. serialize(serializeTexture?: boolean): any;
  91161. /** @hidden */
  91162. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  91163. /** @hidden */
  91164. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  91165. /**
  91166. * Parses a JSON object to create a particle system.
  91167. * @param parsedParticleSystem The JSON object to parse
  91168. * @param scene The scene to create the particle system in
  91169. * @param rootUrl The root url to use to load external dependencies like texture
  91170. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  91171. * @returns the Parsed particle system
  91172. */
  91173. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * A particle represents one of the element emitted by a particle system.
  91179. * This is mainly define by its coordinates, direction, velocity and age.
  91180. */
  91181. export class Particle {
  91182. /**
  91183. * The particle system the particle belongs to.
  91184. */
  91185. particleSystem: ParticleSystem;
  91186. private static _Count;
  91187. /**
  91188. * Unique ID of the particle
  91189. */
  91190. id: number;
  91191. /**
  91192. * The world position of the particle in the scene.
  91193. */
  91194. position: Vector3;
  91195. /**
  91196. * The world direction of the particle in the scene.
  91197. */
  91198. direction: Vector3;
  91199. /**
  91200. * The color of the particle.
  91201. */
  91202. color: Color4;
  91203. /**
  91204. * The color change of the particle per step.
  91205. */
  91206. colorStep: Color4;
  91207. /**
  91208. * Defines how long will the life of the particle be.
  91209. */
  91210. lifeTime: number;
  91211. /**
  91212. * The current age of the particle.
  91213. */
  91214. age: number;
  91215. /**
  91216. * The current size of the particle.
  91217. */
  91218. size: number;
  91219. /**
  91220. * The current scale of the particle.
  91221. */
  91222. scale: Vector2;
  91223. /**
  91224. * The current angle of the particle.
  91225. */
  91226. angle: number;
  91227. /**
  91228. * Defines how fast is the angle changing.
  91229. */
  91230. angularSpeed: number;
  91231. /**
  91232. * Defines the cell index used by the particle to be rendered from a sprite.
  91233. */
  91234. cellIndex: number;
  91235. /**
  91236. * The information required to support color remapping
  91237. */
  91238. remapData: Vector4;
  91239. /** @hidden */
  91240. _randomCellOffset?: number;
  91241. /** @hidden */
  91242. _initialDirection: Nullable<Vector3>;
  91243. /** @hidden */
  91244. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  91245. /** @hidden */
  91246. _initialStartSpriteCellID: number;
  91247. /** @hidden */
  91248. _initialEndSpriteCellID: number;
  91249. /** @hidden */
  91250. _currentColorGradient: Nullable<ColorGradient>;
  91251. /** @hidden */
  91252. _currentColor1: Color4;
  91253. /** @hidden */
  91254. _currentColor2: Color4;
  91255. /** @hidden */
  91256. _currentSizeGradient: Nullable<FactorGradient>;
  91257. /** @hidden */
  91258. _currentSize1: number;
  91259. /** @hidden */
  91260. _currentSize2: number;
  91261. /** @hidden */
  91262. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  91263. /** @hidden */
  91264. _currentAngularSpeed1: number;
  91265. /** @hidden */
  91266. _currentAngularSpeed2: number;
  91267. /** @hidden */
  91268. _currentVelocityGradient: Nullable<FactorGradient>;
  91269. /** @hidden */
  91270. _currentVelocity1: number;
  91271. /** @hidden */
  91272. _currentVelocity2: number;
  91273. /** @hidden */
  91274. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  91275. /** @hidden */
  91276. _currentLimitVelocity1: number;
  91277. /** @hidden */
  91278. _currentLimitVelocity2: number;
  91279. /** @hidden */
  91280. _currentDragGradient: Nullable<FactorGradient>;
  91281. /** @hidden */
  91282. _currentDrag1: number;
  91283. /** @hidden */
  91284. _currentDrag2: number;
  91285. /** @hidden */
  91286. _randomNoiseCoordinates1: Vector3;
  91287. /** @hidden */
  91288. _randomNoiseCoordinates2: Vector3;
  91289. /** @hidden */
  91290. _localPosition?: Vector3;
  91291. /**
  91292. * Creates a new instance Particle
  91293. * @param particleSystem the particle system the particle belongs to
  91294. */
  91295. constructor(
  91296. /**
  91297. * The particle system the particle belongs to.
  91298. */
  91299. particleSystem: ParticleSystem);
  91300. private updateCellInfoFromSystem;
  91301. /**
  91302. * Defines how the sprite cell index is updated for the particle
  91303. */
  91304. updateCellIndex(): void;
  91305. /** @hidden */
  91306. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  91307. /** @hidden */
  91308. _inheritParticleInfoToSubEmitters(): void;
  91309. /** @hidden */
  91310. _reset(): void;
  91311. /**
  91312. * Copy the properties of particle to another one.
  91313. * @param other the particle to copy the information to.
  91314. */
  91315. copyTo(other: Particle): void;
  91316. }
  91317. }
  91318. declare module BABYLON {
  91319. /**
  91320. * Particle emitter represents a volume emitting particles.
  91321. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  91322. */
  91323. export interface IParticleEmitterType {
  91324. /**
  91325. * Called by the particle System when the direction is computed for the created particle.
  91326. * @param worldMatrix is the world matrix of the particle system
  91327. * @param directionToUpdate is the direction vector to update with the result
  91328. * @param particle is the particle we are computed the direction for
  91329. * @param isLocal defines if the direction should be set in local space
  91330. */
  91331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91332. /**
  91333. * Called by the particle System when the position is computed for the created particle.
  91334. * @param worldMatrix is the world matrix of the particle system
  91335. * @param positionToUpdate is the position vector to update with the result
  91336. * @param particle is the particle we are computed the position for
  91337. * @param isLocal defines if the position should be set in local space
  91338. */
  91339. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91340. /**
  91341. * Clones the current emitter and returns a copy of it
  91342. * @returns the new emitter
  91343. */
  91344. clone(): IParticleEmitterType;
  91345. /**
  91346. * Called by the GPUParticleSystem to setup the update shader
  91347. * @param effect defines the update shader
  91348. */
  91349. applyToShader(effect: Effect): void;
  91350. /**
  91351. * Returns a string to use to update the GPU particles update shader
  91352. * @returns the effect defines string
  91353. */
  91354. getEffectDefines(): string;
  91355. /**
  91356. * Returns a string representing the class name
  91357. * @returns a string containing the class name
  91358. */
  91359. getClassName(): string;
  91360. /**
  91361. * Serializes the particle system to a JSON object.
  91362. * @returns the JSON object
  91363. */
  91364. serialize(): any;
  91365. /**
  91366. * Parse properties from a JSON object
  91367. * @param serializationObject defines the JSON object
  91368. * @param scene defines the hosting scene
  91369. */
  91370. parse(serializationObject: any, scene: Scene): void;
  91371. }
  91372. }
  91373. declare module BABYLON {
  91374. /**
  91375. * Particle emitter emitting particles from the inside of a box.
  91376. * It emits the particles randomly between 2 given directions.
  91377. */
  91378. export class BoxParticleEmitter implements IParticleEmitterType {
  91379. /**
  91380. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91381. */
  91382. direction1: Vector3;
  91383. /**
  91384. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91385. */
  91386. direction2: Vector3;
  91387. /**
  91388. * 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.
  91389. */
  91390. minEmitBox: Vector3;
  91391. /**
  91392. * 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.
  91393. */
  91394. maxEmitBox: Vector3;
  91395. /**
  91396. * Creates a new instance BoxParticleEmitter
  91397. */
  91398. constructor();
  91399. /**
  91400. * Called by the particle System when the direction is computed for the created particle.
  91401. * @param worldMatrix is the world matrix of the particle system
  91402. * @param directionToUpdate is the direction vector to update with the result
  91403. * @param particle is the particle we are computed the direction for
  91404. * @param isLocal defines if the direction should be set in local space
  91405. */
  91406. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91407. /**
  91408. * Called by the particle System when the position is computed for the created particle.
  91409. * @param worldMatrix is the world matrix of the particle system
  91410. * @param positionToUpdate is the position vector to update with the result
  91411. * @param particle is the particle we are computed the position for
  91412. * @param isLocal defines if the position should be set in local space
  91413. */
  91414. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91415. /**
  91416. * Clones the current emitter and returns a copy of it
  91417. * @returns the new emitter
  91418. */
  91419. clone(): BoxParticleEmitter;
  91420. /**
  91421. * Called by the GPUParticleSystem to setup the update shader
  91422. * @param effect defines the update shader
  91423. */
  91424. applyToShader(effect: Effect): void;
  91425. /**
  91426. * Returns a string to use to update the GPU particles update shader
  91427. * @returns a string containng the defines string
  91428. */
  91429. getEffectDefines(): string;
  91430. /**
  91431. * Returns the string "BoxParticleEmitter"
  91432. * @returns a string containing the class name
  91433. */
  91434. getClassName(): string;
  91435. /**
  91436. * Serializes the particle system to a JSON object.
  91437. * @returns the JSON object
  91438. */
  91439. serialize(): any;
  91440. /**
  91441. * Parse properties from a JSON object
  91442. * @param serializationObject defines the JSON object
  91443. */
  91444. parse(serializationObject: any): void;
  91445. }
  91446. }
  91447. declare module BABYLON {
  91448. /**
  91449. * Particle emitter emitting particles from the inside of a cone.
  91450. * It emits the particles alongside the cone volume from the base to the particle.
  91451. * The emission direction might be randomized.
  91452. */
  91453. export class ConeParticleEmitter implements IParticleEmitterType {
  91454. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91455. directionRandomizer: number;
  91456. private _radius;
  91457. private _angle;
  91458. private _height;
  91459. /**
  91460. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  91461. */
  91462. radiusRange: number;
  91463. /**
  91464. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  91465. */
  91466. heightRange: number;
  91467. /**
  91468. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  91469. */
  91470. emitFromSpawnPointOnly: boolean;
  91471. /**
  91472. * Gets or sets the radius of the emission cone
  91473. */
  91474. get radius(): number;
  91475. set radius(value: number);
  91476. /**
  91477. * Gets or sets the angle of the emission cone
  91478. */
  91479. get angle(): number;
  91480. set angle(value: number);
  91481. private _buildHeight;
  91482. /**
  91483. * Creates a new instance ConeParticleEmitter
  91484. * @param radius the radius of the emission cone (1 by default)
  91485. * @param angle the cone base angle (PI by default)
  91486. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  91487. */
  91488. constructor(radius?: number, angle?: number,
  91489. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  91490. directionRandomizer?: number);
  91491. /**
  91492. * Called by the particle System when the direction is computed for the created particle.
  91493. * @param worldMatrix is the world matrix of the particle system
  91494. * @param directionToUpdate is the direction vector to update with the result
  91495. * @param particle is the particle we are computed the direction for
  91496. * @param isLocal defines if the direction should be set in local space
  91497. */
  91498. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91499. /**
  91500. * Called by the particle System when the position is computed for the created particle.
  91501. * @param worldMatrix is the world matrix of the particle system
  91502. * @param positionToUpdate is the position vector to update with the result
  91503. * @param particle is the particle we are computed the position for
  91504. * @param isLocal defines if the position should be set in local space
  91505. */
  91506. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91507. /**
  91508. * Clones the current emitter and returns a copy of it
  91509. * @returns the new emitter
  91510. */
  91511. clone(): ConeParticleEmitter;
  91512. /**
  91513. * Called by the GPUParticleSystem to setup the update shader
  91514. * @param effect defines the update shader
  91515. */
  91516. applyToShader(effect: Effect): void;
  91517. /**
  91518. * Returns a string to use to update the GPU particles update shader
  91519. * @returns a string containng the defines string
  91520. */
  91521. getEffectDefines(): string;
  91522. /**
  91523. * Returns the string "ConeParticleEmitter"
  91524. * @returns a string containing the class name
  91525. */
  91526. getClassName(): string;
  91527. /**
  91528. * Serializes the particle system to a JSON object.
  91529. * @returns the JSON object
  91530. */
  91531. serialize(): any;
  91532. /**
  91533. * Parse properties from a JSON object
  91534. * @param serializationObject defines the JSON object
  91535. */
  91536. parse(serializationObject: any): void;
  91537. }
  91538. }
  91539. declare module BABYLON {
  91540. /**
  91541. * Particle emitter emitting particles from the inside of a cylinder.
  91542. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  91543. */
  91544. export class CylinderParticleEmitter implements IParticleEmitterType {
  91545. /**
  91546. * The radius of the emission cylinder.
  91547. */
  91548. radius: number;
  91549. /**
  91550. * The height of the emission cylinder.
  91551. */
  91552. height: number;
  91553. /**
  91554. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91555. */
  91556. radiusRange: number;
  91557. /**
  91558. * How much to randomize the particle direction [0-1].
  91559. */
  91560. directionRandomizer: number;
  91561. /**
  91562. * Creates a new instance CylinderParticleEmitter
  91563. * @param radius the radius of the emission cylinder (1 by default)
  91564. * @param height the height of the emission cylinder (1 by default)
  91565. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91566. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91567. */
  91568. constructor(
  91569. /**
  91570. * The radius of the emission cylinder.
  91571. */
  91572. radius?: number,
  91573. /**
  91574. * The height of the emission cylinder.
  91575. */
  91576. height?: number,
  91577. /**
  91578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91579. */
  91580. radiusRange?: number,
  91581. /**
  91582. * How much to randomize the particle direction [0-1].
  91583. */
  91584. directionRandomizer?: number);
  91585. /**
  91586. * Called by the particle System when the direction is computed for the created particle.
  91587. * @param worldMatrix is the world matrix of the particle system
  91588. * @param directionToUpdate is the direction vector to update with the result
  91589. * @param particle is the particle we are computed the direction for
  91590. * @param isLocal defines if the direction should be set in local space
  91591. */
  91592. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91593. /**
  91594. * Called by the particle System when the position is computed for the created particle.
  91595. * @param worldMatrix is the world matrix of the particle system
  91596. * @param positionToUpdate is the position vector to update with the result
  91597. * @param particle is the particle we are computed the position for
  91598. * @param isLocal defines if the position should be set in local space
  91599. */
  91600. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91601. /**
  91602. * Clones the current emitter and returns a copy of it
  91603. * @returns the new emitter
  91604. */
  91605. clone(): CylinderParticleEmitter;
  91606. /**
  91607. * Called by the GPUParticleSystem to setup the update shader
  91608. * @param effect defines the update shader
  91609. */
  91610. applyToShader(effect: Effect): void;
  91611. /**
  91612. * Returns a string to use to update the GPU particles update shader
  91613. * @returns a string containng the defines string
  91614. */
  91615. getEffectDefines(): string;
  91616. /**
  91617. * Returns the string "CylinderParticleEmitter"
  91618. * @returns a string containing the class name
  91619. */
  91620. getClassName(): string;
  91621. /**
  91622. * Serializes the particle system to a JSON object.
  91623. * @returns the JSON object
  91624. */
  91625. serialize(): any;
  91626. /**
  91627. * Parse properties from a JSON object
  91628. * @param serializationObject defines the JSON object
  91629. */
  91630. parse(serializationObject: any): void;
  91631. }
  91632. /**
  91633. * Particle emitter emitting particles from the inside of a cylinder.
  91634. * It emits the particles randomly between two vectors.
  91635. */
  91636. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  91637. /**
  91638. * The min limit of the emission direction.
  91639. */
  91640. direction1: Vector3;
  91641. /**
  91642. * The max limit of the emission direction.
  91643. */
  91644. direction2: Vector3;
  91645. /**
  91646. * Creates a new instance CylinderDirectedParticleEmitter
  91647. * @param radius the radius of the emission cylinder (1 by default)
  91648. * @param height the height of the emission cylinder (1 by default)
  91649. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91650. * @param direction1 the min limit of the emission direction (up vector by default)
  91651. * @param direction2 the max limit of the emission direction (up vector by default)
  91652. */
  91653. constructor(radius?: number, height?: number, radiusRange?: number,
  91654. /**
  91655. * The min limit of the emission direction.
  91656. */
  91657. direction1?: Vector3,
  91658. /**
  91659. * The max limit of the emission direction.
  91660. */
  91661. direction2?: Vector3);
  91662. /**
  91663. * Called by the particle System when the direction is computed for the created particle.
  91664. * @param worldMatrix is the world matrix of the particle system
  91665. * @param directionToUpdate is the direction vector to update with the result
  91666. * @param particle is the particle we are computed the direction for
  91667. */
  91668. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91669. /**
  91670. * Clones the current emitter and returns a copy of it
  91671. * @returns the new emitter
  91672. */
  91673. clone(): CylinderDirectedParticleEmitter;
  91674. /**
  91675. * Called by the GPUParticleSystem to setup the update shader
  91676. * @param effect defines the update shader
  91677. */
  91678. applyToShader(effect: Effect): void;
  91679. /**
  91680. * Returns a string to use to update the GPU particles update shader
  91681. * @returns a string containng the defines string
  91682. */
  91683. getEffectDefines(): string;
  91684. /**
  91685. * Returns the string "CylinderDirectedParticleEmitter"
  91686. * @returns a string containing the class name
  91687. */
  91688. getClassName(): string;
  91689. /**
  91690. * Serializes the particle system to a JSON object.
  91691. * @returns the JSON object
  91692. */
  91693. serialize(): any;
  91694. /**
  91695. * Parse properties from a JSON object
  91696. * @param serializationObject defines the JSON object
  91697. */
  91698. parse(serializationObject: any): void;
  91699. }
  91700. }
  91701. declare module BABYLON {
  91702. /**
  91703. * Particle emitter emitting particles from the inside of a hemisphere.
  91704. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  91705. */
  91706. export class HemisphericParticleEmitter implements IParticleEmitterType {
  91707. /**
  91708. * The radius of the emission hemisphere.
  91709. */
  91710. radius: number;
  91711. /**
  91712. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91713. */
  91714. radiusRange: number;
  91715. /**
  91716. * How much to randomize the particle direction [0-1].
  91717. */
  91718. directionRandomizer: number;
  91719. /**
  91720. * Creates a new instance HemisphericParticleEmitter
  91721. * @param radius the radius of the emission hemisphere (1 by default)
  91722. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91723. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91724. */
  91725. constructor(
  91726. /**
  91727. * The radius of the emission hemisphere.
  91728. */
  91729. radius?: number,
  91730. /**
  91731. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91732. */
  91733. radiusRange?: number,
  91734. /**
  91735. * How much to randomize the particle direction [0-1].
  91736. */
  91737. directionRandomizer?: number);
  91738. /**
  91739. * Called by the particle System when the direction is computed for the created particle.
  91740. * @param worldMatrix is the world matrix of the particle system
  91741. * @param directionToUpdate is the direction vector to update with the result
  91742. * @param particle is the particle we are computed the direction for
  91743. * @param isLocal defines if the direction should be set in local space
  91744. */
  91745. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91746. /**
  91747. * Called by the particle System when the position is computed for the created particle.
  91748. * @param worldMatrix is the world matrix of the particle system
  91749. * @param positionToUpdate is the position vector to update with the result
  91750. * @param particle is the particle we are computed the position for
  91751. * @param isLocal defines if the position should be set in local space
  91752. */
  91753. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91754. /**
  91755. * Clones the current emitter and returns a copy of it
  91756. * @returns the new emitter
  91757. */
  91758. clone(): HemisphericParticleEmitter;
  91759. /**
  91760. * Called by the GPUParticleSystem to setup the update shader
  91761. * @param effect defines the update shader
  91762. */
  91763. applyToShader(effect: Effect): void;
  91764. /**
  91765. * Returns a string to use to update the GPU particles update shader
  91766. * @returns a string containng the defines string
  91767. */
  91768. getEffectDefines(): string;
  91769. /**
  91770. * Returns the string "HemisphericParticleEmitter"
  91771. * @returns a string containing the class name
  91772. */
  91773. getClassName(): string;
  91774. /**
  91775. * Serializes the particle system to a JSON object.
  91776. * @returns the JSON object
  91777. */
  91778. serialize(): any;
  91779. /**
  91780. * Parse properties from a JSON object
  91781. * @param serializationObject defines the JSON object
  91782. */
  91783. parse(serializationObject: any): void;
  91784. }
  91785. }
  91786. declare module BABYLON {
  91787. /**
  91788. * Particle emitter emitting particles from a point.
  91789. * It emits the particles randomly between 2 given directions.
  91790. */
  91791. export class PointParticleEmitter implements IParticleEmitterType {
  91792. /**
  91793. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91794. */
  91795. direction1: Vector3;
  91796. /**
  91797. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  91798. */
  91799. direction2: Vector3;
  91800. /**
  91801. * Creates a new instance PointParticleEmitter
  91802. */
  91803. constructor();
  91804. /**
  91805. * Called by the particle System when the direction is computed for the created particle.
  91806. * @param worldMatrix is the world matrix of the particle system
  91807. * @param directionToUpdate is the direction vector to update with the result
  91808. * @param particle is the particle we are computed the direction for
  91809. * @param isLocal defines if the direction should be set in local space
  91810. */
  91811. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91812. /**
  91813. * Called by the particle System when the position is computed for the created particle.
  91814. * @param worldMatrix is the world matrix of the particle system
  91815. * @param positionToUpdate is the position vector to update with the result
  91816. * @param particle is the particle we are computed the position for
  91817. * @param isLocal defines if the position should be set in local space
  91818. */
  91819. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91820. /**
  91821. * Clones the current emitter and returns a copy of it
  91822. * @returns the new emitter
  91823. */
  91824. clone(): PointParticleEmitter;
  91825. /**
  91826. * Called by the GPUParticleSystem to setup the update shader
  91827. * @param effect defines the update shader
  91828. */
  91829. applyToShader(effect: Effect): void;
  91830. /**
  91831. * Returns a string to use to update the GPU particles update shader
  91832. * @returns a string containng the defines string
  91833. */
  91834. getEffectDefines(): string;
  91835. /**
  91836. * Returns the string "PointParticleEmitter"
  91837. * @returns a string containing the class name
  91838. */
  91839. getClassName(): string;
  91840. /**
  91841. * Serializes the particle system to a JSON object.
  91842. * @returns the JSON object
  91843. */
  91844. serialize(): any;
  91845. /**
  91846. * Parse properties from a JSON object
  91847. * @param serializationObject defines the JSON object
  91848. */
  91849. parse(serializationObject: any): void;
  91850. }
  91851. }
  91852. declare module BABYLON {
  91853. /**
  91854. * Particle emitter emitting particles from the inside of a sphere.
  91855. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  91856. */
  91857. export class SphereParticleEmitter implements IParticleEmitterType {
  91858. /**
  91859. * The radius of the emission sphere.
  91860. */
  91861. radius: number;
  91862. /**
  91863. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91864. */
  91865. radiusRange: number;
  91866. /**
  91867. * How much to randomize the particle direction [0-1].
  91868. */
  91869. directionRandomizer: number;
  91870. /**
  91871. * Creates a new instance SphereParticleEmitter
  91872. * @param radius the radius of the emission sphere (1 by default)
  91873. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  91874. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  91875. */
  91876. constructor(
  91877. /**
  91878. * The radius of the emission sphere.
  91879. */
  91880. radius?: number,
  91881. /**
  91882. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  91883. */
  91884. radiusRange?: number,
  91885. /**
  91886. * How much to randomize the particle direction [0-1].
  91887. */
  91888. directionRandomizer?: number);
  91889. /**
  91890. * Called by the particle System when the direction is computed for the created particle.
  91891. * @param worldMatrix is the world matrix of the particle system
  91892. * @param directionToUpdate is the direction vector to update with the result
  91893. * @param particle is the particle we are computed the direction for
  91894. * @param isLocal defines if the direction should be set in local space
  91895. */
  91896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91897. /**
  91898. * Called by the particle System when the position is computed for the created particle.
  91899. * @param worldMatrix is the world matrix of the particle system
  91900. * @param positionToUpdate is the position vector to update with the result
  91901. * @param particle is the particle we are computed the position for
  91902. * @param isLocal defines if the position should be set in local space
  91903. */
  91904. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  91905. /**
  91906. * Clones the current emitter and returns a copy of it
  91907. * @returns the new emitter
  91908. */
  91909. clone(): SphereParticleEmitter;
  91910. /**
  91911. * Called by the GPUParticleSystem to setup the update shader
  91912. * @param effect defines the update shader
  91913. */
  91914. applyToShader(effect: Effect): void;
  91915. /**
  91916. * Returns a string to use to update the GPU particles update shader
  91917. * @returns a string containng the defines string
  91918. */
  91919. getEffectDefines(): string;
  91920. /**
  91921. * Returns the string "SphereParticleEmitter"
  91922. * @returns a string containing the class name
  91923. */
  91924. getClassName(): string;
  91925. /**
  91926. * Serializes the particle system to a JSON object.
  91927. * @returns the JSON object
  91928. */
  91929. serialize(): any;
  91930. /**
  91931. * Parse properties from a JSON object
  91932. * @param serializationObject defines the JSON object
  91933. */
  91934. parse(serializationObject: any): void;
  91935. }
  91936. /**
  91937. * Particle emitter emitting particles from the inside of a sphere.
  91938. * It emits the particles randomly between two vectors.
  91939. */
  91940. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  91941. /**
  91942. * The min limit of the emission direction.
  91943. */
  91944. direction1: Vector3;
  91945. /**
  91946. * The max limit of the emission direction.
  91947. */
  91948. direction2: Vector3;
  91949. /**
  91950. * Creates a new instance SphereDirectedParticleEmitter
  91951. * @param radius the radius of the emission sphere (1 by default)
  91952. * @param direction1 the min limit of the emission direction (up vector by default)
  91953. * @param direction2 the max limit of the emission direction (up vector by default)
  91954. */
  91955. constructor(radius?: number,
  91956. /**
  91957. * The min limit of the emission direction.
  91958. */
  91959. direction1?: Vector3,
  91960. /**
  91961. * The max limit of the emission direction.
  91962. */
  91963. direction2?: Vector3);
  91964. /**
  91965. * Called by the particle System when the direction is computed for the created particle.
  91966. * @param worldMatrix is the world matrix of the particle system
  91967. * @param directionToUpdate is the direction vector to update with the result
  91968. * @param particle is the particle we are computed the direction for
  91969. */
  91970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  91971. /**
  91972. * Clones the current emitter and returns a copy of it
  91973. * @returns the new emitter
  91974. */
  91975. clone(): SphereDirectedParticleEmitter;
  91976. /**
  91977. * Called by the GPUParticleSystem to setup the update shader
  91978. * @param effect defines the update shader
  91979. */
  91980. applyToShader(effect: Effect): void;
  91981. /**
  91982. * Returns a string to use to update the GPU particles update shader
  91983. * @returns a string containng the defines string
  91984. */
  91985. getEffectDefines(): string;
  91986. /**
  91987. * Returns the string "SphereDirectedParticleEmitter"
  91988. * @returns a string containing the class name
  91989. */
  91990. getClassName(): string;
  91991. /**
  91992. * Serializes the particle system to a JSON object.
  91993. * @returns the JSON object
  91994. */
  91995. serialize(): any;
  91996. /**
  91997. * Parse properties from a JSON object
  91998. * @param serializationObject defines the JSON object
  91999. */
  92000. parse(serializationObject: any): void;
  92001. }
  92002. }
  92003. declare module BABYLON {
  92004. /**
  92005. * Particle emitter emitting particles from a custom list of positions.
  92006. */
  92007. export class CustomParticleEmitter implements IParticleEmitterType {
  92008. /**
  92009. * Gets or sets the position generator that will create the inital position of each particle.
  92010. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92011. */
  92012. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  92013. /**
  92014. * Gets or sets the destination generator that will create the final destination of each particle.
  92015. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  92016. */
  92017. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  92018. /**
  92019. * Creates a new instance CustomParticleEmitter
  92020. */
  92021. constructor();
  92022. /**
  92023. * Called by the particle System when the direction is computed for the created particle.
  92024. * @param worldMatrix is the world matrix of the particle system
  92025. * @param directionToUpdate is the direction vector to update with the result
  92026. * @param particle is the particle we are computed the direction for
  92027. * @param isLocal defines if the direction should be set in local space
  92028. */
  92029. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92030. /**
  92031. * Called by the particle System when the position is computed for the created particle.
  92032. * @param worldMatrix is the world matrix of the particle system
  92033. * @param positionToUpdate is the position vector to update with the result
  92034. * @param particle is the particle we are computed the position for
  92035. * @param isLocal defines if the position should be set in local space
  92036. */
  92037. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92038. /**
  92039. * Clones the current emitter and returns a copy of it
  92040. * @returns the new emitter
  92041. */
  92042. clone(): CustomParticleEmitter;
  92043. /**
  92044. * Called by the GPUParticleSystem to setup the update shader
  92045. * @param effect defines the update shader
  92046. */
  92047. applyToShader(effect: Effect): void;
  92048. /**
  92049. * Returns a string to use to update the GPU particles update shader
  92050. * @returns a string containng the defines string
  92051. */
  92052. getEffectDefines(): string;
  92053. /**
  92054. * Returns the string "PointParticleEmitter"
  92055. * @returns a string containing the class name
  92056. */
  92057. getClassName(): string;
  92058. /**
  92059. * Serializes the particle system to a JSON object.
  92060. * @returns the JSON object
  92061. */
  92062. serialize(): any;
  92063. /**
  92064. * Parse properties from a JSON object
  92065. * @param serializationObject defines the JSON object
  92066. */
  92067. parse(serializationObject: any): void;
  92068. }
  92069. }
  92070. declare module BABYLON {
  92071. /**
  92072. * Particle emitter emitting particles from the inside of a box.
  92073. * It emits the particles randomly between 2 given directions.
  92074. */
  92075. export class MeshParticleEmitter implements IParticleEmitterType {
  92076. private _indices;
  92077. private _positions;
  92078. private _normals;
  92079. private _storedNormal;
  92080. private _mesh;
  92081. /**
  92082. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92083. */
  92084. direction1: Vector3;
  92085. /**
  92086. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92087. */
  92088. direction2: Vector3;
  92089. /**
  92090. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  92091. */
  92092. useMeshNormalsForDirection: boolean;
  92093. /** Defines the mesh to use as source */
  92094. get mesh(): Nullable<AbstractMesh>;
  92095. set mesh(value: Nullable<AbstractMesh>);
  92096. /**
  92097. * Creates a new instance MeshParticleEmitter
  92098. * @param mesh defines the mesh to use as source
  92099. */
  92100. constructor(mesh?: Nullable<AbstractMesh>);
  92101. /**
  92102. * Called by the particle System when the direction is computed for the created particle.
  92103. * @param worldMatrix is the world matrix of the particle system
  92104. * @param directionToUpdate is the direction vector to update with the result
  92105. * @param particle is the particle we are computed the direction for
  92106. * @param isLocal defines if the direction should be set in local space
  92107. */
  92108. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92109. /**
  92110. * Called by the particle System when the position is computed for the created particle.
  92111. * @param worldMatrix is the world matrix of the particle system
  92112. * @param positionToUpdate is the position vector to update with the result
  92113. * @param particle is the particle we are computed the position for
  92114. * @param isLocal defines if the position should be set in local space
  92115. */
  92116. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  92117. /**
  92118. * Clones the current emitter and returns a copy of it
  92119. * @returns the new emitter
  92120. */
  92121. clone(): MeshParticleEmitter;
  92122. /**
  92123. * Called by the GPUParticleSystem to setup the update shader
  92124. * @param effect defines the update shader
  92125. */
  92126. applyToShader(effect: Effect): void;
  92127. /**
  92128. * Returns a string to use to update the GPU particles update shader
  92129. * @returns a string containng the defines string
  92130. */
  92131. getEffectDefines(): string;
  92132. /**
  92133. * Returns the string "BoxParticleEmitter"
  92134. * @returns a string containing the class name
  92135. */
  92136. getClassName(): string;
  92137. /**
  92138. * Serializes the particle system to a JSON object.
  92139. * @returns the JSON object
  92140. */
  92141. serialize(): any;
  92142. /**
  92143. * Parse properties from a JSON object
  92144. * @param serializationObject defines the JSON object
  92145. * @param scene defines the hosting scene
  92146. */
  92147. parse(serializationObject: any, scene: Scene): void;
  92148. }
  92149. }
  92150. declare module BABYLON {
  92151. /**
  92152. * Interface representing a particle system in Babylon.js.
  92153. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  92154. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  92155. */
  92156. export interface IParticleSystem {
  92157. /**
  92158. * List of animations used by the particle system.
  92159. */
  92160. animations: Animation[];
  92161. /**
  92162. * The id of the Particle system.
  92163. */
  92164. id: string;
  92165. /**
  92166. * The name of the Particle system.
  92167. */
  92168. name: string;
  92169. /**
  92170. * The emitter represents the Mesh or position we are attaching the particle system to.
  92171. */
  92172. emitter: Nullable<AbstractMesh | Vector3>;
  92173. /**
  92174. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92175. */
  92176. isBillboardBased: boolean;
  92177. /**
  92178. * The rendering group used by the Particle system to chose when to render.
  92179. */
  92180. renderingGroupId: number;
  92181. /**
  92182. * The layer mask we are rendering the particles through.
  92183. */
  92184. layerMask: number;
  92185. /**
  92186. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92187. */
  92188. updateSpeed: number;
  92189. /**
  92190. * The amount of time the particle system is running (depends of the overall update speed).
  92191. */
  92192. targetStopDuration: number;
  92193. /**
  92194. * The texture used to render each particle. (this can be a spritesheet)
  92195. */
  92196. particleTexture: Nullable<Texture>;
  92197. /**
  92198. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  92199. */
  92200. blendMode: number;
  92201. /**
  92202. * Minimum life time of emitting particles.
  92203. */
  92204. minLifeTime: number;
  92205. /**
  92206. * Maximum life time of emitting particles.
  92207. */
  92208. maxLifeTime: number;
  92209. /**
  92210. * Minimum Size of emitting particles.
  92211. */
  92212. minSize: number;
  92213. /**
  92214. * Maximum Size of emitting particles.
  92215. */
  92216. maxSize: number;
  92217. /**
  92218. * Minimum scale of emitting particles on X axis.
  92219. */
  92220. minScaleX: number;
  92221. /**
  92222. * Maximum scale of emitting particles on X axis.
  92223. */
  92224. maxScaleX: number;
  92225. /**
  92226. * Minimum scale of emitting particles on Y axis.
  92227. */
  92228. minScaleY: number;
  92229. /**
  92230. * Maximum scale of emitting particles on Y axis.
  92231. */
  92232. maxScaleY: number;
  92233. /**
  92234. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92235. */
  92236. color1: Color4;
  92237. /**
  92238. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  92239. */
  92240. color2: Color4;
  92241. /**
  92242. * Color the particle will have at the end of its lifetime.
  92243. */
  92244. colorDead: Color4;
  92245. /**
  92246. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  92247. */
  92248. emitRate: number;
  92249. /**
  92250. * You can use gravity if you want to give an orientation to your particles.
  92251. */
  92252. gravity: Vector3;
  92253. /**
  92254. * Minimum power of emitting particles.
  92255. */
  92256. minEmitPower: number;
  92257. /**
  92258. * Maximum power of emitting particles.
  92259. */
  92260. maxEmitPower: number;
  92261. /**
  92262. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92263. */
  92264. minAngularSpeed: number;
  92265. /**
  92266. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92267. */
  92268. maxAngularSpeed: number;
  92269. /**
  92270. * Gets or sets the minimal initial rotation in radians.
  92271. */
  92272. minInitialRotation: number;
  92273. /**
  92274. * Gets or sets the maximal initial rotation in radians.
  92275. */
  92276. maxInitialRotation: number;
  92277. /**
  92278. * The particle emitter type defines the emitter used by the particle system.
  92279. * It can be for example box, sphere, or cone...
  92280. */
  92281. particleEmitterType: Nullable<IParticleEmitterType>;
  92282. /**
  92283. * Defines the delay in milliseconds before starting the system (0 by default)
  92284. */
  92285. startDelay: number;
  92286. /**
  92287. * 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
  92288. */
  92289. preWarmCycles: number;
  92290. /**
  92291. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  92292. */
  92293. preWarmStepOffset: number;
  92294. /**
  92295. * 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)
  92296. */
  92297. spriteCellChangeSpeed: number;
  92298. /**
  92299. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92300. */
  92301. startSpriteCellID: number;
  92302. /**
  92303. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92304. */
  92305. endSpriteCellID: number;
  92306. /**
  92307. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92308. */
  92309. spriteCellWidth: number;
  92310. /**
  92311. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92312. */
  92313. spriteCellHeight: number;
  92314. /**
  92315. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92316. */
  92317. spriteRandomStartCell: boolean;
  92318. /**
  92319. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  92320. */
  92321. isAnimationSheetEnabled: boolean;
  92322. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92323. translationPivot: Vector2;
  92324. /**
  92325. * Gets or sets a texture used to add random noise to particle positions
  92326. */
  92327. noiseTexture: Nullable<BaseTexture>;
  92328. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92329. noiseStrength: Vector3;
  92330. /**
  92331. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92332. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92333. */
  92334. billboardMode: number;
  92335. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92336. limitVelocityDamping: number;
  92337. /**
  92338. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92339. */
  92340. beginAnimationOnStart: boolean;
  92341. /**
  92342. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92343. */
  92344. beginAnimationFrom: number;
  92345. /**
  92346. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92347. */
  92348. beginAnimationTo: number;
  92349. /**
  92350. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92351. */
  92352. beginAnimationLoop: boolean;
  92353. /**
  92354. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92355. */
  92356. disposeOnStop: boolean;
  92357. /**
  92358. * Specifies if the particles are updated in emitter local space or world space
  92359. */
  92360. isLocal: boolean;
  92361. /** Snippet ID if the particle system was created from the snippet server */
  92362. snippetId: string;
  92363. /**
  92364. * Gets the maximum number of particles active at the same time.
  92365. * @returns The max number of active particles.
  92366. */
  92367. getCapacity(): number;
  92368. /**
  92369. * Gets the number of particles active at the same time.
  92370. * @returns The number of active particles.
  92371. */
  92372. getActiveCount(): number;
  92373. /**
  92374. * Gets if the system has been started. (Note: this will still be true after stop is called)
  92375. * @returns True if it has been started, otherwise false.
  92376. */
  92377. isStarted(): boolean;
  92378. /**
  92379. * Animates the particle system for this frame.
  92380. */
  92381. animate(): void;
  92382. /**
  92383. * Renders the particle system in its current state.
  92384. * @returns the current number of particles
  92385. */
  92386. render(): number;
  92387. /**
  92388. * Dispose the particle system and frees its associated resources.
  92389. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  92390. */
  92391. dispose(disposeTexture?: boolean): void;
  92392. /**
  92393. * An event triggered when the system is disposed
  92394. */
  92395. onDisposeObservable: Observable<IParticleSystem>;
  92396. /**
  92397. * Clones the particle system.
  92398. * @param name The name of the cloned object
  92399. * @param newEmitter The new emitter to use
  92400. * @returns the cloned particle system
  92401. */
  92402. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  92403. /**
  92404. * Serializes the particle system to a JSON object
  92405. * @param serializeTexture defines if the texture must be serialized as well
  92406. * @returns the JSON object
  92407. */
  92408. serialize(serializeTexture: boolean): any;
  92409. /**
  92410. * Rebuild the particle system
  92411. */
  92412. rebuild(): void;
  92413. /** Force the system to rebuild all gradients that need to be resync */
  92414. forceRefreshGradients(): void;
  92415. /**
  92416. * Starts the particle system and begins to emit
  92417. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  92418. */
  92419. start(delay?: number): void;
  92420. /**
  92421. * Stops the particle system.
  92422. */
  92423. stop(): void;
  92424. /**
  92425. * Remove all active particles
  92426. */
  92427. reset(): void;
  92428. /**
  92429. * Gets a boolean indicating that the system is stopping
  92430. * @returns true if the system is currently stopping
  92431. */
  92432. isStopping(): boolean;
  92433. /**
  92434. * Is this system ready to be used/rendered
  92435. * @return true if the system is ready
  92436. */
  92437. isReady(): boolean;
  92438. /**
  92439. * Returns the string "ParticleSystem"
  92440. * @returns a string containing the class name
  92441. */
  92442. getClassName(): string;
  92443. /**
  92444. * Gets the custom effect used to render the particles
  92445. * @param blendMode Blend mode for which the effect should be retrieved
  92446. * @returns The effect
  92447. */
  92448. getCustomEffect(blendMode: number): Nullable<Effect>;
  92449. /**
  92450. * Sets the custom effect used to render the particles
  92451. * @param effect The effect to set
  92452. * @param blendMode Blend mode for which the effect should be set
  92453. */
  92454. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  92455. /**
  92456. * Fill the defines array according to the current settings of the particle system
  92457. * @param defines Array to be updated
  92458. * @param blendMode blend mode to take into account when updating the array
  92459. */
  92460. fillDefines(defines: Array<string>, blendMode: number): void;
  92461. /**
  92462. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  92463. * @param uniforms Uniforms array to fill
  92464. * @param attributes Attributes array to fill
  92465. * @param samplers Samplers array to fill
  92466. */
  92467. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  92468. /**
  92469. * Observable that will be called just before the particles are drawn
  92470. */
  92471. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  92472. /**
  92473. * Gets the name of the particle vertex shader
  92474. */
  92475. vertexShaderName: string;
  92476. /**
  92477. * Adds a new color gradient
  92478. * @param gradient defines the gradient to use (between 0 and 1)
  92479. * @param color1 defines the color to affect to the specified gradient
  92480. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  92481. * @returns the current particle system
  92482. */
  92483. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  92484. /**
  92485. * Remove a specific color gradient
  92486. * @param gradient defines the gradient to remove
  92487. * @returns the current particle system
  92488. */
  92489. removeColorGradient(gradient: number): IParticleSystem;
  92490. /**
  92491. * Adds a new size gradient
  92492. * @param gradient defines the gradient to use (between 0 and 1)
  92493. * @param factor defines the size factor to affect to the specified gradient
  92494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92495. * @returns the current particle system
  92496. */
  92497. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92498. /**
  92499. * Remove a specific size gradient
  92500. * @param gradient defines the gradient to remove
  92501. * @returns the current particle system
  92502. */
  92503. removeSizeGradient(gradient: number): IParticleSystem;
  92504. /**
  92505. * Gets the current list of color gradients.
  92506. * You must use addColorGradient and removeColorGradient to udpate this list
  92507. * @returns the list of color gradients
  92508. */
  92509. getColorGradients(): Nullable<Array<ColorGradient>>;
  92510. /**
  92511. * Gets the current list of size gradients.
  92512. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92513. * @returns the list of size gradients
  92514. */
  92515. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92516. /**
  92517. * Gets the current list of angular speed gradients.
  92518. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92519. * @returns the list of angular speed gradients
  92520. */
  92521. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92522. /**
  92523. * Adds a new angular speed gradient
  92524. * @param gradient defines the gradient to use (between 0 and 1)
  92525. * @param factor defines the angular speed to affect to the specified gradient
  92526. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92527. * @returns the current particle system
  92528. */
  92529. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92530. /**
  92531. * Remove a specific angular speed gradient
  92532. * @param gradient defines the gradient to remove
  92533. * @returns the current particle system
  92534. */
  92535. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  92536. /**
  92537. * Gets the current list of velocity gradients.
  92538. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92539. * @returns the list of velocity gradients
  92540. */
  92541. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92542. /**
  92543. * Adds a new velocity gradient
  92544. * @param gradient defines the gradient to use (between 0 and 1)
  92545. * @param factor defines the velocity to affect to the specified gradient
  92546. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92547. * @returns the current particle system
  92548. */
  92549. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92550. /**
  92551. * Remove a specific velocity gradient
  92552. * @param gradient defines the gradient to remove
  92553. * @returns the current particle system
  92554. */
  92555. removeVelocityGradient(gradient: number): IParticleSystem;
  92556. /**
  92557. * Gets the current list of limit velocity gradients.
  92558. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92559. * @returns the list of limit velocity gradients
  92560. */
  92561. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92562. /**
  92563. * Adds a new limit velocity gradient
  92564. * @param gradient defines the gradient to use (between 0 and 1)
  92565. * @param factor defines the limit velocity to affect to the specified gradient
  92566. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92567. * @returns the current particle system
  92568. */
  92569. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92570. /**
  92571. * Remove a specific limit velocity gradient
  92572. * @param gradient defines the gradient to remove
  92573. * @returns the current particle system
  92574. */
  92575. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  92576. /**
  92577. * Adds a new drag gradient
  92578. * @param gradient defines the gradient to use (between 0 and 1)
  92579. * @param factor defines the drag to affect to the specified gradient
  92580. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92581. * @returns the current particle system
  92582. */
  92583. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92584. /**
  92585. * Remove a specific drag gradient
  92586. * @param gradient defines the gradient to remove
  92587. * @returns the current particle system
  92588. */
  92589. removeDragGradient(gradient: number): IParticleSystem;
  92590. /**
  92591. * Gets the current list of drag gradients.
  92592. * You must use addDragGradient and removeDragGradient to udpate this list
  92593. * @returns the list of drag gradients
  92594. */
  92595. getDragGradients(): Nullable<Array<FactorGradient>>;
  92596. /**
  92597. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  92598. * @param gradient defines the gradient to use (between 0 and 1)
  92599. * @param factor defines the emit rate to affect to the specified gradient
  92600. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92601. * @returns the current particle system
  92602. */
  92603. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92604. /**
  92605. * Remove a specific emit rate gradient
  92606. * @param gradient defines the gradient to remove
  92607. * @returns the current particle system
  92608. */
  92609. removeEmitRateGradient(gradient: number): IParticleSystem;
  92610. /**
  92611. * Gets the current list of emit rate gradients.
  92612. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92613. * @returns the list of emit rate gradients
  92614. */
  92615. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92616. /**
  92617. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  92618. * @param gradient defines the gradient to use (between 0 and 1)
  92619. * @param factor defines the start size to affect to the specified gradient
  92620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92621. * @returns the current particle system
  92622. */
  92623. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92624. /**
  92625. * Remove a specific start size gradient
  92626. * @param gradient defines the gradient to remove
  92627. * @returns the current particle system
  92628. */
  92629. removeStartSizeGradient(gradient: number): IParticleSystem;
  92630. /**
  92631. * Gets the current list of start size gradients.
  92632. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92633. * @returns the list of start size gradients
  92634. */
  92635. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92636. /**
  92637. * Adds a new life time gradient
  92638. * @param gradient defines the gradient to use (between 0 and 1)
  92639. * @param factor defines the life time factor to affect to the specified gradient
  92640. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  92641. * @returns the current particle system
  92642. */
  92643. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  92644. /**
  92645. * Remove a specific life time gradient
  92646. * @param gradient defines the gradient to remove
  92647. * @returns the current particle system
  92648. */
  92649. removeLifeTimeGradient(gradient: number): IParticleSystem;
  92650. /**
  92651. * Gets the current list of life time gradients.
  92652. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92653. * @returns the list of life time gradients
  92654. */
  92655. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92656. /**
  92657. * Gets the current list of color gradients.
  92658. * You must use addColorGradient and removeColorGradient to udpate this list
  92659. * @returns the list of color gradients
  92660. */
  92661. getColorGradients(): Nullable<Array<ColorGradient>>;
  92662. /**
  92663. * Adds a new ramp gradient used to remap particle colors
  92664. * @param gradient defines the gradient to use (between 0 and 1)
  92665. * @param color defines the color to affect to the specified gradient
  92666. * @returns the current particle system
  92667. */
  92668. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  92669. /**
  92670. * Gets the current list of ramp gradients.
  92671. * You must use addRampGradient and removeRampGradient to udpate this list
  92672. * @returns the list of ramp gradients
  92673. */
  92674. getRampGradients(): Nullable<Array<Color3Gradient>>;
  92675. /** Gets or sets a boolean indicating that ramp gradients must be used
  92676. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92677. */
  92678. useRampGradients: boolean;
  92679. /**
  92680. * Adds a new color remap gradient
  92681. * @param gradient defines the gradient to use (between 0 and 1)
  92682. * @param min defines the color remap minimal range
  92683. * @param max defines the color remap maximal range
  92684. * @returns the current particle system
  92685. */
  92686. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92687. /**
  92688. * Gets the current list of color remap gradients.
  92689. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92690. * @returns the list of color remap gradients
  92691. */
  92692. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92693. /**
  92694. * Adds a new alpha remap gradient
  92695. * @param gradient defines the gradient to use (between 0 and 1)
  92696. * @param min defines the alpha remap minimal range
  92697. * @param max defines the alpha remap maximal range
  92698. * @returns the current particle system
  92699. */
  92700. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  92701. /**
  92702. * Gets the current list of alpha remap gradients.
  92703. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92704. * @returns the list of alpha remap gradients
  92705. */
  92706. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92707. /**
  92708. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92711. * @returns the emitter
  92712. */
  92713. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92714. /**
  92715. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92716. * @param radius The radius of the hemisphere to emit from
  92717. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92718. * @returns the emitter
  92719. */
  92720. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  92721. /**
  92722. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92723. * @param radius The radius of the sphere to emit from
  92724. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92725. * @returns the emitter
  92726. */
  92727. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  92728. /**
  92729. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92730. * @param radius The radius of the sphere to emit from
  92731. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92732. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92733. * @returns the emitter
  92734. */
  92735. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92736. /**
  92737. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92738. * @param radius The radius of the emission cylinder
  92739. * @param height The height of the emission cylinder
  92740. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92741. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92742. * @returns the emitter
  92743. */
  92744. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  92745. /**
  92746. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92747. * @param radius The radius of the cylinder to emit from
  92748. * @param height The height of the emission cylinder
  92749. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92750. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92751. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92752. * @returns the emitter
  92753. */
  92754. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  92755. /**
  92756. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92757. * @param radius The radius of the cone to emit from
  92758. * @param angle The base angle of the cone
  92759. * @returns the emitter
  92760. */
  92761. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  92762. /**
  92763. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92764. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92765. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92766. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92767. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92768. * @returns the emitter
  92769. */
  92770. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92771. /**
  92772. * Get hosting scene
  92773. * @returns the scene
  92774. */
  92775. getScene(): Scene;
  92776. }
  92777. }
  92778. declare module BABYLON {
  92779. /**
  92780. * 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.
  92781. * @see https://doc.babylonjs.com/how_to/transformnode
  92782. */
  92783. export class TransformNode extends Node {
  92784. /**
  92785. * Object will not rotate to face the camera
  92786. */
  92787. static BILLBOARDMODE_NONE: number;
  92788. /**
  92789. * Object will rotate to face the camera but only on the x axis
  92790. */
  92791. static BILLBOARDMODE_X: number;
  92792. /**
  92793. * Object will rotate to face the camera but only on the y axis
  92794. */
  92795. static BILLBOARDMODE_Y: number;
  92796. /**
  92797. * Object will rotate to face the camera but only on the z axis
  92798. */
  92799. static BILLBOARDMODE_Z: number;
  92800. /**
  92801. * Object will rotate to face the camera
  92802. */
  92803. static BILLBOARDMODE_ALL: number;
  92804. /**
  92805. * Object will rotate to face the camera's position instead of orientation
  92806. */
  92807. static BILLBOARDMODE_USE_POSITION: number;
  92808. private static _TmpRotation;
  92809. private static _TmpScaling;
  92810. private static _TmpTranslation;
  92811. private _forward;
  92812. private _forwardInverted;
  92813. private _up;
  92814. private _right;
  92815. private _rightInverted;
  92816. private _position;
  92817. private _rotation;
  92818. private _rotationQuaternion;
  92819. protected _scaling: Vector3;
  92820. protected _isDirty: boolean;
  92821. private _transformToBoneReferal;
  92822. private _isAbsoluteSynced;
  92823. private _billboardMode;
  92824. /**
  92825. * Gets or sets the billboard mode. Default is 0.
  92826. *
  92827. * | Value | Type | Description |
  92828. * | --- | --- | --- |
  92829. * | 0 | BILLBOARDMODE_NONE | |
  92830. * | 1 | BILLBOARDMODE_X | |
  92831. * | 2 | BILLBOARDMODE_Y | |
  92832. * | 4 | BILLBOARDMODE_Z | |
  92833. * | 7 | BILLBOARDMODE_ALL | |
  92834. *
  92835. */
  92836. get billboardMode(): number;
  92837. set billboardMode(value: number);
  92838. private _preserveParentRotationForBillboard;
  92839. /**
  92840. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  92841. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  92842. */
  92843. get preserveParentRotationForBillboard(): boolean;
  92844. set preserveParentRotationForBillboard(value: boolean);
  92845. /**
  92846. * 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
  92847. */
  92848. scalingDeterminant: number;
  92849. private _infiniteDistance;
  92850. /**
  92851. * Gets or sets the distance of the object to max, often used by skybox
  92852. */
  92853. get infiniteDistance(): boolean;
  92854. set infiniteDistance(value: boolean);
  92855. /**
  92856. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  92857. * By default the system will update normals to compensate
  92858. */
  92859. ignoreNonUniformScaling: boolean;
  92860. /**
  92861. * 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
  92862. */
  92863. reIntegrateRotationIntoRotationQuaternion: boolean;
  92864. /** @hidden */
  92865. _poseMatrix: Nullable<Matrix>;
  92866. /** @hidden */
  92867. _localMatrix: Matrix;
  92868. private _usePivotMatrix;
  92869. private _absolutePosition;
  92870. private _absoluteScaling;
  92871. private _absoluteRotationQuaternion;
  92872. private _pivotMatrix;
  92873. private _pivotMatrixInverse;
  92874. protected _postMultiplyPivotMatrix: boolean;
  92875. protected _isWorldMatrixFrozen: boolean;
  92876. /** @hidden */
  92877. _indexInSceneTransformNodesArray: number;
  92878. /**
  92879. * An event triggered after the world matrix is updated
  92880. */
  92881. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  92882. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  92883. /**
  92884. * Gets a string identifying the name of the class
  92885. * @returns "TransformNode" string
  92886. */
  92887. getClassName(): string;
  92888. /**
  92889. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  92890. */
  92891. get position(): Vector3;
  92892. set position(newPosition: Vector3);
  92893. /**
  92894. * 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)).
  92895. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  92896. */
  92897. get rotation(): Vector3;
  92898. set rotation(newRotation: Vector3);
  92899. /**
  92900. * 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)).
  92901. */
  92902. get scaling(): Vector3;
  92903. set scaling(newScaling: Vector3);
  92904. /**
  92905. * 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).
  92906. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  92907. */
  92908. get rotationQuaternion(): Nullable<Quaternion>;
  92909. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  92910. /**
  92911. * The forward direction of that transform in world space.
  92912. */
  92913. get forward(): Vector3;
  92914. /**
  92915. * The up direction of that transform in world space.
  92916. */
  92917. get up(): Vector3;
  92918. /**
  92919. * The right direction of that transform in world space.
  92920. */
  92921. get right(): Vector3;
  92922. /**
  92923. * Copies the parameter passed Matrix into the mesh Pose matrix.
  92924. * @param matrix the matrix to copy the pose from
  92925. * @returns this TransformNode.
  92926. */
  92927. updatePoseMatrix(matrix: Matrix): TransformNode;
  92928. /**
  92929. * Returns the mesh Pose matrix.
  92930. * @returns the pose matrix
  92931. */
  92932. getPoseMatrix(): Matrix;
  92933. /** @hidden */
  92934. _isSynchronized(): boolean;
  92935. /** @hidden */
  92936. _initCache(): void;
  92937. /**
  92938. * Flag the transform node as dirty (Forcing it to update everything)
  92939. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  92940. * @returns this transform node
  92941. */
  92942. markAsDirty(property: string): TransformNode;
  92943. /**
  92944. * Returns the current mesh absolute position.
  92945. * Returns a Vector3.
  92946. */
  92947. get absolutePosition(): Vector3;
  92948. /**
  92949. * Returns the current mesh absolute scaling.
  92950. * Returns a Vector3.
  92951. */
  92952. get absoluteScaling(): Vector3;
  92953. /**
  92954. * Returns the current mesh absolute rotation.
  92955. * Returns a Quaternion.
  92956. */
  92957. get absoluteRotationQuaternion(): Quaternion;
  92958. /**
  92959. * Sets a new matrix to apply before all other transformation
  92960. * @param matrix defines the transform matrix
  92961. * @returns the current TransformNode
  92962. */
  92963. setPreTransformMatrix(matrix: Matrix): TransformNode;
  92964. /**
  92965. * Sets a new pivot matrix to the current node
  92966. * @param matrix defines the new pivot matrix to use
  92967. * @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
  92968. * @returns the current TransformNode
  92969. */
  92970. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  92971. /**
  92972. * Returns the mesh pivot matrix.
  92973. * Default : Identity.
  92974. * @returns the matrix
  92975. */
  92976. getPivotMatrix(): Matrix;
  92977. /**
  92978. * Instantiate (when possible) or clone that node with its hierarchy
  92979. * @param newParent defines the new parent to use for the instance (or clone)
  92980. * @param options defines options to configure how copy is done
  92981. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  92982. * @returns an instance (or a clone) of the current node with its hiearchy
  92983. */
  92984. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  92985. doNotInstantiate: boolean;
  92986. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  92987. /**
  92988. * Prevents the World matrix to be computed any longer
  92989. * @param newWorldMatrix defines an optional matrix to use as world matrix
  92990. * @returns the TransformNode.
  92991. */
  92992. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  92993. /**
  92994. * Allows back the World matrix computation.
  92995. * @returns the TransformNode.
  92996. */
  92997. unfreezeWorldMatrix(): this;
  92998. /**
  92999. * True if the World matrix has been frozen.
  93000. */
  93001. get isWorldMatrixFrozen(): boolean;
  93002. /**
  93003. * Retuns the mesh absolute position in the World.
  93004. * @returns a Vector3.
  93005. */
  93006. getAbsolutePosition(): Vector3;
  93007. /**
  93008. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  93009. * @param absolutePosition the absolute position to set
  93010. * @returns the TransformNode.
  93011. */
  93012. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  93013. /**
  93014. * Sets the mesh position in its local space.
  93015. * @param vector3 the position to set in localspace
  93016. * @returns the TransformNode.
  93017. */
  93018. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  93019. /**
  93020. * Returns the mesh position in the local space from the current World matrix values.
  93021. * @returns a new Vector3.
  93022. */
  93023. getPositionExpressedInLocalSpace(): Vector3;
  93024. /**
  93025. * Translates the mesh along the passed Vector3 in its local space.
  93026. * @param vector3 the distance to translate in localspace
  93027. * @returns the TransformNode.
  93028. */
  93029. locallyTranslate(vector3: Vector3): TransformNode;
  93030. private static _lookAtVectorCache;
  93031. /**
  93032. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  93033. * @param targetPoint the position (must be in same space as current mesh) to look at
  93034. * @param yawCor optional yaw (y-axis) correction in radians
  93035. * @param pitchCor optional pitch (x-axis) correction in radians
  93036. * @param rollCor optional roll (z-axis) correction in radians
  93037. * @param space the choosen space of the target
  93038. * @returns the TransformNode.
  93039. */
  93040. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  93041. /**
  93042. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93043. * This Vector3 is expressed in the World space.
  93044. * @param localAxis axis to rotate
  93045. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  93046. */
  93047. getDirection(localAxis: Vector3): Vector3;
  93048. /**
  93049. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  93050. * localAxis is expressed in the mesh local space.
  93051. * result is computed in the Wordl space from the mesh World matrix.
  93052. * @param localAxis axis to rotate
  93053. * @param result the resulting transformnode
  93054. * @returns this TransformNode.
  93055. */
  93056. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  93057. /**
  93058. * Sets this transform node rotation to the given local axis.
  93059. * @param localAxis the axis in local space
  93060. * @param yawCor optional yaw (y-axis) correction in radians
  93061. * @param pitchCor optional pitch (x-axis) correction in radians
  93062. * @param rollCor optional roll (z-axis) correction in radians
  93063. * @returns this TransformNode
  93064. */
  93065. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  93066. /**
  93067. * Sets a new pivot point to the current node
  93068. * @param point defines the new pivot point to use
  93069. * @param space defines if the point is in world or local space (local by default)
  93070. * @returns the current TransformNode
  93071. */
  93072. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  93073. /**
  93074. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  93075. * @returns the pivot point
  93076. */
  93077. getPivotPoint(): Vector3;
  93078. /**
  93079. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  93080. * @param result the vector3 to store the result
  93081. * @returns this TransformNode.
  93082. */
  93083. getPivotPointToRef(result: Vector3): TransformNode;
  93084. /**
  93085. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  93086. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  93087. */
  93088. getAbsolutePivotPoint(): Vector3;
  93089. /**
  93090. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  93091. * @param result vector3 to store the result
  93092. * @returns this TransformNode.
  93093. */
  93094. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  93095. /**
  93096. * Defines the passed node as the parent of the current node.
  93097. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  93098. * @see https://doc.babylonjs.com/how_to/parenting
  93099. * @param node the node ot set as the parent
  93100. * @returns this TransformNode.
  93101. */
  93102. setParent(node: Nullable<Node>): TransformNode;
  93103. private _nonUniformScaling;
  93104. /**
  93105. * True if the scaling property of this object is non uniform eg. (1,2,1)
  93106. */
  93107. get nonUniformScaling(): boolean;
  93108. /** @hidden */
  93109. _updateNonUniformScalingState(value: boolean): boolean;
  93110. /**
  93111. * Attach the current TransformNode to another TransformNode associated with a bone
  93112. * @param bone Bone affecting the TransformNode
  93113. * @param affectedTransformNode TransformNode associated with the bone
  93114. * @returns this object
  93115. */
  93116. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  93117. /**
  93118. * Detach the transform node if its associated with a bone
  93119. * @returns this object
  93120. */
  93121. detachFromBone(): TransformNode;
  93122. private static _rotationAxisCache;
  93123. /**
  93124. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  93125. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93126. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93127. * The passed axis is also normalized.
  93128. * @param axis the axis to rotate around
  93129. * @param amount the amount to rotate in radians
  93130. * @param space Space to rotate in (Default: local)
  93131. * @returns the TransformNode.
  93132. */
  93133. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  93134. /**
  93135. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  93136. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  93137. * The passed axis is also normalized. .
  93138. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  93139. * @param point the point to rotate around
  93140. * @param axis the axis to rotate around
  93141. * @param amount the amount to rotate in radians
  93142. * @returns the TransformNode
  93143. */
  93144. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  93145. /**
  93146. * Translates the mesh along the axis vector for the passed distance in the given space.
  93147. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  93148. * @param axis the axis to translate in
  93149. * @param distance the distance to translate
  93150. * @param space Space to rotate in (Default: local)
  93151. * @returns the TransformNode.
  93152. */
  93153. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  93154. /**
  93155. * Adds a rotation step to the mesh current rotation.
  93156. * x, y, z are Euler angles expressed in radians.
  93157. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  93158. * This means this rotation is made in the mesh local space only.
  93159. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  93160. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  93161. * ```javascript
  93162. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  93163. * ```
  93164. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  93165. * 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.
  93166. * @param x Rotation to add
  93167. * @param y Rotation to add
  93168. * @param z Rotation to add
  93169. * @returns the TransformNode.
  93170. */
  93171. addRotation(x: number, y: number, z: number): TransformNode;
  93172. /**
  93173. * @hidden
  93174. */
  93175. protected _getEffectiveParent(): Nullable<Node>;
  93176. /**
  93177. * Computes the world matrix of the node
  93178. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93179. * @returns the world matrix
  93180. */
  93181. computeWorldMatrix(force?: boolean): Matrix;
  93182. /**
  93183. * Resets this nodeTransform's local matrix to Matrix.Identity().
  93184. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  93185. */
  93186. resetLocalMatrix(independentOfChildren?: boolean): void;
  93187. protected _afterComputeWorldMatrix(): void;
  93188. /**
  93189. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  93190. * @param func callback function to add
  93191. *
  93192. * @returns the TransformNode.
  93193. */
  93194. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93195. /**
  93196. * Removes a registered callback function.
  93197. * @param func callback function to remove
  93198. * @returns the TransformNode.
  93199. */
  93200. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  93201. /**
  93202. * Gets the position of the current mesh in camera space
  93203. * @param camera defines the camera to use
  93204. * @returns a position
  93205. */
  93206. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  93207. /**
  93208. * Returns the distance from the mesh to the active camera
  93209. * @param camera defines the camera to use
  93210. * @returns the distance
  93211. */
  93212. getDistanceToCamera(camera?: Nullable<Camera>): number;
  93213. /**
  93214. * Clone the current transform node
  93215. * @param name Name of the new clone
  93216. * @param newParent New parent for the clone
  93217. * @param doNotCloneChildren Do not clone children hierarchy
  93218. * @returns the new transform node
  93219. */
  93220. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  93221. /**
  93222. * Serializes the objects information.
  93223. * @param currentSerializationObject defines the object to serialize in
  93224. * @returns the serialized object
  93225. */
  93226. serialize(currentSerializationObject?: any): any;
  93227. /**
  93228. * Returns a new TransformNode object parsed from the source provided.
  93229. * @param parsedTransformNode is the source.
  93230. * @param scene the scne the object belongs to
  93231. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  93232. * @returns a new TransformNode object parsed from the source provided.
  93233. */
  93234. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  93235. /**
  93236. * Get all child-transformNodes of this node
  93237. * @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
  93238. * @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
  93239. * @returns an array of TransformNode
  93240. */
  93241. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  93242. /**
  93243. * Releases resources associated with this transform node.
  93244. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93245. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93246. */
  93247. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93248. /**
  93249. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93250. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93251. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93252. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93253. * @returns the current mesh
  93254. */
  93255. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  93256. private _syncAbsoluteScalingAndRotation;
  93257. }
  93258. }
  93259. declare module BABYLON {
  93260. /**
  93261. * Class used to override all child animations of a given target
  93262. */
  93263. export class AnimationPropertiesOverride {
  93264. /**
  93265. * Gets or sets a value indicating if animation blending must be used
  93266. */
  93267. enableBlending: boolean;
  93268. /**
  93269. * Gets or sets the blending speed to use when enableBlending is true
  93270. */
  93271. blendingSpeed: number;
  93272. /**
  93273. * Gets or sets the default loop mode to use
  93274. */
  93275. loopMode: number;
  93276. }
  93277. }
  93278. declare module BABYLON {
  93279. /**
  93280. * Class used to store bone information
  93281. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93282. */
  93283. export class Bone extends Node {
  93284. /**
  93285. * defines the bone name
  93286. */
  93287. name: string;
  93288. private static _tmpVecs;
  93289. private static _tmpQuat;
  93290. private static _tmpMats;
  93291. /**
  93292. * Gets the list of child bones
  93293. */
  93294. children: Bone[];
  93295. /** Gets the animations associated with this bone */
  93296. animations: Animation[];
  93297. /**
  93298. * Gets or sets bone length
  93299. */
  93300. length: number;
  93301. /**
  93302. * @hidden Internal only
  93303. * Set this value to map this bone to a different index in the transform matrices
  93304. * Set this value to -1 to exclude the bone from the transform matrices
  93305. */
  93306. _index: Nullable<number>;
  93307. private _skeleton;
  93308. private _localMatrix;
  93309. private _restPose;
  93310. private _baseMatrix;
  93311. private _absoluteTransform;
  93312. private _invertedAbsoluteTransform;
  93313. private _parent;
  93314. private _scalingDeterminant;
  93315. private _worldTransform;
  93316. private _localScaling;
  93317. private _localRotation;
  93318. private _localPosition;
  93319. private _needToDecompose;
  93320. private _needToCompose;
  93321. /** @hidden */
  93322. _linkedTransformNode: Nullable<TransformNode>;
  93323. /** @hidden */
  93324. _waitingTransformNodeId: Nullable<string>;
  93325. /** @hidden */
  93326. get _matrix(): Matrix;
  93327. /** @hidden */
  93328. set _matrix(value: Matrix);
  93329. /**
  93330. * Create a new bone
  93331. * @param name defines the bone name
  93332. * @param skeleton defines the parent skeleton
  93333. * @param parentBone defines the parent (can be null if the bone is the root)
  93334. * @param localMatrix defines the local matrix
  93335. * @param restPose defines the rest pose matrix
  93336. * @param baseMatrix defines the base matrix
  93337. * @param index defines index of the bone in the hiearchy
  93338. */
  93339. constructor(
  93340. /**
  93341. * defines the bone name
  93342. */
  93343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  93344. /**
  93345. * Gets the current object class name.
  93346. * @return the class name
  93347. */
  93348. getClassName(): string;
  93349. /**
  93350. * Gets the parent skeleton
  93351. * @returns a skeleton
  93352. */
  93353. getSkeleton(): Skeleton;
  93354. /**
  93355. * Gets parent bone
  93356. * @returns a bone or null if the bone is the root of the bone hierarchy
  93357. */
  93358. getParent(): Nullable<Bone>;
  93359. /**
  93360. * Returns an array containing the root bones
  93361. * @returns an array containing the root bones
  93362. */
  93363. getChildren(): Array<Bone>;
  93364. /**
  93365. * Gets the node index in matrix array generated for rendering
  93366. * @returns the node index
  93367. */
  93368. getIndex(): number;
  93369. /**
  93370. * Sets the parent bone
  93371. * @param parent defines the parent (can be null if the bone is the root)
  93372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93373. */
  93374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  93375. /**
  93376. * Gets the local matrix
  93377. * @returns a matrix
  93378. */
  93379. getLocalMatrix(): Matrix;
  93380. /**
  93381. * Gets the base matrix (initial matrix which remains unchanged)
  93382. * @returns a matrix
  93383. */
  93384. getBaseMatrix(): Matrix;
  93385. /**
  93386. * Gets the rest pose matrix
  93387. * @returns a matrix
  93388. */
  93389. getRestPose(): Matrix;
  93390. /**
  93391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  93392. */
  93393. getWorldMatrix(): Matrix;
  93394. /**
  93395. * Sets the local matrix to rest pose matrix
  93396. */
  93397. returnToRest(): void;
  93398. /**
  93399. * Gets the inverse of the absolute transform matrix.
  93400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  93401. * @returns a matrix
  93402. */
  93403. getInvertedAbsoluteTransform(): Matrix;
  93404. /**
  93405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  93406. * @returns a matrix
  93407. */
  93408. getAbsoluteTransform(): Matrix;
  93409. /**
  93410. * Links with the given transform node.
  93411. * The local matrix of this bone is copied from the transform node every frame.
  93412. * @param transformNode defines the transform node to link to
  93413. */
  93414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  93415. /**
  93416. * Gets the node used to drive the bone's transformation
  93417. * @returns a transform node or null
  93418. */
  93419. getTransformNode(): Nullable<TransformNode>;
  93420. /** Gets or sets current position (in local space) */
  93421. get position(): Vector3;
  93422. set position(newPosition: Vector3);
  93423. /** Gets or sets current rotation (in local space) */
  93424. get rotation(): Vector3;
  93425. set rotation(newRotation: Vector3);
  93426. /** Gets or sets current rotation quaternion (in local space) */
  93427. get rotationQuaternion(): Quaternion;
  93428. set rotationQuaternion(newRotation: Quaternion);
  93429. /** Gets or sets current scaling (in local space) */
  93430. get scaling(): Vector3;
  93431. set scaling(newScaling: Vector3);
  93432. /**
  93433. * Gets the animation properties override
  93434. */
  93435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  93436. private _decompose;
  93437. private _compose;
  93438. /**
  93439. * Update the base and local matrices
  93440. * @param matrix defines the new base or local matrix
  93441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  93442. * @param updateLocalMatrix defines if the local matrix should be updated
  93443. */
  93444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  93445. /** @hidden */
  93446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  93447. /**
  93448. * Flag the bone as dirty (Forcing it to update everything)
  93449. */
  93450. markAsDirty(): void;
  93451. /** @hidden */
  93452. _markAsDirtyAndCompose(): void;
  93453. private _markAsDirtyAndDecompose;
  93454. /**
  93455. * Translate the bone in local or world space
  93456. * @param vec The amount to translate the bone
  93457. * @param space The space that the translation is in
  93458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93459. */
  93460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93461. /**
  93462. * Set the postion of the bone in local or world space
  93463. * @param position The position to set the bone
  93464. * @param space The space that the position is in
  93465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93466. */
  93467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93468. /**
  93469. * Set the absolute position of the bone (world space)
  93470. * @param position The position to set the bone
  93471. * @param mesh The mesh that this bone is attached to
  93472. */
  93473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  93474. /**
  93475. * Scale the bone on the x, y and z axes (in local space)
  93476. * @param x The amount to scale the bone on the x axis
  93477. * @param y The amount to scale the bone on the y axis
  93478. * @param z The amount to scale the bone on the z axis
  93479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  93480. */
  93481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  93482. /**
  93483. * Set the bone scaling in local space
  93484. * @param scale defines the scaling vector
  93485. */
  93486. setScale(scale: Vector3): void;
  93487. /**
  93488. * Gets the current scaling in local space
  93489. * @returns the current scaling vector
  93490. */
  93491. getScale(): Vector3;
  93492. /**
  93493. * Gets the current scaling in local space and stores it in a target vector
  93494. * @param result defines the target vector
  93495. */
  93496. getScaleToRef(result: Vector3): void;
  93497. /**
  93498. * Set the yaw, pitch, and roll of the bone in local or world space
  93499. * @param yaw The rotation of the bone on the y axis
  93500. * @param pitch The rotation of the bone on the x axis
  93501. * @param roll The rotation of the bone on the z axis
  93502. * @param space The space that the axes of rotation are in
  93503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93504. */
  93505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  93506. /**
  93507. * Add a rotation to the bone on an axis in local or world space
  93508. * @param axis The axis to rotate the bone on
  93509. * @param amount The amount to rotate the bone
  93510. * @param space The space that the axis is in
  93511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93512. */
  93513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  93514. /**
  93515. * Set the rotation of the bone to a particular axis angle in local or world space
  93516. * @param axis The axis to rotate the bone on
  93517. * @param angle The angle that the bone should be rotated to
  93518. * @param space The space that the axis is in
  93519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93520. */
  93521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  93522. /**
  93523. * Set the euler rotation of the bone in local of world space
  93524. * @param rotation The euler rotation that the bone should be set to
  93525. * @param space The space that the rotation is in
  93526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93527. */
  93528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  93529. /**
  93530. * Set the quaternion rotation of the bone in local of world space
  93531. * @param quat The quaternion rotation that the bone should be set to
  93532. * @param space The space that the rotation is in
  93533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93534. */
  93535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  93536. /**
  93537. * Set the rotation matrix of the bone in local of world space
  93538. * @param rotMat The rotation matrix that the bone should be set to
  93539. * @param space The space that the rotation is in
  93540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93541. */
  93542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  93543. private _rotateWithMatrix;
  93544. private _getNegativeRotationToRef;
  93545. /**
  93546. * Get the position of the bone in local or world space
  93547. * @param space The space that the returned position is in
  93548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93549. * @returns The position of the bone
  93550. */
  93551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93552. /**
  93553. * Copy the position of the bone to a vector3 in local or world space
  93554. * @param space The space that the returned position is in
  93555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93556. * @param result The vector3 to copy the position to
  93557. */
  93558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  93559. /**
  93560. * Get the absolute position of the bone (world space)
  93561. * @param mesh The mesh that this bone is attached to
  93562. * @returns The absolute position of the bone
  93563. */
  93564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  93565. /**
  93566. * Copy the absolute position of the bone (world space) to the result param
  93567. * @param mesh The mesh that this bone is attached to
  93568. * @param result The vector3 to copy the absolute position to
  93569. */
  93570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  93571. /**
  93572. * Compute the absolute transforms of this bone and its children
  93573. */
  93574. computeAbsoluteTransforms(): void;
  93575. /**
  93576. * Get the world direction from an axis that is in the local space of the bone
  93577. * @param localAxis The local direction that is used to compute the world direction
  93578. * @param mesh The mesh that this bone is attached to
  93579. * @returns The world direction
  93580. */
  93581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93582. /**
  93583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  93584. * @param localAxis The local direction that is used to compute the world direction
  93585. * @param mesh The mesh that this bone is attached to
  93586. * @param result The vector3 that the world direction will be copied to
  93587. */
  93588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93589. /**
  93590. * Get the euler rotation of the bone in local or world space
  93591. * @param space The space that the rotation should be in
  93592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93593. * @returns The euler rotation
  93594. */
  93595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  93596. /**
  93597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  93598. * @param space The space that the rotation should be in
  93599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93600. * @param result The vector3 that the rotation should be copied to
  93601. */
  93602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93603. /**
  93604. * Get the quaternion rotation of the bone in either local or world space
  93605. * @param space The space that the rotation should be in
  93606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93607. * @returns The quaternion rotation
  93608. */
  93609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  93610. /**
  93611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  93612. * @param space The space that the rotation should be in
  93613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93614. * @param result The quaternion that the rotation should be copied to
  93615. */
  93616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  93617. /**
  93618. * Get the rotation matrix of the bone in local or world space
  93619. * @param space The space that the rotation should be in
  93620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93621. * @returns The rotation matrix
  93622. */
  93623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  93624. /**
  93625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  93626. * @param space The space that the rotation should be in
  93627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  93628. * @param result The quaternion that the rotation should be copied to
  93629. */
  93630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  93631. /**
  93632. * Get the world position of a point that is in the local space of the bone
  93633. * @param position The local position
  93634. * @param mesh The mesh that this bone is attached to
  93635. * @returns The world position
  93636. */
  93637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93638. /**
  93639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  93640. * @param position The local position
  93641. * @param mesh The mesh that this bone is attached to
  93642. * @param result The vector3 that the world position should be copied to
  93643. */
  93644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93645. /**
  93646. * Get the local position of a point that is in world space
  93647. * @param position The world position
  93648. * @param mesh The mesh that this bone is attached to
  93649. * @returns The local position
  93650. */
  93651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  93652. /**
  93653. * Get the local position of a point that is in world space and copy it to the result param
  93654. * @param position The world position
  93655. * @param mesh The mesh that this bone is attached to
  93656. * @param result The vector3 that the local position should be copied to
  93657. */
  93658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  93659. }
  93660. }
  93661. declare module BABYLON {
  93662. /**
  93663. * Defines a runtime animation
  93664. */
  93665. export class RuntimeAnimation {
  93666. private _events;
  93667. /**
  93668. * The current frame of the runtime animation
  93669. */
  93670. private _currentFrame;
  93671. /**
  93672. * The animation used by the runtime animation
  93673. */
  93674. private _animation;
  93675. /**
  93676. * The target of the runtime animation
  93677. */
  93678. private _target;
  93679. /**
  93680. * The initiating animatable
  93681. */
  93682. private _host;
  93683. /**
  93684. * The original value of the runtime animation
  93685. */
  93686. private _originalValue;
  93687. /**
  93688. * The original blend value of the runtime animation
  93689. */
  93690. private _originalBlendValue;
  93691. /**
  93692. * The offsets cache of the runtime animation
  93693. */
  93694. private _offsetsCache;
  93695. /**
  93696. * The high limits cache of the runtime animation
  93697. */
  93698. private _highLimitsCache;
  93699. /**
  93700. * Specifies if the runtime animation has been stopped
  93701. */
  93702. private _stopped;
  93703. /**
  93704. * The blending factor of the runtime animation
  93705. */
  93706. private _blendingFactor;
  93707. /**
  93708. * The BabylonJS scene
  93709. */
  93710. private _scene;
  93711. /**
  93712. * The current value of the runtime animation
  93713. */
  93714. private _currentValue;
  93715. /** @hidden */
  93716. _animationState: _IAnimationState;
  93717. /**
  93718. * The active target of the runtime animation
  93719. */
  93720. private _activeTargets;
  93721. private _currentActiveTarget;
  93722. private _directTarget;
  93723. /**
  93724. * The target path of the runtime animation
  93725. */
  93726. private _targetPath;
  93727. /**
  93728. * The weight of the runtime animation
  93729. */
  93730. private _weight;
  93731. /**
  93732. * The ratio offset of the runtime animation
  93733. */
  93734. private _ratioOffset;
  93735. /**
  93736. * The previous delay of the runtime animation
  93737. */
  93738. private _previousDelay;
  93739. /**
  93740. * The previous ratio of the runtime animation
  93741. */
  93742. private _previousRatio;
  93743. private _enableBlending;
  93744. private _keys;
  93745. private _minFrame;
  93746. private _maxFrame;
  93747. private _minValue;
  93748. private _maxValue;
  93749. private _targetIsArray;
  93750. /**
  93751. * Gets the current frame of the runtime animation
  93752. */
  93753. get currentFrame(): number;
  93754. /**
  93755. * Gets the weight of the runtime animation
  93756. */
  93757. get weight(): number;
  93758. /**
  93759. * Gets the current value of the runtime animation
  93760. */
  93761. get currentValue(): any;
  93762. /**
  93763. * Gets the target path of the runtime animation
  93764. */
  93765. get targetPath(): string;
  93766. /**
  93767. * Gets the actual target of the runtime animation
  93768. */
  93769. get target(): any;
  93770. /**
  93771. * Gets the additive state of the runtime animation
  93772. */
  93773. get isAdditive(): boolean;
  93774. /** @hidden */
  93775. _onLoop: () => void;
  93776. /**
  93777. * Create a new RuntimeAnimation object
  93778. * @param target defines the target of the animation
  93779. * @param animation defines the source animation object
  93780. * @param scene defines the hosting scene
  93781. * @param host defines the initiating Animatable
  93782. */
  93783. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  93784. private _preparePath;
  93785. /**
  93786. * Gets the animation from the runtime animation
  93787. */
  93788. get animation(): Animation;
  93789. /**
  93790. * Resets the runtime animation to the beginning
  93791. * @param restoreOriginal defines whether to restore the target property to the original value
  93792. */
  93793. reset(restoreOriginal?: boolean): void;
  93794. /**
  93795. * Specifies if the runtime animation is stopped
  93796. * @returns Boolean specifying if the runtime animation is stopped
  93797. */
  93798. isStopped(): boolean;
  93799. /**
  93800. * Disposes of the runtime animation
  93801. */
  93802. dispose(): void;
  93803. /**
  93804. * Apply the interpolated value to the target
  93805. * @param currentValue defines the value computed by the animation
  93806. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  93807. */
  93808. setValue(currentValue: any, weight: number): void;
  93809. private _getOriginalValues;
  93810. private _setValue;
  93811. /**
  93812. * Gets the loop pmode of the runtime animation
  93813. * @returns Loop Mode
  93814. */
  93815. private _getCorrectLoopMode;
  93816. /**
  93817. * Move the current animation to a given frame
  93818. * @param frame defines the frame to move to
  93819. */
  93820. goToFrame(frame: number): void;
  93821. /**
  93822. * @hidden Internal use only
  93823. */
  93824. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  93825. /**
  93826. * Execute the current animation
  93827. * @param delay defines the delay to add to the current frame
  93828. * @param from defines the lower bound of the animation range
  93829. * @param to defines the upper bound of the animation range
  93830. * @param loop defines if the current animation must loop
  93831. * @param speedRatio defines the current speed ratio
  93832. * @param weight defines the weight of the animation (default is -1 so no weight)
  93833. * @param onLoop optional callback called when animation loops
  93834. * @returns a boolean indicating if the animation is running
  93835. */
  93836. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  93837. }
  93838. }
  93839. declare module BABYLON {
  93840. /**
  93841. * Class used to store an actual running animation
  93842. */
  93843. export class Animatable {
  93844. /** defines the target object */
  93845. target: any;
  93846. /** defines the starting frame number (default is 0) */
  93847. fromFrame: number;
  93848. /** defines the ending frame number (default is 100) */
  93849. toFrame: number;
  93850. /** defines if the animation must loop (default is false) */
  93851. loopAnimation: boolean;
  93852. /** defines a callback to call when animation ends if it is not looping */
  93853. onAnimationEnd?: (() => void) | null | undefined;
  93854. /** defines a callback to call when animation loops */
  93855. onAnimationLoop?: (() => void) | null | undefined;
  93856. /** defines whether the animation should be evaluated additively */
  93857. isAdditive: boolean;
  93858. private _localDelayOffset;
  93859. private _pausedDelay;
  93860. private _runtimeAnimations;
  93861. private _paused;
  93862. private _scene;
  93863. private _speedRatio;
  93864. private _weight;
  93865. private _syncRoot;
  93866. /**
  93867. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  93868. * This will only apply for non looping animation (default is true)
  93869. */
  93870. disposeOnEnd: boolean;
  93871. /**
  93872. * Gets a boolean indicating if the animation has started
  93873. */
  93874. animationStarted: boolean;
  93875. /**
  93876. * Observer raised when the animation ends
  93877. */
  93878. onAnimationEndObservable: Observable<Animatable>;
  93879. /**
  93880. * Observer raised when the animation loops
  93881. */
  93882. onAnimationLoopObservable: Observable<Animatable>;
  93883. /**
  93884. * Gets the root Animatable used to synchronize and normalize animations
  93885. */
  93886. get syncRoot(): Nullable<Animatable>;
  93887. /**
  93888. * Gets the current frame of the first RuntimeAnimation
  93889. * Used to synchronize Animatables
  93890. */
  93891. get masterFrame(): number;
  93892. /**
  93893. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  93894. */
  93895. get weight(): number;
  93896. set weight(value: number);
  93897. /**
  93898. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  93899. */
  93900. get speedRatio(): number;
  93901. set speedRatio(value: number);
  93902. /**
  93903. * Creates a new Animatable
  93904. * @param scene defines the hosting scene
  93905. * @param target defines the target object
  93906. * @param fromFrame defines the starting frame number (default is 0)
  93907. * @param toFrame defines the ending frame number (default is 100)
  93908. * @param loopAnimation defines if the animation must loop (default is false)
  93909. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  93910. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  93911. * @param animations defines a group of animation to add to the new Animatable
  93912. * @param onAnimationLoop defines a callback to call when animation loops
  93913. * @param isAdditive defines whether the animation should be evaluated additively
  93914. */
  93915. constructor(scene: Scene,
  93916. /** defines the target object */
  93917. target: any,
  93918. /** defines the starting frame number (default is 0) */
  93919. fromFrame?: number,
  93920. /** defines the ending frame number (default is 100) */
  93921. toFrame?: number,
  93922. /** defines if the animation must loop (default is false) */
  93923. loopAnimation?: boolean, speedRatio?: number,
  93924. /** defines a callback to call when animation ends if it is not looping */
  93925. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  93926. /** defines a callback to call when animation loops */
  93927. onAnimationLoop?: (() => void) | null | undefined,
  93928. /** defines whether the animation should be evaluated additively */
  93929. isAdditive?: boolean);
  93930. /**
  93931. * Synchronize and normalize current Animatable with a source Animatable
  93932. * This is useful when using animation weights and when animations are not of the same length
  93933. * @param root defines the root Animatable to synchronize with
  93934. * @returns the current Animatable
  93935. */
  93936. syncWith(root: Animatable): Animatable;
  93937. /**
  93938. * Gets the list of runtime animations
  93939. * @returns an array of RuntimeAnimation
  93940. */
  93941. getAnimations(): RuntimeAnimation[];
  93942. /**
  93943. * Adds more animations to the current animatable
  93944. * @param target defines the target of the animations
  93945. * @param animations defines the new animations to add
  93946. */
  93947. appendAnimations(target: any, animations: Animation[]): void;
  93948. /**
  93949. * Gets the source animation for a specific property
  93950. * @param property defines the propertyu to look for
  93951. * @returns null or the source animation for the given property
  93952. */
  93953. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  93954. /**
  93955. * Gets the runtime animation for a specific property
  93956. * @param property defines the propertyu to look for
  93957. * @returns null or the runtime animation for the given property
  93958. */
  93959. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  93960. /**
  93961. * Resets the animatable to its original state
  93962. */
  93963. reset(): void;
  93964. /**
  93965. * Allows the animatable to blend with current running animations
  93966. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93967. * @param blendingSpeed defines the blending speed to use
  93968. */
  93969. enableBlending(blendingSpeed: number): void;
  93970. /**
  93971. * Disable animation blending
  93972. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  93973. */
  93974. disableBlending(): void;
  93975. /**
  93976. * Jump directly to a given frame
  93977. * @param frame defines the frame to jump to
  93978. */
  93979. goToFrame(frame: number): void;
  93980. /**
  93981. * Pause the animation
  93982. */
  93983. pause(): void;
  93984. /**
  93985. * Restart the animation
  93986. */
  93987. restart(): void;
  93988. private _raiseOnAnimationEnd;
  93989. /**
  93990. * Stop and delete the current animation
  93991. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  93992. * @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)
  93993. */
  93994. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  93995. /**
  93996. * Wait asynchronously for the animation to end
  93997. * @returns a promise which will be fullfilled when the animation ends
  93998. */
  93999. waitAsync(): Promise<Animatable>;
  94000. /** @hidden */
  94001. _animate(delay: number): boolean;
  94002. }
  94003. interface Scene {
  94004. /** @hidden */
  94005. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  94006. /** @hidden */
  94007. _processLateAnimationBindingsForMatrices(holder: {
  94008. totalWeight: number;
  94009. totalAdditiveWeight: number;
  94010. animations: RuntimeAnimation[];
  94011. additiveAnimations: RuntimeAnimation[];
  94012. originalValue: Matrix;
  94013. }): any;
  94014. /** @hidden */
  94015. _processLateAnimationBindingsForQuaternions(holder: {
  94016. totalWeight: number;
  94017. totalAdditiveWeight: number;
  94018. animations: RuntimeAnimation[];
  94019. additiveAnimations: RuntimeAnimation[];
  94020. originalValue: Quaternion;
  94021. }, refQuaternion: Quaternion): Quaternion;
  94022. /** @hidden */
  94023. _processLateAnimationBindings(): void;
  94024. /**
  94025. * Will start the animation sequence of a given target
  94026. * @param target defines the target
  94027. * @param from defines from which frame should animation start
  94028. * @param to defines until which frame should animation run.
  94029. * @param weight defines the weight to apply to the animation (1.0 by default)
  94030. * @param loop defines if the animation loops
  94031. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94032. * @param onAnimationEnd defines the function to be executed when the animation ends
  94033. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94034. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94035. * @param onAnimationLoop defines the callback to call when an animation loops
  94036. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94037. * @returns the animatable object created for this animation
  94038. */
  94039. 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;
  94040. /**
  94041. * Will start the animation sequence of a given target
  94042. * @param target defines the target
  94043. * @param from defines from which frame should animation start
  94044. * @param to defines until which frame should animation run.
  94045. * @param loop defines if the animation loops
  94046. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94047. * @param onAnimationEnd defines the function to be executed when the animation ends
  94048. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94049. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94050. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  94051. * @param onAnimationLoop defines the callback to call when an animation loops
  94052. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94053. * @returns the animatable object created for this animation
  94054. */
  94055. 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;
  94056. /**
  94057. * Will start the animation sequence of a given target and its hierarchy
  94058. * @param target defines the target
  94059. * @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.
  94060. * @param from defines from which frame should animation start
  94061. * @param to defines until which frame should animation run.
  94062. * @param loop defines if the animation loops
  94063. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  94064. * @param onAnimationEnd defines the function to be executed when the animation ends
  94065. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  94066. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  94067. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  94068. * @param onAnimationLoop defines the callback to call when an animation loops
  94069. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94070. * @returns the list of created animatables
  94071. */
  94072. 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[];
  94073. /**
  94074. * Begin a new animation on a given node
  94075. * @param target defines the target where the animation will take place
  94076. * @param animations defines the list of animations to start
  94077. * @param from defines the initial value
  94078. * @param to defines the final value
  94079. * @param loop defines if you want animation to loop (off by default)
  94080. * @param speedRatio defines the speed ratio to apply to all animations
  94081. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94082. * @param onAnimationLoop defines the callback to call when an animation loops
  94083. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94084. * @returns the list of created animatables
  94085. */
  94086. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  94087. /**
  94088. * Begin a new animation on a given node and its hierarchy
  94089. * @param target defines the root node where the animation will take place
  94090. * @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.
  94091. * @param animations defines the list of animations to start
  94092. * @param from defines the initial value
  94093. * @param to defines the final value
  94094. * @param loop defines if you want animation to loop (off by default)
  94095. * @param speedRatio defines the speed ratio to apply to all animations
  94096. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94097. * @param onAnimationLoop defines the callback to call when an animation loops
  94098. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  94099. * @returns the list of animatables created for all nodes
  94100. */
  94101. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  94102. /**
  94103. * Gets the animatable associated with a specific target
  94104. * @param target defines the target of the animatable
  94105. * @returns the required animatable if found
  94106. */
  94107. getAnimatableByTarget(target: any): Nullable<Animatable>;
  94108. /**
  94109. * Gets all animatables associated with a given target
  94110. * @param target defines the target to look animatables for
  94111. * @returns an array of Animatables
  94112. */
  94113. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  94114. /**
  94115. * Stops and removes all animations that have been applied to the scene
  94116. */
  94117. stopAllAnimations(): void;
  94118. /**
  94119. * Gets the current delta time used by animation engine
  94120. */
  94121. deltaTime: number;
  94122. }
  94123. interface Bone {
  94124. /**
  94125. * Copy an animation range from another bone
  94126. * @param source defines the source bone
  94127. * @param rangeName defines the range name to copy
  94128. * @param frameOffset defines the frame offset
  94129. * @param rescaleAsRequired defines if rescaling must be applied if required
  94130. * @param skelDimensionsRatio defines the scaling ratio
  94131. * @returns true if operation was successful
  94132. */
  94133. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  94134. }
  94135. }
  94136. declare module BABYLON {
  94137. /**
  94138. * Class used to handle skinning animations
  94139. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  94140. */
  94141. export class Skeleton implements IAnimatable {
  94142. /** defines the skeleton name */
  94143. name: string;
  94144. /** defines the skeleton Id */
  94145. id: string;
  94146. /**
  94147. * Defines the list of child bones
  94148. */
  94149. bones: Bone[];
  94150. /**
  94151. * Defines an estimate of the dimension of the skeleton at rest
  94152. */
  94153. dimensionsAtRest: Vector3;
  94154. /**
  94155. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  94156. */
  94157. needInitialSkinMatrix: boolean;
  94158. /**
  94159. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  94160. */
  94161. overrideMesh: Nullable<AbstractMesh>;
  94162. /**
  94163. * Gets the list of animations attached to this skeleton
  94164. */
  94165. animations: Array<Animation>;
  94166. private _scene;
  94167. private _isDirty;
  94168. private _transformMatrices;
  94169. private _transformMatrixTexture;
  94170. private _meshesWithPoseMatrix;
  94171. private _animatables;
  94172. private _identity;
  94173. private _synchronizedWithMesh;
  94174. private _ranges;
  94175. private _lastAbsoluteTransformsUpdateId;
  94176. private _canUseTextureForBones;
  94177. private _uniqueId;
  94178. /** @hidden */
  94179. _numBonesWithLinkedTransformNode: number;
  94180. /** @hidden */
  94181. _hasWaitingData: Nullable<boolean>;
  94182. /**
  94183. * Specifies if the skeleton should be serialized
  94184. */
  94185. doNotSerialize: boolean;
  94186. private _useTextureToStoreBoneMatrices;
  94187. /**
  94188. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  94189. * Please note that this option is not available if the hardware does not support it
  94190. */
  94191. get useTextureToStoreBoneMatrices(): boolean;
  94192. set useTextureToStoreBoneMatrices(value: boolean);
  94193. private _animationPropertiesOverride;
  94194. /**
  94195. * Gets or sets the animation properties override
  94196. */
  94197. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  94198. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  94199. /**
  94200. * List of inspectable custom properties (used by the Inspector)
  94201. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94202. */
  94203. inspectableCustomProperties: IInspectable[];
  94204. /**
  94205. * An observable triggered before computing the skeleton's matrices
  94206. */
  94207. onBeforeComputeObservable: Observable<Skeleton>;
  94208. /**
  94209. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  94210. */
  94211. get isUsingTextureForMatrices(): boolean;
  94212. /**
  94213. * Gets the unique ID of this skeleton
  94214. */
  94215. get uniqueId(): number;
  94216. /**
  94217. * Creates a new skeleton
  94218. * @param name defines the skeleton name
  94219. * @param id defines the skeleton Id
  94220. * @param scene defines the hosting scene
  94221. */
  94222. constructor(
  94223. /** defines the skeleton name */
  94224. name: string,
  94225. /** defines the skeleton Id */
  94226. id: string, scene: Scene);
  94227. /**
  94228. * Gets the current object class name.
  94229. * @return the class name
  94230. */
  94231. getClassName(): string;
  94232. /**
  94233. * Returns an array containing the root bones
  94234. * @returns an array containing the root bones
  94235. */
  94236. getChildren(): Array<Bone>;
  94237. /**
  94238. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  94239. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94240. * @returns a Float32Array containing matrices data
  94241. */
  94242. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  94243. /**
  94244. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  94245. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  94246. * @returns a raw texture containing the data
  94247. */
  94248. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  94249. /**
  94250. * Gets the current hosting scene
  94251. * @returns a scene object
  94252. */
  94253. getScene(): Scene;
  94254. /**
  94255. * Gets a string representing the current skeleton data
  94256. * @param fullDetails defines a boolean indicating if we want a verbose version
  94257. * @returns a string representing the current skeleton data
  94258. */
  94259. toString(fullDetails?: boolean): string;
  94260. /**
  94261. * Get bone's index searching by name
  94262. * @param name defines bone's name to search for
  94263. * @return the indice of the bone. Returns -1 if not found
  94264. */
  94265. getBoneIndexByName(name: string): number;
  94266. /**
  94267. * Creater a new animation range
  94268. * @param name defines the name of the range
  94269. * @param from defines the start key
  94270. * @param to defines the end key
  94271. */
  94272. createAnimationRange(name: string, from: number, to: number): void;
  94273. /**
  94274. * Delete a specific animation range
  94275. * @param name defines the name of the range
  94276. * @param deleteFrames defines if frames must be removed as well
  94277. */
  94278. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  94279. /**
  94280. * Gets a specific animation range
  94281. * @param name defines the name of the range to look for
  94282. * @returns the requested animation range or null if not found
  94283. */
  94284. getAnimationRange(name: string): Nullable<AnimationRange>;
  94285. /**
  94286. * Gets the list of all animation ranges defined on this skeleton
  94287. * @returns an array
  94288. */
  94289. getAnimationRanges(): Nullable<AnimationRange>[];
  94290. /**
  94291. * Copy animation range from a source skeleton.
  94292. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  94293. * @param source defines the source skeleton
  94294. * @param name defines the name of the range to copy
  94295. * @param rescaleAsRequired defines if rescaling must be applied if required
  94296. * @returns true if operation was successful
  94297. */
  94298. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  94299. /**
  94300. * Forces the skeleton to go to rest pose
  94301. */
  94302. returnToRest(): void;
  94303. private _getHighestAnimationFrame;
  94304. /**
  94305. * Begin a specific animation range
  94306. * @param name defines the name of the range to start
  94307. * @param loop defines if looping must be turned on (false by default)
  94308. * @param speedRatio defines the speed ratio to apply (1 by default)
  94309. * @param onAnimationEnd defines a callback which will be called when animation will end
  94310. * @returns a new animatable
  94311. */
  94312. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  94313. /**
  94314. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  94315. * @param skeleton defines the Skeleton containing the animation range to convert
  94316. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  94317. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  94318. * @returns the original skeleton
  94319. */
  94320. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  94321. /** @hidden */
  94322. _markAsDirty(): void;
  94323. /** @hidden */
  94324. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94325. /** @hidden */
  94326. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  94327. private _computeTransformMatrices;
  94328. /**
  94329. * Build all resources required to render a skeleton
  94330. */
  94331. prepare(): void;
  94332. /**
  94333. * Gets the list of animatables currently running for this skeleton
  94334. * @returns an array of animatables
  94335. */
  94336. getAnimatables(): IAnimatable[];
  94337. /**
  94338. * Clone the current skeleton
  94339. * @param name defines the name of the new skeleton
  94340. * @param id defines the id of the new skeleton
  94341. * @returns the new skeleton
  94342. */
  94343. clone(name: string, id?: string): Skeleton;
  94344. /**
  94345. * Enable animation blending for this skeleton
  94346. * @param blendingSpeed defines the blending speed to apply
  94347. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  94348. */
  94349. enableBlending(blendingSpeed?: number): void;
  94350. /**
  94351. * Releases all resources associated with the current skeleton
  94352. */
  94353. dispose(): void;
  94354. /**
  94355. * Serialize the skeleton in a JSON object
  94356. * @returns a JSON object
  94357. */
  94358. serialize(): any;
  94359. /**
  94360. * Creates a new skeleton from serialized data
  94361. * @param parsedSkeleton defines the serialized data
  94362. * @param scene defines the hosting scene
  94363. * @returns a new skeleton
  94364. */
  94365. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  94366. /**
  94367. * Compute all node absolute transforms
  94368. * @param forceUpdate defines if computation must be done even if cache is up to date
  94369. */
  94370. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  94371. /**
  94372. * Gets the root pose matrix
  94373. * @returns a matrix
  94374. */
  94375. getPoseMatrix(): Nullable<Matrix>;
  94376. /**
  94377. * Sorts bones per internal index
  94378. */
  94379. sortBones(): void;
  94380. private _sortBones;
  94381. }
  94382. }
  94383. declare module BABYLON {
  94384. /**
  94385. * Creates an instance based on a source mesh.
  94386. */
  94387. export class InstancedMesh extends AbstractMesh {
  94388. private _sourceMesh;
  94389. private _currentLOD;
  94390. /** @hidden */
  94391. _indexInSourceMeshInstanceArray: number;
  94392. constructor(name: string, source: Mesh);
  94393. /**
  94394. * Returns the string "InstancedMesh".
  94395. */
  94396. getClassName(): string;
  94397. /** Gets the list of lights affecting that mesh */
  94398. get lightSources(): Light[];
  94399. _resyncLightSources(): void;
  94400. _resyncLightSource(light: Light): void;
  94401. _removeLightSource(light: Light, dispose: boolean): void;
  94402. /**
  94403. * If the source mesh receives shadows
  94404. */
  94405. get receiveShadows(): boolean;
  94406. /**
  94407. * The material of the source mesh
  94408. */
  94409. get material(): Nullable<Material>;
  94410. /**
  94411. * Visibility of the source mesh
  94412. */
  94413. get visibility(): number;
  94414. /**
  94415. * Skeleton of the source mesh
  94416. */
  94417. get skeleton(): Nullable<Skeleton>;
  94418. /**
  94419. * Rendering ground id of the source mesh
  94420. */
  94421. get renderingGroupId(): number;
  94422. set renderingGroupId(value: number);
  94423. /**
  94424. * Returns the total number of vertices (integer).
  94425. */
  94426. getTotalVertices(): number;
  94427. /**
  94428. * Returns a positive integer : the total number of indices in this mesh geometry.
  94429. * @returns the numner of indices or zero if the mesh has no geometry.
  94430. */
  94431. getTotalIndices(): number;
  94432. /**
  94433. * The source mesh of the instance
  94434. */
  94435. get sourceMesh(): Mesh;
  94436. /**
  94437. * Creates a new InstancedMesh object from the mesh model.
  94438. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  94439. * @param name defines the name of the new instance
  94440. * @returns a new InstancedMesh
  94441. */
  94442. createInstance(name: string): InstancedMesh;
  94443. /**
  94444. * Is this node ready to be used/rendered
  94445. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  94446. * @return {boolean} is it ready
  94447. */
  94448. isReady(completeCheck?: boolean): boolean;
  94449. /**
  94450. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  94451. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  94452. * @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.
  94453. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  94454. */
  94455. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  94456. /**
  94457. * Sets the vertex data of the mesh geometry for the requested `kind`.
  94458. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  94459. * The `data` are either a numeric array either a Float32Array.
  94460. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  94461. * 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).
  94462. * Note that a new underlying VertexBuffer object is created each call.
  94463. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  94464. *
  94465. * Possible `kind` values :
  94466. * - VertexBuffer.PositionKind
  94467. * - VertexBuffer.UVKind
  94468. * - VertexBuffer.UV2Kind
  94469. * - VertexBuffer.UV3Kind
  94470. * - VertexBuffer.UV4Kind
  94471. * - VertexBuffer.UV5Kind
  94472. * - VertexBuffer.UV6Kind
  94473. * - VertexBuffer.ColorKind
  94474. * - VertexBuffer.MatricesIndicesKind
  94475. * - VertexBuffer.MatricesIndicesExtraKind
  94476. * - VertexBuffer.MatricesWeightsKind
  94477. * - VertexBuffer.MatricesWeightsExtraKind
  94478. *
  94479. * Returns the Mesh.
  94480. */
  94481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  94482. /**
  94483. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  94484. * If the mesh has no geometry, it is simply returned as it is.
  94485. * The `data` are either a numeric array either a Float32Array.
  94486. * No new underlying VertexBuffer object is created.
  94487. * 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.
  94488. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  94489. *
  94490. * Possible `kind` values :
  94491. * - VertexBuffer.PositionKind
  94492. * - VertexBuffer.UVKind
  94493. * - VertexBuffer.UV2Kind
  94494. * - VertexBuffer.UV3Kind
  94495. * - VertexBuffer.UV4Kind
  94496. * - VertexBuffer.UV5Kind
  94497. * - VertexBuffer.UV6Kind
  94498. * - VertexBuffer.ColorKind
  94499. * - VertexBuffer.MatricesIndicesKind
  94500. * - VertexBuffer.MatricesIndicesExtraKind
  94501. * - VertexBuffer.MatricesWeightsKind
  94502. * - VertexBuffer.MatricesWeightsExtraKind
  94503. *
  94504. * Returns the Mesh.
  94505. */
  94506. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  94507. /**
  94508. * Sets the mesh indices.
  94509. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  94510. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  94511. * This method creates a new index buffer each call.
  94512. * Returns the Mesh.
  94513. */
  94514. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  94515. /**
  94516. * Boolean : True if the mesh owns the requested kind of data.
  94517. */
  94518. isVerticesDataPresent(kind: string): boolean;
  94519. /**
  94520. * Returns an array of indices (IndicesArray).
  94521. */
  94522. getIndices(): Nullable<IndicesArray>;
  94523. get _positions(): Nullable<Vector3[]>;
  94524. /**
  94525. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  94526. * This means the mesh underlying bounding box and sphere are recomputed.
  94527. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  94528. * @returns the current mesh
  94529. */
  94530. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  94531. /** @hidden */
  94532. _preActivate(): InstancedMesh;
  94533. /** @hidden */
  94534. _activate(renderId: number, intermediateRendering: boolean): boolean;
  94535. /** @hidden */
  94536. _postActivate(): void;
  94537. getWorldMatrix(): Matrix;
  94538. get isAnInstance(): boolean;
  94539. /**
  94540. * Returns the current associated LOD AbstractMesh.
  94541. */
  94542. getLOD(camera: Camera): AbstractMesh;
  94543. /** @hidden */
  94544. _preActivateForIntermediateRendering(renderId: number): Mesh;
  94545. /** @hidden */
  94546. _syncSubMeshes(): InstancedMesh;
  94547. /** @hidden */
  94548. _generatePointsArray(): boolean;
  94549. /**
  94550. * Creates a new InstancedMesh from the current mesh.
  94551. * - name (string) : the cloned mesh name
  94552. * - newParent (optional Node) : the optional Node to parent the clone to.
  94553. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  94554. *
  94555. * Returns the clone.
  94556. */
  94557. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  94558. /**
  94559. * Disposes the InstancedMesh.
  94560. * Returns nothing.
  94561. */
  94562. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  94563. }
  94564. interface Mesh {
  94565. /**
  94566. * Register a custom buffer that will be instanced
  94567. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94568. * @param kind defines the buffer kind
  94569. * @param stride defines the stride in floats
  94570. */
  94571. registerInstancedBuffer(kind: string, stride: number): void;
  94572. /**
  94573. * true to use the edge renderer for all instances of this mesh
  94574. */
  94575. edgesShareWithInstances: boolean;
  94576. /** @hidden */
  94577. _userInstancedBuffersStorage: {
  94578. data: {
  94579. [key: string]: Float32Array;
  94580. };
  94581. sizes: {
  94582. [key: string]: number;
  94583. };
  94584. vertexBuffers: {
  94585. [key: string]: Nullable<VertexBuffer>;
  94586. };
  94587. strides: {
  94588. [key: string]: number;
  94589. };
  94590. };
  94591. }
  94592. interface AbstractMesh {
  94593. /**
  94594. * Object used to store instanced buffers defined by user
  94595. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  94596. */
  94597. instancedBuffers: {
  94598. [key: string]: any;
  94599. };
  94600. }
  94601. }
  94602. declare module BABYLON {
  94603. /**
  94604. * Defines the options associated with the creation of a shader material.
  94605. */
  94606. export interface IShaderMaterialOptions {
  94607. /**
  94608. * Does the material work in alpha blend mode
  94609. */
  94610. needAlphaBlending: boolean;
  94611. /**
  94612. * Does the material work in alpha test mode
  94613. */
  94614. needAlphaTesting: boolean;
  94615. /**
  94616. * The list of attribute names used in the shader
  94617. */
  94618. attributes: string[];
  94619. /**
  94620. * The list of unifrom names used in the shader
  94621. */
  94622. uniforms: string[];
  94623. /**
  94624. * The list of UBO names used in the shader
  94625. */
  94626. uniformBuffers: string[];
  94627. /**
  94628. * The list of sampler names used in the shader
  94629. */
  94630. samplers: string[];
  94631. /**
  94632. * The list of defines used in the shader
  94633. */
  94634. defines: string[];
  94635. }
  94636. /**
  94637. * 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.
  94638. *
  94639. * This returned material effects how the mesh will look based on the code in the shaders.
  94640. *
  94641. * @see https://doc.babylonjs.com/how_to/shader_material
  94642. */
  94643. export class ShaderMaterial extends Material {
  94644. private _shaderPath;
  94645. private _options;
  94646. private _textures;
  94647. private _textureArrays;
  94648. private _floats;
  94649. private _ints;
  94650. private _floatsArrays;
  94651. private _colors3;
  94652. private _colors3Arrays;
  94653. private _colors4;
  94654. private _colors4Arrays;
  94655. private _vectors2;
  94656. private _vectors3;
  94657. private _vectors4;
  94658. private _matrices;
  94659. private _matrixArrays;
  94660. private _matrices3x3;
  94661. private _matrices2x2;
  94662. private _vectors2Arrays;
  94663. private _vectors3Arrays;
  94664. private _vectors4Arrays;
  94665. private _cachedWorldViewMatrix;
  94666. private _cachedWorldViewProjectionMatrix;
  94667. private _renderId;
  94668. private _multiview;
  94669. private _cachedDefines;
  94670. /** Define the Url to load snippets */
  94671. static SnippetUrl: string;
  94672. /** Snippet ID if the material was created from the snippet server */
  94673. snippetId: string;
  94674. /**
  94675. * Instantiate a new shader material.
  94676. * 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.
  94677. * This returned material effects how the mesh will look based on the code in the shaders.
  94678. * @see https://doc.babylonjs.com/how_to/shader_material
  94679. * @param name Define the name of the material in the scene
  94680. * @param scene Define the scene the material belongs to
  94681. * @param shaderPath Defines the route to the shader code in one of three ways:
  94682. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  94683. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  94684. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  94685. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  94686. * @param options Define the options used to create the shader
  94687. */
  94688. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  94689. /**
  94690. * Gets the shader path used to define the shader code
  94691. * It can be modified to trigger a new compilation
  94692. */
  94693. get shaderPath(): any;
  94694. /**
  94695. * Sets the shader path used to define the shader code
  94696. * It can be modified to trigger a new compilation
  94697. */
  94698. set shaderPath(shaderPath: any);
  94699. /**
  94700. * Gets the options used to compile the shader.
  94701. * They can be modified to trigger a new compilation
  94702. */
  94703. get options(): IShaderMaterialOptions;
  94704. /**
  94705. * Gets the current class name of the material e.g. "ShaderMaterial"
  94706. * Mainly use in serialization.
  94707. * @returns the class name
  94708. */
  94709. getClassName(): string;
  94710. /**
  94711. * Specifies if the material will require alpha blending
  94712. * @returns a boolean specifying if alpha blending is needed
  94713. */
  94714. needAlphaBlending(): boolean;
  94715. /**
  94716. * Specifies if this material should be rendered in alpha test mode
  94717. * @returns a boolean specifying if an alpha test is needed.
  94718. */
  94719. needAlphaTesting(): boolean;
  94720. private _checkUniform;
  94721. /**
  94722. * Set a texture in the shader.
  94723. * @param name Define the name of the uniform samplers as defined in the shader
  94724. * @param texture Define the texture to bind to this sampler
  94725. * @return the material itself allowing "fluent" like uniform updates
  94726. */
  94727. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  94728. /**
  94729. * Set a texture array in the shader.
  94730. * @param name Define the name of the uniform sampler array as defined in the shader
  94731. * @param textures Define the list of textures to bind to this sampler
  94732. * @return the material itself allowing "fluent" like uniform updates
  94733. */
  94734. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  94735. /**
  94736. * Set a float in the shader.
  94737. * @param name Define the name of the uniform as defined in the shader
  94738. * @param value Define the value to give to the uniform
  94739. * @return the material itself allowing "fluent" like uniform updates
  94740. */
  94741. setFloat(name: string, value: number): ShaderMaterial;
  94742. /**
  94743. * Set a int in the shader.
  94744. * @param name Define the name of the uniform as defined in the shader
  94745. * @param value Define the value to give to the uniform
  94746. * @return the material itself allowing "fluent" like uniform updates
  94747. */
  94748. setInt(name: string, value: number): ShaderMaterial;
  94749. /**
  94750. * Set an array of floats in the shader.
  94751. * @param name Define the name of the uniform as defined in the shader
  94752. * @param value Define the value to give to the uniform
  94753. * @return the material itself allowing "fluent" like uniform updates
  94754. */
  94755. setFloats(name: string, value: number[]): ShaderMaterial;
  94756. /**
  94757. * Set a vec3 in the shader from a Color3.
  94758. * @param name Define the name of the uniform as defined in the shader
  94759. * @param value Define the value to give to the uniform
  94760. * @return the material itself allowing "fluent" like uniform updates
  94761. */
  94762. setColor3(name: string, value: Color3): ShaderMaterial;
  94763. /**
  94764. * Set a vec3 array in the shader from a Color3 array.
  94765. * @param name Define the name of the uniform as defined in the shader
  94766. * @param value Define the value to give to the uniform
  94767. * @return the material itself allowing "fluent" like uniform updates
  94768. */
  94769. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  94770. /**
  94771. * Set a vec4 in the shader from a Color4.
  94772. * @param name Define the name of the uniform as defined in the shader
  94773. * @param value Define the value to give to the uniform
  94774. * @return the material itself allowing "fluent" like uniform updates
  94775. */
  94776. setColor4(name: string, value: Color4): ShaderMaterial;
  94777. /**
  94778. * Set a vec4 array in the shader from a Color4 array.
  94779. * @param name Define the name of the uniform as defined in the shader
  94780. * @param value Define the value to give to the uniform
  94781. * @return the material itself allowing "fluent" like uniform updates
  94782. */
  94783. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  94784. /**
  94785. * Set a vec2 in the shader from a Vector2.
  94786. * @param name Define the name of the uniform as defined in the shader
  94787. * @param value Define the value to give to the uniform
  94788. * @return the material itself allowing "fluent" like uniform updates
  94789. */
  94790. setVector2(name: string, value: Vector2): ShaderMaterial;
  94791. /**
  94792. * Set a vec3 in the shader from a Vector3.
  94793. * @param name Define the name of the uniform as defined in the shader
  94794. * @param value Define the value to give to the uniform
  94795. * @return the material itself allowing "fluent" like uniform updates
  94796. */
  94797. setVector3(name: string, value: Vector3): ShaderMaterial;
  94798. /**
  94799. * Set a vec4 in the shader from a Vector4.
  94800. * @param name Define the name of the uniform as defined in the shader
  94801. * @param value Define the value to give to the uniform
  94802. * @return the material itself allowing "fluent" like uniform updates
  94803. */
  94804. setVector4(name: string, value: Vector4): ShaderMaterial;
  94805. /**
  94806. * Set a mat4 in the shader from a Matrix.
  94807. * @param name Define the name of the uniform as defined in the shader
  94808. * @param value Define the value to give to the uniform
  94809. * @return the material itself allowing "fluent" like uniform updates
  94810. */
  94811. setMatrix(name: string, value: Matrix): ShaderMaterial;
  94812. /**
  94813. * Set a float32Array in the shader from a matrix array.
  94814. * @param name Define the name of the uniform as defined in the shader
  94815. * @param value Define the value to give to the uniform
  94816. * @return the material itself allowing "fluent" like uniform updates
  94817. */
  94818. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  94819. /**
  94820. * Set a mat3 in the shader from a Float32Array.
  94821. * @param name Define the name of the uniform as defined in the shader
  94822. * @param value Define the value to give to the uniform
  94823. * @return the material itself allowing "fluent" like uniform updates
  94824. */
  94825. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  94826. /**
  94827. * Set a mat2 in the shader from a Float32Array.
  94828. * @param name Define the name of the uniform as defined in the shader
  94829. * @param value Define the value to give to the uniform
  94830. * @return the material itself allowing "fluent" like uniform updates
  94831. */
  94832. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  94833. /**
  94834. * Set a vec2 array in the shader from a number array.
  94835. * @param name Define the name of the uniform as defined in the shader
  94836. * @param value Define the value to give to the uniform
  94837. * @return the material itself allowing "fluent" like uniform updates
  94838. */
  94839. setArray2(name: string, value: number[]): ShaderMaterial;
  94840. /**
  94841. * Set a vec3 array in the shader from a number array.
  94842. * @param name Define the name of the uniform as defined in the shader
  94843. * @param value Define the value to give to the uniform
  94844. * @return the material itself allowing "fluent" like uniform updates
  94845. */
  94846. setArray3(name: string, value: number[]): ShaderMaterial;
  94847. /**
  94848. * Set a vec4 array in the shader from a number array.
  94849. * @param name Define the name of the uniform as defined in the shader
  94850. * @param value Define the value to give to the uniform
  94851. * @return the material itself allowing "fluent" like uniform updates
  94852. */
  94853. setArray4(name: string, value: number[]): ShaderMaterial;
  94854. private _checkCache;
  94855. /**
  94856. * Specifies that the submesh is ready to be used
  94857. * @param mesh defines the mesh to check
  94858. * @param subMesh defines which submesh to check
  94859. * @param useInstances specifies that instances should be used
  94860. * @returns a boolean indicating that the submesh is ready or not
  94861. */
  94862. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  94863. /**
  94864. * Checks if the material is ready to render the requested mesh
  94865. * @param mesh Define the mesh to render
  94866. * @param useInstances Define whether or not the material is used with instances
  94867. * @returns true if ready, otherwise false
  94868. */
  94869. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94870. /**
  94871. * Binds the world matrix to the material
  94872. * @param world defines the world transformation matrix
  94873. * @param effectOverride - If provided, use this effect instead of internal effect
  94874. */
  94875. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  94876. /**
  94877. * Binds the submesh to this material by preparing the effect and shader to draw
  94878. * @param world defines the world transformation matrix
  94879. * @param mesh defines the mesh containing the submesh
  94880. * @param subMesh defines the submesh to bind the material to
  94881. */
  94882. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94883. /**
  94884. * Binds the material to the mesh
  94885. * @param world defines the world transformation matrix
  94886. * @param mesh defines the mesh to bind the material to
  94887. * @param effectOverride - If provided, use this effect instead of internal effect
  94888. */
  94889. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  94890. protected _afterBind(mesh?: Mesh): void;
  94891. /**
  94892. * Gets the active textures from the material
  94893. * @returns an array of textures
  94894. */
  94895. getActiveTextures(): BaseTexture[];
  94896. /**
  94897. * Specifies if the material uses a texture
  94898. * @param texture defines the texture to check against the material
  94899. * @returns a boolean specifying if the material uses the texture
  94900. */
  94901. hasTexture(texture: BaseTexture): boolean;
  94902. /**
  94903. * Makes a duplicate of the material, and gives it a new name
  94904. * @param name defines the new name for the duplicated material
  94905. * @returns the cloned material
  94906. */
  94907. clone(name: string): ShaderMaterial;
  94908. /**
  94909. * Disposes the material
  94910. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94911. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94912. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94913. */
  94914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94915. /**
  94916. * Serializes this material in a JSON representation
  94917. * @returns the serialized material object
  94918. */
  94919. serialize(): any;
  94920. /**
  94921. * Creates a shader material from parsed shader material data
  94922. * @param source defines the JSON represnetation of the material
  94923. * @param scene defines the hosting scene
  94924. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94925. * @returns a new material
  94926. */
  94927. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  94928. /**
  94929. * Creates a new ShaderMaterial from a snippet saved in a remote file
  94930. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  94931. * @param url defines the url to load from
  94932. * @param scene defines the hosting scene
  94933. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94934. * @returns a promise that will resolve to the new ShaderMaterial
  94935. */
  94936. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94937. /**
  94938. * Creates a ShaderMaterial from a snippet saved by the Inspector
  94939. * @param snippetId defines the snippet to load
  94940. * @param scene defines the hosting scene
  94941. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  94942. * @returns a promise that will resolve to the new ShaderMaterial
  94943. */
  94944. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  94945. }
  94946. }
  94947. declare module BABYLON {
  94948. /** @hidden */
  94949. export var colorPixelShader: {
  94950. name: string;
  94951. shader: string;
  94952. };
  94953. }
  94954. declare module BABYLON {
  94955. /** @hidden */
  94956. export var colorVertexShader: {
  94957. name: string;
  94958. shader: string;
  94959. };
  94960. }
  94961. declare module BABYLON {
  94962. /**
  94963. * Line mesh
  94964. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  94965. */
  94966. export class LinesMesh extends Mesh {
  94967. /**
  94968. * If vertex color should be applied to the mesh
  94969. */
  94970. readonly useVertexColor?: boolean | undefined;
  94971. /**
  94972. * If vertex alpha should be applied to the mesh
  94973. */
  94974. readonly useVertexAlpha?: boolean | undefined;
  94975. /**
  94976. * Color of the line (Default: White)
  94977. */
  94978. color: Color3;
  94979. /**
  94980. * Alpha of the line (Default: 1)
  94981. */
  94982. alpha: number;
  94983. /**
  94984. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  94985. * This margin is expressed in world space coordinates, so its value may vary.
  94986. * Default value is 0.1
  94987. */
  94988. intersectionThreshold: number;
  94989. private _colorShader;
  94990. private color4;
  94991. /**
  94992. * Creates a new LinesMesh
  94993. * @param name defines the name
  94994. * @param scene defines the hosting scene
  94995. * @param parent defines the parent mesh if any
  94996. * @param source defines the optional source LinesMesh used to clone data from
  94997. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  94998. * When false, achieved by calling a clone(), also passing False.
  94999. * This will make creation of children, recursive.
  95000. * @param useVertexColor defines if this LinesMesh supports vertex color
  95001. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  95002. */
  95003. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  95004. /**
  95005. * If vertex color should be applied to the mesh
  95006. */
  95007. useVertexColor?: boolean | undefined,
  95008. /**
  95009. * If vertex alpha should be applied to the mesh
  95010. */
  95011. useVertexAlpha?: boolean | undefined);
  95012. private _addClipPlaneDefine;
  95013. private _removeClipPlaneDefine;
  95014. isReady(): boolean;
  95015. /**
  95016. * Returns the string "LineMesh"
  95017. */
  95018. getClassName(): string;
  95019. /**
  95020. * @hidden
  95021. */
  95022. get material(): Material;
  95023. /**
  95024. * @hidden
  95025. */
  95026. set material(value: Material);
  95027. /**
  95028. * @hidden
  95029. */
  95030. get checkCollisions(): boolean;
  95031. /** @hidden */
  95032. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  95033. /** @hidden */
  95034. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  95035. /**
  95036. * Disposes of the line mesh
  95037. * @param doNotRecurse If children should be disposed
  95038. */
  95039. dispose(doNotRecurse?: boolean): void;
  95040. /**
  95041. * Returns a new LineMesh object cloned from the current one.
  95042. */
  95043. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  95044. /**
  95045. * Creates a new InstancedLinesMesh object from the mesh model.
  95046. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  95047. * @param name defines the name of the new instance
  95048. * @returns a new InstancedLinesMesh
  95049. */
  95050. createInstance(name: string): InstancedLinesMesh;
  95051. }
  95052. /**
  95053. * Creates an instance based on a source LinesMesh
  95054. */
  95055. export class InstancedLinesMesh extends InstancedMesh {
  95056. /**
  95057. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  95058. * This margin is expressed in world space coordinates, so its value may vary.
  95059. * Initilized with the intersectionThreshold value of the source LinesMesh
  95060. */
  95061. intersectionThreshold: number;
  95062. constructor(name: string, source: LinesMesh);
  95063. /**
  95064. * Returns the string "InstancedLinesMesh".
  95065. */
  95066. getClassName(): string;
  95067. }
  95068. }
  95069. declare module BABYLON {
  95070. /** @hidden */
  95071. export var linePixelShader: {
  95072. name: string;
  95073. shader: string;
  95074. };
  95075. }
  95076. declare module BABYLON {
  95077. /** @hidden */
  95078. export var lineVertexShader: {
  95079. name: string;
  95080. shader: string;
  95081. };
  95082. }
  95083. declare module BABYLON {
  95084. interface Scene {
  95085. /** @hidden */
  95086. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  95087. }
  95088. interface AbstractMesh {
  95089. /**
  95090. * Gets the edgesRenderer associated with the mesh
  95091. */
  95092. edgesRenderer: Nullable<EdgesRenderer>;
  95093. }
  95094. interface LinesMesh {
  95095. /**
  95096. * Enables the edge rendering mode on the mesh.
  95097. * This mode makes the mesh edges visible
  95098. * @param epsilon defines the maximal distance between two angles to detect a face
  95099. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95100. * @returns the currentAbstractMesh
  95101. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95102. */
  95103. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  95104. }
  95105. interface InstancedLinesMesh {
  95106. /**
  95107. * Enables the edge rendering mode on the mesh.
  95108. * This mode makes the mesh edges visible
  95109. * @param epsilon defines the maximal distance between two angles to detect a face
  95110. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  95111. * @returns the current InstancedLinesMesh
  95112. * @see https://www.babylonjs-playground.com/#19O9TU#0
  95113. */
  95114. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  95115. }
  95116. /**
  95117. * Defines the minimum contract an Edges renderer should follow.
  95118. */
  95119. export interface IEdgesRenderer extends IDisposable {
  95120. /**
  95121. * Gets or sets a boolean indicating if the edgesRenderer is active
  95122. */
  95123. isEnabled: boolean;
  95124. /**
  95125. * Renders the edges of the attached mesh,
  95126. */
  95127. render(): void;
  95128. /**
  95129. * Checks wether or not the edges renderer is ready to render.
  95130. * @return true if ready, otherwise false.
  95131. */
  95132. isReady(): boolean;
  95133. /**
  95134. * List of instances to render in case the source mesh has instances
  95135. */
  95136. customInstances: SmartArray<Matrix>;
  95137. }
  95138. /**
  95139. * Defines the additional options of the edges renderer
  95140. */
  95141. export interface IEdgesRendererOptions {
  95142. /**
  95143. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  95144. * If not defined, the default value is true
  95145. */
  95146. useAlternateEdgeFinder?: boolean;
  95147. /**
  95148. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  95149. * If not defined, the default value is true.
  95150. * 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)
  95151. * This option is used only if useAlternateEdgeFinder = true
  95152. */
  95153. useFastVertexMerger?: boolean;
  95154. /**
  95155. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  95156. * The default value is 1e-6
  95157. * This option is used only if useAlternateEdgeFinder = true
  95158. */
  95159. epsilonVertexMerge?: number;
  95160. /**
  95161. * 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
  95162. * 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.
  95163. * This option is used only if useAlternateEdgeFinder = true
  95164. */
  95165. applyTessellation?: boolean;
  95166. /**
  95167. * 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
  95168. * The default value is 1e-6
  95169. * This option is used only if useAlternateEdgeFinder = true
  95170. */
  95171. epsilonVertexAligned?: number;
  95172. }
  95173. /**
  95174. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  95175. */
  95176. export class EdgesRenderer implements IEdgesRenderer {
  95177. /**
  95178. * Define the size of the edges with an orthographic camera
  95179. */
  95180. edgesWidthScalerForOrthographic: number;
  95181. /**
  95182. * Define the size of the edges with a perspective camera
  95183. */
  95184. edgesWidthScalerForPerspective: number;
  95185. protected _source: AbstractMesh;
  95186. protected _linesPositions: number[];
  95187. protected _linesNormals: number[];
  95188. protected _linesIndices: number[];
  95189. protected _epsilon: number;
  95190. protected _indicesCount: number;
  95191. protected _lineShader: ShaderMaterial;
  95192. protected _ib: DataBuffer;
  95193. protected _buffers: {
  95194. [key: string]: Nullable<VertexBuffer>;
  95195. };
  95196. protected _buffersForInstances: {
  95197. [key: string]: Nullable<VertexBuffer>;
  95198. };
  95199. protected _checkVerticesInsteadOfIndices: boolean;
  95200. protected _options: Nullable<IEdgesRendererOptions>;
  95201. private _meshRebuildObserver;
  95202. private _meshDisposeObserver;
  95203. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  95204. isEnabled: boolean;
  95205. /**
  95206. * List of instances to render in case the source mesh has instances
  95207. */
  95208. customInstances: SmartArray<Matrix>;
  95209. private static GetShader;
  95210. /**
  95211. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  95212. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  95213. * @param source Mesh used to create edges
  95214. * @param epsilon sum of angles in adjacency to check for edge
  95215. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  95216. * @param generateEdgesLines - should generate Lines or only prepare resources.
  95217. * @param options The options to apply when generating the edges
  95218. */
  95219. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  95220. protected _prepareRessources(): void;
  95221. /** @hidden */
  95222. _rebuild(): void;
  95223. /**
  95224. * Releases the required resources for the edges renderer
  95225. */
  95226. dispose(): void;
  95227. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  95228. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  95229. /**
  95230. * Checks if the pair of p0 and p1 is en edge
  95231. * @param faceIndex
  95232. * @param edge
  95233. * @param faceNormals
  95234. * @param p0
  95235. * @param p1
  95236. * @private
  95237. */
  95238. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  95239. /**
  95240. * push line into the position, normal and index buffer
  95241. * @protected
  95242. */
  95243. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  95244. /**
  95245. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  95246. */
  95247. private _tessellateTriangle;
  95248. private _generateEdgesLinesAlternate;
  95249. /**
  95250. * Generates lines edges from adjacencjes
  95251. * @private
  95252. */
  95253. _generateEdgesLines(): void;
  95254. /**
  95255. * Checks wether or not the edges renderer is ready to render.
  95256. * @return true if ready, otherwise false.
  95257. */
  95258. isReady(): boolean;
  95259. /**
  95260. * Renders the edges of the attached mesh,
  95261. */
  95262. render(): void;
  95263. }
  95264. /**
  95265. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  95266. */
  95267. export class LineEdgesRenderer extends EdgesRenderer {
  95268. /**
  95269. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  95270. * @param source LineMesh used to generate edges
  95271. * @param epsilon not important (specified angle for edge detection)
  95272. * @param checkVerticesInsteadOfIndices not important for LineMesh
  95273. */
  95274. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  95275. /**
  95276. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  95277. */
  95278. _generateEdgesLines(): void;
  95279. }
  95280. }
  95281. declare module BABYLON {
  95282. /**
  95283. * This represents the object necessary to create a rendering group.
  95284. * This is exclusively used and created by the rendering manager.
  95285. * To modify the behavior, you use the available helpers in your scene or meshes.
  95286. * @hidden
  95287. */
  95288. export class RenderingGroup {
  95289. index: number;
  95290. private static _zeroVector;
  95291. private _scene;
  95292. private _opaqueSubMeshes;
  95293. private _transparentSubMeshes;
  95294. private _alphaTestSubMeshes;
  95295. private _depthOnlySubMeshes;
  95296. private _particleSystems;
  95297. private _spriteManagers;
  95298. private _opaqueSortCompareFn;
  95299. private _alphaTestSortCompareFn;
  95300. private _transparentSortCompareFn;
  95301. private _renderOpaque;
  95302. private _renderAlphaTest;
  95303. private _renderTransparent;
  95304. /** @hidden */
  95305. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  95306. onBeforeTransparentRendering: () => void;
  95307. /**
  95308. * Set the opaque sort comparison function.
  95309. * If null the sub meshes will be render in the order they were created
  95310. */
  95311. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95312. /**
  95313. * Set the alpha test sort comparison function.
  95314. * If null the sub meshes will be render in the order they were created
  95315. */
  95316. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95317. /**
  95318. * Set the transparent sort comparison function.
  95319. * If null the sub meshes will be render in the order they were created
  95320. */
  95321. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  95322. /**
  95323. * Creates a new rendering group.
  95324. * @param index The rendering group index
  95325. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  95326. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  95327. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  95328. */
  95329. 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>);
  95330. /**
  95331. * Render all the sub meshes contained in the group.
  95332. * @param customRenderFunction Used to override the default render behaviour of the group.
  95333. * @returns true if rendered some submeshes.
  95334. */
  95335. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  95336. /**
  95337. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  95338. * @param subMeshes The submeshes to render
  95339. */
  95340. private renderOpaqueSorted;
  95341. /**
  95342. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  95343. * @param subMeshes The submeshes to render
  95344. */
  95345. private renderAlphaTestSorted;
  95346. /**
  95347. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  95348. * @param subMeshes The submeshes to render
  95349. */
  95350. private renderTransparentSorted;
  95351. /**
  95352. * Renders the submeshes in a specified order.
  95353. * @param subMeshes The submeshes to sort before render
  95354. * @param sortCompareFn The comparison function use to sort
  95355. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  95356. * @param transparent Specifies to activate blending if true
  95357. */
  95358. private static renderSorted;
  95359. /**
  95360. * Renders the submeshes in the order they were dispatched (no sort applied).
  95361. * @param subMeshes The submeshes to render
  95362. */
  95363. private static renderUnsorted;
  95364. /**
  95365. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95366. * are rendered back to front if in the same alpha index.
  95367. *
  95368. * @param a The first submesh
  95369. * @param b The second submesh
  95370. * @returns The result of the comparison
  95371. */
  95372. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  95373. /**
  95374. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95375. * are rendered back to front.
  95376. *
  95377. * @param a The first submesh
  95378. * @param b The second submesh
  95379. * @returns The result of the comparison
  95380. */
  95381. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  95382. /**
  95383. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  95384. * are rendered front to back (prevent overdraw).
  95385. *
  95386. * @param a The first submesh
  95387. * @param b The second submesh
  95388. * @returns The result of the comparison
  95389. */
  95390. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  95391. /**
  95392. * Resets the different lists of submeshes to prepare a new frame.
  95393. */
  95394. prepare(): void;
  95395. dispose(): void;
  95396. /**
  95397. * Inserts the submesh in its correct queue depending on its material.
  95398. * @param subMesh The submesh to dispatch
  95399. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95400. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95401. */
  95402. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95403. dispatchSprites(spriteManager: ISpriteManager): void;
  95404. dispatchParticles(particleSystem: IParticleSystem): void;
  95405. private _renderParticles;
  95406. private _renderSprites;
  95407. }
  95408. }
  95409. declare module BABYLON {
  95410. /**
  95411. * Interface describing the different options available in the rendering manager
  95412. * regarding Auto Clear between groups.
  95413. */
  95414. export interface IRenderingManagerAutoClearSetup {
  95415. /**
  95416. * Defines whether or not autoclear is enable.
  95417. */
  95418. autoClear: boolean;
  95419. /**
  95420. * Defines whether or not to autoclear the depth buffer.
  95421. */
  95422. depth: boolean;
  95423. /**
  95424. * Defines whether or not to autoclear the stencil buffer.
  95425. */
  95426. stencil: boolean;
  95427. }
  95428. /**
  95429. * This class is used by the onRenderingGroupObservable
  95430. */
  95431. export class RenderingGroupInfo {
  95432. /**
  95433. * The Scene that being rendered
  95434. */
  95435. scene: Scene;
  95436. /**
  95437. * The camera currently used for the rendering pass
  95438. */
  95439. camera: Nullable<Camera>;
  95440. /**
  95441. * The ID of the renderingGroup being processed
  95442. */
  95443. renderingGroupId: number;
  95444. }
  95445. /**
  95446. * This is the manager responsible of all the rendering for meshes sprites and particles.
  95447. * It is enable to manage the different groups as well as the different necessary sort functions.
  95448. * This should not be used directly aside of the few static configurations
  95449. */
  95450. export class RenderingManager {
  95451. /**
  95452. * The max id used for rendering groups (not included)
  95453. */
  95454. static MAX_RENDERINGGROUPS: number;
  95455. /**
  95456. * The min id used for rendering groups (included)
  95457. */
  95458. static MIN_RENDERINGGROUPS: number;
  95459. /**
  95460. * Used to globally prevent autoclearing scenes.
  95461. */
  95462. static AUTOCLEAR: boolean;
  95463. /**
  95464. * @hidden
  95465. */
  95466. _useSceneAutoClearSetup: boolean;
  95467. private _scene;
  95468. private _renderingGroups;
  95469. private _depthStencilBufferAlreadyCleaned;
  95470. private _autoClearDepthStencil;
  95471. private _customOpaqueSortCompareFn;
  95472. private _customAlphaTestSortCompareFn;
  95473. private _customTransparentSortCompareFn;
  95474. private _renderingGroupInfo;
  95475. /**
  95476. * Instantiates a new rendering group for a particular scene
  95477. * @param scene Defines the scene the groups belongs to
  95478. */
  95479. constructor(scene: Scene);
  95480. private _clearDepthStencilBuffer;
  95481. /**
  95482. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  95483. * @hidden
  95484. */
  95485. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  95486. /**
  95487. * Resets the different information of the group to prepare a new frame
  95488. * @hidden
  95489. */
  95490. reset(): void;
  95491. /**
  95492. * Dispose and release the group and its associated resources.
  95493. * @hidden
  95494. */
  95495. dispose(): void;
  95496. /**
  95497. * Clear the info related to rendering groups preventing retention points during dispose.
  95498. */
  95499. freeRenderingGroups(): void;
  95500. private _prepareRenderingGroup;
  95501. /**
  95502. * Add a sprite manager to the rendering manager in order to render it this frame.
  95503. * @param spriteManager Define the sprite manager to render
  95504. */
  95505. dispatchSprites(spriteManager: ISpriteManager): void;
  95506. /**
  95507. * Add a particle system to the rendering manager in order to render it this frame.
  95508. * @param particleSystem Define the particle system to render
  95509. */
  95510. dispatchParticles(particleSystem: IParticleSystem): void;
  95511. /**
  95512. * Add a submesh to the manager in order to render it this frame
  95513. * @param subMesh The submesh to dispatch
  95514. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  95515. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  95516. */
  95517. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  95518. /**
  95519. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95520. * This allowed control for front to back rendering or reversly depending of the special needs.
  95521. *
  95522. * @param renderingGroupId The rendering group id corresponding to its index
  95523. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95524. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95525. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95526. */
  95527. 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;
  95528. /**
  95529. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95530. *
  95531. * @param renderingGroupId The rendering group id corresponding to its index
  95532. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95533. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95534. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95535. */
  95536. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95537. /**
  95538. * Gets the current auto clear configuration for one rendering group of the rendering
  95539. * manager.
  95540. * @param index the rendering group index to get the information for
  95541. * @returns The auto clear setup for the requested rendering group
  95542. */
  95543. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95544. }
  95545. }
  95546. declare module BABYLON {
  95547. /**
  95548. * Defines the options associated with the creation of a custom shader for a shadow generator.
  95549. */
  95550. export interface ICustomShaderOptions {
  95551. /**
  95552. * Gets or sets the custom shader name to use
  95553. */
  95554. shaderName: string;
  95555. /**
  95556. * The list of attribute names used in the shader
  95557. */
  95558. attributes?: string[];
  95559. /**
  95560. * The list of unifrom names used in the shader
  95561. */
  95562. uniforms?: string[];
  95563. /**
  95564. * The list of sampler names used in the shader
  95565. */
  95566. samplers?: string[];
  95567. /**
  95568. * The list of defines used in the shader
  95569. */
  95570. defines?: string[];
  95571. }
  95572. /**
  95573. * Interface to implement to create a shadow generator compatible with BJS.
  95574. */
  95575. export interface IShadowGenerator {
  95576. /**
  95577. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95578. * @returns The render target texture if present otherwise, null
  95579. */
  95580. getShadowMap(): Nullable<RenderTargetTexture>;
  95581. /**
  95582. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  95583. * @param subMesh The submesh we want to render in the shadow map
  95584. * @param useInstances Defines wether will draw in the map using instances
  95585. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  95586. * @returns true if ready otherwise, false
  95587. */
  95588. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  95589. /**
  95590. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  95591. * @param defines Defines of the material we want to update
  95592. * @param lightIndex Index of the light in the enabled light list of the material
  95593. */
  95594. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  95595. /**
  95596. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  95597. * defined in the generator but impacting the effect).
  95598. * It implies the unifroms available on the materials are the standard BJS ones.
  95599. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  95600. * @param effect The effect we are binfing the information for
  95601. */
  95602. bindShadowLight(lightIndex: string, effect: Effect): void;
  95603. /**
  95604. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  95605. * (eq to shadow prjection matrix * light transform matrix)
  95606. * @returns The transform matrix used to create the shadow map
  95607. */
  95608. getTransformMatrix(): Matrix;
  95609. /**
  95610. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  95611. * Cube and 2D textures for instance.
  95612. */
  95613. recreateShadowMap(): void;
  95614. /**
  95615. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95616. * @param onCompiled Callback triggered at the and of the effects compilation
  95617. * @param options Sets of optional options forcing the compilation with different modes
  95618. */
  95619. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  95620. useInstances: boolean;
  95621. }>): void;
  95622. /**
  95623. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  95624. * @param options Sets of optional options forcing the compilation with different modes
  95625. * @returns A promise that resolves when the compilation completes
  95626. */
  95627. forceCompilationAsync(options?: Partial<{
  95628. useInstances: boolean;
  95629. }>): Promise<void>;
  95630. /**
  95631. * Serializes the shadow generator setup to a json object.
  95632. * @returns The serialized JSON object
  95633. */
  95634. serialize(): any;
  95635. /**
  95636. * Disposes the Shadow map and related Textures and effects.
  95637. */
  95638. dispose(): void;
  95639. }
  95640. /**
  95641. * Default implementation IShadowGenerator.
  95642. * This is the main object responsible of generating shadows in the framework.
  95643. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  95644. */
  95645. export class ShadowGenerator implements IShadowGenerator {
  95646. /**
  95647. * Name of the shadow generator class
  95648. */
  95649. static CLASSNAME: string;
  95650. /**
  95651. * Shadow generator mode None: no filtering applied.
  95652. */
  95653. static readonly FILTER_NONE: number;
  95654. /**
  95655. * Shadow generator mode ESM: Exponential Shadow Mapping.
  95656. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95657. */
  95658. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  95659. /**
  95660. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  95661. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  95662. */
  95663. static readonly FILTER_POISSONSAMPLING: number;
  95664. /**
  95665. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  95666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95667. */
  95668. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  95669. /**
  95670. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  95671. * edge artifacts on steep falloff.
  95672. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95673. */
  95674. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  95675. /**
  95676. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  95677. * edge artifacts on steep falloff.
  95678. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  95679. */
  95680. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  95681. /**
  95682. * Shadow generator mode PCF: Percentage Closer Filtering
  95683. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95684. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  95685. */
  95686. static readonly FILTER_PCF: number;
  95687. /**
  95688. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  95689. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  95690. * Contact Hardening
  95691. */
  95692. static readonly FILTER_PCSS: number;
  95693. /**
  95694. * Reserved for PCF and PCSS
  95695. * Highest Quality.
  95696. *
  95697. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  95698. *
  95699. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  95700. */
  95701. static readonly QUALITY_HIGH: number;
  95702. /**
  95703. * Reserved for PCF and PCSS
  95704. * Good tradeoff for quality/perf cross devices
  95705. *
  95706. * Execute PCF on a 3*3 kernel.
  95707. *
  95708. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  95709. */
  95710. static readonly QUALITY_MEDIUM: number;
  95711. /**
  95712. * Reserved for PCF and PCSS
  95713. * The lowest quality but the fastest.
  95714. *
  95715. * Execute PCF on a 1*1 kernel.
  95716. *
  95717. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  95718. */
  95719. static readonly QUALITY_LOW: number;
  95720. /** Gets or sets the custom shader name to use */
  95721. customShaderOptions: ICustomShaderOptions;
  95722. /**
  95723. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  95724. */
  95725. onBeforeShadowMapRenderObservable: Observable<Effect>;
  95726. /**
  95727. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  95728. */
  95729. onAfterShadowMapRenderObservable: Observable<Effect>;
  95730. /**
  95731. * Observable triggered before a mesh is rendered in the shadow map.
  95732. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  95733. */
  95734. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  95735. /**
  95736. * Observable triggered after a mesh is rendered in the shadow map.
  95737. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  95738. */
  95739. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  95740. protected _bias: number;
  95741. /**
  95742. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  95743. */
  95744. get bias(): number;
  95745. /**
  95746. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  95747. */
  95748. set bias(bias: number);
  95749. protected _normalBias: number;
  95750. /**
  95751. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95752. */
  95753. get normalBias(): number;
  95754. /**
  95755. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  95756. */
  95757. set normalBias(normalBias: number);
  95758. protected _blurBoxOffset: number;
  95759. /**
  95760. * Gets the blur box offset: offset applied during the blur pass.
  95761. * Only useful if useKernelBlur = false
  95762. */
  95763. get blurBoxOffset(): number;
  95764. /**
  95765. * Sets the blur box offset: offset applied during the blur pass.
  95766. * Only useful if useKernelBlur = false
  95767. */
  95768. set blurBoxOffset(value: number);
  95769. protected _blurScale: number;
  95770. /**
  95771. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  95772. * 2 means half of the size.
  95773. */
  95774. get blurScale(): number;
  95775. /**
  95776. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  95777. * 2 means half of the size.
  95778. */
  95779. set blurScale(value: number);
  95780. protected _blurKernel: number;
  95781. /**
  95782. * Gets the blur kernel: kernel size of the blur pass.
  95783. * Only useful if useKernelBlur = true
  95784. */
  95785. get blurKernel(): number;
  95786. /**
  95787. * Sets the blur kernel: kernel size of the blur pass.
  95788. * Only useful if useKernelBlur = true
  95789. */
  95790. set blurKernel(value: number);
  95791. protected _useKernelBlur: boolean;
  95792. /**
  95793. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  95794. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95795. */
  95796. get useKernelBlur(): boolean;
  95797. /**
  95798. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  95799. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  95800. */
  95801. set useKernelBlur(value: boolean);
  95802. protected _depthScale: number;
  95803. /**
  95804. * Gets the depth scale used in ESM mode.
  95805. */
  95806. get depthScale(): number;
  95807. /**
  95808. * Sets the depth scale used in ESM mode.
  95809. * This can override the scale stored on the light.
  95810. */
  95811. set depthScale(value: number);
  95812. protected _validateFilter(filter: number): number;
  95813. protected _filter: number;
  95814. /**
  95815. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  95816. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95817. */
  95818. get filter(): number;
  95819. /**
  95820. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  95821. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  95822. */
  95823. set filter(value: number);
  95824. /**
  95825. * Gets if the current filter is set to Poisson Sampling.
  95826. */
  95827. get usePoissonSampling(): boolean;
  95828. /**
  95829. * Sets the current filter to Poisson Sampling.
  95830. */
  95831. set usePoissonSampling(value: boolean);
  95832. /**
  95833. * Gets if the current filter is set to ESM.
  95834. */
  95835. get useExponentialShadowMap(): boolean;
  95836. /**
  95837. * Sets the current filter is to ESM.
  95838. */
  95839. set useExponentialShadowMap(value: boolean);
  95840. /**
  95841. * Gets if the current filter is set to filtered ESM.
  95842. */
  95843. get useBlurExponentialShadowMap(): boolean;
  95844. /**
  95845. * Gets if the current filter is set to filtered ESM.
  95846. */
  95847. set useBlurExponentialShadowMap(value: boolean);
  95848. /**
  95849. * Gets if the current filter is set to "close ESM" (using the inverse of the
  95850. * exponential to prevent steep falloff artifacts).
  95851. */
  95852. get useCloseExponentialShadowMap(): boolean;
  95853. /**
  95854. * Sets the current filter to "close ESM" (using the inverse of the
  95855. * exponential to prevent steep falloff artifacts).
  95856. */
  95857. set useCloseExponentialShadowMap(value: boolean);
  95858. /**
  95859. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  95860. * exponential to prevent steep falloff artifacts).
  95861. */
  95862. get useBlurCloseExponentialShadowMap(): boolean;
  95863. /**
  95864. * Sets the current filter to filtered "close ESM" (using the inverse of the
  95865. * exponential to prevent steep falloff artifacts).
  95866. */
  95867. set useBlurCloseExponentialShadowMap(value: boolean);
  95868. /**
  95869. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  95870. */
  95871. get usePercentageCloserFiltering(): boolean;
  95872. /**
  95873. * Sets the current filter to "PCF" (percentage closer filtering).
  95874. */
  95875. set usePercentageCloserFiltering(value: boolean);
  95876. protected _filteringQuality: number;
  95877. /**
  95878. * Gets the PCF or PCSS Quality.
  95879. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95880. */
  95881. get filteringQuality(): number;
  95882. /**
  95883. * Sets the PCF or PCSS Quality.
  95884. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  95885. */
  95886. set filteringQuality(filteringQuality: number);
  95887. /**
  95888. * Gets if the current filter is set to "PCSS" (contact hardening).
  95889. */
  95890. get useContactHardeningShadow(): boolean;
  95891. /**
  95892. * Sets the current filter to "PCSS" (contact hardening).
  95893. */
  95894. set useContactHardeningShadow(value: boolean);
  95895. protected _contactHardeningLightSizeUVRatio: number;
  95896. /**
  95897. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95898. * Using a ratio helps keeping shape stability independently of the map size.
  95899. *
  95900. * It does not account for the light projection as it was having too much
  95901. * instability during the light setup or during light position changes.
  95902. *
  95903. * Only valid if useContactHardeningShadow is true.
  95904. */
  95905. get contactHardeningLightSizeUVRatio(): number;
  95906. /**
  95907. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  95908. * Using a ratio helps keeping shape stability independently of the map size.
  95909. *
  95910. * It does not account for the light projection as it was having too much
  95911. * instability during the light setup or during light position changes.
  95912. *
  95913. * Only valid if useContactHardeningShadow is true.
  95914. */
  95915. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  95916. protected _darkness: number;
  95917. /** Gets or sets the actual darkness of a shadow */
  95918. get darkness(): number;
  95919. set darkness(value: number);
  95920. /**
  95921. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  95922. * 0 means strongest and 1 would means no shadow.
  95923. * @returns the darkness.
  95924. */
  95925. getDarkness(): number;
  95926. /**
  95927. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  95928. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  95929. * @returns the shadow generator allowing fluent coding.
  95930. */
  95931. setDarkness(darkness: number): ShadowGenerator;
  95932. protected _transparencyShadow: boolean;
  95933. /** Gets or sets the ability to have transparent shadow */
  95934. get transparencyShadow(): boolean;
  95935. set transparencyShadow(value: boolean);
  95936. /**
  95937. * Sets the ability to have transparent shadow (boolean).
  95938. * @param transparent True if transparent else False
  95939. * @returns the shadow generator allowing fluent coding
  95940. */
  95941. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  95942. /**
  95943. * Enables or disables shadows with varying strength based on the transparency
  95944. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  95945. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  95946. * mesh.visibility * alphaTexture.a
  95947. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  95948. */
  95949. enableSoftTransparentShadow: boolean;
  95950. protected _shadowMap: Nullable<RenderTargetTexture>;
  95951. protected _shadowMap2: Nullable<RenderTargetTexture>;
  95952. /**
  95953. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  95954. * @returns The render target texture if present otherwise, null
  95955. */
  95956. getShadowMap(): Nullable<RenderTargetTexture>;
  95957. /**
  95958. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  95959. * @returns The render target texture if the shadow map is present otherwise, null
  95960. */
  95961. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  95962. /**
  95963. * Gets the class name of that object
  95964. * @returns "ShadowGenerator"
  95965. */
  95966. getClassName(): string;
  95967. /**
  95968. * Helper function to add a mesh and its descendants to the list of shadow casters.
  95969. * @param mesh Mesh to add
  95970. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  95971. * @returns the Shadow Generator itself
  95972. */
  95973. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95974. /**
  95975. * Helper function to remove a mesh and its descendants from the list of shadow casters
  95976. * @param mesh Mesh to remove
  95977. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  95978. * @returns the Shadow Generator itself
  95979. */
  95980. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  95981. /**
  95982. * Controls the extent to which the shadows fade out at the edge of the frustum
  95983. */
  95984. frustumEdgeFalloff: number;
  95985. protected _light: IShadowLight;
  95986. /**
  95987. * Returns the associated light object.
  95988. * @returns the light generating the shadow
  95989. */
  95990. getLight(): IShadowLight;
  95991. /**
  95992. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  95993. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  95994. * It might on the other hand introduce peter panning.
  95995. */
  95996. forceBackFacesOnly: boolean;
  95997. protected _scene: Scene;
  95998. protected _lightDirection: Vector3;
  95999. protected _effect: Effect;
  96000. protected _viewMatrix: Matrix;
  96001. protected _projectionMatrix: Matrix;
  96002. protected _transformMatrix: Matrix;
  96003. protected _cachedPosition: Vector3;
  96004. protected _cachedDirection: Vector3;
  96005. protected _cachedDefines: string;
  96006. protected _currentRenderID: number;
  96007. protected _boxBlurPostprocess: Nullable<PostProcess>;
  96008. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  96009. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  96010. protected _blurPostProcesses: PostProcess[];
  96011. protected _mapSize: number;
  96012. protected _currentFaceIndex: number;
  96013. protected _currentFaceIndexCache: number;
  96014. protected _textureType: number;
  96015. protected _defaultTextureMatrix: Matrix;
  96016. protected _storedUniqueId: Nullable<number>;
  96017. /** @hidden */
  96018. static _SceneComponentInitialization: (scene: Scene) => void;
  96019. /**
  96020. * Creates a ShadowGenerator object.
  96021. * A ShadowGenerator is the required tool to use the shadows.
  96022. * Each light casting shadows needs to use its own ShadowGenerator.
  96023. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  96024. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  96025. * @param light The light object generating the shadows.
  96026. * @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.
  96027. */
  96028. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  96029. protected _initializeGenerator(): void;
  96030. protected _createTargetRenderTexture(): void;
  96031. protected _initializeShadowMap(): void;
  96032. protected _initializeBlurRTTAndPostProcesses(): void;
  96033. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  96034. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  96035. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  96036. protected _applyFilterValues(): void;
  96037. /**
  96038. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96039. * @param onCompiled Callback triggered at the and of the effects compilation
  96040. * @param options Sets of optional options forcing the compilation with different modes
  96041. */
  96042. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  96043. useInstances: boolean;
  96044. }>): void;
  96045. /**
  96046. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  96047. * @param options Sets of optional options forcing the compilation with different modes
  96048. * @returns A promise that resolves when the compilation completes
  96049. */
  96050. forceCompilationAsync(options?: Partial<{
  96051. useInstances: boolean;
  96052. }>): Promise<void>;
  96053. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  96054. private _prepareShadowDefines;
  96055. /**
  96056. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  96057. * @param subMesh The submesh we want to render in the shadow map
  96058. * @param useInstances Defines wether will draw in the map using instances
  96059. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  96060. * @returns true if ready otherwise, false
  96061. */
  96062. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  96063. /**
  96064. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  96065. * @param defines Defines of the material we want to update
  96066. * @param lightIndex Index of the light in the enabled light list of the material
  96067. */
  96068. prepareDefines(defines: any, lightIndex: number): void;
  96069. /**
  96070. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  96071. * defined in the generator but impacting the effect).
  96072. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  96073. * @param effect The effect we are binfing the information for
  96074. */
  96075. bindShadowLight(lightIndex: string, effect: Effect): void;
  96076. /**
  96077. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  96078. * (eq to shadow prjection matrix * light transform matrix)
  96079. * @returns The transform matrix used to create the shadow map
  96080. */
  96081. getTransformMatrix(): Matrix;
  96082. /**
  96083. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  96084. * Cube and 2D textures for instance.
  96085. */
  96086. recreateShadowMap(): void;
  96087. protected _disposeBlurPostProcesses(): void;
  96088. protected _disposeRTTandPostProcesses(): void;
  96089. /**
  96090. * Disposes the ShadowGenerator.
  96091. * Returns nothing.
  96092. */
  96093. dispose(): void;
  96094. /**
  96095. * Serializes the shadow generator setup to a json object.
  96096. * @returns The serialized JSON object
  96097. */
  96098. serialize(): any;
  96099. /**
  96100. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  96101. * @param parsedShadowGenerator The JSON object to parse
  96102. * @param scene The scene to create the shadow map for
  96103. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  96104. * @returns The parsed shadow generator
  96105. */
  96106. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  96107. }
  96108. }
  96109. declare module BABYLON {
  96110. /**
  96111. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  96112. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  96113. * 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.
  96114. */
  96115. export abstract class Light extends Node {
  96116. /**
  96117. * Falloff Default: light is falling off following the material specification:
  96118. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  96119. */
  96120. static readonly FALLOFF_DEFAULT: number;
  96121. /**
  96122. * Falloff Physical: light is falling off following the inverse squared distance law.
  96123. */
  96124. static readonly FALLOFF_PHYSICAL: number;
  96125. /**
  96126. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  96127. * to enhance interoperability with other engines.
  96128. */
  96129. static readonly FALLOFF_GLTF: number;
  96130. /**
  96131. * Falloff Standard: light is falling off like in the standard material
  96132. * to enhance interoperability with other materials.
  96133. */
  96134. static readonly FALLOFF_STANDARD: number;
  96135. /**
  96136. * If every light affecting the material is in this lightmapMode,
  96137. * material.lightmapTexture adds or multiplies
  96138. * (depends on material.useLightmapAsShadowmap)
  96139. * after every other light calculations.
  96140. */
  96141. static readonly LIGHTMAP_DEFAULT: number;
  96142. /**
  96143. * material.lightmapTexture as only diffuse lighting from this light
  96144. * adds only specular lighting from this light
  96145. * adds dynamic shadows
  96146. */
  96147. static readonly LIGHTMAP_SPECULAR: number;
  96148. /**
  96149. * material.lightmapTexture as only lighting
  96150. * no light calculation from this light
  96151. * only adds dynamic shadows from this light
  96152. */
  96153. static readonly LIGHTMAP_SHADOWSONLY: number;
  96154. /**
  96155. * Each light type uses the default quantity according to its type:
  96156. * point/spot lights use luminous intensity
  96157. * directional lights use illuminance
  96158. */
  96159. static readonly INTENSITYMODE_AUTOMATIC: number;
  96160. /**
  96161. * lumen (lm)
  96162. */
  96163. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  96164. /**
  96165. * candela (lm/sr)
  96166. */
  96167. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  96168. /**
  96169. * lux (lm/m^2)
  96170. */
  96171. static readonly INTENSITYMODE_ILLUMINANCE: number;
  96172. /**
  96173. * nit (cd/m^2)
  96174. */
  96175. static readonly INTENSITYMODE_LUMINANCE: number;
  96176. /**
  96177. * Light type const id of the point light.
  96178. */
  96179. static readonly LIGHTTYPEID_POINTLIGHT: number;
  96180. /**
  96181. * Light type const id of the directional light.
  96182. */
  96183. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  96184. /**
  96185. * Light type const id of the spot light.
  96186. */
  96187. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  96188. /**
  96189. * Light type const id of the hemispheric light.
  96190. */
  96191. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  96192. /**
  96193. * Diffuse gives the basic color to an object.
  96194. */
  96195. diffuse: Color3;
  96196. /**
  96197. * Specular produces a highlight color on an object.
  96198. * Note: This is note affecting PBR materials.
  96199. */
  96200. specular: Color3;
  96201. /**
  96202. * Defines the falloff type for this light. This lets overrriding how punctual light are
  96203. * falling off base on range or angle.
  96204. * This can be set to any values in Light.FALLOFF_x.
  96205. *
  96206. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  96207. * other types of materials.
  96208. */
  96209. falloffType: number;
  96210. /**
  96211. * Strength of the light.
  96212. * Note: By default it is define in the framework own unit.
  96213. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  96214. */
  96215. intensity: number;
  96216. private _range;
  96217. protected _inverseSquaredRange: number;
  96218. /**
  96219. * Defines how far from the source the light is impacting in scene units.
  96220. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96221. */
  96222. get range(): number;
  96223. /**
  96224. * Defines how far from the source the light is impacting in scene units.
  96225. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  96226. */
  96227. set range(value: number);
  96228. /**
  96229. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  96230. * of light.
  96231. */
  96232. private _photometricScale;
  96233. private _intensityMode;
  96234. /**
  96235. * Gets the photometric scale used to interpret the intensity.
  96236. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96237. */
  96238. get intensityMode(): number;
  96239. /**
  96240. * Sets the photometric scale used to interpret the intensity.
  96241. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  96242. */
  96243. set intensityMode(value: number);
  96244. private _radius;
  96245. /**
  96246. * Gets the light radius used by PBR Materials to simulate soft area lights.
  96247. */
  96248. get radius(): number;
  96249. /**
  96250. * sets the light radius used by PBR Materials to simulate soft area lights.
  96251. */
  96252. set radius(value: number);
  96253. private _renderPriority;
  96254. /**
  96255. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  96256. * exceeding the number allowed of the materials.
  96257. */
  96258. renderPriority: number;
  96259. private _shadowEnabled;
  96260. /**
  96261. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96262. * the current shadow generator.
  96263. */
  96264. get shadowEnabled(): boolean;
  96265. /**
  96266. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  96267. * the current shadow generator.
  96268. */
  96269. set shadowEnabled(value: boolean);
  96270. private _includedOnlyMeshes;
  96271. /**
  96272. * Gets the only meshes impacted by this light.
  96273. */
  96274. get includedOnlyMeshes(): AbstractMesh[];
  96275. /**
  96276. * Sets the only meshes impacted by this light.
  96277. */
  96278. set includedOnlyMeshes(value: AbstractMesh[]);
  96279. private _excludedMeshes;
  96280. /**
  96281. * Gets the meshes not impacted by this light.
  96282. */
  96283. get excludedMeshes(): AbstractMesh[];
  96284. /**
  96285. * Sets the meshes not impacted by this light.
  96286. */
  96287. set excludedMeshes(value: AbstractMesh[]);
  96288. private _excludeWithLayerMask;
  96289. /**
  96290. * Gets the layer id use to find what meshes are not impacted by the light.
  96291. * Inactive if 0
  96292. */
  96293. get excludeWithLayerMask(): number;
  96294. /**
  96295. * Sets the layer id use to find what meshes are not impacted by the light.
  96296. * Inactive if 0
  96297. */
  96298. set excludeWithLayerMask(value: number);
  96299. private _includeOnlyWithLayerMask;
  96300. /**
  96301. * Gets the layer id use to find what meshes are impacted by the light.
  96302. * Inactive if 0
  96303. */
  96304. get includeOnlyWithLayerMask(): number;
  96305. /**
  96306. * Sets the layer id use to find what meshes are impacted by the light.
  96307. * Inactive if 0
  96308. */
  96309. set includeOnlyWithLayerMask(value: number);
  96310. private _lightmapMode;
  96311. /**
  96312. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96313. */
  96314. get lightmapMode(): number;
  96315. /**
  96316. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  96317. */
  96318. set lightmapMode(value: number);
  96319. /**
  96320. * Shadow generator associted to the light.
  96321. * @hidden Internal use only.
  96322. */
  96323. _shadowGenerator: Nullable<IShadowGenerator>;
  96324. /**
  96325. * @hidden Internal use only.
  96326. */
  96327. _excludedMeshesIds: string[];
  96328. /**
  96329. * @hidden Internal use only.
  96330. */
  96331. _includedOnlyMeshesIds: string[];
  96332. /**
  96333. * The current light unifom buffer.
  96334. * @hidden Internal use only.
  96335. */
  96336. _uniformBuffer: UniformBuffer;
  96337. /** @hidden */
  96338. _renderId: number;
  96339. /**
  96340. * Creates a Light object in the scene.
  96341. * Documentation : https://doc.babylonjs.com/babylon101/lights
  96342. * @param name The firendly name of the light
  96343. * @param scene The scene the light belongs too
  96344. */
  96345. constructor(name: string, scene: Scene);
  96346. protected abstract _buildUniformLayout(): void;
  96347. /**
  96348. * Sets the passed Effect "effect" with the Light information.
  96349. * @param effect The effect to update
  96350. * @param lightIndex The index of the light in the effect to update
  96351. * @returns The light
  96352. */
  96353. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  96354. /**
  96355. * Sets the passed Effect "effect" with the Light textures.
  96356. * @param effect The effect to update
  96357. * @param lightIndex The index of the light in the effect to update
  96358. * @returns The light
  96359. */
  96360. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  96361. /**
  96362. * Binds the lights information from the scene to the effect for the given mesh.
  96363. * @param lightIndex Light index
  96364. * @param scene The scene where the light belongs to
  96365. * @param effect The effect we are binding the data to
  96366. * @param useSpecular Defines if specular is supported
  96367. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  96368. */
  96369. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  96370. /**
  96371. * Sets the passed Effect "effect" with the Light information.
  96372. * @param effect The effect to update
  96373. * @param lightDataUniformName The uniform used to store light data (position or direction)
  96374. * @returns The light
  96375. */
  96376. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  96377. /**
  96378. * Returns the string "Light".
  96379. * @returns the class name
  96380. */
  96381. getClassName(): string;
  96382. /** @hidden */
  96383. readonly _isLight: boolean;
  96384. /**
  96385. * Converts the light information to a readable string for debug purpose.
  96386. * @param fullDetails Supports for multiple levels of logging within scene loading
  96387. * @returns the human readable light info
  96388. */
  96389. toString(fullDetails?: boolean): string;
  96390. /** @hidden */
  96391. protected _syncParentEnabledState(): void;
  96392. /**
  96393. * Set the enabled state of this node.
  96394. * @param value - the new enabled state
  96395. */
  96396. setEnabled(value: boolean): void;
  96397. /**
  96398. * Returns the Light associated shadow generator if any.
  96399. * @return the associated shadow generator.
  96400. */
  96401. getShadowGenerator(): Nullable<IShadowGenerator>;
  96402. /**
  96403. * Returns a Vector3, the absolute light position in the World.
  96404. * @returns the world space position of the light
  96405. */
  96406. getAbsolutePosition(): Vector3;
  96407. /**
  96408. * Specifies if the light will affect the passed mesh.
  96409. * @param mesh The mesh to test against the light
  96410. * @return true the mesh is affected otherwise, false.
  96411. */
  96412. canAffectMesh(mesh: AbstractMesh): boolean;
  96413. /**
  96414. * Sort function to order lights for rendering.
  96415. * @param a First Light object to compare to second.
  96416. * @param b Second Light object to compare first.
  96417. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  96418. */
  96419. static CompareLightsPriority(a: Light, b: Light): number;
  96420. /**
  96421. * Releases resources associated with this node.
  96422. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  96423. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  96424. */
  96425. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96426. /**
  96427. * Returns the light type ID (integer).
  96428. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  96429. */
  96430. getTypeID(): number;
  96431. /**
  96432. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  96433. * @returns the scaled intensity in intensity mode unit
  96434. */
  96435. getScaledIntensity(): number;
  96436. /**
  96437. * Returns a new Light object, named "name", from the current one.
  96438. * @param name The name of the cloned light
  96439. * @param newParent The parent of this light, if it has one
  96440. * @returns the new created light
  96441. */
  96442. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  96443. /**
  96444. * Serializes the current light into a Serialization object.
  96445. * @returns the serialized object.
  96446. */
  96447. serialize(): any;
  96448. /**
  96449. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  96450. * This new light is named "name" and added to the passed scene.
  96451. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  96452. * @param name The friendly name of the light
  96453. * @param scene The scene the new light will belong to
  96454. * @returns the constructor function
  96455. */
  96456. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  96457. /**
  96458. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  96459. * @param parsedLight The JSON representation of the light
  96460. * @param scene The scene to create the parsed light in
  96461. * @returns the created light after parsing
  96462. */
  96463. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  96464. private _hookArrayForExcluded;
  96465. private _hookArrayForIncludedOnly;
  96466. private _resyncMeshes;
  96467. /**
  96468. * Forces the meshes to update their light related information in their rendering used effects
  96469. * @hidden Internal Use Only
  96470. */
  96471. _markMeshesAsLightDirty(): void;
  96472. /**
  96473. * Recomputes the cached photometric scale if needed.
  96474. */
  96475. private _computePhotometricScale;
  96476. /**
  96477. * Returns the Photometric Scale according to the light type and intensity mode.
  96478. */
  96479. private _getPhotometricScale;
  96480. /**
  96481. * Reorder the light in the scene according to their defined priority.
  96482. * @hidden Internal Use Only
  96483. */
  96484. _reorderLightsInScene(): void;
  96485. /**
  96486. * Prepares the list of defines specific to the light type.
  96487. * @param defines the list of defines
  96488. * @param lightIndex defines the index of the light for the effect
  96489. */
  96490. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  96491. }
  96492. }
  96493. declare module BABYLON {
  96494. /**
  96495. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  96496. * This is the base of the follow, arc rotate cameras and Free camera
  96497. * @see https://doc.babylonjs.com/features/cameras
  96498. */
  96499. export class TargetCamera extends Camera {
  96500. private static _RigCamTransformMatrix;
  96501. private static _TargetTransformMatrix;
  96502. private static _TargetFocalPoint;
  96503. private _tmpUpVector;
  96504. private _tmpTargetVector;
  96505. /**
  96506. * Define the current direction the camera is moving to
  96507. */
  96508. cameraDirection: Vector3;
  96509. /**
  96510. * Define the current rotation the camera is rotating to
  96511. */
  96512. cameraRotation: Vector2;
  96513. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  96514. ignoreParentScaling: boolean;
  96515. /**
  96516. * When set, the up vector of the camera will be updated by the rotation of the camera
  96517. */
  96518. updateUpVectorFromRotation: boolean;
  96519. private _tmpQuaternion;
  96520. /**
  96521. * Define the current rotation of the camera
  96522. */
  96523. rotation: Vector3;
  96524. /**
  96525. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  96526. */
  96527. rotationQuaternion: Quaternion;
  96528. /**
  96529. * Define the current speed of the camera
  96530. */
  96531. speed: number;
  96532. /**
  96533. * Add constraint to the camera to prevent it to move freely in all directions and
  96534. * around all axis.
  96535. */
  96536. noRotationConstraint: boolean;
  96537. /**
  96538. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  96539. * panning
  96540. */
  96541. invertRotation: boolean;
  96542. /**
  96543. * Speed multiplier for inverse camera panning
  96544. */
  96545. inverseRotationSpeed: number;
  96546. /**
  96547. * Define the current target of the camera as an object or a position.
  96548. */
  96549. lockedTarget: any;
  96550. /** @hidden */
  96551. _currentTarget: Vector3;
  96552. /** @hidden */
  96553. _initialFocalDistance: number;
  96554. /** @hidden */
  96555. _viewMatrix: Matrix;
  96556. /** @hidden */
  96557. _camMatrix: Matrix;
  96558. /** @hidden */
  96559. _cameraTransformMatrix: Matrix;
  96560. /** @hidden */
  96561. _cameraRotationMatrix: Matrix;
  96562. /** @hidden */
  96563. _referencePoint: Vector3;
  96564. /** @hidden */
  96565. _transformedReferencePoint: Vector3;
  96566. /** @hidden */
  96567. _reset: () => void;
  96568. private _defaultUp;
  96569. /**
  96570. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  96571. * This is the base of the follow, arc rotate cameras and Free camera
  96572. * @see https://doc.babylonjs.com/features/cameras
  96573. * @param name Defines the name of the camera in the scene
  96574. * @param position Defines the start position of the camera in the scene
  96575. * @param scene Defines the scene the camera belongs to
  96576. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  96577. */
  96578. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  96579. /**
  96580. * Gets the position in front of the camera at a given distance.
  96581. * @param distance The distance from the camera we want the position to be
  96582. * @returns the position
  96583. */
  96584. getFrontPosition(distance: number): Vector3;
  96585. /** @hidden */
  96586. _getLockedTargetPosition(): Nullable<Vector3>;
  96587. private _storedPosition;
  96588. private _storedRotation;
  96589. private _storedRotationQuaternion;
  96590. /**
  96591. * Store current camera state of the camera (fov, position, rotation, etc..)
  96592. * @returns the camera
  96593. */
  96594. storeState(): Camera;
  96595. /**
  96596. * Restored camera state. You must call storeState() first
  96597. * @returns whether it was successful or not
  96598. * @hidden
  96599. */
  96600. _restoreStateValues(): boolean;
  96601. /** @hidden */
  96602. _initCache(): void;
  96603. /** @hidden */
  96604. _updateCache(ignoreParentClass?: boolean): void;
  96605. /** @hidden */
  96606. _isSynchronizedViewMatrix(): boolean;
  96607. /** @hidden */
  96608. _computeLocalCameraSpeed(): number;
  96609. /**
  96610. * Defines the target the camera should look at.
  96611. * @param target Defines the new target as a Vector or a mesh
  96612. */
  96613. setTarget(target: Vector3): void;
  96614. /**
  96615. * Return the current target position of the camera. This value is expressed in local space.
  96616. * @returns the target position
  96617. */
  96618. getTarget(): Vector3;
  96619. /** @hidden */
  96620. _decideIfNeedsToMove(): boolean;
  96621. /** @hidden */
  96622. _updatePosition(): void;
  96623. /** @hidden */
  96624. _checkInputs(): void;
  96625. protected _updateCameraRotationMatrix(): void;
  96626. /**
  96627. * 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)
  96628. * @returns the current camera
  96629. */
  96630. private _rotateUpVectorWithCameraRotationMatrix;
  96631. private _cachedRotationZ;
  96632. private _cachedQuaternionRotationZ;
  96633. /** @hidden */
  96634. _getViewMatrix(): Matrix;
  96635. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  96636. /**
  96637. * @hidden
  96638. */
  96639. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  96640. /**
  96641. * @hidden
  96642. */
  96643. _updateRigCameras(): void;
  96644. private _getRigCamPositionAndTarget;
  96645. /**
  96646. * Gets the current object class name.
  96647. * @return the class name
  96648. */
  96649. getClassName(): string;
  96650. }
  96651. }
  96652. declare module BABYLON {
  96653. /**
  96654. * Gather the list of keyboard event types as constants.
  96655. */
  96656. export class KeyboardEventTypes {
  96657. /**
  96658. * The keydown event is fired when a key becomes active (pressed).
  96659. */
  96660. static readonly KEYDOWN: number;
  96661. /**
  96662. * The keyup event is fired when a key has been released.
  96663. */
  96664. static readonly KEYUP: number;
  96665. }
  96666. /**
  96667. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96668. */
  96669. export class KeyboardInfo {
  96670. /**
  96671. * Defines the type of event (KeyboardEventTypes)
  96672. */
  96673. type: number;
  96674. /**
  96675. * Defines the related dom event
  96676. */
  96677. event: KeyboardEvent;
  96678. /**
  96679. * Instantiates a new keyboard info.
  96680. * This class is used to store keyboard related info for the onKeyboardObservable event.
  96681. * @param type Defines the type of event (KeyboardEventTypes)
  96682. * @param event Defines the related dom event
  96683. */
  96684. constructor(
  96685. /**
  96686. * Defines the type of event (KeyboardEventTypes)
  96687. */
  96688. type: number,
  96689. /**
  96690. * Defines the related dom event
  96691. */
  96692. event: KeyboardEvent);
  96693. }
  96694. /**
  96695. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96696. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  96697. */
  96698. export class KeyboardInfoPre extends KeyboardInfo {
  96699. /**
  96700. * Defines the type of event (KeyboardEventTypes)
  96701. */
  96702. type: number;
  96703. /**
  96704. * Defines the related dom event
  96705. */
  96706. event: KeyboardEvent;
  96707. /**
  96708. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  96709. */
  96710. skipOnPointerObservable: boolean;
  96711. /**
  96712. * Instantiates a new keyboard pre info.
  96713. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  96714. * @param type Defines the type of event (KeyboardEventTypes)
  96715. * @param event Defines the related dom event
  96716. */
  96717. constructor(
  96718. /**
  96719. * Defines the type of event (KeyboardEventTypes)
  96720. */
  96721. type: number,
  96722. /**
  96723. * Defines the related dom event
  96724. */
  96725. event: KeyboardEvent);
  96726. }
  96727. }
  96728. declare module BABYLON {
  96729. /**
  96730. * Manage the keyboard inputs to control the movement of a free camera.
  96731. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96732. */
  96733. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  96734. /**
  96735. * Defines the camera the input is attached to.
  96736. */
  96737. camera: FreeCamera;
  96738. /**
  96739. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  96740. */
  96741. keysUp: number[];
  96742. /**
  96743. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  96744. */
  96745. keysUpward: number[];
  96746. /**
  96747. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  96748. */
  96749. keysDown: number[];
  96750. /**
  96751. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  96752. */
  96753. keysDownward: number[];
  96754. /**
  96755. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  96756. */
  96757. keysLeft: number[];
  96758. /**
  96759. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  96760. */
  96761. keysRight: number[];
  96762. private _keys;
  96763. private _onCanvasBlurObserver;
  96764. private _onKeyboardObserver;
  96765. private _engine;
  96766. private _scene;
  96767. /**
  96768. * Attach the input controls to a specific dom element to get the input from.
  96769. * @param element Defines the element the controls should be listened from
  96770. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96771. */
  96772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96773. /**
  96774. * Detach the current controls from the specified dom element.
  96775. * @param element Defines the element to stop listening the inputs from
  96776. */
  96777. detachControl(element: Nullable<HTMLElement>): void;
  96778. /**
  96779. * Update the current camera state depending on the inputs that have been used this frame.
  96780. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96781. */
  96782. checkInputs(): void;
  96783. /**
  96784. * Gets the class name of the current intput.
  96785. * @returns the class name
  96786. */
  96787. getClassName(): string;
  96788. /** @hidden */
  96789. _onLostFocus(): void;
  96790. /**
  96791. * Get the friendly name associated with the input class.
  96792. * @returns the input friendly name
  96793. */
  96794. getSimpleName(): string;
  96795. }
  96796. }
  96797. declare module BABYLON {
  96798. /**
  96799. * Gather the list of pointer event types as constants.
  96800. */
  96801. export class PointerEventTypes {
  96802. /**
  96803. * 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.
  96804. */
  96805. static readonly POINTERDOWN: number;
  96806. /**
  96807. * The pointerup event is fired when a pointer is no longer active.
  96808. */
  96809. static readonly POINTERUP: number;
  96810. /**
  96811. * The pointermove event is fired when a pointer changes coordinates.
  96812. */
  96813. static readonly POINTERMOVE: number;
  96814. /**
  96815. * The pointerwheel event is fired when a mouse wheel has been rotated.
  96816. */
  96817. static readonly POINTERWHEEL: number;
  96818. /**
  96819. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  96820. */
  96821. static readonly POINTERPICK: number;
  96822. /**
  96823. * The pointertap event is fired when a the object has been touched and released without drag.
  96824. */
  96825. static readonly POINTERTAP: number;
  96826. /**
  96827. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  96828. */
  96829. static readonly POINTERDOUBLETAP: number;
  96830. }
  96831. /**
  96832. * Base class of pointer info types.
  96833. */
  96834. export class PointerInfoBase {
  96835. /**
  96836. * Defines the type of event (PointerEventTypes)
  96837. */
  96838. type: number;
  96839. /**
  96840. * Defines the related dom event
  96841. */
  96842. event: PointerEvent | MouseWheelEvent;
  96843. /**
  96844. * Instantiates the base class of pointers info.
  96845. * @param type Defines the type of event (PointerEventTypes)
  96846. * @param event Defines the related dom event
  96847. */
  96848. constructor(
  96849. /**
  96850. * Defines the type of event (PointerEventTypes)
  96851. */
  96852. type: number,
  96853. /**
  96854. * Defines the related dom event
  96855. */
  96856. event: PointerEvent | MouseWheelEvent);
  96857. }
  96858. /**
  96859. * This class is used to store pointer related info for the onPrePointerObservable event.
  96860. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  96861. */
  96862. export class PointerInfoPre extends PointerInfoBase {
  96863. /**
  96864. * Ray from a pointer if availible (eg. 6dof controller)
  96865. */
  96866. ray: Nullable<Ray>;
  96867. /**
  96868. * Defines the local position of the pointer on the canvas.
  96869. */
  96870. localPosition: Vector2;
  96871. /**
  96872. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  96873. */
  96874. skipOnPointerObservable: boolean;
  96875. /**
  96876. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  96877. * @param type Defines the type of event (PointerEventTypes)
  96878. * @param event Defines the related dom event
  96879. * @param localX Defines the local x coordinates of the pointer when the event occured
  96880. * @param localY Defines the local y coordinates of the pointer when the event occured
  96881. */
  96882. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  96883. }
  96884. /**
  96885. * This type contains all the data related to a pointer event in Babylon.js.
  96886. * 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.
  96887. */
  96888. export class PointerInfo extends PointerInfoBase {
  96889. /**
  96890. * Defines the picking info associated to the info (if any)\
  96891. */
  96892. pickInfo: Nullable<PickingInfo>;
  96893. /**
  96894. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  96895. * @param type Defines the type of event (PointerEventTypes)
  96896. * @param event Defines the related dom event
  96897. * @param pickInfo Defines the picking info associated to the info (if any)\
  96898. */
  96899. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  96900. /**
  96901. * Defines the picking info associated to the info (if any)\
  96902. */
  96903. pickInfo: Nullable<PickingInfo>);
  96904. }
  96905. /**
  96906. * Data relating to a touch event on the screen.
  96907. */
  96908. export interface PointerTouch {
  96909. /**
  96910. * X coordinate of touch.
  96911. */
  96912. x: number;
  96913. /**
  96914. * Y coordinate of touch.
  96915. */
  96916. y: number;
  96917. /**
  96918. * Id of touch. Unique for each finger.
  96919. */
  96920. pointerId: number;
  96921. /**
  96922. * Event type passed from DOM.
  96923. */
  96924. type: any;
  96925. }
  96926. }
  96927. declare module BABYLON {
  96928. /**
  96929. * Manage the mouse inputs to control the movement of a free camera.
  96930. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96931. */
  96932. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  96933. /**
  96934. * Define if touch is enabled in the mouse input
  96935. */
  96936. touchEnabled: boolean;
  96937. /**
  96938. * Defines the camera the input is attached to.
  96939. */
  96940. camera: FreeCamera;
  96941. /**
  96942. * Defines the buttons associated with the input to handle camera move.
  96943. */
  96944. buttons: number[];
  96945. /**
  96946. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  96947. */
  96948. angularSensibility: number;
  96949. private _pointerInput;
  96950. private _onMouseMove;
  96951. private _observer;
  96952. private previousPosition;
  96953. /**
  96954. * Observable for when a pointer move event occurs containing the move offset
  96955. */
  96956. onPointerMovedObservable: Observable<{
  96957. offsetX: number;
  96958. offsetY: number;
  96959. }>;
  96960. /**
  96961. * @hidden
  96962. * If the camera should be rotated automatically based on pointer movement
  96963. */
  96964. _allowCameraRotation: boolean;
  96965. /**
  96966. * Manage the mouse inputs to control the movement of a free camera.
  96967. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  96968. * @param touchEnabled Defines if touch is enabled or not
  96969. */
  96970. constructor(
  96971. /**
  96972. * Define if touch is enabled in the mouse input
  96973. */
  96974. touchEnabled?: boolean);
  96975. /**
  96976. * Attach the input controls to a specific dom element to get the input from.
  96977. * @param element Defines the element the controls should be listened from
  96978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96979. */
  96980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96981. /**
  96982. * Called on JS contextmenu event.
  96983. * Override this method to provide functionality.
  96984. */
  96985. protected onContextMenu(evt: PointerEvent): void;
  96986. /**
  96987. * Detach the current controls from the specified dom element.
  96988. * @param element Defines the element to stop listening the inputs from
  96989. */
  96990. detachControl(element: Nullable<HTMLElement>): void;
  96991. /**
  96992. * Gets the class name of the current intput.
  96993. * @returns the class name
  96994. */
  96995. getClassName(): string;
  96996. /**
  96997. * Get the friendly name associated with the input class.
  96998. * @returns the input friendly name
  96999. */
  97000. getSimpleName(): string;
  97001. }
  97002. }
  97003. declare module BABYLON {
  97004. /**
  97005. * Manage the touch inputs to control the movement of a free camera.
  97006. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97007. */
  97008. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  97009. /**
  97010. * Defines the camera the input is attached to.
  97011. */
  97012. camera: FreeCamera;
  97013. /**
  97014. * Defines the touch sensibility for rotation.
  97015. * The higher the faster.
  97016. */
  97017. touchAngularSensibility: number;
  97018. /**
  97019. * Defines the touch sensibility for move.
  97020. * The higher the faster.
  97021. */
  97022. touchMoveSensibility: number;
  97023. private _offsetX;
  97024. private _offsetY;
  97025. private _pointerPressed;
  97026. private _pointerInput;
  97027. private _observer;
  97028. private _onLostFocus;
  97029. /**
  97030. * Attach the input controls to a specific dom element to get the input from.
  97031. * @param element Defines the element the controls should be listened from
  97032. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97033. */
  97034. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97035. /**
  97036. * Detach the current controls from the specified dom element.
  97037. * @param element Defines the element to stop listening the inputs from
  97038. */
  97039. detachControl(element: Nullable<HTMLElement>): void;
  97040. /**
  97041. * Update the current camera state depending on the inputs that have been used this frame.
  97042. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97043. */
  97044. checkInputs(): void;
  97045. /**
  97046. * Gets the class name of the current intput.
  97047. * @returns the class name
  97048. */
  97049. getClassName(): string;
  97050. /**
  97051. * Get the friendly name associated with the input class.
  97052. * @returns the input friendly name
  97053. */
  97054. getSimpleName(): string;
  97055. }
  97056. }
  97057. declare module BABYLON {
  97058. /**
  97059. * Default Inputs manager for the FreeCamera.
  97060. * It groups all the default supported inputs for ease of use.
  97061. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  97062. */
  97063. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  97064. /**
  97065. * @hidden
  97066. */
  97067. _mouseInput: Nullable<FreeCameraMouseInput>;
  97068. /**
  97069. * Instantiates a new FreeCameraInputsManager.
  97070. * @param camera Defines the camera the inputs belong to
  97071. */
  97072. constructor(camera: FreeCamera);
  97073. /**
  97074. * Add keyboard input support to the input manager.
  97075. * @returns the current input manager
  97076. */
  97077. addKeyboard(): FreeCameraInputsManager;
  97078. /**
  97079. * Add mouse input support to the input manager.
  97080. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  97081. * @returns the current input manager
  97082. */
  97083. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  97084. /**
  97085. * Removes the mouse input support from the manager
  97086. * @returns the current input manager
  97087. */
  97088. removeMouse(): FreeCameraInputsManager;
  97089. /**
  97090. * Add touch input support to the input manager.
  97091. * @returns the current input manager
  97092. */
  97093. addTouch(): FreeCameraInputsManager;
  97094. /**
  97095. * Remove all attached input methods from a camera
  97096. */
  97097. clear(): void;
  97098. }
  97099. }
  97100. declare module BABYLON {
  97101. /**
  97102. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97103. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  97104. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97105. */
  97106. export class FreeCamera extends TargetCamera {
  97107. /**
  97108. * Define the collision ellipsoid of the camera.
  97109. * This is helpful to simulate a camera body like the player body around the camera
  97110. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97111. */
  97112. ellipsoid: Vector3;
  97113. /**
  97114. * Define an offset for the position of the ellipsoid around the camera.
  97115. * This can be helpful to determine the center of the body near the gravity center of the body
  97116. * instead of its head.
  97117. */
  97118. ellipsoidOffset: Vector3;
  97119. /**
  97120. * Enable or disable collisions of the camera with the rest of the scene objects.
  97121. */
  97122. checkCollisions: boolean;
  97123. /**
  97124. * Enable or disable gravity on the camera.
  97125. */
  97126. applyGravity: boolean;
  97127. /**
  97128. * Define the input manager associated to the camera.
  97129. */
  97130. inputs: FreeCameraInputsManager;
  97131. /**
  97132. * Gets the input sensibility for a mouse input. (default is 2000.0)
  97133. * Higher values reduce sensitivity.
  97134. */
  97135. get angularSensibility(): number;
  97136. /**
  97137. * Sets the input sensibility for a mouse input. (default is 2000.0)
  97138. * Higher values reduce sensitivity.
  97139. */
  97140. set angularSensibility(value: number);
  97141. /**
  97142. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  97143. */
  97144. get keysUp(): number[];
  97145. set keysUp(value: number[]);
  97146. /**
  97147. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  97148. */
  97149. get keysUpward(): number[];
  97150. set keysUpward(value: number[]);
  97151. /**
  97152. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  97153. */
  97154. get keysDown(): number[];
  97155. set keysDown(value: number[]);
  97156. /**
  97157. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  97158. */
  97159. get keysDownward(): number[];
  97160. set keysDownward(value: number[]);
  97161. /**
  97162. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  97163. */
  97164. get keysLeft(): number[];
  97165. set keysLeft(value: number[]);
  97166. /**
  97167. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  97168. */
  97169. get keysRight(): number[];
  97170. set keysRight(value: number[]);
  97171. /**
  97172. * Event raised when the camera collide with a mesh in the scene.
  97173. */
  97174. onCollide: (collidedMesh: AbstractMesh) => void;
  97175. private _collider;
  97176. private _needMoveForGravity;
  97177. private _oldPosition;
  97178. private _diffPosition;
  97179. private _newPosition;
  97180. /** @hidden */
  97181. _localDirection: Vector3;
  97182. /** @hidden */
  97183. _transformedDirection: Vector3;
  97184. /**
  97185. * Instantiates a Free Camera.
  97186. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97187. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  97188. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  97189. * @param name Define the name of the camera in the scene
  97190. * @param position Define the start position of the camera in the scene
  97191. * @param scene Define the scene the camera belongs to
  97192. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97193. */
  97194. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97195. /**
  97196. * Attached controls to the current camera.
  97197. * @param element Defines the element the controls should be listened from
  97198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97199. */
  97200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97201. /**
  97202. * Detach the current controls from the camera.
  97203. * The camera will stop reacting to inputs.
  97204. * @param element Defines the element to stop listening the inputs from
  97205. */
  97206. detachControl(element: HTMLElement): void;
  97207. private _collisionMask;
  97208. /**
  97209. * Define a collision mask to limit the list of object the camera can collide with
  97210. */
  97211. get collisionMask(): number;
  97212. set collisionMask(mask: number);
  97213. /** @hidden */
  97214. _collideWithWorld(displacement: Vector3): void;
  97215. private _onCollisionPositionChange;
  97216. /** @hidden */
  97217. _checkInputs(): void;
  97218. /** @hidden */
  97219. _decideIfNeedsToMove(): boolean;
  97220. /** @hidden */
  97221. _updatePosition(): void;
  97222. /**
  97223. * Destroy the camera and release the current resources hold by it.
  97224. */
  97225. dispose(): void;
  97226. /**
  97227. * Gets the current object class name.
  97228. * @return the class name
  97229. */
  97230. getClassName(): string;
  97231. }
  97232. }
  97233. declare module BABYLON {
  97234. /**
  97235. * Represents a gamepad control stick position
  97236. */
  97237. export class StickValues {
  97238. /**
  97239. * The x component of the control stick
  97240. */
  97241. x: number;
  97242. /**
  97243. * The y component of the control stick
  97244. */
  97245. y: number;
  97246. /**
  97247. * Initializes the gamepad x and y control stick values
  97248. * @param x The x component of the gamepad control stick value
  97249. * @param y The y component of the gamepad control stick value
  97250. */
  97251. constructor(
  97252. /**
  97253. * The x component of the control stick
  97254. */
  97255. x: number,
  97256. /**
  97257. * The y component of the control stick
  97258. */
  97259. y: number);
  97260. }
  97261. /**
  97262. * An interface which manages callbacks for gamepad button changes
  97263. */
  97264. export interface GamepadButtonChanges {
  97265. /**
  97266. * Called when a gamepad has been changed
  97267. */
  97268. changed: boolean;
  97269. /**
  97270. * Called when a gamepad press event has been triggered
  97271. */
  97272. pressChanged: boolean;
  97273. /**
  97274. * Called when a touch event has been triggered
  97275. */
  97276. touchChanged: boolean;
  97277. /**
  97278. * Called when a value has changed
  97279. */
  97280. valueChanged: boolean;
  97281. }
  97282. /**
  97283. * Represents a gamepad
  97284. */
  97285. export class Gamepad {
  97286. /**
  97287. * The id of the gamepad
  97288. */
  97289. id: string;
  97290. /**
  97291. * The index of the gamepad
  97292. */
  97293. index: number;
  97294. /**
  97295. * The browser gamepad
  97296. */
  97297. browserGamepad: any;
  97298. /**
  97299. * Specifies what type of gamepad this represents
  97300. */
  97301. type: number;
  97302. private _leftStick;
  97303. private _rightStick;
  97304. /** @hidden */
  97305. _isConnected: boolean;
  97306. private _leftStickAxisX;
  97307. private _leftStickAxisY;
  97308. private _rightStickAxisX;
  97309. private _rightStickAxisY;
  97310. /**
  97311. * Triggered when the left control stick has been changed
  97312. */
  97313. private _onleftstickchanged;
  97314. /**
  97315. * Triggered when the right control stick has been changed
  97316. */
  97317. private _onrightstickchanged;
  97318. /**
  97319. * Represents a gamepad controller
  97320. */
  97321. static GAMEPAD: number;
  97322. /**
  97323. * Represents a generic controller
  97324. */
  97325. static GENERIC: number;
  97326. /**
  97327. * Represents an XBox controller
  97328. */
  97329. static XBOX: number;
  97330. /**
  97331. * Represents a pose-enabled controller
  97332. */
  97333. static POSE_ENABLED: number;
  97334. /**
  97335. * Represents an Dual Shock controller
  97336. */
  97337. static DUALSHOCK: number;
  97338. /**
  97339. * Specifies whether the left control stick should be Y-inverted
  97340. */
  97341. protected _invertLeftStickY: boolean;
  97342. /**
  97343. * Specifies if the gamepad has been connected
  97344. */
  97345. get isConnected(): boolean;
  97346. /**
  97347. * Initializes the gamepad
  97348. * @param id The id of the gamepad
  97349. * @param index The index of the gamepad
  97350. * @param browserGamepad The browser gamepad
  97351. * @param leftStickX The x component of the left joystick
  97352. * @param leftStickY The y component of the left joystick
  97353. * @param rightStickX The x component of the right joystick
  97354. * @param rightStickY The y component of the right joystick
  97355. */
  97356. constructor(
  97357. /**
  97358. * The id of the gamepad
  97359. */
  97360. id: string,
  97361. /**
  97362. * The index of the gamepad
  97363. */
  97364. index: number,
  97365. /**
  97366. * The browser gamepad
  97367. */
  97368. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  97369. /**
  97370. * Callback triggered when the left joystick has changed
  97371. * @param callback
  97372. */
  97373. onleftstickchanged(callback: (values: StickValues) => void): void;
  97374. /**
  97375. * Callback triggered when the right joystick has changed
  97376. * @param callback
  97377. */
  97378. onrightstickchanged(callback: (values: StickValues) => void): void;
  97379. /**
  97380. * Gets the left joystick
  97381. */
  97382. get leftStick(): StickValues;
  97383. /**
  97384. * Sets the left joystick values
  97385. */
  97386. set leftStick(newValues: StickValues);
  97387. /**
  97388. * Gets the right joystick
  97389. */
  97390. get rightStick(): StickValues;
  97391. /**
  97392. * Sets the right joystick value
  97393. */
  97394. set rightStick(newValues: StickValues);
  97395. /**
  97396. * Updates the gamepad joystick positions
  97397. */
  97398. update(): void;
  97399. /**
  97400. * Disposes the gamepad
  97401. */
  97402. dispose(): void;
  97403. }
  97404. /**
  97405. * Represents a generic gamepad
  97406. */
  97407. export class GenericPad extends Gamepad {
  97408. private _buttons;
  97409. private _onbuttondown;
  97410. private _onbuttonup;
  97411. /**
  97412. * Observable triggered when a button has been pressed
  97413. */
  97414. onButtonDownObservable: Observable<number>;
  97415. /**
  97416. * Observable triggered when a button has been released
  97417. */
  97418. onButtonUpObservable: Observable<number>;
  97419. /**
  97420. * Callback triggered when a button has been pressed
  97421. * @param callback Called when a button has been pressed
  97422. */
  97423. onbuttondown(callback: (buttonPressed: number) => void): void;
  97424. /**
  97425. * Callback triggered when a button has been released
  97426. * @param callback Called when a button has been released
  97427. */
  97428. onbuttonup(callback: (buttonReleased: number) => void): void;
  97429. /**
  97430. * Initializes the generic gamepad
  97431. * @param id The id of the generic gamepad
  97432. * @param index The index of the generic gamepad
  97433. * @param browserGamepad The browser gamepad
  97434. */
  97435. constructor(id: string, index: number, browserGamepad: any);
  97436. private _setButtonValue;
  97437. /**
  97438. * Updates the generic gamepad
  97439. */
  97440. update(): void;
  97441. /**
  97442. * Disposes the generic gamepad
  97443. */
  97444. dispose(): void;
  97445. }
  97446. }
  97447. declare module BABYLON {
  97448. /**
  97449. * Defines the types of pose enabled controllers that are supported
  97450. */
  97451. export enum PoseEnabledControllerType {
  97452. /**
  97453. * HTC Vive
  97454. */
  97455. VIVE = 0,
  97456. /**
  97457. * Oculus Rift
  97458. */
  97459. OCULUS = 1,
  97460. /**
  97461. * Windows mixed reality
  97462. */
  97463. WINDOWS = 2,
  97464. /**
  97465. * Samsung gear VR
  97466. */
  97467. GEAR_VR = 3,
  97468. /**
  97469. * Google Daydream
  97470. */
  97471. DAYDREAM = 4,
  97472. /**
  97473. * Generic
  97474. */
  97475. GENERIC = 5
  97476. }
  97477. /**
  97478. * Defines the MutableGamepadButton interface for the state of a gamepad button
  97479. */
  97480. export interface MutableGamepadButton {
  97481. /**
  97482. * Value of the button/trigger
  97483. */
  97484. value: number;
  97485. /**
  97486. * If the button/trigger is currently touched
  97487. */
  97488. touched: boolean;
  97489. /**
  97490. * If the button/trigger is currently pressed
  97491. */
  97492. pressed: boolean;
  97493. }
  97494. /**
  97495. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  97496. * @hidden
  97497. */
  97498. export interface ExtendedGamepadButton extends GamepadButton {
  97499. /**
  97500. * If the button/trigger is currently pressed
  97501. */
  97502. readonly pressed: boolean;
  97503. /**
  97504. * If the button/trigger is currently touched
  97505. */
  97506. readonly touched: boolean;
  97507. /**
  97508. * Value of the button/trigger
  97509. */
  97510. readonly value: number;
  97511. }
  97512. /** @hidden */
  97513. export interface _GamePadFactory {
  97514. /**
  97515. * Returns whether or not the current gamepad can be created for this type of controller.
  97516. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97517. * @returns true if it can be created, otherwise false
  97518. */
  97519. canCreate(gamepadInfo: any): boolean;
  97520. /**
  97521. * Creates a new instance of the Gamepad.
  97522. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  97523. * @returns the new gamepad instance
  97524. */
  97525. create(gamepadInfo: any): Gamepad;
  97526. }
  97527. /**
  97528. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97529. */
  97530. export class PoseEnabledControllerHelper {
  97531. /** @hidden */
  97532. static _ControllerFactories: _GamePadFactory[];
  97533. /** @hidden */
  97534. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  97535. /**
  97536. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  97537. * @param vrGamepad the gamepad to initialized
  97538. * @returns a vr controller of the type the gamepad identified as
  97539. */
  97540. static InitiateController(vrGamepad: any): Gamepad;
  97541. }
  97542. /**
  97543. * Defines the PoseEnabledController object that contains state of a vr capable controller
  97544. */
  97545. export class PoseEnabledController extends Gamepad implements PoseControlled {
  97546. /**
  97547. * If the controller is used in a webXR session
  97548. */
  97549. isXR: boolean;
  97550. private _deviceRoomPosition;
  97551. private _deviceRoomRotationQuaternion;
  97552. /**
  97553. * The device position in babylon space
  97554. */
  97555. devicePosition: Vector3;
  97556. /**
  97557. * The device rotation in babylon space
  97558. */
  97559. deviceRotationQuaternion: Quaternion;
  97560. /**
  97561. * The scale factor of the device in babylon space
  97562. */
  97563. deviceScaleFactor: number;
  97564. /**
  97565. * (Likely devicePosition should be used instead) The device position in its room space
  97566. */
  97567. position: Vector3;
  97568. /**
  97569. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  97570. */
  97571. rotationQuaternion: Quaternion;
  97572. /**
  97573. * The type of controller (Eg. Windows mixed reality)
  97574. */
  97575. controllerType: PoseEnabledControllerType;
  97576. protected _calculatedPosition: Vector3;
  97577. private _calculatedRotation;
  97578. /**
  97579. * The raw pose from the device
  97580. */
  97581. rawPose: DevicePose;
  97582. private _trackPosition;
  97583. private _maxRotationDistFromHeadset;
  97584. private _draggedRoomRotation;
  97585. /**
  97586. * @hidden
  97587. */
  97588. _disableTrackPosition(fixedPosition: Vector3): void;
  97589. /**
  97590. * Internal, the mesh attached to the controller
  97591. * @hidden
  97592. */
  97593. _mesh: Nullable<AbstractMesh>;
  97594. private _poseControlledCamera;
  97595. private _leftHandSystemQuaternion;
  97596. /**
  97597. * Internal, matrix used to convert room space to babylon space
  97598. * @hidden
  97599. */
  97600. _deviceToWorld: Matrix;
  97601. /**
  97602. * Node to be used when casting a ray from the controller
  97603. * @hidden
  97604. */
  97605. _pointingPoseNode: Nullable<TransformNode>;
  97606. /**
  97607. * Name of the child mesh that can be used to cast a ray from the controller
  97608. */
  97609. static readonly POINTING_POSE: string;
  97610. /**
  97611. * Creates a new PoseEnabledController from a gamepad
  97612. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  97613. */
  97614. constructor(browserGamepad: any);
  97615. private _workingMatrix;
  97616. /**
  97617. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  97618. */
  97619. update(): void;
  97620. /**
  97621. * Updates only the pose device and mesh without doing any button event checking
  97622. */
  97623. protected _updatePoseAndMesh(): void;
  97624. /**
  97625. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  97626. * @param poseData raw pose fromthe device
  97627. */
  97628. updateFromDevice(poseData: DevicePose): void;
  97629. /**
  97630. * @hidden
  97631. */
  97632. _meshAttachedObservable: Observable<AbstractMesh>;
  97633. /**
  97634. * Attaches a mesh to the controller
  97635. * @param mesh the mesh to be attached
  97636. */
  97637. attachToMesh(mesh: AbstractMesh): void;
  97638. /**
  97639. * Attaches the controllers mesh to a camera
  97640. * @param camera the camera the mesh should be attached to
  97641. */
  97642. attachToPoseControlledCamera(camera: TargetCamera): void;
  97643. /**
  97644. * Disposes of the controller
  97645. */
  97646. dispose(): void;
  97647. /**
  97648. * The mesh that is attached to the controller
  97649. */
  97650. get mesh(): Nullable<AbstractMesh>;
  97651. /**
  97652. * Gets the ray of the controller in the direction the controller is pointing
  97653. * @param length the length the resulting ray should be
  97654. * @returns a ray in the direction the controller is pointing
  97655. */
  97656. getForwardRay(length?: number): Ray;
  97657. }
  97658. }
  97659. declare module BABYLON {
  97660. /**
  97661. * Defines the WebVRController object that represents controllers tracked in 3D space
  97662. */
  97663. export abstract class WebVRController extends PoseEnabledController {
  97664. /**
  97665. * Internal, the default controller model for the controller
  97666. */
  97667. protected _defaultModel: Nullable<AbstractMesh>;
  97668. /**
  97669. * Fired when the trigger state has changed
  97670. */
  97671. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  97672. /**
  97673. * Fired when the main button state has changed
  97674. */
  97675. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97676. /**
  97677. * Fired when the secondary button state has changed
  97678. */
  97679. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  97680. /**
  97681. * Fired when the pad state has changed
  97682. */
  97683. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  97684. /**
  97685. * Fired when controllers stick values have changed
  97686. */
  97687. onPadValuesChangedObservable: Observable<StickValues>;
  97688. /**
  97689. * Array of button availible on the controller
  97690. */
  97691. protected _buttons: Array<MutableGamepadButton>;
  97692. private _onButtonStateChange;
  97693. /**
  97694. * Fired when a controller button's state has changed
  97695. * @param callback the callback containing the button that was modified
  97696. */
  97697. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  97698. /**
  97699. * X and Y axis corresponding to the controllers joystick
  97700. */
  97701. pad: StickValues;
  97702. /**
  97703. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  97704. */
  97705. hand: string;
  97706. /**
  97707. * The default controller model for the controller
  97708. */
  97709. get defaultModel(): Nullable<AbstractMesh>;
  97710. /**
  97711. * Creates a new WebVRController from a gamepad
  97712. * @param vrGamepad the gamepad that the WebVRController should be created from
  97713. */
  97714. constructor(vrGamepad: any);
  97715. /**
  97716. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  97717. */
  97718. update(): void;
  97719. /**
  97720. * Function to be called when a button is modified
  97721. */
  97722. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  97723. /**
  97724. * Loads a mesh and attaches it to the controller
  97725. * @param scene the scene the mesh should be added to
  97726. * @param meshLoaded callback for when the mesh has been loaded
  97727. */
  97728. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  97729. private _setButtonValue;
  97730. private _changes;
  97731. private _checkChanges;
  97732. /**
  97733. * Disposes of th webVRCOntroller
  97734. */
  97735. dispose(): void;
  97736. }
  97737. }
  97738. declare module BABYLON {
  97739. /**
  97740. * The HemisphericLight simulates the ambient environment light,
  97741. * so the passed direction is the light reflection direction, not the incoming direction.
  97742. */
  97743. export class HemisphericLight extends Light {
  97744. /**
  97745. * The groundColor is the light in the opposite direction to the one specified during creation.
  97746. * 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.
  97747. */
  97748. groundColor: Color3;
  97749. /**
  97750. * The light reflection direction, not the incoming direction.
  97751. */
  97752. direction: Vector3;
  97753. /**
  97754. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  97755. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  97756. * The HemisphericLight can't cast shadows.
  97757. * Documentation : https://doc.babylonjs.com/babylon101/lights
  97758. * @param name The friendly name of the light
  97759. * @param direction The direction of the light reflection
  97760. * @param scene The scene the light belongs to
  97761. */
  97762. constructor(name: string, direction: Vector3, scene: Scene);
  97763. protected _buildUniformLayout(): void;
  97764. /**
  97765. * Returns the string "HemisphericLight".
  97766. * @return The class name
  97767. */
  97768. getClassName(): string;
  97769. /**
  97770. * Sets the HemisphericLight direction towards the passed target (Vector3).
  97771. * Returns the updated direction.
  97772. * @param target The target the direction should point to
  97773. * @return The computed direction
  97774. */
  97775. setDirectionToTarget(target: Vector3): Vector3;
  97776. /**
  97777. * Returns the shadow generator associated to the light.
  97778. * @returns Always null for hemispheric lights because it does not support shadows.
  97779. */
  97780. getShadowGenerator(): Nullable<IShadowGenerator>;
  97781. /**
  97782. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  97783. * @param effect The effect to update
  97784. * @param lightIndex The index of the light in the effect to update
  97785. * @returns The hemispheric light
  97786. */
  97787. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  97788. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  97789. /**
  97790. * Computes the world matrix of the node
  97791. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  97792. * @param useWasUpdatedFlag defines a reserved property
  97793. * @returns the world matrix
  97794. */
  97795. computeWorldMatrix(): Matrix;
  97796. /**
  97797. * Returns the integer 3.
  97798. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  97799. */
  97800. getTypeID(): number;
  97801. /**
  97802. * Prepares the list of defines specific to the light type.
  97803. * @param defines the list of defines
  97804. * @param lightIndex defines the index of the light for the effect
  97805. */
  97806. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  97807. }
  97808. }
  97809. declare module BABYLON {
  97810. /** @hidden */
  97811. export var vrMultiviewToSingleviewPixelShader: {
  97812. name: string;
  97813. shader: string;
  97814. };
  97815. }
  97816. declare module BABYLON {
  97817. /**
  97818. * Renders to multiple views with a single draw call
  97819. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  97820. */
  97821. export class MultiviewRenderTarget extends RenderTargetTexture {
  97822. /**
  97823. * Creates a multiview render target
  97824. * @param scene scene used with the render target
  97825. * @param size the size of the render target (used for each view)
  97826. */
  97827. constructor(scene: Scene, size?: number | {
  97828. width: number;
  97829. height: number;
  97830. } | {
  97831. ratio: number;
  97832. });
  97833. /**
  97834. * @hidden
  97835. * @param faceIndex the face index, if its a cube texture
  97836. */
  97837. _bindFrameBuffer(faceIndex?: number): void;
  97838. /**
  97839. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  97840. * @returns the view count
  97841. */
  97842. getViewCount(): number;
  97843. }
  97844. }
  97845. declare module BABYLON {
  97846. interface Engine {
  97847. /**
  97848. * Creates a new multiview render target
  97849. * @param width defines the width of the texture
  97850. * @param height defines the height of the texture
  97851. * @returns the created multiview texture
  97852. */
  97853. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  97854. /**
  97855. * Binds a multiview framebuffer to be drawn to
  97856. * @param multiviewTexture texture to bind
  97857. */
  97858. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  97859. }
  97860. interface Camera {
  97861. /**
  97862. * @hidden
  97863. * 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)
  97864. */
  97865. _useMultiviewToSingleView: boolean;
  97866. /**
  97867. * @hidden
  97868. * 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)
  97869. */
  97870. _multiviewTexture: Nullable<RenderTargetTexture>;
  97871. /**
  97872. * @hidden
  97873. * ensures the multiview texture of the camera exists and has the specified width/height
  97874. * @param width height to set on the multiview texture
  97875. * @param height width to set on the multiview texture
  97876. */
  97877. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  97878. }
  97879. interface Scene {
  97880. /** @hidden */
  97881. _transformMatrixR: Matrix;
  97882. /** @hidden */
  97883. _multiviewSceneUbo: Nullable<UniformBuffer>;
  97884. /** @hidden */
  97885. _createMultiviewUbo(): void;
  97886. /** @hidden */
  97887. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  97888. /** @hidden */
  97889. _renderMultiviewToSingleView(camera: Camera): void;
  97890. }
  97891. }
  97892. declare module BABYLON {
  97893. /**
  97894. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  97895. * This will not be used for webXR as it supports displaying texture arrays directly
  97896. */
  97897. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  97898. /**
  97899. * Initializes a VRMultiviewToSingleview
  97900. * @param name name of the post process
  97901. * @param camera camera to be applied to
  97902. * @param scaleFactor scaling factor to the size of the output texture
  97903. */
  97904. constructor(name: string, camera: Camera, scaleFactor: number);
  97905. }
  97906. }
  97907. declare module BABYLON {
  97908. /**
  97909. * Interface used to define additional presentation attributes
  97910. */
  97911. export interface IVRPresentationAttributes {
  97912. /**
  97913. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  97914. */
  97915. highRefreshRate: boolean;
  97916. /**
  97917. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  97918. */
  97919. foveationLevel: number;
  97920. }
  97921. interface Engine {
  97922. /** @hidden */
  97923. _vrDisplay: any;
  97924. /** @hidden */
  97925. _vrSupported: boolean;
  97926. /** @hidden */
  97927. _oldSize: Size;
  97928. /** @hidden */
  97929. _oldHardwareScaleFactor: number;
  97930. /** @hidden */
  97931. _vrExclusivePointerMode: boolean;
  97932. /** @hidden */
  97933. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  97934. /** @hidden */
  97935. _onVRDisplayPointerRestricted: () => void;
  97936. /** @hidden */
  97937. _onVRDisplayPointerUnrestricted: () => void;
  97938. /** @hidden */
  97939. _onVrDisplayConnect: Nullable<(display: any) => void>;
  97940. /** @hidden */
  97941. _onVrDisplayDisconnect: Nullable<() => void>;
  97942. /** @hidden */
  97943. _onVrDisplayPresentChange: Nullable<() => void>;
  97944. /**
  97945. * Observable signaled when VR display mode changes
  97946. */
  97947. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  97948. /**
  97949. * Observable signaled when VR request present is complete
  97950. */
  97951. onVRRequestPresentComplete: Observable<boolean>;
  97952. /**
  97953. * Observable signaled when VR request present starts
  97954. */
  97955. onVRRequestPresentStart: Observable<Engine>;
  97956. /**
  97957. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  97958. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  97959. */
  97960. isInVRExclusivePointerMode: boolean;
  97961. /**
  97962. * Gets a boolean indicating if a webVR device was detected
  97963. * @returns true if a webVR device was detected
  97964. */
  97965. isVRDevicePresent(): boolean;
  97966. /**
  97967. * Gets the current webVR device
  97968. * @returns the current webVR device (or null)
  97969. */
  97970. getVRDevice(): any;
  97971. /**
  97972. * Initializes a webVR display and starts listening to display change events
  97973. * The onVRDisplayChangedObservable will be notified upon these changes
  97974. * @returns A promise containing a VRDisplay and if vr is supported
  97975. */
  97976. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  97977. /** @hidden */
  97978. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  97979. /**
  97980. * Gets or sets the presentation attributes used to configure VR rendering
  97981. */
  97982. vrPresentationAttributes?: IVRPresentationAttributes;
  97983. /**
  97984. * Call this function to switch to webVR mode
  97985. * Will do nothing if webVR is not supported or if there is no webVR device
  97986. * @param options the webvr options provided to the camera. mainly used for multiview
  97987. * @see https://doc.babylonjs.com/how_to/webvr_camera
  97988. */
  97989. enableVR(options: WebVROptions): void;
  97990. /** @hidden */
  97991. _onVRFullScreenTriggered(): void;
  97992. }
  97993. }
  97994. declare module BABYLON {
  97995. /**
  97996. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  97997. * IMPORTANT!! The data is right-hand data.
  97998. * @export
  97999. * @interface DevicePose
  98000. */
  98001. export interface DevicePose {
  98002. /**
  98003. * The position of the device, values in array are [x,y,z].
  98004. */
  98005. readonly position: Nullable<Float32Array>;
  98006. /**
  98007. * The linearVelocity of the device, values in array are [x,y,z].
  98008. */
  98009. readonly linearVelocity: Nullable<Float32Array>;
  98010. /**
  98011. * The linearAcceleration of the device, values in array are [x,y,z].
  98012. */
  98013. readonly linearAcceleration: Nullable<Float32Array>;
  98014. /**
  98015. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  98016. */
  98017. readonly orientation: Nullable<Float32Array>;
  98018. /**
  98019. * The angularVelocity of the device, values in array are [x,y,z].
  98020. */
  98021. readonly angularVelocity: Nullable<Float32Array>;
  98022. /**
  98023. * The angularAcceleration of the device, values in array are [x,y,z].
  98024. */
  98025. readonly angularAcceleration: Nullable<Float32Array>;
  98026. }
  98027. /**
  98028. * Interface representing a pose controlled object in Babylon.
  98029. * A pose controlled object has both regular pose values as well as pose values
  98030. * from an external device such as a VR head mounted display
  98031. */
  98032. export interface PoseControlled {
  98033. /**
  98034. * The position of the object in babylon space.
  98035. */
  98036. position: Vector3;
  98037. /**
  98038. * The rotation quaternion of the object in babylon space.
  98039. */
  98040. rotationQuaternion: Quaternion;
  98041. /**
  98042. * The position of the device in babylon space.
  98043. */
  98044. devicePosition?: Vector3;
  98045. /**
  98046. * The rotation quaternion of the device in babylon space.
  98047. */
  98048. deviceRotationQuaternion: Quaternion;
  98049. /**
  98050. * The raw pose coming from the device.
  98051. */
  98052. rawPose: Nullable<DevicePose>;
  98053. /**
  98054. * The scale of the device to be used when translating from device space to babylon space.
  98055. */
  98056. deviceScaleFactor: number;
  98057. /**
  98058. * Updates the poseControlled values based on the input device pose.
  98059. * @param poseData the pose data to update the object with
  98060. */
  98061. updateFromDevice(poseData: DevicePose): void;
  98062. }
  98063. /**
  98064. * Set of options to customize the webVRCamera
  98065. */
  98066. export interface WebVROptions {
  98067. /**
  98068. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  98069. */
  98070. trackPosition?: boolean;
  98071. /**
  98072. * Sets the scale of the vrDevice in babylon space. (default: 1)
  98073. */
  98074. positionScale?: number;
  98075. /**
  98076. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  98077. */
  98078. displayName?: string;
  98079. /**
  98080. * Should the native controller meshes be initialized. (default: true)
  98081. */
  98082. controllerMeshes?: boolean;
  98083. /**
  98084. * Creating a default HemiLight only on controllers. (default: true)
  98085. */
  98086. defaultLightingOnControllers?: boolean;
  98087. /**
  98088. * If you don't want to use the default VR button of the helper. (default: false)
  98089. */
  98090. useCustomVRButton?: boolean;
  98091. /**
  98092. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  98093. */
  98094. customVRButton?: HTMLButtonElement;
  98095. /**
  98096. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  98097. */
  98098. rayLength?: number;
  98099. /**
  98100. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  98101. */
  98102. defaultHeight?: number;
  98103. /**
  98104. * If multiview should be used if availible (default: false)
  98105. */
  98106. useMultiview?: boolean;
  98107. }
  98108. /**
  98109. * This represents a WebVR camera.
  98110. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  98111. * @example https://doc.babylonjs.com/how_to/webvr_camera
  98112. */
  98113. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  98114. private webVROptions;
  98115. /**
  98116. * @hidden
  98117. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  98118. */
  98119. _vrDevice: any;
  98120. /**
  98121. * The rawPose of the vrDevice.
  98122. */
  98123. rawPose: Nullable<DevicePose>;
  98124. private _onVREnabled;
  98125. private _specsVersion;
  98126. private _attached;
  98127. private _frameData;
  98128. protected _descendants: Array<Node>;
  98129. private _deviceRoomPosition;
  98130. /** @hidden */
  98131. _deviceRoomRotationQuaternion: Quaternion;
  98132. private _standingMatrix;
  98133. /**
  98134. * Represents device position in babylon space.
  98135. */
  98136. devicePosition: Vector3;
  98137. /**
  98138. * Represents device rotation in babylon space.
  98139. */
  98140. deviceRotationQuaternion: Quaternion;
  98141. /**
  98142. * The scale of the device to be used when translating from device space to babylon space.
  98143. */
  98144. deviceScaleFactor: number;
  98145. private _deviceToWorld;
  98146. private _worldToDevice;
  98147. /**
  98148. * References to the webVR controllers for the vrDevice.
  98149. */
  98150. controllers: Array<WebVRController>;
  98151. /**
  98152. * Emits an event when a controller is attached.
  98153. */
  98154. onControllersAttachedObservable: Observable<WebVRController[]>;
  98155. /**
  98156. * Emits an event when a controller's mesh has been loaded;
  98157. */
  98158. onControllerMeshLoadedObservable: Observable<WebVRController>;
  98159. /**
  98160. * Emits an event when the HMD's pose has been updated.
  98161. */
  98162. onPoseUpdatedFromDeviceObservable: Observable<any>;
  98163. private _poseSet;
  98164. /**
  98165. * If the rig cameras be used as parent instead of this camera.
  98166. */
  98167. rigParenting: boolean;
  98168. private _lightOnControllers;
  98169. private _defaultHeight?;
  98170. /**
  98171. * Instantiates a WebVRFreeCamera.
  98172. * @param name The name of the WebVRFreeCamera
  98173. * @param position The starting anchor position for the camera
  98174. * @param scene The scene the camera belongs to
  98175. * @param webVROptions a set of customizable options for the webVRCamera
  98176. */
  98177. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  98178. /**
  98179. * Gets the device distance from the ground in meters.
  98180. * @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.
  98181. */
  98182. deviceDistanceToRoomGround(): number;
  98183. /**
  98184. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98185. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  98186. */
  98187. useStandingMatrix(callback?: (bool: boolean) => void): void;
  98188. /**
  98189. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  98190. * @returns A promise with a boolean set to if the standing matrix is supported.
  98191. */
  98192. useStandingMatrixAsync(): Promise<boolean>;
  98193. /**
  98194. * Disposes the camera
  98195. */
  98196. dispose(): void;
  98197. /**
  98198. * Gets a vrController by name.
  98199. * @param name The name of the controller to retreive
  98200. * @returns the controller matching the name specified or null if not found
  98201. */
  98202. getControllerByName(name: string): Nullable<WebVRController>;
  98203. private _leftController;
  98204. /**
  98205. * The controller corresponding to the users left hand.
  98206. */
  98207. get leftController(): Nullable<WebVRController>;
  98208. private _rightController;
  98209. /**
  98210. * The controller corresponding to the users right hand.
  98211. */
  98212. get rightController(): Nullable<WebVRController>;
  98213. /**
  98214. * Casts a ray forward from the vrCamera's gaze.
  98215. * @param length Length of the ray (default: 100)
  98216. * @returns the ray corresponding to the gaze
  98217. */
  98218. getForwardRay(length?: number): Ray;
  98219. /**
  98220. * @hidden
  98221. * Updates the camera based on device's frame data
  98222. */
  98223. _checkInputs(): void;
  98224. /**
  98225. * Updates the poseControlled values based on the input device pose.
  98226. * @param poseData Pose coming from the device
  98227. */
  98228. updateFromDevice(poseData: DevicePose): void;
  98229. private _htmlElementAttached;
  98230. private _detachIfAttached;
  98231. /**
  98232. * WebVR's attach control will start broadcasting frames to the device.
  98233. * Note that in certain browsers (chrome for example) this function must be called
  98234. * within a user-interaction callback. Example:
  98235. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  98236. *
  98237. * @param element html element to attach the vrDevice to
  98238. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  98239. */
  98240. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98241. /**
  98242. * Detaches the camera from the html element and disables VR
  98243. *
  98244. * @param element html element to detach from
  98245. */
  98246. detachControl(element: HTMLElement): void;
  98247. /**
  98248. * @returns the name of this class
  98249. */
  98250. getClassName(): string;
  98251. /**
  98252. * Calls resetPose on the vrDisplay
  98253. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  98254. */
  98255. resetToCurrentRotation(): void;
  98256. /**
  98257. * @hidden
  98258. * Updates the rig cameras (left and right eye)
  98259. */
  98260. _updateRigCameras(): void;
  98261. private _workingVector;
  98262. private _oneVector;
  98263. private _workingMatrix;
  98264. private updateCacheCalled;
  98265. private _correctPositionIfNotTrackPosition;
  98266. /**
  98267. * @hidden
  98268. * Updates the cached values of the camera
  98269. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  98270. */
  98271. _updateCache(ignoreParentClass?: boolean): void;
  98272. /**
  98273. * @hidden
  98274. * Get current device position in babylon world
  98275. */
  98276. _computeDevicePosition(): void;
  98277. /**
  98278. * Updates the current device position and rotation in the babylon world
  98279. */
  98280. update(): void;
  98281. /**
  98282. * @hidden
  98283. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  98284. * @returns an identity matrix
  98285. */
  98286. _getViewMatrix(): Matrix;
  98287. private _tmpMatrix;
  98288. /**
  98289. * This function is called by the two RIG cameras.
  98290. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  98291. * @hidden
  98292. */
  98293. _getWebVRViewMatrix(): Matrix;
  98294. /** @hidden */
  98295. _getWebVRProjectionMatrix(): Matrix;
  98296. private _onGamepadConnectedObserver;
  98297. private _onGamepadDisconnectedObserver;
  98298. private _updateCacheWhenTrackingDisabledObserver;
  98299. /**
  98300. * Initializes the controllers and their meshes
  98301. */
  98302. initControllers(): void;
  98303. }
  98304. }
  98305. declare module BABYLON {
  98306. /**
  98307. * "Static Class" containing the most commonly used helper while dealing with material for
  98308. * rendering purpose.
  98309. *
  98310. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  98311. *
  98312. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  98313. */
  98314. export class MaterialHelper {
  98315. /**
  98316. * Bind the current view position to an effect.
  98317. * @param effect The effect to be bound
  98318. * @param scene The scene the eyes position is used from
  98319. * @param variableName name of the shader variable that will hold the eye position
  98320. */
  98321. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  98322. /**
  98323. * Helps preparing the defines values about the UVs in used in the effect.
  98324. * UVs are shared as much as we can accross channels in the shaders.
  98325. * @param texture The texture we are preparing the UVs for
  98326. * @param defines The defines to update
  98327. * @param key The channel key "diffuse", "specular"... used in the shader
  98328. */
  98329. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  98330. /**
  98331. * Binds a texture matrix value to its corrsponding uniform
  98332. * @param texture The texture to bind the matrix for
  98333. * @param uniformBuffer The uniform buffer receivin the data
  98334. * @param key The channel key "diffuse", "specular"... used in the shader
  98335. */
  98336. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  98337. /**
  98338. * Gets the current status of the fog (should it be enabled?)
  98339. * @param mesh defines the mesh to evaluate for fog support
  98340. * @param scene defines the hosting scene
  98341. * @returns true if fog must be enabled
  98342. */
  98343. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  98344. /**
  98345. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  98346. * @param mesh defines the current mesh
  98347. * @param scene defines the current scene
  98348. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  98349. * @param pointsCloud defines if point cloud rendering has to be turned on
  98350. * @param fogEnabled defines if fog has to be turned on
  98351. * @param alphaTest defines if alpha testing has to be turned on
  98352. * @param defines defines the current list of defines
  98353. */
  98354. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  98355. /**
  98356. * Helper used to prepare the list of defines associated with frame values for shader compilation
  98357. * @param scene defines the current scene
  98358. * @param engine defines the current engine
  98359. * @param defines specifies the list of active defines
  98360. * @param useInstances defines if instances have to be turned on
  98361. * @param useClipPlane defines if clip plane have to be turned on
  98362. * @param useInstances defines if instances have to be turned on
  98363. * @param useThinInstances defines if thin instances have to be turned on
  98364. */
  98365. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  98366. /**
  98367. * Prepares the defines for bones
  98368. * @param mesh The mesh containing the geometry data we will draw
  98369. * @param defines The defines to update
  98370. */
  98371. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  98372. /**
  98373. * Prepares the defines for morph targets
  98374. * @param mesh The mesh containing the geometry data we will draw
  98375. * @param defines The defines to update
  98376. */
  98377. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  98378. /**
  98379. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  98380. * @param mesh The mesh containing the geometry data we will draw
  98381. * @param defines The defines to update
  98382. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  98383. * @param useBones Precise whether bones should be used or not (override mesh info)
  98384. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  98385. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  98386. * @returns false if defines are considered not dirty and have not been checked
  98387. */
  98388. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  98389. /**
  98390. * Prepares the defines related to multiview
  98391. * @param scene The scene we are intending to draw
  98392. * @param defines The defines to update
  98393. */
  98394. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  98395. /**
  98396. * Prepares the defines related to the prepass
  98397. * @param scene The scene we are intending to draw
  98398. * @param defines The defines to update
  98399. * @param shouldRenderToMRT Indicates if this material renders to several textures in the prepass
  98400. */
  98401. static PrepareDefinesForPrePass(scene: Scene, defines: any, shouldRenderToMRT: boolean): void;
  98402. /**
  98403. * Prepares the defines related to the light information passed in parameter
  98404. * @param scene The scene we are intending to draw
  98405. * @param mesh The mesh the effect is compiling for
  98406. * @param light The light the effect is compiling for
  98407. * @param lightIndex The index of the light
  98408. * @param defines The defines to update
  98409. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98410. * @param state Defines the current state regarding what is needed (normals, etc...)
  98411. */
  98412. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  98413. needNormals: boolean;
  98414. needRebuild: boolean;
  98415. shadowEnabled: boolean;
  98416. specularEnabled: boolean;
  98417. lightmapMode: boolean;
  98418. }): void;
  98419. /**
  98420. * Prepares the defines related to the light information passed in parameter
  98421. * @param scene The scene we are intending to draw
  98422. * @param mesh The mesh the effect is compiling for
  98423. * @param defines The defines to update
  98424. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  98425. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  98426. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  98427. * @returns true if normals will be required for the rest of the effect
  98428. */
  98429. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  98430. /**
  98431. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  98432. * @param lightIndex defines the light index
  98433. * @param uniformsList The uniform list
  98434. * @param samplersList The sampler list
  98435. * @param projectedLightTexture defines if projected texture must be used
  98436. * @param uniformBuffersList defines an optional list of uniform buffers
  98437. */
  98438. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  98439. /**
  98440. * Prepares the uniforms and samplers list to be used in the effect
  98441. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  98442. * @param samplersList The sampler list
  98443. * @param defines The defines helping in the list generation
  98444. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  98445. */
  98446. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  98447. /**
  98448. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  98449. * @param defines The defines to update while falling back
  98450. * @param fallbacks The authorized effect fallbacks
  98451. * @param maxSimultaneousLights The maximum number of lights allowed
  98452. * @param rank the current rank of the Effect
  98453. * @returns The newly affected rank
  98454. */
  98455. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  98456. private static _TmpMorphInfluencers;
  98457. /**
  98458. * Prepares the list of attributes required for morph targets according to the effect defines.
  98459. * @param attribs The current list of supported attribs
  98460. * @param mesh The mesh to prepare the morph targets attributes for
  98461. * @param influencers The number of influencers
  98462. */
  98463. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  98464. /**
  98465. * Prepares the list of attributes required for morph targets according to the effect defines.
  98466. * @param attribs The current list of supported attribs
  98467. * @param mesh The mesh to prepare the morph targets attributes for
  98468. * @param defines The current Defines of the effect
  98469. */
  98470. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  98471. /**
  98472. * Prepares the list of attributes required for bones according to the effect defines.
  98473. * @param attribs The current list of supported attribs
  98474. * @param mesh The mesh to prepare the bones attributes for
  98475. * @param defines The current Defines of the effect
  98476. * @param fallbacks The current efffect fallback strategy
  98477. */
  98478. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  98479. /**
  98480. * Check and prepare the list of attributes required for instances according to the effect defines.
  98481. * @param attribs The current list of supported attribs
  98482. * @param defines The current MaterialDefines of the effect
  98483. */
  98484. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  98485. /**
  98486. * Add the list of attributes required for instances to the attribs array.
  98487. * @param attribs The current list of supported attribs
  98488. */
  98489. static PushAttributesForInstances(attribs: string[]): void;
  98490. /**
  98491. * Binds the light information to the effect.
  98492. * @param light The light containing the generator
  98493. * @param effect The effect we are binding the data to
  98494. * @param lightIndex The light index in the effect used to render
  98495. */
  98496. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  98497. /**
  98498. * Binds the lights information from the scene to the effect for the given mesh.
  98499. * @param light Light to bind
  98500. * @param lightIndex Light index
  98501. * @param scene The scene where the light belongs to
  98502. * @param effect The effect we are binding the data to
  98503. * @param useSpecular Defines if specular is supported
  98504. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98505. */
  98506. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98507. /**
  98508. * Binds the lights information from the scene to the effect for the given mesh.
  98509. * @param scene The scene the lights belongs to
  98510. * @param mesh The mesh we are binding the information to render
  98511. * @param effect The effect we are binding the data to
  98512. * @param defines The generated defines for the effect
  98513. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  98514. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98515. */
  98516. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  98517. private static _tempFogColor;
  98518. /**
  98519. * Binds the fog information from the scene to the effect for the given mesh.
  98520. * @param scene The scene the lights belongs to
  98521. * @param mesh The mesh we are binding the information to render
  98522. * @param effect The effect we are binding the data to
  98523. * @param linearSpace Defines if the fog effect is applied in linear space
  98524. */
  98525. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  98526. /**
  98527. * Binds the bones information from the mesh to the effect.
  98528. * @param mesh The mesh we are binding the information to render
  98529. * @param effect The effect we are binding the data to
  98530. */
  98531. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  98532. /**
  98533. * Binds the morph targets information from the mesh to the effect.
  98534. * @param abstractMesh The mesh we are binding the information to render
  98535. * @param effect The effect we are binding the data to
  98536. */
  98537. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  98538. /**
  98539. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  98540. * @param defines The generated defines used in the effect
  98541. * @param effect The effect we are binding the data to
  98542. * @param scene The scene we are willing to render with logarithmic scale for
  98543. */
  98544. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  98545. /**
  98546. * Binds the clip plane information from the scene to the effect.
  98547. * @param scene The scene the clip plane information are extracted from
  98548. * @param effect The effect we are binding the data to
  98549. */
  98550. static BindClipPlane(effect: Effect, scene: Scene): void;
  98551. }
  98552. }
  98553. declare module BABYLON {
  98554. /**
  98555. * Block used to expose an input value
  98556. */
  98557. export class InputBlock extends NodeMaterialBlock {
  98558. private _mode;
  98559. private _associatedVariableName;
  98560. private _storedValue;
  98561. private _valueCallback;
  98562. private _type;
  98563. private _animationType;
  98564. /** Gets or set a value used to limit the range of float values */
  98565. min: number;
  98566. /** Gets or set a value used to limit the range of float values */
  98567. max: number;
  98568. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  98569. isBoolean: boolean;
  98570. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  98571. matrixMode: number;
  98572. /** @hidden */
  98573. _systemValue: Nullable<NodeMaterialSystemValues>;
  98574. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  98575. visibleInInspector: boolean;
  98576. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  98577. isConstant: boolean;
  98578. /** Gets or sets the group to use to display this block in the Inspector */
  98579. groupInInspector: string;
  98580. /** Gets an observable raised when the value is changed */
  98581. onValueChangedObservable: Observable<InputBlock>;
  98582. /**
  98583. * Gets or sets the connection point type (default is float)
  98584. */
  98585. get type(): NodeMaterialBlockConnectionPointTypes;
  98586. /**
  98587. * Creates a new InputBlock
  98588. * @param name defines the block name
  98589. * @param target defines the target of that block (Vertex by default)
  98590. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  98591. */
  98592. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  98593. /**
  98594. * Gets the output component
  98595. */
  98596. get output(): NodeMaterialConnectionPoint;
  98597. /**
  98598. * Set the source of this connection point to a vertex attribute
  98599. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  98600. * @returns the current connection point
  98601. */
  98602. setAsAttribute(attributeName?: string): InputBlock;
  98603. /**
  98604. * Set the source of this connection point to a system value
  98605. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  98606. * @returns the current connection point
  98607. */
  98608. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  98609. /**
  98610. * Gets or sets the value of that point.
  98611. * Please note that this value will be ignored if valueCallback is defined
  98612. */
  98613. get value(): any;
  98614. set value(value: any);
  98615. /**
  98616. * Gets or sets a callback used to get the value of that point.
  98617. * Please note that setting this value will force the connection point to ignore the value property
  98618. */
  98619. get valueCallback(): () => any;
  98620. set valueCallback(value: () => any);
  98621. /**
  98622. * Gets or sets the associated variable name in the shader
  98623. */
  98624. get associatedVariableName(): string;
  98625. set associatedVariableName(value: string);
  98626. /** Gets or sets the type of animation applied to the input */
  98627. get animationType(): AnimatedInputBlockTypes;
  98628. set animationType(value: AnimatedInputBlockTypes);
  98629. /**
  98630. * Gets a boolean indicating that this connection point not defined yet
  98631. */
  98632. get isUndefined(): boolean;
  98633. /**
  98634. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  98635. * In this case the connection point name must be the name of the uniform to use.
  98636. * Can only be set on inputs
  98637. */
  98638. get isUniform(): boolean;
  98639. set isUniform(value: boolean);
  98640. /**
  98641. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  98642. * In this case the connection point name must be the name of the attribute to use
  98643. * Can only be set on inputs
  98644. */
  98645. get isAttribute(): boolean;
  98646. set isAttribute(value: boolean);
  98647. /**
  98648. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  98649. * Can only be set on exit points
  98650. */
  98651. get isVarying(): boolean;
  98652. set isVarying(value: boolean);
  98653. /**
  98654. * Gets a boolean indicating that the current connection point is a system value
  98655. */
  98656. get isSystemValue(): boolean;
  98657. /**
  98658. * Gets or sets the current well known value or null if not defined as a system value
  98659. */
  98660. get systemValue(): Nullable<NodeMaterialSystemValues>;
  98661. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  98662. /**
  98663. * Gets the current class name
  98664. * @returns the class name
  98665. */
  98666. getClassName(): string;
  98667. /**
  98668. * Animate the input if animationType !== None
  98669. * @param scene defines the rendering scene
  98670. */
  98671. animate(scene: Scene): void;
  98672. private _emitDefine;
  98673. initialize(state: NodeMaterialBuildState): void;
  98674. /**
  98675. * Set the input block to its default value (based on its type)
  98676. */
  98677. setDefaultValue(): void;
  98678. private _emitConstant;
  98679. /** @hidden */
  98680. get _noContextSwitch(): boolean;
  98681. private _emit;
  98682. /** @hidden */
  98683. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  98684. /** @hidden */
  98685. _transmit(effect: Effect, scene: Scene): void;
  98686. protected _buildBlock(state: NodeMaterialBuildState): void;
  98687. protected _dumpPropertiesCode(): string;
  98688. dispose(): void;
  98689. serialize(): any;
  98690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98691. }
  98692. }
  98693. declare module BABYLON {
  98694. /**
  98695. * Enum used to define the compatibility state between two connection points
  98696. */
  98697. export enum NodeMaterialConnectionPointCompatibilityStates {
  98698. /** Points are compatibles */
  98699. Compatible = 0,
  98700. /** Points are incompatible because of their types */
  98701. TypeIncompatible = 1,
  98702. /** Points are incompatible because of their targets (vertex vs fragment) */
  98703. TargetIncompatible = 2
  98704. }
  98705. /**
  98706. * Defines the direction of a connection point
  98707. */
  98708. export enum NodeMaterialConnectionPointDirection {
  98709. /** Input */
  98710. Input = 0,
  98711. /** Output */
  98712. Output = 1
  98713. }
  98714. /**
  98715. * Defines a connection point for a block
  98716. */
  98717. export class NodeMaterialConnectionPoint {
  98718. /** @hidden */
  98719. _ownerBlock: NodeMaterialBlock;
  98720. /** @hidden */
  98721. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  98722. private _endpoints;
  98723. private _associatedVariableName;
  98724. private _direction;
  98725. /** @hidden */
  98726. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98727. /** @hidden */
  98728. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  98729. private _type;
  98730. /** @hidden */
  98731. _enforceAssociatedVariableName: boolean;
  98732. /** Gets the direction of the point */
  98733. get direction(): NodeMaterialConnectionPointDirection;
  98734. /** Indicates that this connection point needs dual validation before being connected to another point */
  98735. needDualDirectionValidation: boolean;
  98736. /**
  98737. * Gets or sets the additional types supported by this connection point
  98738. */
  98739. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98740. /**
  98741. * Gets or sets the additional types excluded by this connection point
  98742. */
  98743. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  98744. /**
  98745. * Observable triggered when this point is connected
  98746. */
  98747. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  98748. /**
  98749. * Gets or sets the associated variable name in the shader
  98750. */
  98751. get associatedVariableName(): string;
  98752. set associatedVariableName(value: string);
  98753. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  98754. get innerType(): NodeMaterialBlockConnectionPointTypes;
  98755. /**
  98756. * Gets or sets the connection point type (default is float)
  98757. */
  98758. get type(): NodeMaterialBlockConnectionPointTypes;
  98759. set type(value: NodeMaterialBlockConnectionPointTypes);
  98760. /**
  98761. * Gets or sets the connection point name
  98762. */
  98763. name: string;
  98764. /**
  98765. * Gets or sets the connection point name
  98766. */
  98767. displayName: string;
  98768. /**
  98769. * Gets or sets a boolean indicating that this connection point can be omitted
  98770. */
  98771. isOptional: boolean;
  98772. /**
  98773. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  98774. */
  98775. isExposedOnFrame: boolean;
  98776. /**
  98777. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  98778. */
  98779. define: string;
  98780. /** @hidden */
  98781. _prioritizeVertex: boolean;
  98782. private _target;
  98783. /** Gets or sets the target of that connection point */
  98784. get target(): NodeMaterialBlockTargets;
  98785. set target(value: NodeMaterialBlockTargets);
  98786. /**
  98787. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  98788. */
  98789. get isConnected(): boolean;
  98790. /**
  98791. * Gets a boolean indicating that the current point is connected to an input block
  98792. */
  98793. get isConnectedToInputBlock(): boolean;
  98794. /**
  98795. * Gets a the connected input block (if any)
  98796. */
  98797. get connectInputBlock(): Nullable<InputBlock>;
  98798. /** Get the other side of the connection (if any) */
  98799. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  98800. /** Get the block that owns this connection point */
  98801. get ownerBlock(): NodeMaterialBlock;
  98802. /** Get the block connected on the other side of this connection (if any) */
  98803. get sourceBlock(): Nullable<NodeMaterialBlock>;
  98804. /** Get the block connected on the endpoints of this connection (if any) */
  98805. get connectedBlocks(): Array<NodeMaterialBlock>;
  98806. /** Gets the list of connected endpoints */
  98807. get endpoints(): NodeMaterialConnectionPoint[];
  98808. /** Gets a boolean indicating if that output point is connected to at least one input */
  98809. get hasEndpoints(): boolean;
  98810. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  98811. get isConnectedInVertexShader(): boolean;
  98812. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  98813. get isConnectedInFragmentShader(): boolean;
  98814. /**
  98815. * Creates a block suitable to be used as an input for this input point.
  98816. * If null is returned, a block based on the point type will be created.
  98817. * @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
  98818. */
  98819. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  98820. /**
  98821. * Creates a new connection point
  98822. * @param name defines the connection point name
  98823. * @param ownerBlock defines the block hosting this connection point
  98824. * @param direction defines the direction of the connection point
  98825. */
  98826. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  98827. /**
  98828. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  98829. * @returns the class name
  98830. */
  98831. getClassName(): string;
  98832. /**
  98833. * Gets a boolean indicating if the current point can be connected to another point
  98834. * @param connectionPoint defines the other connection point
  98835. * @returns a boolean
  98836. */
  98837. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  98838. /**
  98839. * Gets a number indicating if the current point can be connected to another point
  98840. * @param connectionPoint defines the other connection point
  98841. * @returns a number defining the compatibility state
  98842. */
  98843. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  98844. /**
  98845. * Connect this point to another connection point
  98846. * @param connectionPoint defines the other connection point
  98847. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  98848. * @returns the current connection point
  98849. */
  98850. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  98851. /**
  98852. * Disconnect this point from one of his endpoint
  98853. * @param endpoint defines the other connection point
  98854. * @returns the current connection point
  98855. */
  98856. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  98857. /**
  98858. * Serializes this point in a JSON representation
  98859. * @param isInput defines if the connection point is an input (default is true)
  98860. * @returns the serialized point object
  98861. */
  98862. serialize(isInput?: boolean): any;
  98863. /**
  98864. * Release resources
  98865. */
  98866. dispose(): void;
  98867. }
  98868. }
  98869. declare module BABYLON {
  98870. /**
  98871. * Enum used to define the material modes
  98872. */
  98873. export enum NodeMaterialModes {
  98874. /** Regular material */
  98875. Material = 0,
  98876. /** For post process */
  98877. PostProcess = 1,
  98878. /** For particle system */
  98879. Particle = 2
  98880. }
  98881. }
  98882. declare module BABYLON {
  98883. /**
  98884. * Block used to read a texture from a sampler
  98885. */
  98886. export class TextureBlock extends NodeMaterialBlock {
  98887. private _defineName;
  98888. private _linearDefineName;
  98889. private _gammaDefineName;
  98890. private _tempTextureRead;
  98891. private _samplerName;
  98892. private _transformedUVName;
  98893. private _textureTransformName;
  98894. private _textureInfoName;
  98895. private _mainUVName;
  98896. private _mainUVDefineName;
  98897. private _fragmentOnly;
  98898. /**
  98899. * Gets or sets the texture associated with the node
  98900. */
  98901. texture: Nullable<Texture>;
  98902. /**
  98903. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  98904. */
  98905. convertToGammaSpace: boolean;
  98906. /**
  98907. * Gets or sets a boolean indicating if content needs to be converted to linear space
  98908. */
  98909. convertToLinearSpace: boolean;
  98910. /**
  98911. * Create a new TextureBlock
  98912. * @param name defines the block name
  98913. */
  98914. constructor(name: string, fragmentOnly?: boolean);
  98915. /**
  98916. * Gets the current class name
  98917. * @returns the class name
  98918. */
  98919. getClassName(): string;
  98920. /**
  98921. * Gets the uv input component
  98922. */
  98923. get uv(): NodeMaterialConnectionPoint;
  98924. /**
  98925. * Gets the rgba output component
  98926. */
  98927. get rgba(): NodeMaterialConnectionPoint;
  98928. /**
  98929. * Gets the rgb output component
  98930. */
  98931. get rgb(): NodeMaterialConnectionPoint;
  98932. /**
  98933. * Gets the r output component
  98934. */
  98935. get r(): NodeMaterialConnectionPoint;
  98936. /**
  98937. * Gets the g output component
  98938. */
  98939. get g(): NodeMaterialConnectionPoint;
  98940. /**
  98941. * Gets the b output component
  98942. */
  98943. get b(): NodeMaterialConnectionPoint;
  98944. /**
  98945. * Gets the a output component
  98946. */
  98947. get a(): NodeMaterialConnectionPoint;
  98948. get target(): NodeMaterialBlockTargets;
  98949. autoConfigure(material: NodeMaterial): void;
  98950. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  98951. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  98952. isReady(): boolean;
  98953. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  98954. private get _isMixed();
  98955. private _injectVertexCode;
  98956. private _writeTextureRead;
  98957. private _writeOutput;
  98958. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  98959. protected _dumpPropertiesCode(): string;
  98960. serialize(): any;
  98961. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  98962. }
  98963. }
  98964. declare module BABYLON {
  98965. /** @hidden */
  98966. export var reflectionFunction: {
  98967. name: string;
  98968. shader: string;
  98969. };
  98970. }
  98971. declare module BABYLON {
  98972. /**
  98973. * Base block used to read a reflection texture from a sampler
  98974. */
  98975. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  98976. /** @hidden */
  98977. _define3DName: string;
  98978. /** @hidden */
  98979. _defineCubicName: string;
  98980. /** @hidden */
  98981. _defineExplicitName: string;
  98982. /** @hidden */
  98983. _defineProjectionName: string;
  98984. /** @hidden */
  98985. _defineLocalCubicName: string;
  98986. /** @hidden */
  98987. _defineSphericalName: string;
  98988. /** @hidden */
  98989. _definePlanarName: string;
  98990. /** @hidden */
  98991. _defineEquirectangularName: string;
  98992. /** @hidden */
  98993. _defineMirroredEquirectangularFixedName: string;
  98994. /** @hidden */
  98995. _defineEquirectangularFixedName: string;
  98996. /** @hidden */
  98997. _defineSkyboxName: string;
  98998. /** @hidden */
  98999. _defineOppositeZ: string;
  99000. /** @hidden */
  99001. _cubeSamplerName: string;
  99002. /** @hidden */
  99003. _2DSamplerName: string;
  99004. protected _positionUVWName: string;
  99005. protected _directionWName: string;
  99006. protected _reflectionVectorName: string;
  99007. /** @hidden */
  99008. _reflectionCoordsName: string;
  99009. /** @hidden */
  99010. _reflectionMatrixName: string;
  99011. protected _reflectionColorName: string;
  99012. /**
  99013. * Gets or sets the texture associated with the node
  99014. */
  99015. texture: Nullable<BaseTexture>;
  99016. /**
  99017. * Create a new ReflectionTextureBaseBlock
  99018. * @param name defines the block name
  99019. */
  99020. constructor(name: string);
  99021. /**
  99022. * Gets the current class name
  99023. * @returns the class name
  99024. */
  99025. getClassName(): string;
  99026. /**
  99027. * Gets the world position input component
  99028. */
  99029. abstract get position(): NodeMaterialConnectionPoint;
  99030. /**
  99031. * Gets the world position input component
  99032. */
  99033. abstract get worldPosition(): NodeMaterialConnectionPoint;
  99034. /**
  99035. * Gets the world normal input component
  99036. */
  99037. abstract get worldNormal(): NodeMaterialConnectionPoint;
  99038. /**
  99039. * Gets the world input component
  99040. */
  99041. abstract get world(): NodeMaterialConnectionPoint;
  99042. /**
  99043. * Gets the camera (or eye) position component
  99044. */
  99045. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  99046. /**
  99047. * Gets the view input component
  99048. */
  99049. abstract get view(): NodeMaterialConnectionPoint;
  99050. protected _getTexture(): Nullable<BaseTexture>;
  99051. autoConfigure(material: NodeMaterial): void;
  99052. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99053. isReady(): boolean;
  99054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  99055. /**
  99056. * Gets the code to inject in the vertex shader
  99057. * @param state current state of the node material building
  99058. * @returns the shader code
  99059. */
  99060. handleVertexSide(state: NodeMaterialBuildState): string;
  99061. /**
  99062. * Handles the inits for the fragment code path
  99063. * @param state node material build state
  99064. */
  99065. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  99066. /**
  99067. * Generates the reflection coords code for the fragment code path
  99068. * @param worldNormalVarName name of the world normal variable
  99069. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  99070. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  99071. * @returns the shader code
  99072. */
  99073. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  99074. /**
  99075. * Generates the reflection color code for the fragment code path
  99076. * @param lodVarName name of the lod variable
  99077. * @param swizzleLookupTexture swizzle to use for the final color variable
  99078. * @returns the shader code
  99079. */
  99080. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  99081. /**
  99082. * Generates the code corresponding to the connected output points
  99083. * @param state node material build state
  99084. * @param varName name of the variable to output
  99085. * @returns the shader code
  99086. */
  99087. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  99088. protected _buildBlock(state: NodeMaterialBuildState): this;
  99089. protected _dumpPropertiesCode(): string;
  99090. serialize(): any;
  99091. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99092. }
  99093. }
  99094. declare module BABYLON {
  99095. /**
  99096. * Defines a connection point to be used for points with a custom object type
  99097. */
  99098. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  99099. private _blockType;
  99100. private _blockName;
  99101. private _nameForCheking?;
  99102. /**
  99103. * Creates a new connection point
  99104. * @param name defines the connection point name
  99105. * @param ownerBlock defines the block hosting this connection point
  99106. * @param direction defines the direction of the connection point
  99107. */
  99108. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  99109. /**
  99110. * Gets a number indicating if the current point can be connected to another point
  99111. * @param connectionPoint defines the other connection point
  99112. * @returns a number defining the compatibility state
  99113. */
  99114. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  99115. /**
  99116. * Creates a block suitable to be used as an input for this input point.
  99117. * If null is returned, a block based on the point type will be created.
  99118. * @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
  99119. */
  99120. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  99121. }
  99122. }
  99123. declare module BABYLON {
  99124. /**
  99125. * Enum defining the type of properties that can be edited in the property pages in the NME
  99126. */
  99127. export enum PropertyTypeForEdition {
  99128. /** property is a boolean */
  99129. Boolean = 0,
  99130. /** property is a float */
  99131. Float = 1,
  99132. /** property is a Vector2 */
  99133. Vector2 = 2,
  99134. /** property is a list of values */
  99135. List = 3
  99136. }
  99137. /**
  99138. * Interface that defines an option in a variable of type list
  99139. */
  99140. export interface IEditablePropertyListOption {
  99141. /** label of the option */
  99142. "label": string;
  99143. /** value of the option */
  99144. "value": number;
  99145. }
  99146. /**
  99147. * Interface that defines the options available for an editable property
  99148. */
  99149. export interface IEditablePropertyOption {
  99150. /** min value */
  99151. "min"?: number;
  99152. /** max value */
  99153. "max"?: number;
  99154. /** notifiers: indicates which actions to take when the property is changed */
  99155. "notifiers"?: {
  99156. /** the material should be rebuilt */
  99157. "rebuild"?: boolean;
  99158. /** the preview should be updated */
  99159. "update"?: boolean;
  99160. };
  99161. /** list of the options for a variable of type list */
  99162. "options"?: IEditablePropertyListOption[];
  99163. }
  99164. /**
  99165. * Interface that describes an editable property
  99166. */
  99167. export interface IPropertyDescriptionForEdition {
  99168. /** name of the property */
  99169. "propertyName": string;
  99170. /** display name of the property */
  99171. "displayName": string;
  99172. /** type of the property */
  99173. "type": PropertyTypeForEdition;
  99174. /** group of the property - all properties with the same group value will be displayed in a specific section */
  99175. "groupName": string;
  99176. /** options for the property */
  99177. "options": IEditablePropertyOption;
  99178. }
  99179. /**
  99180. * Decorator that flags a property in a node material block as being editable
  99181. */
  99182. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  99183. }
  99184. declare module BABYLON {
  99185. /**
  99186. * Block used to implement the refraction part of the sub surface module of the PBR material
  99187. */
  99188. export class RefractionBlock extends NodeMaterialBlock {
  99189. /** @hidden */
  99190. _define3DName: string;
  99191. /** @hidden */
  99192. _refractionMatrixName: string;
  99193. /** @hidden */
  99194. _defineLODRefractionAlpha: string;
  99195. /** @hidden */
  99196. _defineLinearSpecularRefraction: string;
  99197. /** @hidden */
  99198. _defineOppositeZ: string;
  99199. /** @hidden */
  99200. _cubeSamplerName: string;
  99201. /** @hidden */
  99202. _2DSamplerName: string;
  99203. /** @hidden */
  99204. _vRefractionMicrosurfaceInfosName: string;
  99205. /** @hidden */
  99206. _vRefractionInfosName: string;
  99207. private _scene;
  99208. /**
  99209. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  99210. * Materials half opaque for instance using refraction could benefit from this control.
  99211. */
  99212. linkRefractionWithTransparency: boolean;
  99213. /**
  99214. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  99215. */
  99216. invertRefractionY: boolean;
  99217. /**
  99218. * Gets or sets the texture associated with the node
  99219. */
  99220. texture: Nullable<BaseTexture>;
  99221. /**
  99222. * Create a new RefractionBlock
  99223. * @param name defines the block name
  99224. */
  99225. constructor(name: string);
  99226. /**
  99227. * Gets the current class name
  99228. * @returns the class name
  99229. */
  99230. getClassName(): string;
  99231. /**
  99232. * Gets the intensity input component
  99233. */
  99234. get intensity(): NodeMaterialConnectionPoint;
  99235. /**
  99236. * Gets the index of refraction input component
  99237. */
  99238. get indexOfRefraction(): NodeMaterialConnectionPoint;
  99239. /**
  99240. * Gets the tint at distance input component
  99241. */
  99242. get tintAtDistance(): NodeMaterialConnectionPoint;
  99243. /**
  99244. * Gets the view input component
  99245. */
  99246. get view(): NodeMaterialConnectionPoint;
  99247. /**
  99248. * Gets the refraction object output component
  99249. */
  99250. get refraction(): NodeMaterialConnectionPoint;
  99251. /**
  99252. * Returns true if the block has a texture
  99253. */
  99254. get hasTexture(): boolean;
  99255. protected _getTexture(): Nullable<BaseTexture>;
  99256. autoConfigure(material: NodeMaterial): void;
  99257. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99258. isReady(): boolean;
  99259. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99260. /**
  99261. * Gets the main code of the block (fragment side)
  99262. * @param state current state of the node material building
  99263. * @returns the shader code
  99264. */
  99265. getCode(state: NodeMaterialBuildState): string;
  99266. protected _buildBlock(state: NodeMaterialBuildState): this;
  99267. protected _dumpPropertiesCode(): string;
  99268. serialize(): any;
  99269. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99270. }
  99271. }
  99272. declare module BABYLON {
  99273. /**
  99274. * Base block used as input for post process
  99275. */
  99276. export class CurrentScreenBlock extends NodeMaterialBlock {
  99277. private _samplerName;
  99278. private _linearDefineName;
  99279. private _gammaDefineName;
  99280. private _mainUVName;
  99281. private _tempTextureRead;
  99282. /**
  99283. * Gets or sets the texture associated with the node
  99284. */
  99285. texture: Nullable<BaseTexture>;
  99286. /**
  99287. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99288. */
  99289. convertToGammaSpace: boolean;
  99290. /**
  99291. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99292. */
  99293. convertToLinearSpace: boolean;
  99294. /**
  99295. * Create a new CurrentScreenBlock
  99296. * @param name defines the block name
  99297. */
  99298. constructor(name: string);
  99299. /**
  99300. * Gets the current class name
  99301. * @returns the class name
  99302. */
  99303. getClassName(): string;
  99304. /**
  99305. * Gets the uv input component
  99306. */
  99307. get uv(): NodeMaterialConnectionPoint;
  99308. /**
  99309. * Gets the rgba output component
  99310. */
  99311. get rgba(): NodeMaterialConnectionPoint;
  99312. /**
  99313. * Gets the rgb output component
  99314. */
  99315. get rgb(): NodeMaterialConnectionPoint;
  99316. /**
  99317. * Gets the r output component
  99318. */
  99319. get r(): NodeMaterialConnectionPoint;
  99320. /**
  99321. * Gets the g output component
  99322. */
  99323. get g(): NodeMaterialConnectionPoint;
  99324. /**
  99325. * Gets the b output component
  99326. */
  99327. get b(): NodeMaterialConnectionPoint;
  99328. /**
  99329. * Gets the a output component
  99330. */
  99331. get a(): NodeMaterialConnectionPoint;
  99332. /**
  99333. * Initialize the block and prepare the context for build
  99334. * @param state defines the state that will be used for the build
  99335. */
  99336. initialize(state: NodeMaterialBuildState): void;
  99337. get target(): NodeMaterialBlockTargets;
  99338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99339. isReady(): boolean;
  99340. private _injectVertexCode;
  99341. private _writeTextureRead;
  99342. private _writeOutput;
  99343. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99344. serialize(): any;
  99345. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99346. }
  99347. }
  99348. declare module BABYLON {
  99349. /**
  99350. * Base block used for the particle texture
  99351. */
  99352. export class ParticleTextureBlock extends NodeMaterialBlock {
  99353. private _samplerName;
  99354. private _linearDefineName;
  99355. private _gammaDefineName;
  99356. private _tempTextureRead;
  99357. /**
  99358. * Gets or sets the texture associated with the node
  99359. */
  99360. texture: Nullable<BaseTexture>;
  99361. /**
  99362. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  99363. */
  99364. convertToGammaSpace: boolean;
  99365. /**
  99366. * Gets or sets a boolean indicating if content needs to be converted to linear space
  99367. */
  99368. convertToLinearSpace: boolean;
  99369. /**
  99370. * Create a new ParticleTextureBlock
  99371. * @param name defines the block name
  99372. */
  99373. constructor(name: string);
  99374. /**
  99375. * Gets the current class name
  99376. * @returns the class name
  99377. */
  99378. getClassName(): string;
  99379. /**
  99380. * Gets the uv input component
  99381. */
  99382. get uv(): NodeMaterialConnectionPoint;
  99383. /**
  99384. * Gets the rgba output component
  99385. */
  99386. get rgba(): NodeMaterialConnectionPoint;
  99387. /**
  99388. * Gets the rgb output component
  99389. */
  99390. get rgb(): NodeMaterialConnectionPoint;
  99391. /**
  99392. * Gets the r output component
  99393. */
  99394. get r(): NodeMaterialConnectionPoint;
  99395. /**
  99396. * Gets the g output component
  99397. */
  99398. get g(): NodeMaterialConnectionPoint;
  99399. /**
  99400. * Gets the b output component
  99401. */
  99402. get b(): NodeMaterialConnectionPoint;
  99403. /**
  99404. * Gets the a output component
  99405. */
  99406. get a(): NodeMaterialConnectionPoint;
  99407. /**
  99408. * Initialize the block and prepare the context for build
  99409. * @param state defines the state that will be used for the build
  99410. */
  99411. initialize(state: NodeMaterialBuildState): void;
  99412. autoConfigure(material: NodeMaterial): void;
  99413. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  99414. isReady(): boolean;
  99415. private _writeOutput;
  99416. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  99417. serialize(): any;
  99418. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99419. }
  99420. }
  99421. declare module BABYLON {
  99422. /**
  99423. * Class used to store shared data between 2 NodeMaterialBuildState
  99424. */
  99425. export class NodeMaterialBuildStateSharedData {
  99426. /**
  99427. * Gets the list of emitted varyings
  99428. */
  99429. temps: string[];
  99430. /**
  99431. * Gets the list of emitted varyings
  99432. */
  99433. varyings: string[];
  99434. /**
  99435. * Gets the varying declaration string
  99436. */
  99437. varyingDeclaration: string;
  99438. /**
  99439. * Input blocks
  99440. */
  99441. inputBlocks: InputBlock[];
  99442. /**
  99443. * Input blocks
  99444. */
  99445. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  99446. /**
  99447. * Bindable blocks (Blocks that need to set data to the effect)
  99448. */
  99449. bindableBlocks: NodeMaterialBlock[];
  99450. /**
  99451. * List of blocks that can provide a compilation fallback
  99452. */
  99453. blocksWithFallbacks: NodeMaterialBlock[];
  99454. /**
  99455. * List of blocks that can provide a define update
  99456. */
  99457. blocksWithDefines: NodeMaterialBlock[];
  99458. /**
  99459. * List of blocks that can provide a repeatable content
  99460. */
  99461. repeatableContentBlocks: NodeMaterialBlock[];
  99462. /**
  99463. * List of blocks that can provide a dynamic list of uniforms
  99464. */
  99465. dynamicUniformBlocks: NodeMaterialBlock[];
  99466. /**
  99467. * List of blocks that can block the isReady function for the material
  99468. */
  99469. blockingBlocks: NodeMaterialBlock[];
  99470. /**
  99471. * Gets the list of animated inputs
  99472. */
  99473. animatedInputs: InputBlock[];
  99474. /**
  99475. * Build Id used to avoid multiple recompilations
  99476. */
  99477. buildId: number;
  99478. /** List of emitted variables */
  99479. variableNames: {
  99480. [key: string]: number;
  99481. };
  99482. /** List of emitted defines */
  99483. defineNames: {
  99484. [key: string]: number;
  99485. };
  99486. /** Should emit comments? */
  99487. emitComments: boolean;
  99488. /** Emit build activity */
  99489. verbose: boolean;
  99490. /** Gets or sets the hosting scene */
  99491. scene: Scene;
  99492. /**
  99493. * Gets the compilation hints emitted at compilation time
  99494. */
  99495. hints: {
  99496. needWorldViewMatrix: boolean;
  99497. needWorldViewProjectionMatrix: boolean;
  99498. needAlphaBlending: boolean;
  99499. needAlphaTesting: boolean;
  99500. };
  99501. /**
  99502. * List of compilation checks
  99503. */
  99504. checks: {
  99505. emitVertex: boolean;
  99506. emitFragment: boolean;
  99507. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  99508. };
  99509. /**
  99510. * Is vertex program allowed to be empty?
  99511. */
  99512. allowEmptyVertexProgram: boolean;
  99513. /** Creates a new shared data */
  99514. constructor();
  99515. /**
  99516. * Emits console errors and exceptions if there is a failing check
  99517. */
  99518. emitErrors(): void;
  99519. }
  99520. }
  99521. declare module BABYLON {
  99522. /**
  99523. * Class used to store node based material build state
  99524. */
  99525. export class NodeMaterialBuildState {
  99526. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  99527. supportUniformBuffers: boolean;
  99528. /**
  99529. * Gets the list of emitted attributes
  99530. */
  99531. attributes: string[];
  99532. /**
  99533. * Gets the list of emitted uniforms
  99534. */
  99535. uniforms: string[];
  99536. /**
  99537. * Gets the list of emitted constants
  99538. */
  99539. constants: string[];
  99540. /**
  99541. * Gets the list of emitted samplers
  99542. */
  99543. samplers: string[];
  99544. /**
  99545. * Gets the list of emitted functions
  99546. */
  99547. functions: {
  99548. [key: string]: string;
  99549. };
  99550. /**
  99551. * Gets the list of emitted extensions
  99552. */
  99553. extensions: {
  99554. [key: string]: string;
  99555. };
  99556. /**
  99557. * Gets the target of the compilation state
  99558. */
  99559. target: NodeMaterialBlockTargets;
  99560. /**
  99561. * Gets the list of emitted counters
  99562. */
  99563. counters: {
  99564. [key: string]: number;
  99565. };
  99566. /**
  99567. * Shared data between multiple NodeMaterialBuildState instances
  99568. */
  99569. sharedData: NodeMaterialBuildStateSharedData;
  99570. /** @hidden */
  99571. _vertexState: NodeMaterialBuildState;
  99572. /** @hidden */
  99573. _attributeDeclaration: string;
  99574. /** @hidden */
  99575. _uniformDeclaration: string;
  99576. /** @hidden */
  99577. _constantDeclaration: string;
  99578. /** @hidden */
  99579. _samplerDeclaration: string;
  99580. /** @hidden */
  99581. _varyingTransfer: string;
  99582. /** @hidden */
  99583. _injectAtEnd: string;
  99584. private _repeatableContentAnchorIndex;
  99585. /** @hidden */
  99586. _builtCompilationString: string;
  99587. /**
  99588. * Gets the emitted compilation strings
  99589. */
  99590. compilationString: string;
  99591. /**
  99592. * Finalize the compilation strings
  99593. * @param state defines the current compilation state
  99594. */
  99595. finalize(state: NodeMaterialBuildState): void;
  99596. /** @hidden */
  99597. get _repeatableContentAnchor(): string;
  99598. /** @hidden */
  99599. _getFreeVariableName(prefix: string): string;
  99600. /** @hidden */
  99601. _getFreeDefineName(prefix: string): string;
  99602. /** @hidden */
  99603. _excludeVariableName(name: string): void;
  99604. /** @hidden */
  99605. _emit2DSampler(name: string): void;
  99606. /** @hidden */
  99607. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  99608. /** @hidden */
  99609. _emitExtension(name: string, extension: string, define?: string): void;
  99610. /** @hidden */
  99611. _emitFunction(name: string, code: string, comments: string): void;
  99612. /** @hidden */
  99613. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  99614. replaceStrings?: {
  99615. search: RegExp;
  99616. replace: string;
  99617. }[];
  99618. repeatKey?: string;
  99619. }): string;
  99620. /** @hidden */
  99621. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  99622. repeatKey?: string;
  99623. removeAttributes?: boolean;
  99624. removeUniforms?: boolean;
  99625. removeVaryings?: boolean;
  99626. removeIfDef?: boolean;
  99627. replaceStrings?: {
  99628. search: RegExp;
  99629. replace: string;
  99630. }[];
  99631. }, storeKey?: string): void;
  99632. /** @hidden */
  99633. _registerTempVariable(name: string): boolean;
  99634. /** @hidden */
  99635. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  99636. /** @hidden */
  99637. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  99638. /** @hidden */
  99639. _emitFloat(value: number): string;
  99640. }
  99641. }
  99642. declare module BABYLON {
  99643. /**
  99644. * Helper class used to generate session unique ID
  99645. */
  99646. export class UniqueIdGenerator {
  99647. private static _UniqueIdCounter;
  99648. /**
  99649. * Gets an unique (relatively to the current scene) Id
  99650. */
  99651. static get UniqueId(): number;
  99652. }
  99653. }
  99654. declare module BABYLON {
  99655. /**
  99656. * Defines a block that can be used inside a node based material
  99657. */
  99658. export class NodeMaterialBlock {
  99659. private _buildId;
  99660. private _buildTarget;
  99661. private _target;
  99662. private _isFinalMerger;
  99663. private _isInput;
  99664. protected _isUnique: boolean;
  99665. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  99666. inputsAreExclusive: boolean;
  99667. /** @hidden */
  99668. _codeVariableName: string;
  99669. /** @hidden */
  99670. _inputs: NodeMaterialConnectionPoint[];
  99671. /** @hidden */
  99672. _outputs: NodeMaterialConnectionPoint[];
  99673. /** @hidden */
  99674. _preparationId: number;
  99675. /**
  99676. * Gets or sets the name of the block
  99677. */
  99678. name: string;
  99679. /**
  99680. * Gets or sets the unique id of the node
  99681. */
  99682. uniqueId: number;
  99683. /**
  99684. * Gets or sets the comments associated with this block
  99685. */
  99686. comments: string;
  99687. /**
  99688. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  99689. */
  99690. get isUnique(): boolean;
  99691. /**
  99692. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  99693. */
  99694. get isFinalMerger(): boolean;
  99695. /**
  99696. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  99697. */
  99698. get isInput(): boolean;
  99699. /**
  99700. * Gets or sets the build Id
  99701. */
  99702. get buildId(): number;
  99703. set buildId(value: number);
  99704. /**
  99705. * Gets or sets the target of the block
  99706. */
  99707. get target(): NodeMaterialBlockTargets;
  99708. set target(value: NodeMaterialBlockTargets);
  99709. /**
  99710. * Gets the list of input points
  99711. */
  99712. get inputs(): NodeMaterialConnectionPoint[];
  99713. /** Gets the list of output points */
  99714. get outputs(): NodeMaterialConnectionPoint[];
  99715. /**
  99716. * Find an input by its name
  99717. * @param name defines the name of the input to look for
  99718. * @returns the input or null if not found
  99719. */
  99720. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99721. /**
  99722. * Find an output by its name
  99723. * @param name defines the name of the outputto look for
  99724. * @returns the output or null if not found
  99725. */
  99726. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  99727. /**
  99728. * Creates a new NodeMaterialBlock
  99729. * @param name defines the block name
  99730. * @param target defines the target of that block (Vertex by default)
  99731. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  99732. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  99733. */
  99734. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  99735. /**
  99736. * Initialize the block and prepare the context for build
  99737. * @param state defines the state that will be used for the build
  99738. */
  99739. initialize(state: NodeMaterialBuildState): void;
  99740. /**
  99741. * Bind data to effect. Will only be called for blocks with isBindable === true
  99742. * @param effect defines the effect to bind data to
  99743. * @param nodeMaterial defines the hosting NodeMaterial
  99744. * @param mesh defines the mesh that will be rendered
  99745. * @param subMesh defines the submesh that will be rendered
  99746. */
  99747. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  99748. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  99749. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  99750. protected _writeFloat(value: number): string;
  99751. /**
  99752. * Gets the current class name e.g. "NodeMaterialBlock"
  99753. * @returns the class name
  99754. */
  99755. getClassName(): string;
  99756. /**
  99757. * Register a new input. Must be called inside a block constructor
  99758. * @param name defines the connection point name
  99759. * @param type defines the connection point type
  99760. * @param isOptional defines a boolean indicating that this input can be omitted
  99761. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99762. * @param point an already created connection point. If not provided, create a new one
  99763. * @returns the current block
  99764. */
  99765. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99766. /**
  99767. * Register a new output. Must be called inside a block constructor
  99768. * @param name defines the connection point name
  99769. * @param type defines the connection point type
  99770. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  99771. * @param point an already created connection point. If not provided, create a new one
  99772. * @returns the current block
  99773. */
  99774. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  99775. /**
  99776. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  99777. * @param forOutput defines an optional connection point to check compatibility with
  99778. * @returns the first available input or null
  99779. */
  99780. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  99781. /**
  99782. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  99783. * @param forBlock defines an optional block to check compatibility with
  99784. * @returns the first available input or null
  99785. */
  99786. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  99787. /**
  99788. * Gets the sibling of the given output
  99789. * @param current defines the current output
  99790. * @returns the next output in the list or null
  99791. */
  99792. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  99793. /**
  99794. * Connect current block with another block
  99795. * @param other defines the block to connect with
  99796. * @param options define the various options to help pick the right connections
  99797. * @returns the current block
  99798. */
  99799. connectTo(other: NodeMaterialBlock, options?: {
  99800. input?: string;
  99801. output?: string;
  99802. outputSwizzle?: string;
  99803. }): this | undefined;
  99804. protected _buildBlock(state: NodeMaterialBuildState): void;
  99805. /**
  99806. * Add uniforms, samplers and uniform buffers at compilation time
  99807. * @param state defines the state to update
  99808. * @param nodeMaterial defines the node material requesting the update
  99809. * @param defines defines the material defines to update
  99810. * @param uniformBuffers defines the list of uniform buffer names
  99811. */
  99812. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  99813. /**
  99814. * Add potential fallbacks if shader compilation fails
  99815. * @param mesh defines the mesh to be rendered
  99816. * @param fallbacks defines the current prioritized list of fallbacks
  99817. */
  99818. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  99819. /**
  99820. * Initialize defines for shader compilation
  99821. * @param mesh defines the mesh to be rendered
  99822. * @param nodeMaterial defines the node material requesting the update
  99823. * @param defines defines the material defines to update
  99824. * @param useInstances specifies that instances should be used
  99825. */
  99826. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  99827. /**
  99828. * Update defines for shader compilation
  99829. * @param mesh defines the mesh to be rendered
  99830. * @param nodeMaterial defines the node material requesting the update
  99831. * @param defines defines the material defines to update
  99832. * @param useInstances specifies that instances should be used
  99833. * @param subMesh defines which submesh to render
  99834. */
  99835. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99836. /**
  99837. * Lets the block try to connect some inputs automatically
  99838. * @param material defines the hosting NodeMaterial
  99839. */
  99840. autoConfigure(material: NodeMaterial): void;
  99841. /**
  99842. * Function called when a block is declared as repeatable content generator
  99843. * @param vertexShaderState defines the current compilation state for the vertex shader
  99844. * @param fragmentShaderState defines the current compilation state for the fragment shader
  99845. * @param mesh defines the mesh to be rendered
  99846. * @param defines defines the material defines to update
  99847. */
  99848. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  99849. /**
  99850. * Checks if the block is ready
  99851. * @param mesh defines the mesh to be rendered
  99852. * @param nodeMaterial defines the node material requesting the update
  99853. * @param defines defines the material defines to update
  99854. * @param useInstances specifies that instances should be used
  99855. * @returns true if the block is ready
  99856. */
  99857. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  99858. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  99859. private _processBuild;
  99860. /**
  99861. * Compile the current node and generate the shader code
  99862. * @param state defines the current compilation state (uniforms, samplers, current string)
  99863. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  99864. * @returns true if already built
  99865. */
  99866. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  99867. protected _inputRename(name: string): string;
  99868. protected _outputRename(name: string): string;
  99869. protected _dumpPropertiesCode(): string;
  99870. /** @hidden */
  99871. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  99872. /** @hidden */
  99873. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  99874. /**
  99875. * Clone the current block to a new identical block
  99876. * @param scene defines the hosting scene
  99877. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  99878. * @returns a copy of the current block
  99879. */
  99880. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  99881. /**
  99882. * Serializes this block in a JSON representation
  99883. * @returns the serialized block object
  99884. */
  99885. serialize(): any;
  99886. /** @hidden */
  99887. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99888. private _deserializePortDisplayNamesAndExposedOnFrame;
  99889. /**
  99890. * Release resources
  99891. */
  99892. dispose(): void;
  99893. }
  99894. }
  99895. declare module BABYLON {
  99896. /**
  99897. * Base class of materials working in push mode in babylon JS
  99898. * @hidden
  99899. */
  99900. export class PushMaterial extends Material {
  99901. protected _activeEffect: Effect;
  99902. protected _normalMatrix: Matrix;
  99903. constructor(name: string, scene: Scene);
  99904. getEffect(): Effect;
  99905. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99906. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  99907. /**
  99908. * Binds the given world matrix to the active effect
  99909. *
  99910. * @param world the matrix to bind
  99911. */
  99912. bindOnlyWorldMatrix(world: Matrix): void;
  99913. /**
  99914. * Binds the given normal matrix to the active effect
  99915. *
  99916. * @param normalMatrix the matrix to bind
  99917. */
  99918. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99919. bind(world: Matrix, mesh?: Mesh): void;
  99920. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99921. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99922. }
  99923. }
  99924. declare module BABYLON {
  99925. /**
  99926. * Root class for all node material optimizers
  99927. */
  99928. export class NodeMaterialOptimizer {
  99929. /**
  99930. * Function used to optimize a NodeMaterial graph
  99931. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  99932. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  99933. */
  99934. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  99935. }
  99936. }
  99937. declare module BABYLON {
  99938. /**
  99939. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  99940. */
  99941. export class TransformBlock extends NodeMaterialBlock {
  99942. /**
  99943. * Defines the value to use to complement W value to transform it to a Vector4
  99944. */
  99945. complementW: number;
  99946. /**
  99947. * Defines the value to use to complement z value to transform it to a Vector4
  99948. */
  99949. complementZ: number;
  99950. /**
  99951. * Creates a new TransformBlock
  99952. * @param name defines the block name
  99953. */
  99954. constructor(name: string);
  99955. /**
  99956. * Gets the current class name
  99957. * @returns the class name
  99958. */
  99959. getClassName(): string;
  99960. /**
  99961. * Gets the vector input
  99962. */
  99963. get vector(): NodeMaterialConnectionPoint;
  99964. /**
  99965. * Gets the output component
  99966. */
  99967. get output(): NodeMaterialConnectionPoint;
  99968. /**
  99969. * Gets the xyz output component
  99970. */
  99971. get xyz(): NodeMaterialConnectionPoint;
  99972. /**
  99973. * Gets the matrix transform input
  99974. */
  99975. get transform(): NodeMaterialConnectionPoint;
  99976. protected _buildBlock(state: NodeMaterialBuildState): this;
  99977. /**
  99978. * Update defines for shader compilation
  99979. * @param mesh defines the mesh to be rendered
  99980. * @param nodeMaterial defines the node material requesting the update
  99981. * @param defines defines the material defines to update
  99982. * @param useInstances specifies that instances should be used
  99983. * @param subMesh defines which submesh to render
  99984. */
  99985. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  99986. serialize(): any;
  99987. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  99988. protected _dumpPropertiesCode(): string;
  99989. }
  99990. }
  99991. declare module BABYLON {
  99992. /**
  99993. * Block used to output the vertex position
  99994. */
  99995. export class VertexOutputBlock extends NodeMaterialBlock {
  99996. /**
  99997. * Creates a new VertexOutputBlock
  99998. * @param name defines the block name
  99999. */
  100000. constructor(name: string);
  100001. /**
  100002. * Gets the current class name
  100003. * @returns the class name
  100004. */
  100005. getClassName(): string;
  100006. /**
  100007. * Gets the vector input component
  100008. */
  100009. get vector(): NodeMaterialConnectionPoint;
  100010. protected _buildBlock(state: NodeMaterialBuildState): this;
  100011. }
  100012. }
  100013. declare module BABYLON {
  100014. /**
  100015. * Block used to output the final color
  100016. */
  100017. export class FragmentOutputBlock extends NodeMaterialBlock {
  100018. /**
  100019. * Create a new FragmentOutputBlock
  100020. * @param name defines the block name
  100021. */
  100022. constructor(name: string);
  100023. /**
  100024. * Gets the current class name
  100025. * @returns the class name
  100026. */
  100027. getClassName(): string;
  100028. /**
  100029. * Gets the rgba input component
  100030. */
  100031. get rgba(): NodeMaterialConnectionPoint;
  100032. /**
  100033. * Gets the rgb input component
  100034. */
  100035. get rgb(): NodeMaterialConnectionPoint;
  100036. /**
  100037. * Gets the a input component
  100038. */
  100039. get a(): NodeMaterialConnectionPoint;
  100040. protected _buildBlock(state: NodeMaterialBuildState): this;
  100041. }
  100042. }
  100043. declare module BABYLON {
  100044. /**
  100045. * Block used for the particle ramp gradient section
  100046. */
  100047. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  100048. /**
  100049. * Create a new ParticleRampGradientBlock
  100050. * @param name defines the block name
  100051. */
  100052. constructor(name: string);
  100053. /**
  100054. * Gets the current class name
  100055. * @returns the class name
  100056. */
  100057. getClassName(): string;
  100058. /**
  100059. * Gets the color input component
  100060. */
  100061. get color(): NodeMaterialConnectionPoint;
  100062. /**
  100063. * Gets the rampColor output component
  100064. */
  100065. get rampColor(): NodeMaterialConnectionPoint;
  100066. /**
  100067. * Initialize the block and prepare the context for build
  100068. * @param state defines the state that will be used for the build
  100069. */
  100070. initialize(state: NodeMaterialBuildState): void;
  100071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100072. }
  100073. }
  100074. declare module BABYLON {
  100075. /**
  100076. * Block used for the particle blend multiply section
  100077. */
  100078. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  100079. /**
  100080. * Create a new ParticleBlendMultiplyBlock
  100081. * @param name defines the block name
  100082. */
  100083. constructor(name: string);
  100084. /**
  100085. * Gets the current class name
  100086. * @returns the class name
  100087. */
  100088. getClassName(): string;
  100089. /**
  100090. * Gets the color input component
  100091. */
  100092. get color(): NodeMaterialConnectionPoint;
  100093. /**
  100094. * Gets the alphaTexture input component
  100095. */
  100096. get alphaTexture(): NodeMaterialConnectionPoint;
  100097. /**
  100098. * Gets the alphaColor input component
  100099. */
  100100. get alphaColor(): NodeMaterialConnectionPoint;
  100101. /**
  100102. * Gets the blendColor output component
  100103. */
  100104. get blendColor(): NodeMaterialConnectionPoint;
  100105. /**
  100106. * Initialize the block and prepare the context for build
  100107. * @param state defines the state that will be used for the build
  100108. */
  100109. initialize(state: NodeMaterialBuildState): void;
  100110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100111. }
  100112. }
  100113. declare module BABYLON {
  100114. /**
  100115. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  100116. */
  100117. export class VectorMergerBlock extends NodeMaterialBlock {
  100118. /**
  100119. * Create a new VectorMergerBlock
  100120. * @param name defines the block name
  100121. */
  100122. constructor(name: string);
  100123. /**
  100124. * Gets the current class name
  100125. * @returns the class name
  100126. */
  100127. getClassName(): string;
  100128. /**
  100129. * Gets the xyz component (input)
  100130. */
  100131. get xyzIn(): NodeMaterialConnectionPoint;
  100132. /**
  100133. * Gets the xy component (input)
  100134. */
  100135. get xyIn(): NodeMaterialConnectionPoint;
  100136. /**
  100137. * Gets the x component (input)
  100138. */
  100139. get x(): NodeMaterialConnectionPoint;
  100140. /**
  100141. * Gets the y component (input)
  100142. */
  100143. get y(): NodeMaterialConnectionPoint;
  100144. /**
  100145. * Gets the z component (input)
  100146. */
  100147. get z(): NodeMaterialConnectionPoint;
  100148. /**
  100149. * Gets the w component (input)
  100150. */
  100151. get w(): NodeMaterialConnectionPoint;
  100152. /**
  100153. * Gets the xyzw component (output)
  100154. */
  100155. get xyzw(): NodeMaterialConnectionPoint;
  100156. /**
  100157. * Gets the xyz component (output)
  100158. */
  100159. get xyzOut(): NodeMaterialConnectionPoint;
  100160. /**
  100161. * Gets the xy component (output)
  100162. */
  100163. get xyOut(): NodeMaterialConnectionPoint;
  100164. /**
  100165. * Gets the xy component (output)
  100166. * @deprecated Please use xyOut instead.
  100167. */
  100168. get xy(): NodeMaterialConnectionPoint;
  100169. /**
  100170. * Gets the xyz component (output)
  100171. * @deprecated Please use xyzOut instead.
  100172. */
  100173. get xyz(): NodeMaterialConnectionPoint;
  100174. protected _buildBlock(state: NodeMaterialBuildState): this;
  100175. }
  100176. }
  100177. declare module BABYLON {
  100178. /**
  100179. * Block used to remap a float from a range to a new one
  100180. */
  100181. export class RemapBlock extends NodeMaterialBlock {
  100182. /**
  100183. * Gets or sets the source range
  100184. */
  100185. sourceRange: Vector2;
  100186. /**
  100187. * Gets or sets the target range
  100188. */
  100189. targetRange: Vector2;
  100190. /**
  100191. * Creates a new RemapBlock
  100192. * @param name defines the block name
  100193. */
  100194. constructor(name: string);
  100195. /**
  100196. * Gets the current class name
  100197. * @returns the class name
  100198. */
  100199. getClassName(): string;
  100200. /**
  100201. * Gets the input component
  100202. */
  100203. get input(): NodeMaterialConnectionPoint;
  100204. /**
  100205. * Gets the source min input component
  100206. */
  100207. get sourceMin(): NodeMaterialConnectionPoint;
  100208. /**
  100209. * Gets the source max input component
  100210. */
  100211. get sourceMax(): NodeMaterialConnectionPoint;
  100212. /**
  100213. * Gets the target min input component
  100214. */
  100215. get targetMin(): NodeMaterialConnectionPoint;
  100216. /**
  100217. * Gets the target max input component
  100218. */
  100219. get targetMax(): NodeMaterialConnectionPoint;
  100220. /**
  100221. * Gets the output component
  100222. */
  100223. get output(): NodeMaterialConnectionPoint;
  100224. protected _buildBlock(state: NodeMaterialBuildState): this;
  100225. protected _dumpPropertiesCode(): string;
  100226. serialize(): any;
  100227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100228. }
  100229. }
  100230. declare module BABYLON {
  100231. /**
  100232. * Block used to multiply 2 values
  100233. */
  100234. export class MultiplyBlock extends NodeMaterialBlock {
  100235. /**
  100236. * Creates a new MultiplyBlock
  100237. * @param name defines the block name
  100238. */
  100239. constructor(name: string);
  100240. /**
  100241. * Gets the current class name
  100242. * @returns the class name
  100243. */
  100244. getClassName(): string;
  100245. /**
  100246. * Gets the left operand input component
  100247. */
  100248. get left(): NodeMaterialConnectionPoint;
  100249. /**
  100250. * Gets the right operand input component
  100251. */
  100252. get right(): NodeMaterialConnectionPoint;
  100253. /**
  100254. * Gets the output component
  100255. */
  100256. get output(): NodeMaterialConnectionPoint;
  100257. protected _buildBlock(state: NodeMaterialBuildState): this;
  100258. }
  100259. }
  100260. declare module BABYLON {
  100261. /**
  100262. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  100263. */
  100264. export class ColorSplitterBlock extends NodeMaterialBlock {
  100265. /**
  100266. * Create a new ColorSplitterBlock
  100267. * @param name defines the block name
  100268. */
  100269. constructor(name: string);
  100270. /**
  100271. * Gets the current class name
  100272. * @returns the class name
  100273. */
  100274. getClassName(): string;
  100275. /**
  100276. * Gets the rgba component (input)
  100277. */
  100278. get rgba(): NodeMaterialConnectionPoint;
  100279. /**
  100280. * Gets the rgb component (input)
  100281. */
  100282. get rgbIn(): NodeMaterialConnectionPoint;
  100283. /**
  100284. * Gets the rgb component (output)
  100285. */
  100286. get rgbOut(): NodeMaterialConnectionPoint;
  100287. /**
  100288. * Gets the r component (output)
  100289. */
  100290. get r(): NodeMaterialConnectionPoint;
  100291. /**
  100292. * Gets the g component (output)
  100293. */
  100294. get g(): NodeMaterialConnectionPoint;
  100295. /**
  100296. * Gets the b component (output)
  100297. */
  100298. get b(): NodeMaterialConnectionPoint;
  100299. /**
  100300. * Gets the a component (output)
  100301. */
  100302. get a(): NodeMaterialConnectionPoint;
  100303. protected _inputRename(name: string): string;
  100304. protected _outputRename(name: string): string;
  100305. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  100306. }
  100307. }
  100308. declare module BABYLON {
  100309. /**
  100310. * Interface used to configure the node material editor
  100311. */
  100312. export interface INodeMaterialEditorOptions {
  100313. /** Define the URl to load node editor script */
  100314. editorURL?: string;
  100315. }
  100316. /** @hidden */
  100317. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100318. NORMAL: boolean;
  100319. TANGENT: boolean;
  100320. UV1: boolean;
  100321. /** BONES */
  100322. NUM_BONE_INFLUENCERS: number;
  100323. BonesPerMesh: number;
  100324. BONETEXTURE: boolean;
  100325. /** MORPH TARGETS */
  100326. MORPHTARGETS: boolean;
  100327. MORPHTARGETS_NORMAL: boolean;
  100328. MORPHTARGETS_TANGENT: boolean;
  100329. MORPHTARGETS_UV: boolean;
  100330. NUM_MORPH_INFLUENCERS: number;
  100331. /** IMAGE PROCESSING */
  100332. IMAGEPROCESSING: boolean;
  100333. VIGNETTE: boolean;
  100334. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100335. VIGNETTEBLENDMODEOPAQUE: boolean;
  100336. TONEMAPPING: boolean;
  100337. TONEMAPPING_ACES: boolean;
  100338. CONTRAST: boolean;
  100339. EXPOSURE: boolean;
  100340. COLORCURVES: boolean;
  100341. COLORGRADING: boolean;
  100342. COLORGRADING3D: boolean;
  100343. SAMPLER3DGREENDEPTH: boolean;
  100344. SAMPLER3DBGRMAP: boolean;
  100345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100346. /** MISC. */
  100347. BUMPDIRECTUV: number;
  100348. constructor();
  100349. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  100350. }
  100351. /**
  100352. * Class used to configure NodeMaterial
  100353. */
  100354. export interface INodeMaterialOptions {
  100355. /**
  100356. * Defines if blocks should emit comments
  100357. */
  100358. emitComments: boolean;
  100359. }
  100360. /**
  100361. * Class used to create a node based material built by assembling shader blocks
  100362. */
  100363. export class NodeMaterial extends PushMaterial {
  100364. private static _BuildIdGenerator;
  100365. private _options;
  100366. private _vertexCompilationState;
  100367. private _fragmentCompilationState;
  100368. private _sharedData;
  100369. private _buildId;
  100370. private _buildWasSuccessful;
  100371. private _cachedWorldViewMatrix;
  100372. private _cachedWorldViewProjectionMatrix;
  100373. private _optimizers;
  100374. private _animationFrame;
  100375. /** Define the Url to load node editor script */
  100376. static EditorURL: string;
  100377. /** Define the Url to load snippets */
  100378. static SnippetUrl: string;
  100379. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  100380. static IgnoreTexturesAtLoadTime: boolean;
  100381. private BJSNODEMATERIALEDITOR;
  100382. /** Get the inspector from bundle or global */
  100383. private _getGlobalNodeMaterialEditor;
  100384. /**
  100385. * Snippet ID if the material was created from the snippet server
  100386. */
  100387. snippetId: string;
  100388. /**
  100389. * Gets or sets data used by visual editor
  100390. * @see https://nme.babylonjs.com
  100391. */
  100392. editorData: any;
  100393. /**
  100394. * 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)
  100395. */
  100396. ignoreAlpha: boolean;
  100397. /**
  100398. * Defines the maximum number of lights that can be used in the material
  100399. */
  100400. maxSimultaneousLights: number;
  100401. /**
  100402. * Observable raised when the material is built
  100403. */
  100404. onBuildObservable: Observable<NodeMaterial>;
  100405. /**
  100406. * Gets or sets the root nodes of the material vertex shader
  100407. */
  100408. _vertexOutputNodes: NodeMaterialBlock[];
  100409. /**
  100410. * Gets or sets the root nodes of the material fragment (pixel) shader
  100411. */
  100412. _fragmentOutputNodes: NodeMaterialBlock[];
  100413. /** Gets or sets options to control the node material overall behavior */
  100414. get options(): INodeMaterialOptions;
  100415. set options(options: INodeMaterialOptions);
  100416. /**
  100417. * Default configuration related to image processing available in the standard Material.
  100418. */
  100419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  100420. /**
  100421. * Gets the image processing configuration used either in this material.
  100422. */
  100423. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  100424. /**
  100425. * Sets the Default image processing configuration used either in the this material.
  100426. *
  100427. * If sets to null, the scene one is in use.
  100428. */
  100429. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  100430. /**
  100431. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  100432. */
  100433. attachedBlocks: NodeMaterialBlock[];
  100434. /**
  100435. * Specifies the mode of the node material
  100436. * @hidden
  100437. */
  100438. _mode: NodeMaterialModes;
  100439. /**
  100440. * Gets the mode property
  100441. */
  100442. get mode(): NodeMaterialModes;
  100443. /**
  100444. * Create a new node based material
  100445. * @param name defines the material name
  100446. * @param scene defines the hosting scene
  100447. * @param options defines creation option
  100448. */
  100449. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  100450. /**
  100451. * Gets the current class name of the material e.g. "NodeMaterial"
  100452. * @returns the class name
  100453. */
  100454. getClassName(): string;
  100455. /**
  100456. * Keep track of the image processing observer to allow dispose and replace.
  100457. */
  100458. private _imageProcessingObserver;
  100459. /**
  100460. * Attaches a new image processing configuration to the Standard Material.
  100461. * @param configuration
  100462. */
  100463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  100464. /**
  100465. * Get a block by its name
  100466. * @param name defines the name of the block to retrieve
  100467. * @returns the required block or null if not found
  100468. */
  100469. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  100470. /**
  100471. * Get a block by its name
  100472. * @param predicate defines the predicate used to find the good candidate
  100473. * @returns the required block or null if not found
  100474. */
  100475. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  100476. /**
  100477. * Get an input block by its name
  100478. * @param predicate defines the predicate used to find the good candidate
  100479. * @returns the required input block or null if not found
  100480. */
  100481. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  100482. /**
  100483. * Gets the list of input blocks attached to this material
  100484. * @returns an array of InputBlocks
  100485. */
  100486. getInputBlocks(): InputBlock[];
  100487. /**
  100488. * Adds a new optimizer to the list of optimizers
  100489. * @param optimizer defines the optimizers to add
  100490. * @returns the current material
  100491. */
  100492. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100493. /**
  100494. * Remove an optimizer from the list of optimizers
  100495. * @param optimizer defines the optimizers to remove
  100496. * @returns the current material
  100497. */
  100498. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  100499. /**
  100500. * Add a new block to the list of output nodes
  100501. * @param node defines the node to add
  100502. * @returns the current material
  100503. */
  100504. addOutputNode(node: NodeMaterialBlock): this;
  100505. /**
  100506. * Remove a block from the list of root nodes
  100507. * @param node defines the node to remove
  100508. * @returns the current material
  100509. */
  100510. removeOutputNode(node: NodeMaterialBlock): this;
  100511. private _addVertexOutputNode;
  100512. private _removeVertexOutputNode;
  100513. private _addFragmentOutputNode;
  100514. private _removeFragmentOutputNode;
  100515. /**
  100516. * Specifies if the material will require alpha blending
  100517. * @returns a boolean specifying if alpha blending is needed
  100518. */
  100519. needAlphaBlending(): boolean;
  100520. /**
  100521. * Specifies if this material should be rendered in alpha test mode
  100522. * @returns a boolean specifying if an alpha test is needed.
  100523. */
  100524. needAlphaTesting(): boolean;
  100525. private _initializeBlock;
  100526. private _resetDualBlocks;
  100527. /**
  100528. * Remove a block from the current node material
  100529. * @param block defines the block to remove
  100530. */
  100531. removeBlock(block: NodeMaterialBlock): void;
  100532. /**
  100533. * Build the material and generates the inner effect
  100534. * @param verbose defines if the build should log activity
  100535. */
  100536. build(verbose?: boolean): void;
  100537. /**
  100538. * Runs an otpimization phase to try to improve the shader code
  100539. */
  100540. optimize(): void;
  100541. private _prepareDefinesForAttributes;
  100542. /**
  100543. * Create a post process from the material
  100544. * @param camera The camera to apply the render pass to.
  100545. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100546. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100547. * @param engine The engine which the post process will be applied. (default: current engine)
  100548. * @param reusable If the post process can be reused on the same frame. (default: false)
  100549. * @param textureType Type of textures used when performing the post process. (default: 0)
  100550. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100551. * @returns the post process created
  100552. */
  100553. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): PostProcess;
  100554. /**
  100555. * Create the post process effect from the material
  100556. * @param postProcess The post process to create the effect for
  100557. */
  100558. createEffectForPostProcess(postProcess: PostProcess): void;
  100559. private _createEffectOrPostProcess;
  100560. private _createEffectForParticles;
  100561. /**
  100562. * Create the effect to be used as the custom effect for a particle system
  100563. * @param particleSystem Particle system to create the effect for
  100564. * @param onCompiled defines a function to call when the effect creation is successful
  100565. * @param onError defines a function to call when the effect creation has failed
  100566. */
  100567. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  100568. private _processDefines;
  100569. /**
  100570. * Get if the submesh is ready to be used and all its information available.
  100571. * Child classes can use it to update shaders
  100572. * @param mesh defines the mesh to check
  100573. * @param subMesh defines which submesh to check
  100574. * @param useInstances specifies that instances should be used
  100575. * @returns a boolean indicating that the submesh is ready or not
  100576. */
  100577. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100578. /**
  100579. * Get a string representing the shaders built by the current node graph
  100580. */
  100581. get compiledShaders(): string;
  100582. /**
  100583. * Binds the world matrix to the material
  100584. * @param world defines the world transformation matrix
  100585. */
  100586. bindOnlyWorldMatrix(world: Matrix): void;
  100587. /**
  100588. * Binds the submesh to this material by preparing the effect and shader to draw
  100589. * @param world defines the world transformation matrix
  100590. * @param mesh defines the mesh containing the submesh
  100591. * @param subMesh defines the submesh to bind the material to
  100592. */
  100593. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100594. /**
  100595. * Gets the active textures from the material
  100596. * @returns an array of textures
  100597. */
  100598. getActiveTextures(): BaseTexture[];
  100599. /**
  100600. * Gets the list of texture blocks
  100601. * @returns an array of texture blocks
  100602. */
  100603. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  100604. /**
  100605. * Specifies if the material uses a texture
  100606. * @param texture defines the texture to check against the material
  100607. * @returns a boolean specifying if the material uses the texture
  100608. */
  100609. hasTexture(texture: BaseTexture): boolean;
  100610. /**
  100611. * Disposes the material
  100612. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100613. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100614. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  100615. */
  100616. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  100617. /** Creates the node editor window. */
  100618. private _createNodeEditor;
  100619. /**
  100620. * Launch the node material editor
  100621. * @param config Define the configuration of the editor
  100622. * @return a promise fulfilled when the node editor is visible
  100623. */
  100624. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  100625. /**
  100626. * Clear the current material
  100627. */
  100628. clear(): void;
  100629. /**
  100630. * Clear the current material and set it to a default state
  100631. */
  100632. setToDefault(): void;
  100633. /**
  100634. * Clear the current material and set it to a default state for post process
  100635. */
  100636. setToDefaultPostProcess(): void;
  100637. /**
  100638. * Clear the current material and set it to a default state for particle
  100639. */
  100640. setToDefaultParticle(): void;
  100641. /**
  100642. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  100643. * @param url defines the url to load from
  100644. * @returns a promise that will fullfil when the material is fully loaded
  100645. */
  100646. loadAsync(url: string): Promise<void>;
  100647. private _gatherBlocks;
  100648. /**
  100649. * Generate a string containing the code declaration required to create an equivalent of this material
  100650. * @returns a string
  100651. */
  100652. generateCode(): string;
  100653. /**
  100654. * Serializes this material in a JSON representation
  100655. * @returns the serialized material object
  100656. */
  100657. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  100658. private _restoreConnections;
  100659. /**
  100660. * Clear the current graph and load a new one from a serialization object
  100661. * @param source defines the JSON representation of the material
  100662. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100663. * @param merge defines whether or not the source must be merged or replace the current content
  100664. */
  100665. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  100666. /**
  100667. * Makes a duplicate of the current material.
  100668. * @param name - name to use for the new material.
  100669. */
  100670. clone(name: string): NodeMaterial;
  100671. /**
  100672. * Creates a node material from parsed material data
  100673. * @param source defines the JSON representation of the material
  100674. * @param scene defines the hosting scene
  100675. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100676. * @returns a new node material
  100677. */
  100678. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  100679. /**
  100680. * Creates a node material from a snippet saved in a remote file
  100681. * @param name defines the name of the material to create
  100682. * @param url defines the url to load from
  100683. * @param scene defines the hosting scene
  100684. * @returns a promise that will resolve to the new node material
  100685. */
  100686. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  100687. /**
  100688. * Creates a node material from a snippet saved by the node material editor
  100689. * @param snippetId defines the snippet to load
  100690. * @param scene defines the hosting scene
  100691. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100692. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  100693. * @returns a promise that will resolve to the new node material
  100694. */
  100695. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  100696. /**
  100697. * Creates a new node material set to default basic configuration
  100698. * @param name defines the name of the material
  100699. * @param scene defines the hosting scene
  100700. * @returns a new NodeMaterial
  100701. */
  100702. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  100703. }
  100704. }
  100705. declare module BABYLON {
  100706. /**
  100707. * Size options for a post process
  100708. */
  100709. export type PostProcessOptions = {
  100710. width: number;
  100711. height: number;
  100712. };
  100713. /**
  100714. * PostProcess can be used to apply a shader to a texture after it has been rendered
  100715. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  100716. */
  100717. export class PostProcess {
  100718. /** Name of the PostProcess. */
  100719. name: string;
  100720. /**
  100721. * Gets or sets the unique id of the post process
  100722. */
  100723. uniqueId: number;
  100724. /**
  100725. * Width of the texture to apply the post process on
  100726. */
  100727. width: number;
  100728. /**
  100729. * Height of the texture to apply the post process on
  100730. */
  100731. height: number;
  100732. /**
  100733. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  100734. */
  100735. nodeMaterialSource: Nullable<NodeMaterial>;
  100736. /**
  100737. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  100738. * @hidden
  100739. */
  100740. _outputTexture: Nullable<InternalTexture>;
  100741. /**
  100742. * Sampling mode used by the shader
  100743. * See https://doc.babylonjs.com/classes/3.1/texture
  100744. */
  100745. renderTargetSamplingMode: number;
  100746. /**
  100747. * Clear color to use when screen clearing
  100748. */
  100749. clearColor: Color4;
  100750. /**
  100751. * If the buffer needs to be cleared before applying the post process. (default: true)
  100752. * Should be set to false if shader will overwrite all previous pixels.
  100753. */
  100754. autoClear: boolean;
  100755. /**
  100756. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  100757. */
  100758. alphaMode: number;
  100759. /**
  100760. * Sets the setAlphaBlendConstants of the babylon engine
  100761. */
  100762. alphaConstants: Color4;
  100763. /**
  100764. * Animations to be used for the post processing
  100765. */
  100766. animations: Animation[];
  100767. /**
  100768. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  100769. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  100770. */
  100771. enablePixelPerfectMode: boolean;
  100772. /**
  100773. * Force the postprocess to be applied without taking in account viewport
  100774. */
  100775. forceFullscreenViewport: boolean;
  100776. /**
  100777. * List of inspectable custom properties (used by the Inspector)
  100778. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  100779. */
  100780. inspectableCustomProperties: IInspectable[];
  100781. /**
  100782. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  100783. *
  100784. * | Value | Type | Description |
  100785. * | ----- | ----------------------------------- | ----------- |
  100786. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  100787. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  100788. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  100789. *
  100790. */
  100791. scaleMode: number;
  100792. /**
  100793. * Force textures to be a power of two (default: false)
  100794. */
  100795. alwaysForcePOT: boolean;
  100796. private _samples;
  100797. /**
  100798. * Number of sample textures (default: 1)
  100799. */
  100800. get samples(): number;
  100801. set samples(n: number);
  100802. /**
  100803. * Modify the scale of the post process to be the same as the viewport (default: false)
  100804. */
  100805. adaptScaleToCurrentViewport: boolean;
  100806. private _camera;
  100807. protected _scene: Scene;
  100808. private _engine;
  100809. private _options;
  100810. private _reusable;
  100811. private _textureType;
  100812. private _textureFormat;
  100813. /**
  100814. * Smart array of input and output textures for the post process.
  100815. * @hidden
  100816. */
  100817. _textures: SmartArray<InternalTexture>;
  100818. /**
  100819. * The index in _textures that corresponds to the output texture.
  100820. * @hidden
  100821. */
  100822. _currentRenderTextureInd: number;
  100823. private _effect;
  100824. private _samplers;
  100825. private _fragmentUrl;
  100826. private _vertexUrl;
  100827. private _parameters;
  100828. private _scaleRatio;
  100829. protected _indexParameters: any;
  100830. private _shareOutputWithPostProcess;
  100831. private _texelSize;
  100832. private _forcedOutputTexture;
  100833. /**
  100834. * Returns the fragment url or shader name used in the post process.
  100835. * @returns the fragment url or name in the shader store.
  100836. */
  100837. getEffectName(): string;
  100838. /**
  100839. * An event triggered when the postprocess is activated.
  100840. */
  100841. onActivateObservable: Observable<Camera>;
  100842. private _onActivateObserver;
  100843. /**
  100844. * A function that is added to the onActivateObservable
  100845. */
  100846. set onActivate(callback: Nullable<(camera: Camera) => void>);
  100847. /**
  100848. * An event triggered when the postprocess changes its size.
  100849. */
  100850. onSizeChangedObservable: Observable<PostProcess>;
  100851. private _onSizeChangedObserver;
  100852. /**
  100853. * A function that is added to the onSizeChangedObservable
  100854. */
  100855. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  100856. /**
  100857. * An event triggered when the postprocess applies its effect.
  100858. */
  100859. onApplyObservable: Observable<Effect>;
  100860. private _onApplyObserver;
  100861. /**
  100862. * A function that is added to the onApplyObservable
  100863. */
  100864. set onApply(callback: (effect: Effect) => void);
  100865. /**
  100866. * An event triggered before rendering the postprocess
  100867. */
  100868. onBeforeRenderObservable: Observable<Effect>;
  100869. private _onBeforeRenderObserver;
  100870. /**
  100871. * A function that is added to the onBeforeRenderObservable
  100872. */
  100873. set onBeforeRender(callback: (effect: Effect) => void);
  100874. /**
  100875. * An event triggered after rendering the postprocess
  100876. */
  100877. onAfterRenderObservable: Observable<Effect>;
  100878. private _onAfterRenderObserver;
  100879. /**
  100880. * A function that is added to the onAfterRenderObservable
  100881. */
  100882. set onAfterRender(callback: (efect: Effect) => void);
  100883. /**
  100884. * 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
  100885. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  100886. */
  100887. get inputTexture(): InternalTexture;
  100888. set inputTexture(value: InternalTexture);
  100889. /**
  100890. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  100891. * the only way to unset it is to use this function to restore its internal state
  100892. */
  100893. restoreDefaultInputTexture(): void;
  100894. /**
  100895. * Gets the camera which post process is applied to.
  100896. * @returns The camera the post process is applied to.
  100897. */
  100898. getCamera(): Camera;
  100899. /**
  100900. * Gets the texel size of the postprocess.
  100901. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  100902. */
  100903. get texelSize(): Vector2;
  100904. /**
  100905. * Creates a new instance PostProcess
  100906. * @param name The name of the PostProcess.
  100907. * @param fragmentUrl The url of the fragment shader to be used.
  100908. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  100909. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  100910. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  100911. * @param camera The camera to apply the render pass to.
  100912. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100913. * @param engine The engine which the post process will be applied. (default: current engine)
  100914. * @param reusable If the post process can be reused on the same frame. (default: false)
  100915. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  100916. * @param textureType Type of textures used when performing the post process. (default: 0)
  100917. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  100918. * @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
  100919. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  100920. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  100921. */
  100922. constructor(
  100923. /** Name of the PostProcess. */
  100924. 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);
  100925. /**
  100926. * Gets a string idenfifying the name of the class
  100927. * @returns "PostProcess" string
  100928. */
  100929. getClassName(): string;
  100930. /**
  100931. * Gets the engine which this post process belongs to.
  100932. * @returns The engine the post process was enabled with.
  100933. */
  100934. getEngine(): Engine;
  100935. /**
  100936. * The effect that is created when initializing the post process.
  100937. * @returns The created effect corresponding the the postprocess.
  100938. */
  100939. getEffect(): Effect;
  100940. /**
  100941. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  100942. * @param postProcess The post process to share the output with.
  100943. * @returns This post process.
  100944. */
  100945. shareOutputWith(postProcess: PostProcess): PostProcess;
  100946. /**
  100947. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  100948. * This should be called if the post process that shares output with this post process is disabled/disposed.
  100949. */
  100950. useOwnOutput(): void;
  100951. /**
  100952. * Updates the effect with the current post process compile time values and recompiles the shader.
  100953. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  100954. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  100955. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  100956. * @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
  100957. * @param onCompiled Called when the shader has been compiled.
  100958. * @param onError Called if there is an error when compiling a shader.
  100959. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  100960. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  100961. */
  100962. 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;
  100963. /**
  100964. * The post process is reusable if it can be used multiple times within one frame.
  100965. * @returns If the post process is reusable
  100966. */
  100967. isReusable(): boolean;
  100968. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  100969. markTextureDirty(): void;
  100970. /**
  100971. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  100972. * 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.
  100973. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  100974. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  100975. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  100976. * @returns The target texture that was bound to be written to.
  100977. */
  100978. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  100979. /**
  100980. * If the post process is supported.
  100981. */
  100982. get isSupported(): boolean;
  100983. /**
  100984. * The aspect ratio of the output texture.
  100985. */
  100986. get aspectRatio(): number;
  100987. /**
  100988. * Get a value indicating if the post-process is ready to be used
  100989. * @returns true if the post-process is ready (shader is compiled)
  100990. */
  100991. isReady(): boolean;
  100992. /**
  100993. * Binds all textures and uniforms to the shader, this will be run on every pass.
  100994. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  100995. */
  100996. apply(): Nullable<Effect>;
  100997. private _disposeTextures;
  100998. /**
  100999. * Disposes the post process.
  101000. * @param camera The camera to dispose the post process on.
  101001. */
  101002. dispose(camera?: Camera): void;
  101003. }
  101004. }
  101005. declare module BABYLON {
  101006. /** @hidden */
  101007. export var kernelBlurVaryingDeclaration: {
  101008. name: string;
  101009. shader: string;
  101010. };
  101011. }
  101012. declare module BABYLON {
  101013. /** @hidden */
  101014. export var kernelBlurFragment: {
  101015. name: string;
  101016. shader: string;
  101017. };
  101018. }
  101019. declare module BABYLON {
  101020. /** @hidden */
  101021. export var kernelBlurFragment2: {
  101022. name: string;
  101023. shader: string;
  101024. };
  101025. }
  101026. declare module BABYLON {
  101027. /** @hidden */
  101028. export var kernelBlurPixelShader: {
  101029. name: string;
  101030. shader: string;
  101031. };
  101032. }
  101033. declare module BABYLON {
  101034. /** @hidden */
  101035. export var kernelBlurVertex: {
  101036. name: string;
  101037. shader: string;
  101038. };
  101039. }
  101040. declare module BABYLON {
  101041. /** @hidden */
  101042. export var kernelBlurVertexShader: {
  101043. name: string;
  101044. shader: string;
  101045. };
  101046. }
  101047. declare module BABYLON {
  101048. /**
  101049. * The Blur Post Process which blurs an image based on a kernel and direction.
  101050. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  101051. */
  101052. export class BlurPostProcess extends PostProcess {
  101053. /** The direction in which to blur the image. */
  101054. direction: Vector2;
  101055. private blockCompilation;
  101056. protected _kernel: number;
  101057. protected _idealKernel: number;
  101058. protected _packedFloat: boolean;
  101059. private _staticDefines;
  101060. /**
  101061. * Sets the length in pixels of the blur sample region
  101062. */
  101063. set kernel(v: number);
  101064. /**
  101065. * Gets the length in pixels of the blur sample region
  101066. */
  101067. get kernel(): number;
  101068. /**
  101069. * Sets wether or not the blur needs to unpack/repack floats
  101070. */
  101071. set packedFloat(v: boolean);
  101072. /**
  101073. * Gets wether or not the blur is unpacking/repacking floats
  101074. */
  101075. get packedFloat(): boolean;
  101076. /**
  101077. * Creates a new instance BlurPostProcess
  101078. * @param name The name of the effect.
  101079. * @param direction The direction in which to blur the image.
  101080. * @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.
  101081. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  101082. * @param camera The camera to apply the render pass to.
  101083. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  101084. * @param engine The engine which the post process will be applied. (default: current engine)
  101085. * @param reusable If the post process can be reused on the same frame. (default: false)
  101086. * @param textureType Type of textures used when performing the post process. (default: 0)
  101087. * @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)
  101088. */
  101089. constructor(name: string,
  101090. /** The direction in which to blur the image. */
  101091. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  101092. /**
  101093. * Updates the effect with the current post process compile time values and recompiles the shader.
  101094. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  101095. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  101096. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  101097. * @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
  101098. * @param onCompiled Called when the shader has been compiled.
  101099. * @param onError Called if there is an error when compiling a shader.
  101100. */
  101101. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101102. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  101103. /**
  101104. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  101105. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  101106. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  101107. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  101108. * The gaps between physical kernels are compensated for in the weighting of the samples
  101109. * @param idealKernel Ideal blur kernel.
  101110. * @return Nearest best kernel.
  101111. */
  101112. protected _nearestBestKernel(idealKernel: number): number;
  101113. /**
  101114. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  101115. * @param x The point on the Gaussian distribution to sample.
  101116. * @return the value of the Gaussian function at x.
  101117. */
  101118. protected _gaussianWeight(x: number): number;
  101119. /**
  101120. * Generates a string that can be used as a floating point number in GLSL.
  101121. * @param x Value to print.
  101122. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  101123. * @return GLSL float string.
  101124. */
  101125. protected _glslFloat(x: number, decimalFigures?: number): string;
  101126. }
  101127. }
  101128. declare module BABYLON {
  101129. /**
  101130. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101131. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101132. * You can then easily use it as a reflectionTexture on a flat surface.
  101133. * In case the surface is not a plane, please consider relying on reflection probes.
  101134. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101135. */
  101136. export class MirrorTexture extends RenderTargetTexture {
  101137. private scene;
  101138. /**
  101139. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  101140. * 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.
  101141. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101142. */
  101143. mirrorPlane: Plane;
  101144. /**
  101145. * Define the blur ratio used to blur the reflection if needed.
  101146. */
  101147. set blurRatio(value: number);
  101148. get blurRatio(): number;
  101149. /**
  101150. * Define the adaptive blur kernel used to blur the reflection if needed.
  101151. * This will autocompute the closest best match for the `blurKernel`
  101152. */
  101153. set adaptiveBlurKernel(value: number);
  101154. /**
  101155. * Define the blur kernel used to blur the reflection if needed.
  101156. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101157. */
  101158. set blurKernel(value: number);
  101159. /**
  101160. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  101161. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101162. */
  101163. set blurKernelX(value: number);
  101164. get blurKernelX(): number;
  101165. /**
  101166. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  101167. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  101168. */
  101169. set blurKernelY(value: number);
  101170. get blurKernelY(): number;
  101171. private _autoComputeBlurKernel;
  101172. protected _onRatioRescale(): void;
  101173. private _updateGammaSpace;
  101174. private _imageProcessingConfigChangeObserver;
  101175. private _transformMatrix;
  101176. private _mirrorMatrix;
  101177. private _savedViewMatrix;
  101178. private _blurX;
  101179. private _blurY;
  101180. private _adaptiveBlurKernel;
  101181. private _blurKernelX;
  101182. private _blurKernelY;
  101183. private _blurRatio;
  101184. /**
  101185. * Instantiates a Mirror Texture.
  101186. * Mirror texture can be used to simulate the view from a mirror in a scene.
  101187. * It will dynamically be rendered every frame to adapt to the camera point of view.
  101188. * You can then easily use it as a reflectionTexture on a flat surface.
  101189. * In case the surface is not a plane, please consider relying on reflection probes.
  101190. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  101191. * @param name
  101192. * @param size
  101193. * @param scene
  101194. * @param generateMipMaps
  101195. * @param type
  101196. * @param samplingMode
  101197. * @param generateDepthBuffer
  101198. */
  101199. constructor(name: string, size: number | {
  101200. width: number;
  101201. height: number;
  101202. } | {
  101203. ratio: number;
  101204. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  101205. private _preparePostProcesses;
  101206. /**
  101207. * Clone the mirror texture.
  101208. * @returns the cloned texture
  101209. */
  101210. clone(): MirrorTexture;
  101211. /**
  101212. * Serialize the texture to a JSON representation you could use in Parse later on
  101213. * @returns the serialized JSON representation
  101214. */
  101215. serialize(): any;
  101216. /**
  101217. * Dispose the texture and release its associated resources.
  101218. */
  101219. dispose(): void;
  101220. }
  101221. }
  101222. declare module BABYLON {
  101223. /**
  101224. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101225. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101226. */
  101227. export class Texture extends BaseTexture {
  101228. /**
  101229. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  101230. */
  101231. static SerializeBuffers: boolean;
  101232. /** @hidden */
  101233. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  101234. /** @hidden */
  101235. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  101236. /** @hidden */
  101237. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  101238. /** nearest is mag = nearest and min = nearest and mip = linear */
  101239. static readonly NEAREST_SAMPLINGMODE: number;
  101240. /** nearest is mag = nearest and min = nearest and mip = linear */
  101241. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  101242. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101243. static readonly BILINEAR_SAMPLINGMODE: number;
  101244. /** Bilinear is mag = linear and min = linear and mip = nearest */
  101245. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  101246. /** Trilinear is mag = linear and min = linear and mip = linear */
  101247. static readonly TRILINEAR_SAMPLINGMODE: number;
  101248. /** Trilinear is mag = linear and min = linear and mip = linear */
  101249. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  101250. /** mag = nearest and min = nearest and mip = nearest */
  101251. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  101252. /** mag = nearest and min = linear and mip = nearest */
  101253. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  101254. /** mag = nearest and min = linear and mip = linear */
  101255. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  101256. /** mag = nearest and min = linear and mip = none */
  101257. static readonly NEAREST_LINEAR: number;
  101258. /** mag = nearest and min = nearest and mip = none */
  101259. static readonly NEAREST_NEAREST: number;
  101260. /** mag = linear and min = nearest and mip = nearest */
  101261. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  101262. /** mag = linear and min = nearest and mip = linear */
  101263. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  101264. /** mag = linear and min = linear and mip = none */
  101265. static readonly LINEAR_LINEAR: number;
  101266. /** mag = linear and min = nearest and mip = none */
  101267. static readonly LINEAR_NEAREST: number;
  101268. /** Explicit coordinates mode */
  101269. static readonly EXPLICIT_MODE: number;
  101270. /** Spherical coordinates mode */
  101271. static readonly SPHERICAL_MODE: number;
  101272. /** Planar coordinates mode */
  101273. static readonly PLANAR_MODE: number;
  101274. /** Cubic coordinates mode */
  101275. static readonly CUBIC_MODE: number;
  101276. /** Projection coordinates mode */
  101277. static readonly PROJECTION_MODE: number;
  101278. /** Inverse Cubic coordinates mode */
  101279. static readonly SKYBOX_MODE: number;
  101280. /** Inverse Cubic coordinates mode */
  101281. static readonly INVCUBIC_MODE: number;
  101282. /** Equirectangular coordinates mode */
  101283. static readonly EQUIRECTANGULAR_MODE: number;
  101284. /** Equirectangular Fixed coordinates mode */
  101285. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  101286. /** Equirectangular Fixed Mirrored coordinates mode */
  101287. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  101288. /** Texture is not repeating outside of 0..1 UVs */
  101289. static readonly CLAMP_ADDRESSMODE: number;
  101290. /** Texture is repeating outside of 0..1 UVs */
  101291. static readonly WRAP_ADDRESSMODE: number;
  101292. /** Texture is repeating and mirrored */
  101293. static readonly MIRROR_ADDRESSMODE: number;
  101294. /**
  101295. * 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
  101296. */
  101297. static UseSerializedUrlIfAny: boolean;
  101298. /**
  101299. * Define the url of the texture.
  101300. */
  101301. url: Nullable<string>;
  101302. /**
  101303. * Define an offset on the texture to offset the u coordinates of the UVs
  101304. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101305. */
  101306. uOffset: number;
  101307. /**
  101308. * Define an offset on the texture to offset the v coordinates of the UVs
  101309. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  101310. */
  101311. vOffset: number;
  101312. /**
  101313. * Define an offset on the texture to scale the u coordinates of the UVs
  101314. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101315. */
  101316. uScale: number;
  101317. /**
  101318. * Define an offset on the texture to scale the v coordinates of the UVs
  101319. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  101320. */
  101321. vScale: number;
  101322. /**
  101323. * Define an offset on the texture to rotate around the u coordinates of the UVs
  101324. * @see https://doc.babylonjs.com/how_to/more_materials
  101325. */
  101326. uAng: number;
  101327. /**
  101328. * Define an offset on the texture to rotate around the v coordinates of the UVs
  101329. * @see https://doc.babylonjs.com/how_to/more_materials
  101330. */
  101331. vAng: number;
  101332. /**
  101333. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  101334. * @see https://doc.babylonjs.com/how_to/more_materials
  101335. */
  101336. wAng: number;
  101337. /**
  101338. * Defines the center of rotation (U)
  101339. */
  101340. uRotationCenter: number;
  101341. /**
  101342. * Defines the center of rotation (V)
  101343. */
  101344. vRotationCenter: number;
  101345. /**
  101346. * Defines the center of rotation (W)
  101347. */
  101348. wRotationCenter: number;
  101349. /**
  101350. * Are mip maps generated for this texture or not.
  101351. */
  101352. get noMipmap(): boolean;
  101353. /**
  101354. * List of inspectable custom properties (used by the Inspector)
  101355. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  101356. */
  101357. inspectableCustomProperties: Nullable<IInspectable[]>;
  101358. private _noMipmap;
  101359. /** @hidden */
  101360. _invertY: boolean;
  101361. private _rowGenerationMatrix;
  101362. private _cachedTextureMatrix;
  101363. private _projectionModeMatrix;
  101364. private _t0;
  101365. private _t1;
  101366. private _t2;
  101367. private _cachedUOffset;
  101368. private _cachedVOffset;
  101369. private _cachedUScale;
  101370. private _cachedVScale;
  101371. private _cachedUAng;
  101372. private _cachedVAng;
  101373. private _cachedWAng;
  101374. private _cachedProjectionMatrixId;
  101375. private _cachedCoordinatesMode;
  101376. /** @hidden */
  101377. protected _initialSamplingMode: number;
  101378. /** @hidden */
  101379. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  101380. private _deleteBuffer;
  101381. protected _format: Nullable<number>;
  101382. private _delayedOnLoad;
  101383. private _delayedOnError;
  101384. private _mimeType?;
  101385. /**
  101386. * Observable triggered once the texture has been loaded.
  101387. */
  101388. onLoadObservable: Observable<Texture>;
  101389. protected _isBlocking: boolean;
  101390. /**
  101391. * Is the texture preventing material to render while loading.
  101392. * If false, a default texture will be used instead of the loading one during the preparation step.
  101393. */
  101394. set isBlocking(value: boolean);
  101395. get isBlocking(): boolean;
  101396. /**
  101397. * Get the current sampling mode associated with the texture.
  101398. */
  101399. get samplingMode(): number;
  101400. /**
  101401. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  101402. */
  101403. get invertY(): boolean;
  101404. /**
  101405. * Instantiates a new texture.
  101406. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  101407. * @see https://doc.babylonjs.com/babylon101/materials#texture
  101408. * @param url defines the url of the picture to load as a texture
  101409. * @param sceneOrEngine defines the scene or engine the texture will belong to
  101410. * @param noMipmap defines if the texture will require mip maps or not
  101411. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  101412. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101413. * @param onLoad defines a callback triggered when the texture has been loaded
  101414. * @param onError defines a callback triggered when an error occurred during the loading session
  101415. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  101416. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  101417. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101418. * @param mimeType defines an optional mime type information
  101419. */
  101420. 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);
  101421. /**
  101422. * Update the url (and optional buffer) of this texture if url was null during construction.
  101423. * @param url the url of the texture
  101424. * @param buffer the buffer of the texture (defaults to null)
  101425. * @param onLoad callback called when the texture is loaded (defaults to null)
  101426. */
  101427. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  101428. /**
  101429. * Finish the loading sequence of a texture flagged as delayed load.
  101430. * @hidden
  101431. */
  101432. delayLoad(): void;
  101433. private _prepareRowForTextureGeneration;
  101434. /**
  101435. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  101436. * @returns the transform matrix of the texture.
  101437. */
  101438. getTextureMatrix(uBase?: number): Matrix;
  101439. /**
  101440. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  101441. * @returns The reflection texture transform
  101442. */
  101443. getReflectionTextureMatrix(): Matrix;
  101444. /**
  101445. * Clones the texture.
  101446. * @returns the cloned texture
  101447. */
  101448. clone(): Texture;
  101449. /**
  101450. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101451. * @returns The JSON representation of the texture
  101452. */
  101453. serialize(): any;
  101454. /**
  101455. * Get the current class name of the texture useful for serialization or dynamic coding.
  101456. * @returns "Texture"
  101457. */
  101458. getClassName(): string;
  101459. /**
  101460. * Dispose the texture and release its associated resources.
  101461. */
  101462. dispose(): void;
  101463. /**
  101464. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  101465. * @param parsedTexture Define the JSON representation of the texture
  101466. * @param scene Define the scene the parsed texture should be instantiated in
  101467. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  101468. * @returns The parsed texture if successful
  101469. */
  101470. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  101471. /**
  101472. * Creates a texture from its base 64 representation.
  101473. * @param data Define the base64 payload without the data: prefix
  101474. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101475. * @param scene Define the scene the texture should belong to
  101476. * @param noMipmap Forces the texture to not create mip map information if true
  101477. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101478. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101479. * @param onLoad define a callback triggered when the texture has been loaded
  101480. * @param onError define a callback triggered when an error occurred during the loading session
  101481. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101482. * @returns the created texture
  101483. */
  101484. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  101485. /**
  101486. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  101487. * @param data Define the base64 payload without the data: prefix
  101488. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  101489. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  101490. * @param scene Define the scene the texture should belong to
  101491. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  101492. * @param noMipmap Forces the texture to not create mip map information if true
  101493. * @param invertY define if the texture needs to be inverted on the y axis during loading
  101494. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  101495. * @param onLoad define a callback triggered when the texture has been loaded
  101496. * @param onError define a callback triggered when an error occurred during the loading session
  101497. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  101498. * @returns the created texture
  101499. */
  101500. 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;
  101501. }
  101502. }
  101503. declare module BABYLON {
  101504. /**
  101505. * PostProcessManager is used to manage one or more post processes or post process pipelines
  101506. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  101507. */
  101508. export class PostProcessManager {
  101509. private _scene;
  101510. private _indexBuffer;
  101511. private _vertexBuffers;
  101512. /**
  101513. * Creates a new instance PostProcess
  101514. * @param scene The scene that the post process is associated with.
  101515. */
  101516. constructor(scene: Scene);
  101517. private _prepareBuffers;
  101518. private _buildIndexBuffer;
  101519. /**
  101520. * Rebuilds the vertex buffers of the manager.
  101521. * @hidden
  101522. */
  101523. _rebuild(): void;
  101524. /**
  101525. * Prepares a frame to be run through a post process.
  101526. * @param sourceTexture The input texture to the post procesess. (default: null)
  101527. * @param postProcesses An array of post processes to be run. (default: null)
  101528. * @returns True if the post processes were able to be run.
  101529. * @hidden
  101530. */
  101531. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  101532. /**
  101533. * Manually render a set of post processes to a texture.
  101534. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  101535. * @param postProcesses An array of post processes to be run.
  101536. * @param targetTexture The target texture to render to.
  101537. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  101538. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  101539. * @param lodLevel defines which lod of the texture to render to
  101540. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  101541. */
  101542. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  101543. /**
  101544. * Finalize the result of the output of the postprocesses.
  101545. * @param doNotPresent If true the result will not be displayed to the screen.
  101546. * @param targetTexture The target texture to render to.
  101547. * @param faceIndex The index of the face to bind the target texture to.
  101548. * @param postProcesses The array of post processes to render.
  101549. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  101550. * @hidden
  101551. */
  101552. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  101553. /**
  101554. * Disposes of the post process manager.
  101555. */
  101556. dispose(): void;
  101557. }
  101558. }
  101559. declare module BABYLON {
  101560. /**
  101561. * This Helps creating a texture that will be created from a camera in your scene.
  101562. * It is basically a dynamic texture that could be used to create special effects for instance.
  101563. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  101564. */
  101565. export class RenderTargetTexture extends Texture {
  101566. isCube: boolean;
  101567. /**
  101568. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  101569. */
  101570. static readonly REFRESHRATE_RENDER_ONCE: number;
  101571. /**
  101572. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  101573. */
  101574. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  101575. /**
  101576. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  101577. * the central point of your effect and can save a lot of performances.
  101578. */
  101579. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  101580. /**
  101581. * Use this predicate to dynamically define the list of mesh you want to render.
  101582. * If set, the renderList property will be overwritten.
  101583. */
  101584. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  101585. private _renderList;
  101586. /**
  101587. * Use this list to define the list of mesh you want to render.
  101588. */
  101589. get renderList(): Nullable<Array<AbstractMesh>>;
  101590. set renderList(value: Nullable<Array<AbstractMesh>>);
  101591. /**
  101592. * Use this function to overload the renderList array at rendering time.
  101593. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  101594. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  101595. * the cube (if the RTT is a cube, else layerOrFace=0).
  101596. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  101597. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  101598. * hold dummy elements!
  101599. */
  101600. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  101601. private _hookArray;
  101602. /**
  101603. * Define if particles should be rendered in your texture.
  101604. */
  101605. renderParticles: boolean;
  101606. /**
  101607. * Define if sprites should be rendered in your texture.
  101608. */
  101609. renderSprites: boolean;
  101610. /**
  101611. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  101612. */
  101613. coordinatesMode: number;
  101614. /**
  101615. * Define the camera used to render the texture.
  101616. */
  101617. activeCamera: Nullable<Camera>;
  101618. /**
  101619. * Override the mesh isReady function with your own one.
  101620. */
  101621. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  101622. /**
  101623. * Override the render function of the texture with your own one.
  101624. */
  101625. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  101626. /**
  101627. * Define if camera post processes should be use while rendering the texture.
  101628. */
  101629. useCameraPostProcesses: boolean;
  101630. /**
  101631. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  101632. */
  101633. ignoreCameraViewport: boolean;
  101634. private _postProcessManager;
  101635. private _postProcesses;
  101636. private _resizeObserver;
  101637. /**
  101638. * An event triggered when the texture is unbind.
  101639. */
  101640. onBeforeBindObservable: Observable<RenderTargetTexture>;
  101641. /**
  101642. * An event triggered when the texture is unbind.
  101643. */
  101644. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  101645. private _onAfterUnbindObserver;
  101646. /**
  101647. * Set a after unbind callback in the texture.
  101648. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  101649. */
  101650. set onAfterUnbind(callback: () => void);
  101651. /**
  101652. * An event triggered before rendering the texture
  101653. */
  101654. onBeforeRenderObservable: Observable<number>;
  101655. private _onBeforeRenderObserver;
  101656. /**
  101657. * Set a before render callback in the texture.
  101658. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  101659. */
  101660. set onBeforeRender(callback: (faceIndex: number) => void);
  101661. /**
  101662. * An event triggered after rendering the texture
  101663. */
  101664. onAfterRenderObservable: Observable<number>;
  101665. private _onAfterRenderObserver;
  101666. /**
  101667. * Set a after render callback in the texture.
  101668. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  101669. */
  101670. set onAfterRender(callback: (faceIndex: number) => void);
  101671. /**
  101672. * An event triggered after the texture clear
  101673. */
  101674. onClearObservable: Observable<Engine>;
  101675. private _onClearObserver;
  101676. /**
  101677. * Set a clear callback in the texture.
  101678. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  101679. */
  101680. set onClear(callback: (Engine: Engine) => void);
  101681. /**
  101682. * An event triggered when the texture is resized.
  101683. */
  101684. onResizeObservable: Observable<RenderTargetTexture>;
  101685. /**
  101686. * Define the clear color of the Render Target if it should be different from the scene.
  101687. */
  101688. clearColor: Color4;
  101689. protected _size: number | {
  101690. width: number;
  101691. height: number;
  101692. layers?: number;
  101693. };
  101694. protected _initialSizeParameter: number | {
  101695. width: number;
  101696. height: number;
  101697. } | {
  101698. ratio: number;
  101699. };
  101700. protected _sizeRatio: Nullable<number>;
  101701. /** @hidden */
  101702. _generateMipMaps: boolean;
  101703. protected _renderingManager: RenderingManager;
  101704. /** @hidden */
  101705. _waitingRenderList: string[];
  101706. protected _doNotChangeAspectRatio: boolean;
  101707. protected _currentRefreshId: number;
  101708. protected _refreshRate: number;
  101709. protected _textureMatrix: Matrix;
  101710. protected _samples: number;
  101711. protected _renderTargetOptions: RenderTargetCreationOptions;
  101712. /**
  101713. * Gets render target creation options that were used.
  101714. */
  101715. get renderTargetOptions(): RenderTargetCreationOptions;
  101716. protected _onRatioRescale(): void;
  101717. /**
  101718. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  101719. * It must define where the camera used to render the texture is set
  101720. */
  101721. boundingBoxPosition: Vector3;
  101722. private _boundingBoxSize;
  101723. /**
  101724. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  101725. * When defined, the cubemap will switch to local mode
  101726. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  101727. * @example https://www.babylonjs-playground.com/#RNASML
  101728. */
  101729. set boundingBoxSize(value: Vector3);
  101730. get boundingBoxSize(): Vector3;
  101731. /**
  101732. * In case the RTT has been created with a depth texture, get the associated
  101733. * depth texture.
  101734. * Otherwise, return null.
  101735. */
  101736. get depthStencilTexture(): Nullable<InternalTexture>;
  101737. /**
  101738. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  101739. * or used a shadow, depth texture...
  101740. * @param name The friendly name of the texture
  101741. * @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)
  101742. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  101743. * @param generateMipMaps True if mip maps need to be generated after render.
  101744. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  101745. * @param type The type of the buffer in the RTT (int, half float, float...)
  101746. * @param isCube True if a cube texture needs to be created
  101747. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  101748. * @param generateDepthBuffer True to generate a depth buffer
  101749. * @param generateStencilBuffer True to generate a stencil buffer
  101750. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  101751. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  101752. * @param delayAllocation if the texture allocation should be delayed (default: false)
  101753. */
  101754. constructor(name: string, size: number | {
  101755. width: number;
  101756. height: number;
  101757. layers?: number;
  101758. } | {
  101759. ratio: number;
  101760. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  101761. /**
  101762. * Creates a depth stencil texture.
  101763. * This is only available in WebGL 2 or with the depth texture extension available.
  101764. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  101765. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  101766. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  101767. */
  101768. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  101769. private _processSizeParameter;
  101770. /**
  101771. * Define the number of samples to use in case of MSAA.
  101772. * It defaults to one meaning no MSAA has been enabled.
  101773. */
  101774. get samples(): number;
  101775. set samples(value: number);
  101776. /**
  101777. * Resets the refresh counter of the texture and start bak from scratch.
  101778. * Could be useful to regenerate the texture if it is setup to render only once.
  101779. */
  101780. resetRefreshCounter(): void;
  101781. /**
  101782. * Define the refresh rate of the texture or the rendering frequency.
  101783. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  101784. */
  101785. get refreshRate(): number;
  101786. set refreshRate(value: number);
  101787. /**
  101788. * Adds a post process to the render target rendering passes.
  101789. * @param postProcess define the post process to add
  101790. */
  101791. addPostProcess(postProcess: PostProcess): void;
  101792. /**
  101793. * Clear all the post processes attached to the render target
  101794. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  101795. */
  101796. clearPostProcesses(dispose?: boolean): void;
  101797. /**
  101798. * Remove one of the post process from the list of attached post processes to the texture
  101799. * @param postProcess define the post process to remove from the list
  101800. */
  101801. removePostProcess(postProcess: PostProcess): void;
  101802. /** @hidden */
  101803. _shouldRender(): boolean;
  101804. /**
  101805. * Gets the actual render size of the texture.
  101806. * @returns the width of the render size
  101807. */
  101808. getRenderSize(): number;
  101809. /**
  101810. * Gets the actual render width of the texture.
  101811. * @returns the width of the render size
  101812. */
  101813. getRenderWidth(): number;
  101814. /**
  101815. * Gets the actual render height of the texture.
  101816. * @returns the height of the render size
  101817. */
  101818. getRenderHeight(): number;
  101819. /**
  101820. * Gets the actual number of layers of the texture.
  101821. * @returns the number of layers
  101822. */
  101823. getRenderLayers(): number;
  101824. /**
  101825. * Get if the texture can be rescaled or not.
  101826. */
  101827. get canRescale(): boolean;
  101828. /**
  101829. * Resize the texture using a ratio.
  101830. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  101831. */
  101832. scale(ratio: number): void;
  101833. /**
  101834. * Get the texture reflection matrix used to rotate/transform the reflection.
  101835. * @returns the reflection matrix
  101836. */
  101837. getReflectionTextureMatrix(): Matrix;
  101838. /**
  101839. * Resize the texture to a new desired size.
  101840. * Be carrefull as it will recreate all the data in the new texture.
  101841. * @param size Define the new size. It can be:
  101842. * - a number for squared texture,
  101843. * - an object containing { width: number, height: number }
  101844. * - or an object containing a ratio { ratio: number }
  101845. */
  101846. resize(size: number | {
  101847. width: number;
  101848. height: number;
  101849. } | {
  101850. ratio: number;
  101851. }): void;
  101852. private _defaultRenderListPrepared;
  101853. /**
  101854. * Renders all the objects from the render list into the texture.
  101855. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  101856. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  101857. */
  101858. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  101859. private _bestReflectionRenderTargetDimension;
  101860. private _prepareRenderingManager;
  101861. /**
  101862. * @hidden
  101863. * @param faceIndex face index to bind to if this is a cubetexture
  101864. * @param layer defines the index of the texture to bind in the array
  101865. */
  101866. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  101867. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  101868. private renderToTarget;
  101869. /**
  101870. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101871. * This allowed control for front to back rendering or reversly depending of the special needs.
  101872. *
  101873. * @param renderingGroupId The rendering group id corresponding to its index
  101874. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101875. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101876. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101877. */
  101878. 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;
  101879. /**
  101880. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101881. *
  101882. * @param renderingGroupId The rendering group id corresponding to its index
  101883. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101884. */
  101885. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  101886. /**
  101887. * Clones the texture.
  101888. * @returns the cloned texture
  101889. */
  101890. clone(): RenderTargetTexture;
  101891. /**
  101892. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  101893. * @returns The JSON representation of the texture
  101894. */
  101895. serialize(): any;
  101896. /**
  101897. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  101898. */
  101899. disposeFramebufferObjects(): void;
  101900. /**
  101901. * Dispose the texture and release its associated resources.
  101902. */
  101903. dispose(): void;
  101904. /** @hidden */
  101905. _rebuild(): void;
  101906. /**
  101907. * Clear the info related to rendering groups preventing retention point in material dispose.
  101908. */
  101909. freeRenderingGroups(): void;
  101910. /**
  101911. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  101912. * @returns the view count
  101913. */
  101914. getViewCount(): number;
  101915. }
  101916. }
  101917. declare module BABYLON {
  101918. /**
  101919. * Class used to manipulate GUIDs
  101920. */
  101921. export class GUID {
  101922. /**
  101923. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  101924. * Be aware Math.random() could cause collisions, but:
  101925. * "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"
  101926. * @returns a pseudo random id
  101927. */
  101928. static RandomId(): string;
  101929. }
  101930. }
  101931. declare module BABYLON {
  101932. /**
  101933. * Options to be used when creating a shadow depth material
  101934. */
  101935. export interface IIOptionShadowDepthMaterial {
  101936. /** Variables in the vertex shader code that need to have their names remapped.
  101937. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  101938. * "var_name" should be either: worldPos or vNormalW
  101939. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  101940. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  101941. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  101942. */
  101943. remappedVariables?: string[];
  101944. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  101945. standalone?: boolean;
  101946. }
  101947. /**
  101948. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  101949. */
  101950. export class ShadowDepthWrapper {
  101951. private _scene;
  101952. private _options?;
  101953. private _baseMaterial;
  101954. private _onEffectCreatedObserver;
  101955. private _subMeshToEffect;
  101956. private _subMeshToDepthEffect;
  101957. private _meshes;
  101958. /** @hidden */
  101959. _matriceNames: any;
  101960. /** Gets the standalone status of the wrapper */
  101961. get standalone(): boolean;
  101962. /** Gets the base material the wrapper is built upon */
  101963. get baseMaterial(): Material;
  101964. /**
  101965. * Instantiate a new shadow depth wrapper.
  101966. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  101967. * generate the shadow depth map. For more information, please refer to the documentation:
  101968. * https://doc.babylonjs.com/babylon101/shadows
  101969. * @param baseMaterial Material to wrap
  101970. * @param scene Define the scene the material belongs to
  101971. * @param options Options used to create the wrapper
  101972. */
  101973. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  101974. /**
  101975. * Gets the effect to use to generate the depth map
  101976. * @param subMesh subMesh to get the effect for
  101977. * @param shadowGenerator shadow generator to get the effect for
  101978. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  101979. */
  101980. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  101981. /**
  101982. * Specifies that the submesh is ready to be used for depth rendering
  101983. * @param subMesh submesh to check
  101984. * @param defines the list of defines to take into account when checking the effect
  101985. * @param shadowGenerator combined with subMesh, it defines the effect to check
  101986. * @param useInstances specifies that instances should be used
  101987. * @returns a boolean indicating that the submesh is ready or not
  101988. */
  101989. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  101990. /**
  101991. * Disposes the resources
  101992. */
  101993. dispose(): void;
  101994. private _makeEffect;
  101995. }
  101996. }
  101997. declare module BABYLON {
  101998. /**
  101999. * Options for compiling materials.
  102000. */
  102001. export interface IMaterialCompilationOptions {
  102002. /**
  102003. * Defines whether clip planes are enabled.
  102004. */
  102005. clipPlane: boolean;
  102006. /**
  102007. * Defines whether instances are enabled.
  102008. */
  102009. useInstances: boolean;
  102010. }
  102011. /**
  102012. * Options passed when calling customShaderNameResolve
  102013. */
  102014. export interface ICustomShaderNameResolveOptions {
  102015. /**
  102016. * 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
  102017. */
  102018. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  102019. }
  102020. /**
  102021. * Base class for the main features of a material in Babylon.js
  102022. */
  102023. export class Material implements IAnimatable {
  102024. /**
  102025. * Returns the triangle fill mode
  102026. */
  102027. static readonly TriangleFillMode: number;
  102028. /**
  102029. * Returns the wireframe mode
  102030. */
  102031. static readonly WireFrameFillMode: number;
  102032. /**
  102033. * Returns the point fill mode
  102034. */
  102035. static readonly PointFillMode: number;
  102036. /**
  102037. * Returns the point list draw mode
  102038. */
  102039. static readonly PointListDrawMode: number;
  102040. /**
  102041. * Returns the line list draw mode
  102042. */
  102043. static readonly LineListDrawMode: number;
  102044. /**
  102045. * Returns the line loop draw mode
  102046. */
  102047. static readonly LineLoopDrawMode: number;
  102048. /**
  102049. * Returns the line strip draw mode
  102050. */
  102051. static readonly LineStripDrawMode: number;
  102052. /**
  102053. * Returns the triangle strip draw mode
  102054. */
  102055. static readonly TriangleStripDrawMode: number;
  102056. /**
  102057. * Returns the triangle fan draw mode
  102058. */
  102059. static readonly TriangleFanDrawMode: number;
  102060. /**
  102061. * Stores the clock-wise side orientation
  102062. */
  102063. static readonly ClockWiseSideOrientation: number;
  102064. /**
  102065. * Stores the counter clock-wise side orientation
  102066. */
  102067. static readonly CounterClockWiseSideOrientation: number;
  102068. /**
  102069. * The dirty texture flag value
  102070. */
  102071. static readonly TextureDirtyFlag: number;
  102072. /**
  102073. * The dirty light flag value
  102074. */
  102075. static readonly LightDirtyFlag: number;
  102076. /**
  102077. * The dirty fresnel flag value
  102078. */
  102079. static readonly FresnelDirtyFlag: number;
  102080. /**
  102081. * The dirty attribute flag value
  102082. */
  102083. static readonly AttributesDirtyFlag: number;
  102084. /**
  102085. * The dirty misc flag value
  102086. */
  102087. static readonly MiscDirtyFlag: number;
  102088. /**
  102089. * The all dirty flag value
  102090. */
  102091. static readonly AllDirtyFlag: number;
  102092. /**
  102093. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  102094. */
  102095. static readonly MATERIAL_OPAQUE: number;
  102096. /**
  102097. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  102098. */
  102099. static readonly MATERIAL_ALPHATEST: number;
  102100. /**
  102101. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102102. */
  102103. static readonly MATERIAL_ALPHABLEND: number;
  102104. /**
  102105. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  102106. * They are also discarded below the alpha cutoff threshold to improve performances.
  102107. */
  102108. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  102109. /**
  102110. * The Whiteout method is used to blend normals.
  102111. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102112. */
  102113. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  102114. /**
  102115. * The Reoriented Normal Mapping method is used to blend normals.
  102116. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  102117. */
  102118. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  102119. /**
  102120. * Custom callback helping to override the default shader used in the material.
  102121. */
  102122. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  102123. /**
  102124. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  102125. */
  102126. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  102127. /**
  102128. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  102129. * This means that the material can keep using a previous shader while a new one is being compiled.
  102130. * This is mostly used when shader parallel compilation is supported (true by default)
  102131. */
  102132. allowShaderHotSwapping: boolean;
  102133. /**
  102134. * The ID of the material
  102135. */
  102136. id: string;
  102137. /**
  102138. * Gets or sets the unique id of the material
  102139. */
  102140. uniqueId: number;
  102141. /**
  102142. * The name of the material
  102143. */
  102144. name: string;
  102145. /**
  102146. * Gets or sets user defined metadata
  102147. */
  102148. metadata: any;
  102149. /**
  102150. * For internal use only. Please do not use.
  102151. */
  102152. reservedDataStore: any;
  102153. /**
  102154. * Specifies if the ready state should be checked on each call
  102155. */
  102156. checkReadyOnEveryCall: boolean;
  102157. /**
  102158. * Specifies if the ready state should be checked once
  102159. */
  102160. checkReadyOnlyOnce: boolean;
  102161. /**
  102162. * The state of the material
  102163. */
  102164. state: string;
  102165. /**
  102166. * If the material should be rendered to several textures with MRT extension
  102167. */
  102168. get shouldRenderToMRT(): boolean;
  102169. /**
  102170. * The alpha value of the material
  102171. */
  102172. protected _alpha: number;
  102173. /**
  102174. * List of inspectable custom properties (used by the Inspector)
  102175. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102176. */
  102177. inspectableCustomProperties: IInspectable[];
  102178. /**
  102179. * Sets the alpha value of the material
  102180. */
  102181. set alpha(value: number);
  102182. /**
  102183. * Gets the alpha value of the material
  102184. */
  102185. get alpha(): number;
  102186. /**
  102187. * Specifies if back face culling is enabled
  102188. */
  102189. protected _backFaceCulling: boolean;
  102190. /**
  102191. * Sets the back-face culling state
  102192. */
  102193. set backFaceCulling(value: boolean);
  102194. /**
  102195. * Gets the back-face culling state
  102196. */
  102197. get backFaceCulling(): boolean;
  102198. /**
  102199. * Stores the value for side orientation
  102200. */
  102201. sideOrientation: number;
  102202. /**
  102203. * Callback triggered when the material is compiled
  102204. */
  102205. onCompiled: Nullable<(effect: Effect) => void>;
  102206. /**
  102207. * Callback triggered when an error occurs
  102208. */
  102209. onError: Nullable<(effect: Effect, errors: string) => void>;
  102210. /**
  102211. * Callback triggered to get the render target textures
  102212. */
  102213. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  102214. /**
  102215. * Gets a boolean indicating that current material needs to register RTT
  102216. */
  102217. get hasRenderTargetTextures(): boolean;
  102218. /**
  102219. * Specifies if the material should be serialized
  102220. */
  102221. doNotSerialize: boolean;
  102222. /**
  102223. * @hidden
  102224. */
  102225. _storeEffectOnSubMeshes: boolean;
  102226. /**
  102227. * Stores the animations for the material
  102228. */
  102229. animations: Nullable<Array<Animation>>;
  102230. /**
  102231. * An event triggered when the material is disposed
  102232. */
  102233. onDisposeObservable: Observable<Material>;
  102234. /**
  102235. * An observer which watches for dispose events
  102236. */
  102237. private _onDisposeObserver;
  102238. private _onUnBindObservable;
  102239. /**
  102240. * Called during a dispose event
  102241. */
  102242. set onDispose(callback: () => void);
  102243. private _onBindObservable;
  102244. /**
  102245. * An event triggered when the material is bound
  102246. */
  102247. get onBindObservable(): Observable<AbstractMesh>;
  102248. /**
  102249. * An observer which watches for bind events
  102250. */
  102251. private _onBindObserver;
  102252. /**
  102253. * Called during a bind event
  102254. */
  102255. set onBind(callback: (Mesh: AbstractMesh) => void);
  102256. /**
  102257. * An event triggered when the material is unbound
  102258. */
  102259. get onUnBindObservable(): Observable<Material>;
  102260. protected _onEffectCreatedObservable: Nullable<Observable<{
  102261. effect: Effect;
  102262. subMesh: Nullable<SubMesh>;
  102263. }>>;
  102264. /**
  102265. * An event triggered when the effect is (re)created
  102266. */
  102267. get onEffectCreatedObservable(): Observable<{
  102268. effect: Effect;
  102269. subMesh: Nullable<SubMesh>;
  102270. }>;
  102271. /**
  102272. * Stores the value of the alpha mode
  102273. */
  102274. private _alphaMode;
  102275. /**
  102276. * Sets the value of the alpha mode.
  102277. *
  102278. * | Value | Type | Description |
  102279. * | --- | --- | --- |
  102280. * | 0 | ALPHA_DISABLE | |
  102281. * | 1 | ALPHA_ADD | |
  102282. * | 2 | ALPHA_COMBINE | |
  102283. * | 3 | ALPHA_SUBTRACT | |
  102284. * | 4 | ALPHA_MULTIPLY | |
  102285. * | 5 | ALPHA_MAXIMIZED | |
  102286. * | 6 | ALPHA_ONEONE | |
  102287. * | 7 | ALPHA_PREMULTIPLIED | |
  102288. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  102289. * | 9 | ALPHA_INTERPOLATE | |
  102290. * | 10 | ALPHA_SCREENMODE | |
  102291. *
  102292. */
  102293. set alphaMode(value: number);
  102294. /**
  102295. * Gets the value of the alpha mode
  102296. */
  102297. get alphaMode(): number;
  102298. /**
  102299. * Stores the state of the need depth pre-pass value
  102300. */
  102301. private _needDepthPrePass;
  102302. /**
  102303. * Sets the need depth pre-pass value
  102304. */
  102305. set needDepthPrePass(value: boolean);
  102306. /**
  102307. * Gets the depth pre-pass value
  102308. */
  102309. get needDepthPrePass(): boolean;
  102310. /**
  102311. * Specifies if depth writing should be disabled
  102312. */
  102313. disableDepthWrite: boolean;
  102314. /**
  102315. * Specifies if color writing should be disabled
  102316. */
  102317. disableColorWrite: boolean;
  102318. /**
  102319. * Specifies if depth writing should be forced
  102320. */
  102321. forceDepthWrite: boolean;
  102322. /**
  102323. * Specifies the depth function that should be used. 0 means the default engine function
  102324. */
  102325. depthFunction: number;
  102326. /**
  102327. * Specifies if there should be a separate pass for culling
  102328. */
  102329. separateCullingPass: boolean;
  102330. /**
  102331. * Stores the state specifing if fog should be enabled
  102332. */
  102333. private _fogEnabled;
  102334. /**
  102335. * Sets the state for enabling fog
  102336. */
  102337. set fogEnabled(value: boolean);
  102338. /**
  102339. * Gets the value of the fog enabled state
  102340. */
  102341. get fogEnabled(): boolean;
  102342. /**
  102343. * Stores the size of points
  102344. */
  102345. pointSize: number;
  102346. /**
  102347. * Stores the z offset value
  102348. */
  102349. zOffset: number;
  102350. get wireframe(): boolean;
  102351. /**
  102352. * Sets the state of wireframe mode
  102353. */
  102354. set wireframe(value: boolean);
  102355. /**
  102356. * Gets the value specifying if point clouds are enabled
  102357. */
  102358. get pointsCloud(): boolean;
  102359. /**
  102360. * Sets the state of point cloud mode
  102361. */
  102362. set pointsCloud(value: boolean);
  102363. /**
  102364. * Gets the material fill mode
  102365. */
  102366. get fillMode(): number;
  102367. /**
  102368. * Sets the material fill mode
  102369. */
  102370. set fillMode(value: number);
  102371. /**
  102372. * @hidden
  102373. * Stores the effects for the material
  102374. */
  102375. _effect: Nullable<Effect>;
  102376. /**
  102377. * Specifies if uniform buffers should be used
  102378. */
  102379. private _useUBO;
  102380. /**
  102381. * Stores a reference to the scene
  102382. */
  102383. private _scene;
  102384. /**
  102385. * Stores the fill mode state
  102386. */
  102387. private _fillMode;
  102388. /**
  102389. * Specifies if the depth write state should be cached
  102390. */
  102391. private _cachedDepthWriteState;
  102392. /**
  102393. * Specifies if the color write state should be cached
  102394. */
  102395. private _cachedColorWriteState;
  102396. /**
  102397. * Specifies if the depth function state should be cached
  102398. */
  102399. private _cachedDepthFunctionState;
  102400. /**
  102401. * Stores the uniform buffer
  102402. */
  102403. protected _uniformBuffer: UniformBuffer;
  102404. /** @hidden */
  102405. _indexInSceneMaterialArray: number;
  102406. /** @hidden */
  102407. meshMap: Nullable<{
  102408. [id: string]: AbstractMesh | undefined;
  102409. }>;
  102410. /**
  102411. * Creates a material instance
  102412. * @param name defines the name of the material
  102413. * @param scene defines the scene to reference
  102414. * @param doNotAdd specifies if the material should be added to the scene
  102415. */
  102416. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  102417. /**
  102418. * Returns a string representation of the current material
  102419. * @param fullDetails defines a boolean indicating which levels of logging is desired
  102420. * @returns a string with material information
  102421. */
  102422. toString(fullDetails?: boolean): string;
  102423. /**
  102424. * Gets the class name of the material
  102425. * @returns a string with the class name of the material
  102426. */
  102427. getClassName(): string;
  102428. /**
  102429. * Specifies if updates for the material been locked
  102430. */
  102431. get isFrozen(): boolean;
  102432. /**
  102433. * Locks updates for the material
  102434. */
  102435. freeze(): void;
  102436. /**
  102437. * Unlocks updates for the material
  102438. */
  102439. unfreeze(): void;
  102440. /**
  102441. * Specifies if the material is ready to be used
  102442. * @param mesh defines the mesh to check
  102443. * @param useInstances specifies if instances should be used
  102444. * @returns a boolean indicating if the material is ready to be used
  102445. */
  102446. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102447. /**
  102448. * Specifies that the submesh is ready to be used
  102449. * @param mesh defines the mesh to check
  102450. * @param subMesh defines which submesh to check
  102451. * @param useInstances specifies that instances should be used
  102452. * @returns a boolean indicating that the submesh is ready or not
  102453. */
  102454. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102455. /**
  102456. * Returns the material effect
  102457. * @returns the effect associated with the material
  102458. */
  102459. getEffect(): Nullable<Effect>;
  102460. /**
  102461. * Returns the current scene
  102462. * @returns a Scene
  102463. */
  102464. getScene(): Scene;
  102465. /**
  102466. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  102467. */
  102468. protected _forceAlphaTest: boolean;
  102469. /**
  102470. * The transparency mode of the material.
  102471. */
  102472. protected _transparencyMode: Nullable<number>;
  102473. /**
  102474. * Gets the current transparency mode.
  102475. */
  102476. get transparencyMode(): Nullable<number>;
  102477. /**
  102478. * Sets the transparency mode of the material.
  102479. *
  102480. * | Value | Type | Description |
  102481. * | ----- | ----------------------------------- | ----------- |
  102482. * | 0 | OPAQUE | |
  102483. * | 1 | ALPHATEST | |
  102484. * | 2 | ALPHABLEND | |
  102485. * | 3 | ALPHATESTANDBLEND | |
  102486. *
  102487. */
  102488. set transparencyMode(value: Nullable<number>);
  102489. /**
  102490. * Returns true if alpha blending should be disabled.
  102491. */
  102492. protected get _disableAlphaBlending(): boolean;
  102493. /**
  102494. * Specifies whether or not this material should be rendered in alpha blend mode.
  102495. * @returns a boolean specifying if alpha blending is needed
  102496. */
  102497. needAlphaBlending(): boolean;
  102498. /**
  102499. * Specifies if the mesh will require alpha blending
  102500. * @param mesh defines the mesh to check
  102501. * @returns a boolean specifying if alpha blending is needed for the mesh
  102502. */
  102503. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  102504. /**
  102505. * Specifies whether or not this material should be rendered in alpha test mode.
  102506. * @returns a boolean specifying if an alpha test is needed.
  102507. */
  102508. needAlphaTesting(): boolean;
  102509. /**
  102510. * Specifies if material alpha testing should be turned on for the mesh
  102511. * @param mesh defines the mesh to check
  102512. */
  102513. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  102514. /**
  102515. * Gets the texture used for the alpha test
  102516. * @returns the texture to use for alpha testing
  102517. */
  102518. getAlphaTestTexture(): Nullable<BaseTexture>;
  102519. /**
  102520. * Marks the material to indicate that it needs to be re-calculated
  102521. */
  102522. markDirty(): void;
  102523. /** @hidden */
  102524. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  102525. /**
  102526. * Binds the material to the mesh
  102527. * @param world defines the world transformation matrix
  102528. * @param mesh defines the mesh to bind the material to
  102529. */
  102530. bind(world: Matrix, mesh?: Mesh): void;
  102531. /**
  102532. * Binds the submesh to the material
  102533. * @param world defines the world transformation matrix
  102534. * @param mesh defines the mesh containing the submesh
  102535. * @param subMesh defines the submesh to bind the material to
  102536. */
  102537. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102538. /**
  102539. * Binds the world matrix to the material
  102540. * @param world defines the world transformation matrix
  102541. */
  102542. bindOnlyWorldMatrix(world: Matrix): void;
  102543. /**
  102544. * Binds the scene's uniform buffer to the effect.
  102545. * @param effect defines the effect to bind to the scene uniform buffer
  102546. * @param sceneUbo defines the uniform buffer storing scene data
  102547. */
  102548. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  102549. /**
  102550. * Binds the view matrix to the effect
  102551. * @param effect defines the effect to bind the view matrix to
  102552. */
  102553. bindView(effect: Effect): void;
  102554. /**
  102555. * Binds the view projection matrix to the effect
  102556. * @param effect defines the effect to bind the view projection matrix to
  102557. */
  102558. bindViewProjection(effect: Effect): void;
  102559. /**
  102560. * Processes to execute after binding the material to a mesh
  102561. * @param mesh defines the rendered mesh
  102562. */
  102563. protected _afterBind(mesh?: Mesh): void;
  102564. /**
  102565. * Unbinds the material from the mesh
  102566. */
  102567. unbind(): void;
  102568. /**
  102569. * Gets the active textures from the material
  102570. * @returns an array of textures
  102571. */
  102572. getActiveTextures(): BaseTexture[];
  102573. /**
  102574. * Specifies if the material uses a texture
  102575. * @param texture defines the texture to check against the material
  102576. * @returns a boolean specifying if the material uses the texture
  102577. */
  102578. hasTexture(texture: BaseTexture): boolean;
  102579. /**
  102580. * Makes a duplicate of the material, and gives it a new name
  102581. * @param name defines the new name for the duplicated material
  102582. * @returns the cloned material
  102583. */
  102584. clone(name: string): Nullable<Material>;
  102585. /**
  102586. * Gets the meshes bound to the material
  102587. * @returns an array of meshes bound to the material
  102588. */
  102589. getBindedMeshes(): AbstractMesh[];
  102590. /**
  102591. * Force shader compilation
  102592. * @param mesh defines the mesh associated with this material
  102593. * @param onCompiled defines a function to execute once the material is compiled
  102594. * @param options defines the options to configure the compilation
  102595. * @param onError defines a function to execute if the material fails compiling
  102596. */
  102597. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  102598. /**
  102599. * Force shader compilation
  102600. * @param mesh defines the mesh that will use this material
  102601. * @param options defines additional options for compiling the shaders
  102602. * @returns a promise that resolves when the compilation completes
  102603. */
  102604. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  102605. private static readonly _AllDirtyCallBack;
  102606. private static readonly _ImageProcessingDirtyCallBack;
  102607. private static readonly _TextureDirtyCallBack;
  102608. private static readonly _FresnelDirtyCallBack;
  102609. private static readonly _MiscDirtyCallBack;
  102610. private static readonly _LightsDirtyCallBack;
  102611. private static readonly _AttributeDirtyCallBack;
  102612. private static _FresnelAndMiscDirtyCallBack;
  102613. private static _TextureAndMiscDirtyCallBack;
  102614. private static readonly _DirtyCallbackArray;
  102615. private static readonly _RunDirtyCallBacks;
  102616. /**
  102617. * Marks a define in the material to indicate that it needs to be re-computed
  102618. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  102619. */
  102620. markAsDirty(flag: number): void;
  102621. /**
  102622. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  102623. * @param func defines a function which checks material defines against the submeshes
  102624. */
  102625. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  102626. /**
  102627. * Indicates that the scene should check if the rendering now needs a prepass
  102628. */
  102629. protected _markScenePrePassDirty(): void;
  102630. /**
  102631. * Indicates that we need to re-calculated for all submeshes
  102632. */
  102633. protected _markAllSubMeshesAsAllDirty(): void;
  102634. /**
  102635. * Indicates that image processing needs to be re-calculated for all submeshes
  102636. */
  102637. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  102638. /**
  102639. * Indicates that textures need to be re-calculated for all submeshes
  102640. */
  102641. protected _markAllSubMeshesAsTexturesDirty(): void;
  102642. /**
  102643. * Indicates that fresnel needs to be re-calculated for all submeshes
  102644. */
  102645. protected _markAllSubMeshesAsFresnelDirty(): void;
  102646. /**
  102647. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  102648. */
  102649. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  102650. /**
  102651. * Indicates that lights need to be re-calculated for all submeshes
  102652. */
  102653. protected _markAllSubMeshesAsLightsDirty(): void;
  102654. /**
  102655. * Indicates that attributes need to be re-calculated for all submeshes
  102656. */
  102657. protected _markAllSubMeshesAsAttributesDirty(): void;
  102658. /**
  102659. * Indicates that misc needs to be re-calculated for all submeshes
  102660. */
  102661. protected _markAllSubMeshesAsMiscDirty(): void;
  102662. /**
  102663. * Indicates that textures and misc need to be re-calculated for all submeshes
  102664. */
  102665. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  102666. /**
  102667. * Disposes the material
  102668. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102669. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102670. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102671. */
  102672. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102673. /** @hidden */
  102674. private releaseVertexArrayObject;
  102675. /**
  102676. * Serializes this material
  102677. * @returns the serialized material object
  102678. */
  102679. serialize(): any;
  102680. /**
  102681. * Creates a material from parsed material data
  102682. * @param parsedMaterial defines parsed material data
  102683. * @param scene defines the hosting scene
  102684. * @param rootUrl defines the root URL to use to load textures
  102685. * @returns a new material
  102686. */
  102687. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  102688. }
  102689. }
  102690. declare module BABYLON {
  102691. /**
  102692. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102693. * separate meshes. This can be use to improve performances.
  102694. * @see https://doc.babylonjs.com/how_to/multi_materials
  102695. */
  102696. export class MultiMaterial extends Material {
  102697. private _subMaterials;
  102698. /**
  102699. * Gets or Sets the list of Materials used within the multi material.
  102700. * They need to be ordered according to the submeshes order in the associated mesh
  102701. */
  102702. get subMaterials(): Nullable<Material>[];
  102703. set subMaterials(value: Nullable<Material>[]);
  102704. /**
  102705. * Function used to align with Node.getChildren()
  102706. * @returns the list of Materials used within the multi material
  102707. */
  102708. getChildren(): Nullable<Material>[];
  102709. /**
  102710. * Instantiates a new Multi Material
  102711. * A multi-material is used to apply different materials to different parts of the same object without the need of
  102712. * separate meshes. This can be use to improve performances.
  102713. * @see https://doc.babylonjs.com/how_to/multi_materials
  102714. * @param name Define the name in the scene
  102715. * @param scene Define the scene the material belongs to
  102716. */
  102717. constructor(name: string, scene: Scene);
  102718. private _hookArray;
  102719. /**
  102720. * Get one of the submaterial by its index in the submaterials array
  102721. * @param index The index to look the sub material at
  102722. * @returns The Material if the index has been defined
  102723. */
  102724. getSubMaterial(index: number): Nullable<Material>;
  102725. /**
  102726. * Get the list of active textures for the whole sub materials list.
  102727. * @returns All the textures that will be used during the rendering
  102728. */
  102729. getActiveTextures(): BaseTexture[];
  102730. /**
  102731. * Gets the current class name of the material e.g. "MultiMaterial"
  102732. * Mainly use in serialization.
  102733. * @returns the class name
  102734. */
  102735. getClassName(): string;
  102736. /**
  102737. * Checks if the material is ready to render the requested sub mesh
  102738. * @param mesh Define the mesh the submesh belongs to
  102739. * @param subMesh Define the sub mesh to look readyness for
  102740. * @param useInstances Define whether or not the material is used with instances
  102741. * @returns true if ready, otherwise false
  102742. */
  102743. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102744. /**
  102745. * Clones the current material and its related sub materials
  102746. * @param name Define the name of the newly cloned material
  102747. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  102748. * @returns the cloned material
  102749. */
  102750. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  102751. /**
  102752. * Serializes the materials into a JSON representation.
  102753. * @returns the JSON representation
  102754. */
  102755. serialize(): any;
  102756. /**
  102757. * Dispose the material and release its associated resources
  102758. * @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)
  102759. * @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)
  102760. * @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)
  102761. */
  102762. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  102763. /**
  102764. * Creates a MultiMaterial from parsed MultiMaterial data.
  102765. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  102766. * @param scene defines the hosting scene
  102767. * @returns a new MultiMaterial
  102768. */
  102769. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  102770. }
  102771. }
  102772. declare module BABYLON {
  102773. /**
  102774. * Defines a subdivision inside a mesh
  102775. */
  102776. export class SubMesh implements ICullable {
  102777. /** the material index to use */
  102778. materialIndex: number;
  102779. /** vertex index start */
  102780. verticesStart: number;
  102781. /** vertices count */
  102782. verticesCount: number;
  102783. /** index start */
  102784. indexStart: number;
  102785. /** indices count */
  102786. indexCount: number;
  102787. /** @hidden */
  102788. _materialDefines: Nullable<MaterialDefines>;
  102789. /** @hidden */
  102790. _materialEffect: Nullable<Effect>;
  102791. /** @hidden */
  102792. _effectOverride: Nullable<Effect>;
  102793. /**
  102794. * Gets material defines used by the effect associated to the sub mesh
  102795. */
  102796. get materialDefines(): Nullable<MaterialDefines>;
  102797. /**
  102798. * Sets material defines used by the effect associated to the sub mesh
  102799. */
  102800. set materialDefines(defines: Nullable<MaterialDefines>);
  102801. /**
  102802. * Gets associated effect
  102803. */
  102804. get effect(): Nullable<Effect>;
  102805. /**
  102806. * Sets associated effect (effect used to render this submesh)
  102807. * @param effect defines the effect to associate with
  102808. * @param defines defines the set of defines used to compile this effect
  102809. */
  102810. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  102811. /** @hidden */
  102812. _linesIndexCount: number;
  102813. private _mesh;
  102814. private _renderingMesh;
  102815. private _boundingInfo;
  102816. private _linesIndexBuffer;
  102817. /** @hidden */
  102818. _lastColliderWorldVertices: Nullable<Vector3[]>;
  102819. /** @hidden */
  102820. _trianglePlanes: Plane[];
  102821. /** @hidden */
  102822. _lastColliderTransformMatrix: Nullable<Matrix>;
  102823. /** @hidden */
  102824. _renderId: number;
  102825. /** @hidden */
  102826. _alphaIndex: number;
  102827. /** @hidden */
  102828. _distanceToCamera: number;
  102829. /** @hidden */
  102830. _id: number;
  102831. private _currentMaterial;
  102832. /**
  102833. * Add a new submesh to a mesh
  102834. * @param materialIndex defines the material index to use
  102835. * @param verticesStart defines vertex index start
  102836. * @param verticesCount defines vertices count
  102837. * @param indexStart defines index start
  102838. * @param indexCount defines indices count
  102839. * @param mesh defines the parent mesh
  102840. * @param renderingMesh defines an optional rendering mesh
  102841. * @param createBoundingBox defines if bounding box should be created for this submesh
  102842. * @returns the new submesh
  102843. */
  102844. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  102845. /**
  102846. * Creates a new submesh
  102847. * @param materialIndex defines the material index to use
  102848. * @param verticesStart defines vertex index start
  102849. * @param verticesCount defines vertices count
  102850. * @param indexStart defines index start
  102851. * @param indexCount defines indices count
  102852. * @param mesh defines the parent mesh
  102853. * @param renderingMesh defines an optional rendering mesh
  102854. * @param createBoundingBox defines if bounding box should be created for this submesh
  102855. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  102856. */
  102857. constructor(
  102858. /** the material index to use */
  102859. materialIndex: number,
  102860. /** vertex index start */
  102861. verticesStart: number,
  102862. /** vertices count */
  102863. verticesCount: number,
  102864. /** index start */
  102865. indexStart: number,
  102866. /** indices count */
  102867. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  102868. /**
  102869. * Returns true if this submesh covers the entire parent mesh
  102870. * @ignorenaming
  102871. */
  102872. get IsGlobal(): boolean;
  102873. /**
  102874. * Returns the submesh BoudingInfo object
  102875. * @returns current bounding info (or mesh's one if the submesh is global)
  102876. */
  102877. getBoundingInfo(): BoundingInfo;
  102878. /**
  102879. * Sets the submesh BoundingInfo
  102880. * @param boundingInfo defines the new bounding info to use
  102881. * @returns the SubMesh
  102882. */
  102883. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  102884. /**
  102885. * Returns the mesh of the current submesh
  102886. * @return the parent mesh
  102887. */
  102888. getMesh(): AbstractMesh;
  102889. /**
  102890. * Returns the rendering mesh of the submesh
  102891. * @returns the rendering mesh (could be different from parent mesh)
  102892. */
  102893. getRenderingMesh(): Mesh;
  102894. /**
  102895. * Returns the replacement mesh of the submesh
  102896. * @returns the replacement mesh (could be different from parent mesh)
  102897. */
  102898. getReplacementMesh(): Nullable<AbstractMesh>;
  102899. /**
  102900. * Returns the effective mesh of the submesh
  102901. * @returns the effective mesh (could be different from parent mesh)
  102902. */
  102903. getEffectiveMesh(): AbstractMesh;
  102904. /**
  102905. * Returns the submesh material
  102906. * @returns null or the current material
  102907. */
  102908. getMaterial(): Nullable<Material>;
  102909. private _IsMultiMaterial;
  102910. /**
  102911. * Sets a new updated BoundingInfo object to the submesh
  102912. * @param data defines an optional position array to use to determine the bounding info
  102913. * @returns the SubMesh
  102914. */
  102915. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  102916. /** @hidden */
  102917. _checkCollision(collider: Collider): boolean;
  102918. /**
  102919. * Updates the submesh BoundingInfo
  102920. * @param world defines the world matrix to use to update the bounding info
  102921. * @returns the submesh
  102922. */
  102923. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  102924. /**
  102925. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  102926. * @param frustumPlanes defines the frustum planes
  102927. * @returns true if the submesh is intersecting with the frustum
  102928. */
  102929. isInFrustum(frustumPlanes: Plane[]): boolean;
  102930. /**
  102931. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  102932. * @param frustumPlanes defines the frustum planes
  102933. * @returns true if the submesh is inside the frustum
  102934. */
  102935. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102936. /**
  102937. * Renders the submesh
  102938. * @param enableAlphaMode defines if alpha needs to be used
  102939. * @returns the submesh
  102940. */
  102941. render(enableAlphaMode: boolean): SubMesh;
  102942. /**
  102943. * @hidden
  102944. */
  102945. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  102946. /**
  102947. * Checks if the submesh intersects with a ray
  102948. * @param ray defines the ray to test
  102949. * @returns true is the passed ray intersects the submesh bounding box
  102950. */
  102951. canIntersects(ray: Ray): boolean;
  102952. /**
  102953. * Intersects current submesh with a ray
  102954. * @param ray defines the ray to test
  102955. * @param positions defines mesh's positions array
  102956. * @param indices defines mesh's indices array
  102957. * @param fastCheck defines if the first intersection will be used (and not the closest)
  102958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  102959. * @returns intersection info or null if no intersection
  102960. */
  102961. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  102962. /** @hidden */
  102963. private _intersectLines;
  102964. /** @hidden */
  102965. private _intersectUnIndexedLines;
  102966. /** @hidden */
  102967. private _intersectTriangles;
  102968. /** @hidden */
  102969. private _intersectUnIndexedTriangles;
  102970. /** @hidden */
  102971. _rebuild(): void;
  102972. /**
  102973. * Creates a new submesh from the passed mesh
  102974. * @param newMesh defines the new hosting mesh
  102975. * @param newRenderingMesh defines an optional rendering mesh
  102976. * @returns the new submesh
  102977. */
  102978. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  102979. /**
  102980. * Release associated resources
  102981. */
  102982. dispose(): void;
  102983. /**
  102984. * Gets the class name
  102985. * @returns the string "SubMesh".
  102986. */
  102987. getClassName(): string;
  102988. /**
  102989. * Creates a new submesh from indices data
  102990. * @param materialIndex the index of the main mesh material
  102991. * @param startIndex the index where to start the copy in the mesh indices array
  102992. * @param indexCount the number of indices to copy then from the startIndex
  102993. * @param mesh the main mesh to create the submesh from
  102994. * @param renderingMesh the optional rendering mesh
  102995. * @returns a new submesh
  102996. */
  102997. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  102998. }
  102999. }
  103000. declare module BABYLON {
  103001. /**
  103002. * Class used to represent data loading progression
  103003. */
  103004. export class SceneLoaderFlags {
  103005. private static _ForceFullSceneLoadingForIncremental;
  103006. private static _ShowLoadingScreen;
  103007. private static _CleanBoneMatrixWeights;
  103008. private static _loggingLevel;
  103009. /**
  103010. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  103011. */
  103012. static get ForceFullSceneLoadingForIncremental(): boolean;
  103013. static set ForceFullSceneLoadingForIncremental(value: boolean);
  103014. /**
  103015. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  103016. */
  103017. static get ShowLoadingScreen(): boolean;
  103018. static set ShowLoadingScreen(value: boolean);
  103019. /**
  103020. * Defines the current logging level (while loading the scene)
  103021. * @ignorenaming
  103022. */
  103023. static get loggingLevel(): number;
  103024. static set loggingLevel(value: number);
  103025. /**
  103026. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  103027. */
  103028. static get CleanBoneMatrixWeights(): boolean;
  103029. static set CleanBoneMatrixWeights(value: boolean);
  103030. }
  103031. }
  103032. declare module BABYLON {
  103033. /**
  103034. * Class used to store geometry data (vertex buffers + index buffer)
  103035. */
  103036. export class Geometry implements IGetSetVerticesData {
  103037. /**
  103038. * Gets or sets the ID of the geometry
  103039. */
  103040. id: string;
  103041. /**
  103042. * Gets or sets the unique ID of the geometry
  103043. */
  103044. uniqueId: number;
  103045. /**
  103046. * Gets the delay loading state of the geometry (none by default which means not delayed)
  103047. */
  103048. delayLoadState: number;
  103049. /**
  103050. * Gets the file containing the data to load when running in delay load state
  103051. */
  103052. delayLoadingFile: Nullable<string>;
  103053. /**
  103054. * Callback called when the geometry is updated
  103055. */
  103056. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  103057. private _scene;
  103058. private _engine;
  103059. private _meshes;
  103060. private _totalVertices;
  103061. /** @hidden */
  103062. _indices: IndicesArray;
  103063. /** @hidden */
  103064. _vertexBuffers: {
  103065. [key: string]: VertexBuffer;
  103066. };
  103067. private _isDisposed;
  103068. private _extend;
  103069. private _boundingBias;
  103070. /** @hidden */
  103071. _delayInfo: Array<string>;
  103072. private _indexBuffer;
  103073. private _indexBufferIsUpdatable;
  103074. /** @hidden */
  103075. _boundingInfo: Nullable<BoundingInfo>;
  103076. /** @hidden */
  103077. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  103078. /** @hidden */
  103079. _softwareSkinningFrameId: number;
  103080. private _vertexArrayObjects;
  103081. private _updatable;
  103082. /** @hidden */
  103083. _positions: Nullable<Vector3[]>;
  103084. /**
  103085. * 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
  103086. */
  103087. get boundingBias(): Vector2;
  103088. /**
  103089. * 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
  103090. */
  103091. set boundingBias(value: Vector2);
  103092. /**
  103093. * Static function used to attach a new empty geometry to a mesh
  103094. * @param mesh defines the mesh to attach the geometry to
  103095. * @returns the new Geometry
  103096. */
  103097. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  103098. /** Get the list of meshes using this geometry */
  103099. get meshes(): Mesh[];
  103100. /**
  103101. * 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
  103102. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  103103. */
  103104. useBoundingInfoFromGeometry: boolean;
  103105. /**
  103106. * Creates a new geometry
  103107. * @param id defines the unique ID
  103108. * @param scene defines the hosting scene
  103109. * @param vertexData defines the VertexData used to get geometry data
  103110. * @param updatable defines if geometry must be updatable (false by default)
  103111. * @param mesh defines the mesh that will be associated with the geometry
  103112. */
  103113. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  103114. /**
  103115. * Gets the current extend of the geometry
  103116. */
  103117. get extend(): {
  103118. minimum: Vector3;
  103119. maximum: Vector3;
  103120. };
  103121. /**
  103122. * Gets the hosting scene
  103123. * @returns the hosting Scene
  103124. */
  103125. getScene(): Scene;
  103126. /**
  103127. * Gets the hosting engine
  103128. * @returns the hosting Engine
  103129. */
  103130. getEngine(): Engine;
  103131. /**
  103132. * Defines if the geometry is ready to use
  103133. * @returns true if the geometry is ready to be used
  103134. */
  103135. isReady(): boolean;
  103136. /**
  103137. * Gets a value indicating that the geometry should not be serialized
  103138. */
  103139. get doNotSerialize(): boolean;
  103140. /** @hidden */
  103141. _rebuild(): void;
  103142. /**
  103143. * Affects all geometry data in one call
  103144. * @param vertexData defines the geometry data
  103145. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  103146. */
  103147. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  103148. /**
  103149. * Set specific vertex data
  103150. * @param kind defines the data kind (Position, normal, etc...)
  103151. * @param data defines the vertex data to use
  103152. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103153. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103154. */
  103155. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  103156. /**
  103157. * Removes a specific vertex data
  103158. * @param kind defines the data kind (Position, normal, etc...)
  103159. */
  103160. removeVerticesData(kind: string): void;
  103161. /**
  103162. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  103163. * @param buffer defines the vertex buffer to use
  103164. * @param totalVertices defines the total number of vertices for position kind (could be null)
  103165. */
  103166. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  103167. /**
  103168. * Update a specific vertex buffer
  103169. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  103170. * It will do nothing if the buffer is not updatable
  103171. * @param kind defines the data kind (Position, normal, etc...)
  103172. * @param data defines the data to use
  103173. * @param offset defines the offset in the target buffer where to store the data
  103174. * @param useBytes set to true if the offset is in bytes
  103175. */
  103176. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  103177. /**
  103178. * Update a specific vertex buffer
  103179. * This function will create a new buffer if the current one is not updatable
  103180. * @param kind defines the data kind (Position, normal, etc...)
  103181. * @param data defines the data to use
  103182. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  103183. */
  103184. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  103185. private _updateBoundingInfo;
  103186. /** @hidden */
  103187. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  103188. /**
  103189. * Gets total number of vertices
  103190. * @returns the total number of vertices
  103191. */
  103192. getTotalVertices(): number;
  103193. /**
  103194. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103195. * @param kind defines the data kind (Position, normal, etc...)
  103196. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103197. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103198. * @returns a float array containing vertex data
  103199. */
  103200. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103201. /**
  103202. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  103203. * @param kind defines the data kind (Position, normal, etc...)
  103204. * @returns true if the vertex buffer with the specified kind is updatable
  103205. */
  103206. isVertexBufferUpdatable(kind: string): boolean;
  103207. /**
  103208. * Gets a specific vertex buffer
  103209. * @param kind defines the data kind (Position, normal, etc...)
  103210. * @returns a VertexBuffer
  103211. */
  103212. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  103213. /**
  103214. * Returns all vertex buffers
  103215. * @return an object holding all vertex buffers indexed by kind
  103216. */
  103217. getVertexBuffers(): Nullable<{
  103218. [key: string]: VertexBuffer;
  103219. }>;
  103220. /**
  103221. * Gets a boolean indicating if specific vertex buffer is present
  103222. * @param kind defines the data kind (Position, normal, etc...)
  103223. * @returns true if data is present
  103224. */
  103225. isVerticesDataPresent(kind: string): boolean;
  103226. /**
  103227. * Gets a list of all attached data kinds (Position, normal, etc...)
  103228. * @returns a list of string containing all kinds
  103229. */
  103230. getVerticesDataKinds(): string[];
  103231. /**
  103232. * Update index buffer
  103233. * @param indices defines the indices to store in the index buffer
  103234. * @param offset defines the offset in the target buffer where to store the data
  103235. * @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)
  103236. */
  103237. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  103238. /**
  103239. * Creates a new index buffer
  103240. * @param indices defines the indices to store in the index buffer
  103241. * @param totalVertices defines the total number of vertices (could be null)
  103242. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103243. */
  103244. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  103245. /**
  103246. * Return the total number of indices
  103247. * @returns the total number of indices
  103248. */
  103249. getTotalIndices(): number;
  103250. /**
  103251. * Gets the index buffer array
  103252. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103253. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103254. * @returns the index buffer array
  103255. */
  103256. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103257. /**
  103258. * Gets the index buffer
  103259. * @return the index buffer
  103260. */
  103261. getIndexBuffer(): Nullable<DataBuffer>;
  103262. /** @hidden */
  103263. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  103264. /**
  103265. * Release the associated resources for a specific mesh
  103266. * @param mesh defines the source mesh
  103267. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  103268. */
  103269. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  103270. /**
  103271. * Apply current geometry to a given mesh
  103272. * @param mesh defines the mesh to apply geometry to
  103273. */
  103274. applyToMesh(mesh: Mesh): void;
  103275. private _updateExtend;
  103276. private _applyToMesh;
  103277. private notifyUpdate;
  103278. /**
  103279. * Load the geometry if it was flagged as delay loaded
  103280. * @param scene defines the hosting scene
  103281. * @param onLoaded defines a callback called when the geometry is loaded
  103282. */
  103283. load(scene: Scene, onLoaded?: () => void): void;
  103284. private _queueLoad;
  103285. /**
  103286. * Invert the geometry to move from a right handed system to a left handed one.
  103287. */
  103288. toLeftHanded(): void;
  103289. /** @hidden */
  103290. _resetPointsArrayCache(): void;
  103291. /** @hidden */
  103292. _generatePointsArray(): boolean;
  103293. /**
  103294. * Gets a value indicating if the geometry is disposed
  103295. * @returns true if the geometry was disposed
  103296. */
  103297. isDisposed(): boolean;
  103298. private _disposeVertexArrayObjects;
  103299. /**
  103300. * Free all associated resources
  103301. */
  103302. dispose(): void;
  103303. /**
  103304. * Clone the current geometry into a new geometry
  103305. * @param id defines the unique ID of the new geometry
  103306. * @returns a new geometry object
  103307. */
  103308. copy(id: string): Geometry;
  103309. /**
  103310. * Serialize the current geometry info (and not the vertices data) into a JSON object
  103311. * @return a JSON representation of the current geometry data (without the vertices data)
  103312. */
  103313. serialize(): any;
  103314. private toNumberArray;
  103315. /**
  103316. * Serialize all vertices data into a JSON oject
  103317. * @returns a JSON representation of the current geometry data
  103318. */
  103319. serializeVerticeData(): any;
  103320. /**
  103321. * Extracts a clone of a mesh geometry
  103322. * @param mesh defines the source mesh
  103323. * @param id defines the unique ID of the new geometry object
  103324. * @returns the new geometry object
  103325. */
  103326. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  103327. /**
  103328. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  103329. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  103330. * Be aware Math.random() could cause collisions, but:
  103331. * "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"
  103332. * @returns a string containing a new GUID
  103333. */
  103334. static RandomId(): string;
  103335. /** @hidden */
  103336. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  103337. private static _CleanMatricesWeights;
  103338. /**
  103339. * Create a new geometry from persisted data (Using .babylon file format)
  103340. * @param parsedVertexData defines the persisted data
  103341. * @param scene defines the hosting scene
  103342. * @param rootUrl defines the root url to use to load assets (like delayed data)
  103343. * @returns the new geometry object
  103344. */
  103345. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  103346. }
  103347. }
  103348. declare module BABYLON {
  103349. /**
  103350. * Define an interface for all classes that will get and set the data on vertices
  103351. */
  103352. export interface IGetSetVerticesData {
  103353. /**
  103354. * Gets a boolean indicating if specific vertex data is present
  103355. * @param kind defines the vertex data kind to use
  103356. * @returns true is data kind is present
  103357. */
  103358. isVerticesDataPresent(kind: string): boolean;
  103359. /**
  103360. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  103361. * @param kind defines the data kind (Position, normal, etc...)
  103362. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  103363. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103364. * @returns a float array containing vertex data
  103365. */
  103366. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  103367. /**
  103368. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  103369. * @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.
  103370. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  103371. * @returns the indices array or an empty array if the mesh has no geometry
  103372. */
  103373. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  103374. /**
  103375. * Set specific vertex data
  103376. * @param kind defines the data kind (Position, normal, etc...)
  103377. * @param data defines the vertex data to use
  103378. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  103379. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  103380. */
  103381. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  103382. /**
  103383. * Update a specific associated vertex buffer
  103384. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  103385. * - VertexBuffer.PositionKind
  103386. * - VertexBuffer.UVKind
  103387. * - VertexBuffer.UV2Kind
  103388. * - VertexBuffer.UV3Kind
  103389. * - VertexBuffer.UV4Kind
  103390. * - VertexBuffer.UV5Kind
  103391. * - VertexBuffer.UV6Kind
  103392. * - VertexBuffer.ColorKind
  103393. * - VertexBuffer.MatricesIndicesKind
  103394. * - VertexBuffer.MatricesIndicesExtraKind
  103395. * - VertexBuffer.MatricesWeightsKind
  103396. * - VertexBuffer.MatricesWeightsExtraKind
  103397. * @param data defines the data source
  103398. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  103399. * @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)
  103400. */
  103401. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  103402. /**
  103403. * Creates a new index buffer
  103404. * @param indices defines the indices to store in the index buffer
  103405. * @param totalVertices defines the total number of vertices (could be null)
  103406. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  103407. */
  103408. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  103409. }
  103410. /**
  103411. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  103412. */
  103413. export class VertexData {
  103414. /**
  103415. * Mesh side orientation : usually the external or front surface
  103416. */
  103417. static readonly FRONTSIDE: number;
  103418. /**
  103419. * Mesh side orientation : usually the internal or back surface
  103420. */
  103421. static readonly BACKSIDE: number;
  103422. /**
  103423. * Mesh side orientation : both internal and external or front and back surfaces
  103424. */
  103425. static readonly DOUBLESIDE: number;
  103426. /**
  103427. * Mesh side orientation : by default, `FRONTSIDE`
  103428. */
  103429. static readonly DEFAULTSIDE: number;
  103430. /**
  103431. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  103432. */
  103433. positions: Nullable<FloatArray>;
  103434. /**
  103435. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  103436. */
  103437. normals: Nullable<FloatArray>;
  103438. /**
  103439. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  103440. */
  103441. tangents: Nullable<FloatArray>;
  103442. /**
  103443. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103444. */
  103445. uvs: Nullable<FloatArray>;
  103446. /**
  103447. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103448. */
  103449. uvs2: Nullable<FloatArray>;
  103450. /**
  103451. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103452. */
  103453. uvs3: Nullable<FloatArray>;
  103454. /**
  103455. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103456. */
  103457. uvs4: Nullable<FloatArray>;
  103458. /**
  103459. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103460. */
  103461. uvs5: Nullable<FloatArray>;
  103462. /**
  103463. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  103464. */
  103465. uvs6: Nullable<FloatArray>;
  103466. /**
  103467. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  103468. */
  103469. colors: Nullable<FloatArray>;
  103470. /**
  103471. * 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).
  103472. */
  103473. matricesIndices: Nullable<FloatArray>;
  103474. /**
  103475. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  103476. */
  103477. matricesWeights: Nullable<FloatArray>;
  103478. /**
  103479. * An array extending the number of possible indices
  103480. */
  103481. matricesIndicesExtra: Nullable<FloatArray>;
  103482. /**
  103483. * An array extending the number of possible weights when the number of indices is extended
  103484. */
  103485. matricesWeightsExtra: Nullable<FloatArray>;
  103486. /**
  103487. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  103488. */
  103489. indices: Nullable<IndicesArray>;
  103490. /**
  103491. * Uses the passed data array to set the set the values for the specified kind of data
  103492. * @param data a linear array of floating numbers
  103493. * @param kind the type of data that is being set, eg positions, colors etc
  103494. */
  103495. set(data: FloatArray, kind: string): void;
  103496. /**
  103497. * Associates the vertexData to the passed Mesh.
  103498. * Sets it as updatable or not (default `false`)
  103499. * @param mesh the mesh the vertexData is applied to
  103500. * @param updatable when used and having the value true allows new data to update the vertexData
  103501. * @returns the VertexData
  103502. */
  103503. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  103504. /**
  103505. * Associates the vertexData to the passed Geometry.
  103506. * Sets it as updatable or not (default `false`)
  103507. * @param geometry the geometry the vertexData is applied to
  103508. * @param updatable when used and having the value true allows new data to update the vertexData
  103509. * @returns VertexData
  103510. */
  103511. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  103512. /**
  103513. * Updates the associated mesh
  103514. * @param mesh the mesh to be updated
  103515. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103516. * @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
  103517. * @returns VertexData
  103518. */
  103519. updateMesh(mesh: Mesh): VertexData;
  103520. /**
  103521. * Updates the associated geometry
  103522. * @param geometry the geometry to be updated
  103523. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  103524. * @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
  103525. * @returns VertexData.
  103526. */
  103527. updateGeometry(geometry: Geometry): VertexData;
  103528. private _applyTo;
  103529. private _update;
  103530. /**
  103531. * Transforms each position and each normal of the vertexData according to the passed Matrix
  103532. * @param matrix the transforming matrix
  103533. * @returns the VertexData
  103534. */
  103535. transform(matrix: Matrix): VertexData;
  103536. /**
  103537. * Merges the passed VertexData into the current one
  103538. * @param other the VertexData to be merged into the current one
  103539. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  103540. * @returns the modified VertexData
  103541. */
  103542. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  103543. private _mergeElement;
  103544. private _validate;
  103545. /**
  103546. * Serializes the VertexData
  103547. * @returns a serialized object
  103548. */
  103549. serialize(): any;
  103550. /**
  103551. * Extracts the vertexData from a mesh
  103552. * @param mesh the mesh from which to extract the VertexData
  103553. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  103554. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103555. * @returns the object VertexData associated to the passed mesh
  103556. */
  103557. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103558. /**
  103559. * Extracts the vertexData from the geometry
  103560. * @param geometry the geometry from which to extract the VertexData
  103561. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  103562. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  103563. * @returns the object VertexData associated to the passed mesh
  103564. */
  103565. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  103566. private static _ExtractFrom;
  103567. /**
  103568. * Creates the VertexData for a Ribbon
  103569. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  103570. * * pathArray array of paths, each of which an array of successive Vector3
  103571. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  103572. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  103573. * * 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
  103574. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103575. * * 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)
  103576. * * 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)
  103577. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  103578. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  103579. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  103580. * @returns the VertexData of the ribbon
  103581. */
  103582. static CreateRibbon(options: {
  103583. pathArray: Vector3[][];
  103584. closeArray?: boolean;
  103585. closePath?: boolean;
  103586. offset?: number;
  103587. sideOrientation?: number;
  103588. frontUVs?: Vector4;
  103589. backUVs?: Vector4;
  103590. invertUV?: boolean;
  103591. uvs?: Vector2[];
  103592. colors?: Color4[];
  103593. }): VertexData;
  103594. /**
  103595. * Creates the VertexData for a box
  103596. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103597. * * size sets the width, height and depth of the box to the value of size, optional default 1
  103598. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  103599. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  103600. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  103601. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103602. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103603. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103604. * * 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)
  103605. * * 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)
  103606. * @returns the VertexData of the box
  103607. */
  103608. static CreateBox(options: {
  103609. size?: number;
  103610. width?: number;
  103611. height?: number;
  103612. depth?: number;
  103613. faceUV?: Vector4[];
  103614. faceColors?: Color4[];
  103615. sideOrientation?: number;
  103616. frontUVs?: Vector4;
  103617. backUVs?: Vector4;
  103618. }): VertexData;
  103619. /**
  103620. * Creates the VertexData for a tiled box
  103621. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103622. * * faceTiles sets the pattern, tile size and number of tiles for a face
  103623. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  103624. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  103625. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103626. * @returns the VertexData of the box
  103627. */
  103628. static CreateTiledBox(options: {
  103629. pattern?: number;
  103630. width?: number;
  103631. height?: number;
  103632. depth?: number;
  103633. tileSize?: number;
  103634. tileWidth?: number;
  103635. tileHeight?: number;
  103636. alignHorizontal?: number;
  103637. alignVertical?: number;
  103638. faceUV?: Vector4[];
  103639. faceColors?: Color4[];
  103640. sideOrientation?: number;
  103641. }): VertexData;
  103642. /**
  103643. * Creates the VertexData for a tiled plane
  103644. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103645. * * pattern a limited pattern arrangement depending on the number
  103646. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  103647. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  103648. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  103649. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103650. * * 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)
  103651. * * 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)
  103652. * @returns the VertexData of the tiled plane
  103653. */
  103654. static CreateTiledPlane(options: {
  103655. pattern?: number;
  103656. tileSize?: number;
  103657. tileWidth?: number;
  103658. tileHeight?: number;
  103659. size?: number;
  103660. width?: number;
  103661. height?: number;
  103662. alignHorizontal?: number;
  103663. alignVertical?: number;
  103664. sideOrientation?: number;
  103665. frontUVs?: Vector4;
  103666. backUVs?: Vector4;
  103667. }): VertexData;
  103668. /**
  103669. * Creates the VertexData for an ellipsoid, defaults to a sphere
  103670. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103671. * * segments sets the number of horizontal strips optional, default 32
  103672. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  103673. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  103674. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  103675. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  103676. * * 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
  103677. * * 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
  103678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103679. * * 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)
  103680. * * 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)
  103681. * @returns the VertexData of the ellipsoid
  103682. */
  103683. static CreateSphere(options: {
  103684. segments?: number;
  103685. diameter?: number;
  103686. diameterX?: number;
  103687. diameterY?: number;
  103688. diameterZ?: number;
  103689. arc?: number;
  103690. slice?: number;
  103691. sideOrientation?: number;
  103692. frontUVs?: Vector4;
  103693. backUVs?: Vector4;
  103694. }): VertexData;
  103695. /**
  103696. * Creates the VertexData for a cylinder, cone or prism
  103697. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103698. * * height sets the height (y direction) of the cylinder, optional, default 2
  103699. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  103700. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  103701. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  103702. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103703. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  103704. * * 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
  103705. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103706. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103707. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  103708. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  103709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103710. * * 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)
  103711. * * 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)
  103712. * @returns the VertexData of the cylinder, cone or prism
  103713. */
  103714. static CreateCylinder(options: {
  103715. height?: number;
  103716. diameterTop?: number;
  103717. diameterBottom?: number;
  103718. diameter?: number;
  103719. tessellation?: number;
  103720. subdivisions?: number;
  103721. arc?: number;
  103722. faceColors?: Color4[];
  103723. faceUV?: Vector4[];
  103724. hasRings?: boolean;
  103725. enclose?: boolean;
  103726. sideOrientation?: number;
  103727. frontUVs?: Vector4;
  103728. backUVs?: Vector4;
  103729. }): VertexData;
  103730. /**
  103731. * Creates the VertexData for a torus
  103732. * @param options an object used to set the following optional parameters for the box, required but can be empty
  103733. * * diameter the diameter of the torus, optional default 1
  103734. * * thickness the diameter of the tube forming the torus, optional default 0.5
  103735. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  103736. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103737. * * 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)
  103738. * * 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)
  103739. * @returns the VertexData of the torus
  103740. */
  103741. static CreateTorus(options: {
  103742. diameter?: number;
  103743. thickness?: number;
  103744. tessellation?: number;
  103745. sideOrientation?: number;
  103746. frontUVs?: Vector4;
  103747. backUVs?: Vector4;
  103748. }): VertexData;
  103749. /**
  103750. * Creates the VertexData of the LineSystem
  103751. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  103752. * - lines an array of lines, each line being an array of successive Vector3
  103753. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  103754. * @returns the VertexData of the LineSystem
  103755. */
  103756. static CreateLineSystem(options: {
  103757. lines: Vector3[][];
  103758. colors?: Nullable<Color4[][]>;
  103759. }): VertexData;
  103760. /**
  103761. * Create the VertexData for a DashedLines
  103762. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  103763. * - points an array successive Vector3
  103764. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  103765. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  103766. * - dashNb the intended total number of dashes, optional, default 200
  103767. * @returns the VertexData for the DashedLines
  103768. */
  103769. static CreateDashedLines(options: {
  103770. points: Vector3[];
  103771. dashSize?: number;
  103772. gapSize?: number;
  103773. dashNb?: number;
  103774. }): VertexData;
  103775. /**
  103776. * Creates the VertexData for a Ground
  103777. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103778. * - width the width (x direction) of the ground, optional, default 1
  103779. * - height the height (z direction) of the ground, optional, default 1
  103780. * - subdivisions the number of subdivisions per side, optional, default 1
  103781. * @returns the VertexData of the Ground
  103782. */
  103783. static CreateGround(options: {
  103784. width?: number;
  103785. height?: number;
  103786. subdivisions?: number;
  103787. subdivisionsX?: number;
  103788. subdivisionsY?: number;
  103789. }): VertexData;
  103790. /**
  103791. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  103792. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  103793. * * xmin the ground minimum X coordinate, optional, default -1
  103794. * * zmin the ground minimum Z coordinate, optional, default -1
  103795. * * xmax the ground maximum X coordinate, optional, default 1
  103796. * * zmax the ground maximum Z coordinate, optional, default 1
  103797. * * 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}
  103798. * * 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}
  103799. * @returns the VertexData of the TiledGround
  103800. */
  103801. static CreateTiledGround(options: {
  103802. xmin: number;
  103803. zmin: number;
  103804. xmax: number;
  103805. zmax: number;
  103806. subdivisions?: {
  103807. w: number;
  103808. h: number;
  103809. };
  103810. precision?: {
  103811. w: number;
  103812. h: number;
  103813. };
  103814. }): VertexData;
  103815. /**
  103816. * Creates the VertexData of the Ground designed from a heightmap
  103817. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  103818. * * width the width (x direction) of the ground
  103819. * * height the height (z direction) of the ground
  103820. * * subdivisions the number of subdivisions per side
  103821. * * minHeight the minimum altitude on the ground, optional, default 0
  103822. * * maxHeight the maximum altitude on the ground, optional default 1
  103823. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  103824. * * buffer the array holding the image color data
  103825. * * bufferWidth the width of image
  103826. * * bufferHeight the height of image
  103827. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  103828. * @returns the VertexData of the Ground designed from a heightmap
  103829. */
  103830. static CreateGroundFromHeightMap(options: {
  103831. width: number;
  103832. height: number;
  103833. subdivisions: number;
  103834. minHeight: number;
  103835. maxHeight: number;
  103836. colorFilter: Color3;
  103837. buffer: Uint8Array;
  103838. bufferWidth: number;
  103839. bufferHeight: number;
  103840. alphaFilter: number;
  103841. }): VertexData;
  103842. /**
  103843. * Creates the VertexData for a Plane
  103844. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  103845. * * size sets the width and height of the plane to the value of size, optional default 1
  103846. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  103847. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  103848. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103849. * * 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)
  103850. * * 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)
  103851. * @returns the VertexData of the box
  103852. */
  103853. static CreatePlane(options: {
  103854. size?: number;
  103855. width?: number;
  103856. height?: number;
  103857. sideOrientation?: number;
  103858. frontUVs?: Vector4;
  103859. backUVs?: Vector4;
  103860. }): VertexData;
  103861. /**
  103862. * Creates the VertexData of the Disc or regular Polygon
  103863. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  103864. * * radius the radius of the disc, optional default 0.5
  103865. * * tessellation the number of polygon sides, optional, default 64
  103866. * * 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
  103867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103868. * * 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)
  103869. * * 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)
  103870. * @returns the VertexData of the box
  103871. */
  103872. static CreateDisc(options: {
  103873. radius?: number;
  103874. tessellation?: number;
  103875. arc?: number;
  103876. sideOrientation?: number;
  103877. frontUVs?: Vector4;
  103878. backUVs?: Vector4;
  103879. }): VertexData;
  103880. /**
  103881. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  103882. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  103883. * @param polygon a mesh built from polygonTriangulation.build()
  103884. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103885. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103886. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103887. * @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)
  103888. * @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)
  103889. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  103890. * @returns the VertexData of the Polygon
  103891. */
  103892. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  103893. /**
  103894. * Creates the VertexData of the IcoSphere
  103895. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  103896. * * radius the radius of the IcoSphere, optional default 1
  103897. * * radiusX allows stretching in the x direction, optional, default radius
  103898. * * radiusY allows stretching in the y direction, optional, default radius
  103899. * * radiusZ allows stretching in the z direction, optional, default radius
  103900. * * flat when true creates a flat shaded mesh, optional, default true
  103901. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103902. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103903. * * 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)
  103904. * * 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)
  103905. * @returns the VertexData of the IcoSphere
  103906. */
  103907. static CreateIcoSphere(options: {
  103908. radius?: number;
  103909. radiusX?: number;
  103910. radiusY?: number;
  103911. radiusZ?: number;
  103912. flat?: boolean;
  103913. subdivisions?: number;
  103914. sideOrientation?: number;
  103915. frontUVs?: Vector4;
  103916. backUVs?: Vector4;
  103917. }): VertexData;
  103918. /**
  103919. * Creates the VertexData for a Polyhedron
  103920. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  103921. * * type provided types are:
  103922. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  103923. * * 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)
  103924. * * size the size of the IcoSphere, optional default 1
  103925. * * sizeX allows stretching in the x direction, optional, default size
  103926. * * sizeY allows stretching in the y direction, optional, default size
  103927. * * sizeZ allows stretching in the z direction, optional, default size
  103928. * * 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
  103929. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  103930. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  103931. * * flat when true creates a flat shaded mesh, optional, default true
  103932. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  103933. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103934. * * 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)
  103935. * * 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)
  103936. * @returns the VertexData of the Polyhedron
  103937. */
  103938. static CreatePolyhedron(options: {
  103939. type?: number;
  103940. size?: number;
  103941. sizeX?: number;
  103942. sizeY?: number;
  103943. sizeZ?: number;
  103944. custom?: any;
  103945. faceUV?: Vector4[];
  103946. faceColors?: Color4[];
  103947. flat?: boolean;
  103948. sideOrientation?: number;
  103949. frontUVs?: Vector4;
  103950. backUVs?: Vector4;
  103951. }): VertexData;
  103952. /**
  103953. * Creates the VertexData for a TorusKnot
  103954. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  103955. * * radius the radius of the torus knot, optional, default 2
  103956. * * tube the thickness of the tube, optional, default 0.5
  103957. * * radialSegments the number of sides on each tube segments, optional, default 32
  103958. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  103959. * * p the number of windings around the z axis, optional, default 2
  103960. * * q the number of windings around the x axis, optional, default 3
  103961. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  103962. * * 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)
  103963. * * 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)
  103964. * @returns the VertexData of the Torus Knot
  103965. */
  103966. static CreateTorusKnot(options: {
  103967. radius?: number;
  103968. tube?: number;
  103969. radialSegments?: number;
  103970. tubularSegments?: number;
  103971. p?: number;
  103972. q?: number;
  103973. sideOrientation?: number;
  103974. frontUVs?: Vector4;
  103975. backUVs?: Vector4;
  103976. }): VertexData;
  103977. /**
  103978. * Compute normals for given positions and indices
  103979. * @param positions an array of vertex positions, [...., x, y, z, ......]
  103980. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  103981. * @param normals an array of vertex normals, [...., x, y, z, ......]
  103982. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  103983. * * facetNormals : optional array of facet normals (vector3)
  103984. * * facetPositions : optional array of facet positions (vector3)
  103985. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  103986. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  103987. * * bInfo : optional bounding info, required for facetPartitioning computation
  103988. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  103989. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  103990. * * useRightHandedSystem: optional boolean to for right handed system computation
  103991. * * depthSort : optional boolean to enable the facet depth sort computation
  103992. * * distanceTo : optional Vector3 to compute the facet depth from this location
  103993. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  103994. */
  103995. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  103996. facetNormals?: any;
  103997. facetPositions?: any;
  103998. facetPartitioning?: any;
  103999. ratio?: number;
  104000. bInfo?: any;
  104001. bbSize?: Vector3;
  104002. subDiv?: any;
  104003. useRightHandedSystem?: boolean;
  104004. depthSort?: boolean;
  104005. distanceTo?: Vector3;
  104006. depthSortedFacets?: any;
  104007. }): void;
  104008. /** @hidden */
  104009. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  104010. /**
  104011. * Applies VertexData created from the imported parameters to the geometry
  104012. * @param parsedVertexData the parsed data from an imported file
  104013. * @param geometry the geometry to apply the VertexData to
  104014. */
  104015. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  104016. }
  104017. }
  104018. declare module BABYLON {
  104019. /**
  104020. * Defines a target to use with MorphTargetManager
  104021. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104022. */
  104023. export class MorphTarget implements IAnimatable {
  104024. /** defines the name of the target */
  104025. name: string;
  104026. /**
  104027. * Gets or sets the list of animations
  104028. */
  104029. animations: Animation[];
  104030. private _scene;
  104031. private _positions;
  104032. private _normals;
  104033. private _tangents;
  104034. private _uvs;
  104035. private _influence;
  104036. private _uniqueId;
  104037. /**
  104038. * Observable raised when the influence changes
  104039. */
  104040. onInfluenceChanged: Observable<boolean>;
  104041. /** @hidden */
  104042. _onDataLayoutChanged: Observable<void>;
  104043. /**
  104044. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  104045. */
  104046. get influence(): number;
  104047. set influence(influence: number);
  104048. /**
  104049. * Gets or sets the id of the morph Target
  104050. */
  104051. id: string;
  104052. private _animationPropertiesOverride;
  104053. /**
  104054. * Gets or sets the animation properties override
  104055. */
  104056. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  104057. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  104058. /**
  104059. * Creates a new MorphTarget
  104060. * @param name defines the name of the target
  104061. * @param influence defines the influence to use
  104062. * @param scene defines the scene the morphtarget belongs to
  104063. */
  104064. constructor(
  104065. /** defines the name of the target */
  104066. name: string, influence?: number, scene?: Nullable<Scene>);
  104067. /**
  104068. * Gets the unique ID of this manager
  104069. */
  104070. get uniqueId(): number;
  104071. /**
  104072. * Gets a boolean defining if the target contains position data
  104073. */
  104074. get hasPositions(): boolean;
  104075. /**
  104076. * Gets a boolean defining if the target contains normal data
  104077. */
  104078. get hasNormals(): boolean;
  104079. /**
  104080. * Gets a boolean defining if the target contains tangent data
  104081. */
  104082. get hasTangents(): boolean;
  104083. /**
  104084. * Gets a boolean defining if the target contains texture coordinates data
  104085. */
  104086. get hasUVs(): boolean;
  104087. /**
  104088. * Affects position data to this target
  104089. * @param data defines the position data to use
  104090. */
  104091. setPositions(data: Nullable<FloatArray>): void;
  104092. /**
  104093. * Gets the position data stored in this target
  104094. * @returns a FloatArray containing the position data (or null if not present)
  104095. */
  104096. getPositions(): Nullable<FloatArray>;
  104097. /**
  104098. * Affects normal data to this target
  104099. * @param data defines the normal data to use
  104100. */
  104101. setNormals(data: Nullable<FloatArray>): void;
  104102. /**
  104103. * Gets the normal data stored in this target
  104104. * @returns a FloatArray containing the normal data (or null if not present)
  104105. */
  104106. getNormals(): Nullable<FloatArray>;
  104107. /**
  104108. * Affects tangent data to this target
  104109. * @param data defines the tangent data to use
  104110. */
  104111. setTangents(data: Nullable<FloatArray>): void;
  104112. /**
  104113. * Gets the tangent data stored in this target
  104114. * @returns a FloatArray containing the tangent data (or null if not present)
  104115. */
  104116. getTangents(): Nullable<FloatArray>;
  104117. /**
  104118. * Affects texture coordinates data to this target
  104119. * @param data defines the texture coordinates data to use
  104120. */
  104121. setUVs(data: Nullable<FloatArray>): void;
  104122. /**
  104123. * Gets the texture coordinates data stored in this target
  104124. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  104125. */
  104126. getUVs(): Nullable<FloatArray>;
  104127. /**
  104128. * Clone the current target
  104129. * @returns a new MorphTarget
  104130. */
  104131. clone(): MorphTarget;
  104132. /**
  104133. * Serializes the current target into a Serialization object
  104134. * @returns the serialized object
  104135. */
  104136. serialize(): any;
  104137. /**
  104138. * Returns the string "MorphTarget"
  104139. * @returns "MorphTarget"
  104140. */
  104141. getClassName(): string;
  104142. /**
  104143. * Creates a new target from serialized data
  104144. * @param serializationObject defines the serialized data to use
  104145. * @returns a new MorphTarget
  104146. */
  104147. static Parse(serializationObject: any): MorphTarget;
  104148. /**
  104149. * Creates a MorphTarget from mesh data
  104150. * @param mesh defines the source mesh
  104151. * @param name defines the name to use for the new target
  104152. * @param influence defines the influence to attach to the target
  104153. * @returns a new MorphTarget
  104154. */
  104155. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  104156. }
  104157. }
  104158. declare module BABYLON {
  104159. /**
  104160. * This class is used to deform meshes using morphing between different targets
  104161. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  104162. */
  104163. export class MorphTargetManager {
  104164. private _targets;
  104165. private _targetInfluenceChangedObservers;
  104166. private _targetDataLayoutChangedObservers;
  104167. private _activeTargets;
  104168. private _scene;
  104169. private _influences;
  104170. private _supportsNormals;
  104171. private _supportsTangents;
  104172. private _supportsUVs;
  104173. private _vertexCount;
  104174. private _uniqueId;
  104175. private _tempInfluences;
  104176. /**
  104177. * Gets or sets a boolean indicating if normals must be morphed
  104178. */
  104179. enableNormalMorphing: boolean;
  104180. /**
  104181. * Gets or sets a boolean indicating if tangents must be morphed
  104182. */
  104183. enableTangentMorphing: boolean;
  104184. /**
  104185. * Gets or sets a boolean indicating if UV must be morphed
  104186. */
  104187. enableUVMorphing: boolean;
  104188. /**
  104189. * Creates a new MorphTargetManager
  104190. * @param scene defines the current scene
  104191. */
  104192. constructor(scene?: Nullable<Scene>);
  104193. /**
  104194. * Gets the unique ID of this manager
  104195. */
  104196. get uniqueId(): number;
  104197. /**
  104198. * Gets the number of vertices handled by this manager
  104199. */
  104200. get vertexCount(): number;
  104201. /**
  104202. * Gets a boolean indicating if this manager supports morphing of normals
  104203. */
  104204. get supportsNormals(): boolean;
  104205. /**
  104206. * Gets a boolean indicating if this manager supports morphing of tangents
  104207. */
  104208. get supportsTangents(): boolean;
  104209. /**
  104210. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  104211. */
  104212. get supportsUVs(): boolean;
  104213. /**
  104214. * Gets the number of targets stored in this manager
  104215. */
  104216. get numTargets(): number;
  104217. /**
  104218. * Gets the number of influencers (ie. the number of targets with influences > 0)
  104219. */
  104220. get numInfluencers(): number;
  104221. /**
  104222. * Gets the list of influences (one per target)
  104223. */
  104224. get influences(): Float32Array;
  104225. /**
  104226. * Gets the active target at specified index. An active target is a target with an influence > 0
  104227. * @param index defines the index to check
  104228. * @returns the requested target
  104229. */
  104230. getActiveTarget(index: number): MorphTarget;
  104231. /**
  104232. * Gets the target at specified index
  104233. * @param index defines the index to check
  104234. * @returns the requested target
  104235. */
  104236. getTarget(index: number): MorphTarget;
  104237. /**
  104238. * Add a new target to this manager
  104239. * @param target defines the target to add
  104240. */
  104241. addTarget(target: MorphTarget): void;
  104242. /**
  104243. * Removes a target from the manager
  104244. * @param target defines the target to remove
  104245. */
  104246. removeTarget(target: MorphTarget): void;
  104247. /**
  104248. * Clone the current manager
  104249. * @returns a new MorphTargetManager
  104250. */
  104251. clone(): MorphTargetManager;
  104252. /**
  104253. * Serializes the current manager into a Serialization object
  104254. * @returns the serialized object
  104255. */
  104256. serialize(): any;
  104257. private _syncActiveTargets;
  104258. /**
  104259. * Syncrhonize the targets with all the meshes using this morph target manager
  104260. */
  104261. synchronize(): void;
  104262. /**
  104263. * Creates a new MorphTargetManager from serialized data
  104264. * @param serializationObject defines the serialized data
  104265. * @param scene defines the hosting scene
  104266. * @returns the new MorphTargetManager
  104267. */
  104268. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  104269. }
  104270. }
  104271. declare module BABYLON {
  104272. /**
  104273. * Class used to represent a specific level of detail of a mesh
  104274. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  104275. */
  104276. export class MeshLODLevel {
  104277. /** Defines the distance where this level should start being displayed */
  104278. distance: number;
  104279. /** Defines the mesh to use to render this level */
  104280. mesh: Nullable<Mesh>;
  104281. /**
  104282. * Creates a new LOD level
  104283. * @param distance defines the distance where this level should star being displayed
  104284. * @param mesh defines the mesh to use to render this level
  104285. */
  104286. constructor(
  104287. /** Defines the distance where this level should start being displayed */
  104288. distance: number,
  104289. /** Defines the mesh to use to render this level */
  104290. mesh: Nullable<Mesh>);
  104291. }
  104292. }
  104293. declare module BABYLON {
  104294. /**
  104295. * Helper class used to generate a canvas to manipulate images
  104296. */
  104297. export class CanvasGenerator {
  104298. /**
  104299. * Create a new canvas (or offscreen canvas depending on the context)
  104300. * @param width defines the expected width
  104301. * @param height defines the expected height
  104302. * @return a new canvas or offscreen canvas
  104303. */
  104304. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  104305. }
  104306. }
  104307. declare module BABYLON {
  104308. /**
  104309. * Mesh representing the gorund
  104310. */
  104311. export class GroundMesh extends Mesh {
  104312. /** If octree should be generated */
  104313. generateOctree: boolean;
  104314. private _heightQuads;
  104315. /** @hidden */
  104316. _subdivisionsX: number;
  104317. /** @hidden */
  104318. _subdivisionsY: number;
  104319. /** @hidden */
  104320. _width: number;
  104321. /** @hidden */
  104322. _height: number;
  104323. /** @hidden */
  104324. _minX: number;
  104325. /** @hidden */
  104326. _maxX: number;
  104327. /** @hidden */
  104328. _minZ: number;
  104329. /** @hidden */
  104330. _maxZ: number;
  104331. constructor(name: string, scene: Scene);
  104332. /**
  104333. * "GroundMesh"
  104334. * @returns "GroundMesh"
  104335. */
  104336. getClassName(): string;
  104337. /**
  104338. * The minimum of x and y subdivisions
  104339. */
  104340. get subdivisions(): number;
  104341. /**
  104342. * X subdivisions
  104343. */
  104344. get subdivisionsX(): number;
  104345. /**
  104346. * Y subdivisions
  104347. */
  104348. get subdivisionsY(): number;
  104349. /**
  104350. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  104351. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  104352. * @param chunksCount the number of subdivisions for x and y
  104353. * @param octreeBlocksSize (Default: 32)
  104354. */
  104355. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  104356. /**
  104357. * Returns a height (y) value in the Worl system :
  104358. * the ground altitude at the coordinates (x, z) expressed in the World system.
  104359. * @param x x coordinate
  104360. * @param z z coordinate
  104361. * @returns the ground y position if (x, z) are outside the ground surface.
  104362. */
  104363. getHeightAtCoordinates(x: number, z: number): number;
  104364. /**
  104365. * Returns a normalized vector (Vector3) orthogonal to the ground
  104366. * at the ground coordinates (x, z) expressed in the World system.
  104367. * @param x x coordinate
  104368. * @param z z coordinate
  104369. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  104370. */
  104371. getNormalAtCoordinates(x: number, z: number): Vector3;
  104372. /**
  104373. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  104374. * at the ground coordinates (x, z) expressed in the World system.
  104375. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  104376. * @param x x coordinate
  104377. * @param z z coordinate
  104378. * @param ref vector to store the result
  104379. * @returns the GroundMesh.
  104380. */
  104381. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  104382. /**
  104383. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  104384. * if the ground has been updated.
  104385. * This can be used in the render loop.
  104386. * @returns the GroundMesh.
  104387. */
  104388. updateCoordinateHeights(): GroundMesh;
  104389. private _getFacetAt;
  104390. private _initHeightQuads;
  104391. private _computeHeightQuads;
  104392. /**
  104393. * Serializes this ground mesh
  104394. * @param serializationObject object to write serialization to
  104395. */
  104396. serialize(serializationObject: any): void;
  104397. /**
  104398. * Parses a serialized ground mesh
  104399. * @param parsedMesh the serialized mesh
  104400. * @param scene the scene to create the ground mesh in
  104401. * @returns the created ground mesh
  104402. */
  104403. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  104404. }
  104405. }
  104406. declare module BABYLON {
  104407. /**
  104408. * Interface for Physics-Joint data
  104409. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104410. */
  104411. export interface PhysicsJointData {
  104412. /**
  104413. * The main pivot of the joint
  104414. */
  104415. mainPivot?: Vector3;
  104416. /**
  104417. * The connected pivot of the joint
  104418. */
  104419. connectedPivot?: Vector3;
  104420. /**
  104421. * The main axis of the joint
  104422. */
  104423. mainAxis?: Vector3;
  104424. /**
  104425. * The connected axis of the joint
  104426. */
  104427. connectedAxis?: Vector3;
  104428. /**
  104429. * The collision of the joint
  104430. */
  104431. collision?: boolean;
  104432. /**
  104433. * Native Oimo/Cannon/Energy data
  104434. */
  104435. nativeParams?: any;
  104436. }
  104437. /**
  104438. * This is a holder class for the physics joint created by the physics plugin
  104439. * It holds a set of functions to control the underlying joint
  104440. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104441. */
  104442. export class PhysicsJoint {
  104443. /**
  104444. * The type of the physics joint
  104445. */
  104446. type: number;
  104447. /**
  104448. * The data for the physics joint
  104449. */
  104450. jointData: PhysicsJointData;
  104451. private _physicsJoint;
  104452. protected _physicsPlugin: IPhysicsEnginePlugin;
  104453. /**
  104454. * Initializes the physics joint
  104455. * @param type The type of the physics joint
  104456. * @param jointData The data for the physics joint
  104457. */
  104458. constructor(
  104459. /**
  104460. * The type of the physics joint
  104461. */
  104462. type: number,
  104463. /**
  104464. * The data for the physics joint
  104465. */
  104466. jointData: PhysicsJointData);
  104467. /**
  104468. * Gets the physics joint
  104469. */
  104470. get physicsJoint(): any;
  104471. /**
  104472. * Sets the physics joint
  104473. */
  104474. set physicsJoint(newJoint: any);
  104475. /**
  104476. * Sets the physics plugin
  104477. */
  104478. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  104479. /**
  104480. * Execute a function that is physics-plugin specific.
  104481. * @param {Function} func the function that will be executed.
  104482. * It accepts two parameters: the physics world and the physics joint
  104483. */
  104484. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  104485. /**
  104486. * Distance-Joint type
  104487. */
  104488. static DistanceJoint: number;
  104489. /**
  104490. * Hinge-Joint type
  104491. */
  104492. static HingeJoint: number;
  104493. /**
  104494. * Ball-and-Socket joint type
  104495. */
  104496. static BallAndSocketJoint: number;
  104497. /**
  104498. * Wheel-Joint type
  104499. */
  104500. static WheelJoint: number;
  104501. /**
  104502. * Slider-Joint type
  104503. */
  104504. static SliderJoint: number;
  104505. /**
  104506. * Prismatic-Joint type
  104507. */
  104508. static PrismaticJoint: number;
  104509. /**
  104510. * Universal-Joint type
  104511. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  104512. */
  104513. static UniversalJoint: number;
  104514. /**
  104515. * Hinge-Joint 2 type
  104516. */
  104517. static Hinge2Joint: number;
  104518. /**
  104519. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  104520. */
  104521. static PointToPointJoint: number;
  104522. /**
  104523. * Spring-Joint type
  104524. */
  104525. static SpringJoint: number;
  104526. /**
  104527. * Lock-Joint type
  104528. */
  104529. static LockJoint: number;
  104530. }
  104531. /**
  104532. * A class representing a physics distance joint
  104533. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104534. */
  104535. export class DistanceJoint extends PhysicsJoint {
  104536. /**
  104537. *
  104538. * @param jointData The data for the Distance-Joint
  104539. */
  104540. constructor(jointData: DistanceJointData);
  104541. /**
  104542. * Update the predefined distance.
  104543. * @param maxDistance The maximum preferred distance
  104544. * @param minDistance The minimum preferred distance
  104545. */
  104546. updateDistance(maxDistance: number, minDistance?: number): void;
  104547. }
  104548. /**
  104549. * Represents a Motor-Enabled Joint
  104550. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104551. */
  104552. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  104553. /**
  104554. * Initializes the Motor-Enabled Joint
  104555. * @param type The type of the joint
  104556. * @param jointData The physica joint data for the joint
  104557. */
  104558. constructor(type: number, jointData: PhysicsJointData);
  104559. /**
  104560. * Set the motor values.
  104561. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104562. * @param force the force to apply
  104563. * @param maxForce max force for this motor.
  104564. */
  104565. setMotor(force?: number, maxForce?: number): void;
  104566. /**
  104567. * Set the motor's limits.
  104568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104569. * @param upperLimit The upper limit of the motor
  104570. * @param lowerLimit The lower limit of the motor
  104571. */
  104572. setLimit(upperLimit: number, lowerLimit?: number): void;
  104573. }
  104574. /**
  104575. * This class represents a single physics Hinge-Joint
  104576. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104577. */
  104578. export class HingeJoint extends MotorEnabledJoint {
  104579. /**
  104580. * Initializes the Hinge-Joint
  104581. * @param jointData The joint data for the Hinge-Joint
  104582. */
  104583. constructor(jointData: PhysicsJointData);
  104584. /**
  104585. * Set the motor values.
  104586. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104587. * @param {number} force the force to apply
  104588. * @param {number} maxForce max force for this motor.
  104589. */
  104590. setMotor(force?: number, maxForce?: number): void;
  104591. /**
  104592. * Set the motor's limits.
  104593. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104594. * @param upperLimit The upper limit of the motor
  104595. * @param lowerLimit The lower limit of the motor
  104596. */
  104597. setLimit(upperLimit: number, lowerLimit?: number): void;
  104598. }
  104599. /**
  104600. * This class represents a dual hinge physics joint (same as wheel joint)
  104601. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104602. */
  104603. export class Hinge2Joint extends MotorEnabledJoint {
  104604. /**
  104605. * Initializes the Hinge2-Joint
  104606. * @param jointData The joint data for the Hinge2-Joint
  104607. */
  104608. constructor(jointData: PhysicsJointData);
  104609. /**
  104610. * Set the motor values.
  104611. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104612. * @param {number} targetSpeed the speed the motor is to reach
  104613. * @param {number} maxForce max force for this motor.
  104614. * @param {motorIndex} the motor's index, 0 or 1.
  104615. */
  104616. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  104617. /**
  104618. * Set the motor limits.
  104619. * Attention, this function is plugin specific. Engines won't react 100% the same.
  104620. * @param {number} upperLimit the upper limit
  104621. * @param {number} lowerLimit lower limit
  104622. * @param {motorIndex} the motor's index, 0 or 1.
  104623. */
  104624. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104625. }
  104626. /**
  104627. * Interface for a motor enabled joint
  104628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104629. */
  104630. export interface IMotorEnabledJoint {
  104631. /**
  104632. * Physics joint
  104633. */
  104634. physicsJoint: any;
  104635. /**
  104636. * Sets the motor of the motor-enabled joint
  104637. * @param force The force of the motor
  104638. * @param maxForce The maximum force of the motor
  104639. * @param motorIndex The index of the motor
  104640. */
  104641. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  104642. /**
  104643. * Sets the limit of the motor
  104644. * @param upperLimit The upper limit of the motor
  104645. * @param lowerLimit The lower limit of the motor
  104646. * @param motorIndex The index of the motor
  104647. */
  104648. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104649. }
  104650. /**
  104651. * Joint data for a Distance-Joint
  104652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104653. */
  104654. export interface DistanceJointData extends PhysicsJointData {
  104655. /**
  104656. * Max distance the 2 joint objects can be apart
  104657. */
  104658. maxDistance: number;
  104659. }
  104660. /**
  104661. * Joint data from a spring joint
  104662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104663. */
  104664. export interface SpringJointData extends PhysicsJointData {
  104665. /**
  104666. * Length of the spring
  104667. */
  104668. length: number;
  104669. /**
  104670. * Stiffness of the spring
  104671. */
  104672. stiffness: number;
  104673. /**
  104674. * Damping of the spring
  104675. */
  104676. damping: number;
  104677. /** this callback will be called when applying the force to the impostors. */
  104678. forceApplicationCallback: () => void;
  104679. }
  104680. }
  104681. declare module BABYLON {
  104682. /**
  104683. * Holds the data for the raycast result
  104684. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104685. */
  104686. export class PhysicsRaycastResult {
  104687. private _hasHit;
  104688. private _hitDistance;
  104689. private _hitNormalWorld;
  104690. private _hitPointWorld;
  104691. private _rayFromWorld;
  104692. private _rayToWorld;
  104693. /**
  104694. * Gets if there was a hit
  104695. */
  104696. get hasHit(): boolean;
  104697. /**
  104698. * Gets the distance from the hit
  104699. */
  104700. get hitDistance(): number;
  104701. /**
  104702. * Gets the hit normal/direction in the world
  104703. */
  104704. get hitNormalWorld(): Vector3;
  104705. /**
  104706. * Gets the hit point in the world
  104707. */
  104708. get hitPointWorld(): Vector3;
  104709. /**
  104710. * Gets the ray "start point" of the ray in the world
  104711. */
  104712. get rayFromWorld(): Vector3;
  104713. /**
  104714. * Gets the ray "end point" of the ray in the world
  104715. */
  104716. get rayToWorld(): Vector3;
  104717. /**
  104718. * Sets the hit data (normal & point in world space)
  104719. * @param hitNormalWorld defines the normal in world space
  104720. * @param hitPointWorld defines the point in world space
  104721. */
  104722. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  104723. /**
  104724. * Sets the distance from the start point to the hit point
  104725. * @param distance
  104726. */
  104727. setHitDistance(distance: number): void;
  104728. /**
  104729. * Calculates the distance manually
  104730. */
  104731. calculateHitDistance(): void;
  104732. /**
  104733. * Resets all the values to default
  104734. * @param from The from point on world space
  104735. * @param to The to point on world space
  104736. */
  104737. reset(from?: Vector3, to?: Vector3): void;
  104738. }
  104739. /**
  104740. * Interface for the size containing width and height
  104741. */
  104742. interface IXYZ {
  104743. /**
  104744. * X
  104745. */
  104746. x: number;
  104747. /**
  104748. * Y
  104749. */
  104750. y: number;
  104751. /**
  104752. * Z
  104753. */
  104754. z: number;
  104755. }
  104756. }
  104757. declare module BABYLON {
  104758. /**
  104759. * Interface used to describe a physics joint
  104760. */
  104761. export interface PhysicsImpostorJoint {
  104762. /** Defines the main impostor to which the joint is linked */
  104763. mainImpostor: PhysicsImpostor;
  104764. /** Defines the impostor that is connected to the main impostor using this joint */
  104765. connectedImpostor: PhysicsImpostor;
  104766. /** Defines the joint itself */
  104767. joint: PhysicsJoint;
  104768. }
  104769. /** @hidden */
  104770. export interface IPhysicsEnginePlugin {
  104771. world: any;
  104772. name: string;
  104773. setGravity(gravity: Vector3): void;
  104774. setTimeStep(timeStep: number): void;
  104775. getTimeStep(): number;
  104776. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  104777. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104778. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  104779. generatePhysicsBody(impostor: PhysicsImpostor): void;
  104780. removePhysicsBody(impostor: PhysicsImpostor): void;
  104781. generateJoint(joint: PhysicsImpostorJoint): void;
  104782. removeJoint(joint: PhysicsImpostorJoint): void;
  104783. isSupported(): boolean;
  104784. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  104785. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  104786. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104787. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  104788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104789. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  104790. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  104791. getBodyMass(impostor: PhysicsImpostor): number;
  104792. getBodyFriction(impostor: PhysicsImpostor): number;
  104793. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  104794. getBodyRestitution(impostor: PhysicsImpostor): number;
  104795. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  104796. getBodyPressure?(impostor: PhysicsImpostor): number;
  104797. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  104798. getBodyStiffness?(impostor: PhysicsImpostor): number;
  104799. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  104800. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  104801. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  104802. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  104803. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  104804. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104805. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  104806. sleepBody(impostor: PhysicsImpostor): void;
  104807. wakeUpBody(impostor: PhysicsImpostor): void;
  104808. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104809. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  104810. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  104811. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  104812. getRadius(impostor: PhysicsImpostor): number;
  104813. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  104814. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  104815. dispose(): void;
  104816. }
  104817. /**
  104818. * Interface used to define a physics engine
  104819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104820. */
  104821. export interface IPhysicsEngine {
  104822. /**
  104823. * Gets the gravity vector used by the simulation
  104824. */
  104825. gravity: Vector3;
  104826. /**
  104827. * Sets the gravity vector used by the simulation
  104828. * @param gravity defines the gravity vector to use
  104829. */
  104830. setGravity(gravity: Vector3): void;
  104831. /**
  104832. * Set the time step of the physics engine.
  104833. * Default is 1/60.
  104834. * To slow it down, enter 1/600 for example.
  104835. * To speed it up, 1/30
  104836. * @param newTimeStep the new timestep to apply to this world.
  104837. */
  104838. setTimeStep(newTimeStep: number): void;
  104839. /**
  104840. * Get the time step of the physics engine.
  104841. * @returns the current time step
  104842. */
  104843. getTimeStep(): number;
  104844. /**
  104845. * Set the sub time step of the physics engine.
  104846. * Default is 0 meaning there is no sub steps
  104847. * To increase physics resolution precision, set a small value (like 1 ms)
  104848. * @param subTimeStep defines the new sub timestep used for physics resolution.
  104849. */
  104850. setSubTimeStep(subTimeStep: number): void;
  104851. /**
  104852. * Get the sub time step of the physics engine.
  104853. * @returns the current sub time step
  104854. */
  104855. getSubTimeStep(): number;
  104856. /**
  104857. * Release all resources
  104858. */
  104859. dispose(): void;
  104860. /**
  104861. * Gets the name of the current physics plugin
  104862. * @returns the name of the plugin
  104863. */
  104864. getPhysicsPluginName(): string;
  104865. /**
  104866. * Adding a new impostor for the impostor tracking.
  104867. * This will be done by the impostor itself.
  104868. * @param impostor the impostor to add
  104869. */
  104870. addImpostor(impostor: PhysicsImpostor): void;
  104871. /**
  104872. * Remove an impostor from the engine.
  104873. * This impostor and its mesh will not longer be updated by the physics engine.
  104874. * @param impostor the impostor to remove
  104875. */
  104876. removeImpostor(impostor: PhysicsImpostor): void;
  104877. /**
  104878. * Add a joint to the physics engine
  104879. * @param mainImpostor defines the main impostor to which the joint is added.
  104880. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  104881. * @param joint defines the joint that will connect both impostors.
  104882. */
  104883. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104884. /**
  104885. * Removes a joint from the simulation
  104886. * @param mainImpostor defines the impostor used with the joint
  104887. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  104888. * @param joint defines the joint to remove
  104889. */
  104890. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  104891. /**
  104892. * Gets the current plugin used to run the simulation
  104893. * @returns current plugin
  104894. */
  104895. getPhysicsPlugin(): IPhysicsEnginePlugin;
  104896. /**
  104897. * Gets the list of physic impostors
  104898. * @returns an array of PhysicsImpostor
  104899. */
  104900. getImpostors(): Array<PhysicsImpostor>;
  104901. /**
  104902. * Gets the impostor for a physics enabled object
  104903. * @param object defines the object impersonated by the impostor
  104904. * @returns the PhysicsImpostor or null if not found
  104905. */
  104906. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  104907. /**
  104908. * Gets the impostor for a physics body object
  104909. * @param body defines physics body used by the impostor
  104910. * @returns the PhysicsImpostor or null if not found
  104911. */
  104912. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  104913. /**
  104914. * Does a raycast in the physics world
  104915. * @param from when should the ray start?
  104916. * @param to when should the ray end?
  104917. * @returns PhysicsRaycastResult
  104918. */
  104919. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  104920. /**
  104921. * Called by the scene. No need to call it.
  104922. * @param delta defines the timespam between frames
  104923. */
  104924. _step(delta: number): void;
  104925. }
  104926. }
  104927. declare module BABYLON {
  104928. /**
  104929. * The interface for the physics imposter parameters
  104930. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104931. */
  104932. export interface PhysicsImpostorParameters {
  104933. /**
  104934. * The mass of the physics imposter
  104935. */
  104936. mass: number;
  104937. /**
  104938. * The friction of the physics imposter
  104939. */
  104940. friction?: number;
  104941. /**
  104942. * The coefficient of restitution of the physics imposter
  104943. */
  104944. restitution?: number;
  104945. /**
  104946. * The native options of the physics imposter
  104947. */
  104948. nativeOptions?: any;
  104949. /**
  104950. * Specifies if the parent should be ignored
  104951. */
  104952. ignoreParent?: boolean;
  104953. /**
  104954. * Specifies if bi-directional transformations should be disabled
  104955. */
  104956. disableBidirectionalTransformation?: boolean;
  104957. /**
  104958. * The pressure inside the physics imposter, soft object only
  104959. */
  104960. pressure?: number;
  104961. /**
  104962. * The stiffness the physics imposter, soft object only
  104963. */
  104964. stiffness?: number;
  104965. /**
  104966. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  104967. */
  104968. velocityIterations?: number;
  104969. /**
  104970. * The number of iterations used in maintaining consistent vertex positions, soft object only
  104971. */
  104972. positionIterations?: number;
  104973. /**
  104974. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  104975. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  104976. * Add to fix multiple points
  104977. */
  104978. fixedPoints?: number;
  104979. /**
  104980. * The collision margin around a soft object
  104981. */
  104982. margin?: number;
  104983. /**
  104984. * The collision margin around a soft object
  104985. */
  104986. damping?: number;
  104987. /**
  104988. * The path for a rope based on an extrusion
  104989. */
  104990. path?: any;
  104991. /**
  104992. * The shape of an extrusion used for a rope based on an extrusion
  104993. */
  104994. shape?: any;
  104995. }
  104996. /**
  104997. * Interface for a physics-enabled object
  104998. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  104999. */
  105000. export interface IPhysicsEnabledObject {
  105001. /**
  105002. * The position of the physics-enabled object
  105003. */
  105004. position: Vector3;
  105005. /**
  105006. * The rotation of the physics-enabled object
  105007. */
  105008. rotationQuaternion: Nullable<Quaternion>;
  105009. /**
  105010. * The scale of the physics-enabled object
  105011. */
  105012. scaling: Vector3;
  105013. /**
  105014. * The rotation of the physics-enabled object
  105015. */
  105016. rotation?: Vector3;
  105017. /**
  105018. * The parent of the physics-enabled object
  105019. */
  105020. parent?: any;
  105021. /**
  105022. * The bounding info of the physics-enabled object
  105023. * @returns The bounding info of the physics-enabled object
  105024. */
  105025. getBoundingInfo(): BoundingInfo;
  105026. /**
  105027. * Computes the world matrix
  105028. * @param force Specifies if the world matrix should be computed by force
  105029. * @returns A world matrix
  105030. */
  105031. computeWorldMatrix(force: boolean): Matrix;
  105032. /**
  105033. * Gets the world matrix
  105034. * @returns A world matrix
  105035. */
  105036. getWorldMatrix?(): Matrix;
  105037. /**
  105038. * Gets the child meshes
  105039. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  105040. * @returns An array of abstract meshes
  105041. */
  105042. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  105043. /**
  105044. * Gets the vertex data
  105045. * @param kind The type of vertex data
  105046. * @returns A nullable array of numbers, or a float32 array
  105047. */
  105048. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  105049. /**
  105050. * Gets the indices from the mesh
  105051. * @returns A nullable array of index arrays
  105052. */
  105053. getIndices?(): Nullable<IndicesArray>;
  105054. /**
  105055. * Gets the scene from the mesh
  105056. * @returns the indices array or null
  105057. */
  105058. getScene?(): Scene;
  105059. /**
  105060. * Gets the absolute position from the mesh
  105061. * @returns the absolute position
  105062. */
  105063. getAbsolutePosition(): Vector3;
  105064. /**
  105065. * Gets the absolute pivot point from the mesh
  105066. * @returns the absolute pivot point
  105067. */
  105068. getAbsolutePivotPoint(): Vector3;
  105069. /**
  105070. * Rotates the mesh
  105071. * @param axis The axis of rotation
  105072. * @param amount The amount of rotation
  105073. * @param space The space of the rotation
  105074. * @returns The rotation transform node
  105075. */
  105076. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  105077. /**
  105078. * Translates the mesh
  105079. * @param axis The axis of translation
  105080. * @param distance The distance of translation
  105081. * @param space The space of the translation
  105082. * @returns The transform node
  105083. */
  105084. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  105085. /**
  105086. * Sets the absolute position of the mesh
  105087. * @param absolutePosition The absolute position of the mesh
  105088. * @returns The transform node
  105089. */
  105090. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  105091. /**
  105092. * Gets the class name of the mesh
  105093. * @returns The class name
  105094. */
  105095. getClassName(): string;
  105096. }
  105097. /**
  105098. * Represents a physics imposter
  105099. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  105100. */
  105101. export class PhysicsImpostor {
  105102. /**
  105103. * The physics-enabled object used as the physics imposter
  105104. */
  105105. object: IPhysicsEnabledObject;
  105106. /**
  105107. * The type of the physics imposter
  105108. */
  105109. type: number;
  105110. private _options;
  105111. private _scene?;
  105112. /**
  105113. * The default object size of the imposter
  105114. */
  105115. static DEFAULT_OBJECT_SIZE: Vector3;
  105116. /**
  105117. * The identity quaternion of the imposter
  105118. */
  105119. static IDENTITY_QUATERNION: Quaternion;
  105120. /** @hidden */
  105121. _pluginData: any;
  105122. private _physicsEngine;
  105123. private _physicsBody;
  105124. private _bodyUpdateRequired;
  105125. private _onBeforePhysicsStepCallbacks;
  105126. private _onAfterPhysicsStepCallbacks;
  105127. /** @hidden */
  105128. _onPhysicsCollideCallbacks: Array<{
  105129. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  105130. otherImpostors: Array<PhysicsImpostor>;
  105131. }>;
  105132. private _deltaPosition;
  105133. private _deltaRotation;
  105134. private _deltaRotationConjugated;
  105135. /** @hidden */
  105136. _isFromLine: boolean;
  105137. private _parent;
  105138. private _isDisposed;
  105139. private static _tmpVecs;
  105140. private static _tmpQuat;
  105141. /**
  105142. * Specifies if the physics imposter is disposed
  105143. */
  105144. get isDisposed(): boolean;
  105145. /**
  105146. * Gets the mass of the physics imposter
  105147. */
  105148. get mass(): number;
  105149. set mass(value: number);
  105150. /**
  105151. * Gets the coefficient of friction
  105152. */
  105153. get friction(): number;
  105154. /**
  105155. * Sets the coefficient of friction
  105156. */
  105157. set friction(value: number);
  105158. /**
  105159. * Gets the coefficient of restitution
  105160. */
  105161. get restitution(): number;
  105162. /**
  105163. * Sets the coefficient of restitution
  105164. */
  105165. set restitution(value: number);
  105166. /**
  105167. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  105168. */
  105169. get pressure(): number;
  105170. /**
  105171. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  105172. */
  105173. set pressure(value: number);
  105174. /**
  105175. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  105176. */
  105177. get stiffness(): number;
  105178. /**
  105179. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  105180. */
  105181. set stiffness(value: number);
  105182. /**
  105183. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  105184. */
  105185. get velocityIterations(): number;
  105186. /**
  105187. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  105188. */
  105189. set velocityIterations(value: number);
  105190. /**
  105191. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105192. */
  105193. get positionIterations(): number;
  105194. /**
  105195. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  105196. */
  105197. set positionIterations(value: number);
  105198. /**
  105199. * The unique id of the physics imposter
  105200. * set by the physics engine when adding this impostor to the array
  105201. */
  105202. uniqueId: number;
  105203. /**
  105204. * @hidden
  105205. */
  105206. soft: boolean;
  105207. /**
  105208. * @hidden
  105209. */
  105210. segments: number;
  105211. private _joints;
  105212. /**
  105213. * Initializes the physics imposter
  105214. * @param object The physics-enabled object used as the physics imposter
  105215. * @param type The type of the physics imposter
  105216. * @param _options The options for the physics imposter
  105217. * @param _scene The Babylon scene
  105218. */
  105219. constructor(
  105220. /**
  105221. * The physics-enabled object used as the physics imposter
  105222. */
  105223. object: IPhysicsEnabledObject,
  105224. /**
  105225. * The type of the physics imposter
  105226. */
  105227. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  105228. /**
  105229. * This function will completly initialize this impostor.
  105230. * It will create a new body - but only if this mesh has no parent.
  105231. * If it has, this impostor will not be used other than to define the impostor
  105232. * of the child mesh.
  105233. * @hidden
  105234. */
  105235. _init(): void;
  105236. private _getPhysicsParent;
  105237. /**
  105238. * Should a new body be generated.
  105239. * @returns boolean specifying if body initialization is required
  105240. */
  105241. isBodyInitRequired(): boolean;
  105242. /**
  105243. * Sets the updated scaling
  105244. * @param updated Specifies if the scaling is updated
  105245. */
  105246. setScalingUpdated(): void;
  105247. /**
  105248. * Force a regeneration of this or the parent's impostor's body.
  105249. * Use under cautious - This will remove all joints already implemented.
  105250. */
  105251. forceUpdate(): void;
  105252. /**
  105253. * Gets the body that holds this impostor. Either its own, or its parent.
  105254. */
  105255. get physicsBody(): any;
  105256. /**
  105257. * Get the parent of the physics imposter
  105258. * @returns Physics imposter or null
  105259. */
  105260. get parent(): Nullable<PhysicsImpostor>;
  105261. /**
  105262. * Sets the parent of the physics imposter
  105263. */
  105264. set parent(value: Nullable<PhysicsImpostor>);
  105265. /**
  105266. * Set the physics body. Used mainly by the physics engine/plugin
  105267. */
  105268. set physicsBody(physicsBody: any);
  105269. /**
  105270. * Resets the update flags
  105271. */
  105272. resetUpdateFlags(): void;
  105273. /**
  105274. * Gets the object extend size
  105275. * @returns the object extend size
  105276. */
  105277. getObjectExtendSize(): Vector3;
  105278. /**
  105279. * Gets the object center
  105280. * @returns The object center
  105281. */
  105282. getObjectCenter(): Vector3;
  105283. /**
  105284. * Get a specific parameter from the options parameters
  105285. * @param paramName The object parameter name
  105286. * @returns The object parameter
  105287. */
  105288. getParam(paramName: string): any;
  105289. /**
  105290. * Sets a specific parameter in the options given to the physics plugin
  105291. * @param paramName The parameter name
  105292. * @param value The value of the parameter
  105293. */
  105294. setParam(paramName: string, value: number): void;
  105295. /**
  105296. * Specifically change the body's mass option. Won't recreate the physics body object
  105297. * @param mass The mass of the physics imposter
  105298. */
  105299. setMass(mass: number): void;
  105300. /**
  105301. * Gets the linear velocity
  105302. * @returns linear velocity or null
  105303. */
  105304. getLinearVelocity(): Nullable<Vector3>;
  105305. /**
  105306. * Sets the linear velocity
  105307. * @param velocity linear velocity or null
  105308. */
  105309. setLinearVelocity(velocity: Nullable<Vector3>): void;
  105310. /**
  105311. * Gets the angular velocity
  105312. * @returns angular velocity or null
  105313. */
  105314. getAngularVelocity(): Nullable<Vector3>;
  105315. /**
  105316. * Sets the angular velocity
  105317. * @param velocity The velocity or null
  105318. */
  105319. setAngularVelocity(velocity: Nullable<Vector3>): void;
  105320. /**
  105321. * Execute a function with the physics plugin native code
  105322. * Provide a function the will have two variables - the world object and the physics body object
  105323. * @param func The function to execute with the physics plugin native code
  105324. */
  105325. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  105326. /**
  105327. * Register a function that will be executed before the physics world is stepping forward
  105328. * @param func The function to execute before the physics world is stepped forward
  105329. */
  105330. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105331. /**
  105332. * Unregister a function that will be executed before the physics world is stepping forward
  105333. * @param func The function to execute before the physics world is stepped forward
  105334. */
  105335. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105336. /**
  105337. * Register a function that will be executed after the physics step
  105338. * @param func The function to execute after physics step
  105339. */
  105340. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105341. /**
  105342. * Unregisters a function that will be executed after the physics step
  105343. * @param func The function to execute after physics step
  105344. */
  105345. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  105346. /**
  105347. * register a function that will be executed when this impostor collides against a different body
  105348. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  105349. * @param func Callback that is executed on collision
  105350. */
  105351. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  105352. /**
  105353. * Unregisters the physics imposter on contact
  105354. * @param collideAgainst The physics object to collide against
  105355. * @param func Callback to execute on collision
  105356. */
  105357. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  105358. private _tmpQuat;
  105359. private _tmpQuat2;
  105360. /**
  105361. * Get the parent rotation
  105362. * @returns The parent rotation
  105363. */
  105364. getParentsRotation(): Quaternion;
  105365. /**
  105366. * this function is executed by the physics engine.
  105367. */
  105368. beforeStep: () => void;
  105369. /**
  105370. * this function is executed by the physics engine
  105371. */
  105372. afterStep: () => void;
  105373. /**
  105374. * Legacy collision detection event support
  105375. */
  105376. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  105377. /**
  105378. * event and body object due to cannon's event-based architecture.
  105379. */
  105380. onCollide: (e: {
  105381. body: any;
  105382. }) => void;
  105383. /**
  105384. * Apply a force
  105385. * @param force The force to apply
  105386. * @param contactPoint The contact point for the force
  105387. * @returns The physics imposter
  105388. */
  105389. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105390. /**
  105391. * Apply an impulse
  105392. * @param force The impulse force
  105393. * @param contactPoint The contact point for the impulse force
  105394. * @returns The physics imposter
  105395. */
  105396. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  105397. /**
  105398. * A help function to create a joint
  105399. * @param otherImpostor A physics imposter used to create a joint
  105400. * @param jointType The type of joint
  105401. * @param jointData The data for the joint
  105402. * @returns The physics imposter
  105403. */
  105404. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  105405. /**
  105406. * Add a joint to this impostor with a different impostor
  105407. * @param otherImpostor A physics imposter used to add a joint
  105408. * @param joint The joint to add
  105409. * @returns The physics imposter
  105410. */
  105411. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  105412. /**
  105413. * Add an anchor to a cloth impostor
  105414. * @param otherImpostor rigid impostor to anchor to
  105415. * @param width ratio across width from 0 to 1
  105416. * @param height ratio up height from 0 to 1
  105417. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  105418. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  105419. * @returns impostor the soft imposter
  105420. */
  105421. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105422. /**
  105423. * Add a hook to a rope impostor
  105424. * @param otherImpostor rigid impostor to anchor to
  105425. * @param length ratio across rope from 0 to 1
  105426. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  105427. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  105428. * @returns impostor the rope imposter
  105429. */
  105430. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  105431. /**
  105432. * Will keep this body still, in a sleep mode.
  105433. * @returns the physics imposter
  105434. */
  105435. sleep(): PhysicsImpostor;
  105436. /**
  105437. * Wake the body up.
  105438. * @returns The physics imposter
  105439. */
  105440. wakeUp(): PhysicsImpostor;
  105441. /**
  105442. * Clones the physics imposter
  105443. * @param newObject The physics imposter clones to this physics-enabled object
  105444. * @returns A nullable physics imposter
  105445. */
  105446. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  105447. /**
  105448. * Disposes the physics imposter
  105449. */
  105450. dispose(): void;
  105451. /**
  105452. * Sets the delta position
  105453. * @param position The delta position amount
  105454. */
  105455. setDeltaPosition(position: Vector3): void;
  105456. /**
  105457. * Sets the delta rotation
  105458. * @param rotation The delta rotation amount
  105459. */
  105460. setDeltaRotation(rotation: Quaternion): void;
  105461. /**
  105462. * Gets the box size of the physics imposter and stores the result in the input parameter
  105463. * @param result Stores the box size
  105464. * @returns The physics imposter
  105465. */
  105466. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  105467. /**
  105468. * Gets the radius of the physics imposter
  105469. * @returns Radius of the physics imposter
  105470. */
  105471. getRadius(): number;
  105472. /**
  105473. * Sync a bone with this impostor
  105474. * @param bone The bone to sync to the impostor.
  105475. * @param boneMesh The mesh that the bone is influencing.
  105476. * @param jointPivot The pivot of the joint / bone in local space.
  105477. * @param distToJoint Optional distance from the impostor to the joint.
  105478. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105479. */
  105480. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  105481. /**
  105482. * Sync impostor to a bone
  105483. * @param bone The bone that the impostor will be synced to.
  105484. * @param boneMesh The mesh that the bone is influencing.
  105485. * @param jointPivot The pivot of the joint / bone in local space.
  105486. * @param distToJoint Optional distance from the impostor to the joint.
  105487. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  105488. * @param boneAxis Optional vector3 axis the bone is aligned with
  105489. */
  105490. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  105491. /**
  105492. * No-Imposter type
  105493. */
  105494. static NoImpostor: number;
  105495. /**
  105496. * Sphere-Imposter type
  105497. */
  105498. static SphereImpostor: number;
  105499. /**
  105500. * Box-Imposter type
  105501. */
  105502. static BoxImpostor: number;
  105503. /**
  105504. * Plane-Imposter type
  105505. */
  105506. static PlaneImpostor: number;
  105507. /**
  105508. * Mesh-imposter type
  105509. */
  105510. static MeshImpostor: number;
  105511. /**
  105512. * Capsule-Impostor type (Ammo.js plugin only)
  105513. */
  105514. static CapsuleImpostor: number;
  105515. /**
  105516. * Cylinder-Imposter type
  105517. */
  105518. static CylinderImpostor: number;
  105519. /**
  105520. * Particle-Imposter type
  105521. */
  105522. static ParticleImpostor: number;
  105523. /**
  105524. * Heightmap-Imposter type
  105525. */
  105526. static HeightmapImpostor: number;
  105527. /**
  105528. * ConvexHull-Impostor type (Ammo.js plugin only)
  105529. */
  105530. static ConvexHullImpostor: number;
  105531. /**
  105532. * Custom-Imposter type (Ammo.js plugin only)
  105533. */
  105534. static CustomImpostor: number;
  105535. /**
  105536. * Rope-Imposter type
  105537. */
  105538. static RopeImpostor: number;
  105539. /**
  105540. * Cloth-Imposter type
  105541. */
  105542. static ClothImpostor: number;
  105543. /**
  105544. * Softbody-Imposter type
  105545. */
  105546. static SoftbodyImpostor: number;
  105547. }
  105548. }
  105549. declare module BABYLON {
  105550. /**
  105551. * @hidden
  105552. **/
  105553. export class _CreationDataStorage {
  105554. closePath?: boolean;
  105555. closeArray?: boolean;
  105556. idx: number[];
  105557. dashSize: number;
  105558. gapSize: number;
  105559. path3D: Path3D;
  105560. pathArray: Vector3[][];
  105561. arc: number;
  105562. radius: number;
  105563. cap: number;
  105564. tessellation: number;
  105565. }
  105566. /**
  105567. * @hidden
  105568. **/
  105569. class _InstanceDataStorage {
  105570. visibleInstances: any;
  105571. batchCache: _InstancesBatch;
  105572. instancesBufferSize: number;
  105573. instancesBuffer: Nullable<Buffer>;
  105574. instancesData: Float32Array;
  105575. overridenInstanceCount: number;
  105576. isFrozen: boolean;
  105577. previousBatch: Nullable<_InstancesBatch>;
  105578. hardwareInstancedRendering: boolean;
  105579. sideOrientation: number;
  105580. manualUpdate: boolean;
  105581. }
  105582. /**
  105583. * @hidden
  105584. **/
  105585. export class _InstancesBatch {
  105586. mustReturn: boolean;
  105587. visibleInstances: Nullable<InstancedMesh[]>[];
  105588. renderSelf: boolean[];
  105589. hardwareInstancedRendering: boolean[];
  105590. }
  105591. /**
  105592. * @hidden
  105593. **/
  105594. class _ThinInstanceDataStorage {
  105595. instancesCount: number;
  105596. matrixBuffer: Nullable<Buffer>;
  105597. matrixBufferSize: number;
  105598. matrixData: Nullable<Float32Array>;
  105599. boundingVectors: Array<Vector3>;
  105600. }
  105601. /**
  105602. * Class used to represent renderable models
  105603. */
  105604. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  105605. /**
  105606. * Mesh side orientation : usually the external or front surface
  105607. */
  105608. static readonly FRONTSIDE: number;
  105609. /**
  105610. * Mesh side orientation : usually the internal or back surface
  105611. */
  105612. static readonly BACKSIDE: number;
  105613. /**
  105614. * Mesh side orientation : both internal and external or front and back surfaces
  105615. */
  105616. static readonly DOUBLESIDE: number;
  105617. /**
  105618. * Mesh side orientation : by default, `FRONTSIDE`
  105619. */
  105620. static readonly DEFAULTSIDE: number;
  105621. /**
  105622. * Mesh cap setting : no cap
  105623. */
  105624. static readonly NO_CAP: number;
  105625. /**
  105626. * Mesh cap setting : one cap at the beginning of the mesh
  105627. */
  105628. static readonly CAP_START: number;
  105629. /**
  105630. * Mesh cap setting : one cap at the end of the mesh
  105631. */
  105632. static readonly CAP_END: number;
  105633. /**
  105634. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  105635. */
  105636. static readonly CAP_ALL: number;
  105637. /**
  105638. * Mesh pattern setting : no flip or rotate
  105639. */
  105640. static readonly NO_FLIP: number;
  105641. /**
  105642. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  105643. */
  105644. static readonly FLIP_TILE: number;
  105645. /**
  105646. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  105647. */
  105648. static readonly ROTATE_TILE: number;
  105649. /**
  105650. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  105651. */
  105652. static readonly FLIP_ROW: number;
  105653. /**
  105654. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  105655. */
  105656. static readonly ROTATE_ROW: number;
  105657. /**
  105658. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  105659. */
  105660. static readonly FLIP_N_ROTATE_TILE: number;
  105661. /**
  105662. * Mesh pattern setting : rotate pattern and rotate
  105663. */
  105664. static readonly FLIP_N_ROTATE_ROW: number;
  105665. /**
  105666. * Mesh tile positioning : part tiles same on left/right or top/bottom
  105667. */
  105668. static readonly CENTER: number;
  105669. /**
  105670. * Mesh tile positioning : part tiles on left
  105671. */
  105672. static readonly LEFT: number;
  105673. /**
  105674. * Mesh tile positioning : part tiles on right
  105675. */
  105676. static readonly RIGHT: number;
  105677. /**
  105678. * Mesh tile positioning : part tiles on top
  105679. */
  105680. static readonly TOP: number;
  105681. /**
  105682. * Mesh tile positioning : part tiles on bottom
  105683. */
  105684. static readonly BOTTOM: number;
  105685. /**
  105686. * Gets the default side orientation.
  105687. * @param orientation the orientation to value to attempt to get
  105688. * @returns the default orientation
  105689. * @hidden
  105690. */
  105691. static _GetDefaultSideOrientation(orientation?: number): number;
  105692. private _internalMeshDataInfo;
  105693. /**
  105694. * An event triggered before rendering the mesh
  105695. */
  105696. get onBeforeRenderObservable(): Observable<Mesh>;
  105697. /**
  105698. * An event triggered before binding the mesh
  105699. */
  105700. get onBeforeBindObservable(): Observable<Mesh>;
  105701. /**
  105702. * An event triggered after rendering the mesh
  105703. */
  105704. get onAfterRenderObservable(): Observable<Mesh>;
  105705. /**
  105706. * An event triggered before drawing the mesh
  105707. */
  105708. get onBeforeDrawObservable(): Observable<Mesh>;
  105709. private _onBeforeDrawObserver;
  105710. /**
  105711. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  105712. */
  105713. set onBeforeDraw(callback: () => void);
  105714. get hasInstances(): boolean;
  105715. get hasThinInstances(): boolean;
  105716. /**
  105717. * Gets the delay loading state of the mesh (when delay loading is turned on)
  105718. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  105719. */
  105720. delayLoadState: number;
  105721. /**
  105722. * Gets the list of instances created from this mesh
  105723. * it is not supposed to be modified manually.
  105724. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  105725. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  105726. */
  105727. instances: InstancedMesh[];
  105728. /**
  105729. * Gets the file containing delay loading data for this mesh
  105730. */
  105731. delayLoadingFile: string;
  105732. /** @hidden */
  105733. _binaryInfo: any;
  105734. /**
  105735. * User defined function used to change how LOD level selection is done
  105736. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105737. */
  105738. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  105739. /**
  105740. * Gets or sets the morph target manager
  105741. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  105742. */
  105743. get morphTargetManager(): Nullable<MorphTargetManager>;
  105744. set morphTargetManager(value: Nullable<MorphTargetManager>);
  105745. /** @hidden */
  105746. _creationDataStorage: Nullable<_CreationDataStorage>;
  105747. /** @hidden */
  105748. _geometry: Nullable<Geometry>;
  105749. /** @hidden */
  105750. _delayInfo: Array<string>;
  105751. /** @hidden */
  105752. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  105753. /** @hidden */
  105754. _instanceDataStorage: _InstanceDataStorage;
  105755. /** @hidden */
  105756. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  105757. private _effectiveMaterial;
  105758. /** @hidden */
  105759. _shouldGenerateFlatShading: boolean;
  105760. /** @hidden */
  105761. _originalBuilderSideOrientation: number;
  105762. /**
  105763. * Use this property to change the original side orientation defined at construction time
  105764. */
  105765. overrideMaterialSideOrientation: Nullable<number>;
  105766. /**
  105767. * Gets the source mesh (the one used to clone this one from)
  105768. */
  105769. get source(): Nullable<Mesh>;
  105770. /**
  105771. * Gets or sets a boolean indicating that this mesh does not use index buffer
  105772. */
  105773. get isUnIndexed(): boolean;
  105774. set isUnIndexed(value: boolean);
  105775. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  105776. get worldMatrixInstancedBuffer(): Float32Array;
  105777. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  105778. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  105779. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  105780. /**
  105781. * @constructor
  105782. * @param name The value used by scene.getMeshByName() to do a lookup.
  105783. * @param scene The scene to add this mesh to.
  105784. * @param parent The parent of this mesh, if it has one
  105785. * @param source An optional Mesh from which geometry is shared, cloned.
  105786. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  105787. * When false, achieved by calling a clone(), also passing False.
  105788. * This will make creation of children, recursive.
  105789. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  105790. */
  105791. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  105792. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  105793. doNotInstantiate: boolean;
  105794. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  105795. /**
  105796. * Gets the class name
  105797. * @returns the string "Mesh".
  105798. */
  105799. getClassName(): string;
  105800. /** @hidden */
  105801. get _isMesh(): boolean;
  105802. /**
  105803. * Returns a description of this mesh
  105804. * @param fullDetails define if full details about this mesh must be used
  105805. * @returns a descriptive string representing this mesh
  105806. */
  105807. toString(fullDetails?: boolean): string;
  105808. /** @hidden */
  105809. _unBindEffect(): void;
  105810. /**
  105811. * Gets a boolean indicating if this mesh has LOD
  105812. */
  105813. get hasLODLevels(): boolean;
  105814. /**
  105815. * Gets the list of MeshLODLevel associated with the current mesh
  105816. * @returns an array of MeshLODLevel
  105817. */
  105818. getLODLevels(): MeshLODLevel[];
  105819. private _sortLODLevels;
  105820. /**
  105821. * Add a mesh as LOD level triggered at the given distance.
  105822. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105823. * @param distance The distance from the center of the object to show this level
  105824. * @param mesh The mesh to be added as LOD level (can be null)
  105825. * @return This mesh (for chaining)
  105826. */
  105827. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  105828. /**
  105829. * Returns the LOD level mesh at the passed distance or null if not found.
  105830. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105831. * @param distance The distance from the center of the object to show this level
  105832. * @returns a Mesh or `null`
  105833. */
  105834. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  105835. /**
  105836. * Remove a mesh from the LOD array
  105837. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105838. * @param mesh defines the mesh to be removed
  105839. * @return This mesh (for chaining)
  105840. */
  105841. removeLODLevel(mesh: Mesh): Mesh;
  105842. /**
  105843. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  105844. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  105845. * @param camera defines the camera to use to compute distance
  105846. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  105847. * @return This mesh (for chaining)
  105848. */
  105849. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  105850. /**
  105851. * Gets the mesh internal Geometry object
  105852. */
  105853. get geometry(): Nullable<Geometry>;
  105854. /**
  105855. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  105856. * @returns the total number of vertices
  105857. */
  105858. getTotalVertices(): number;
  105859. /**
  105860. * Returns the content of an associated vertex buffer
  105861. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105862. * - VertexBuffer.PositionKind
  105863. * - VertexBuffer.UVKind
  105864. * - VertexBuffer.UV2Kind
  105865. * - VertexBuffer.UV3Kind
  105866. * - VertexBuffer.UV4Kind
  105867. * - VertexBuffer.UV5Kind
  105868. * - VertexBuffer.UV6Kind
  105869. * - VertexBuffer.ColorKind
  105870. * - VertexBuffer.MatricesIndicesKind
  105871. * - VertexBuffer.MatricesIndicesExtraKind
  105872. * - VertexBuffer.MatricesWeightsKind
  105873. * - VertexBuffer.MatricesWeightsExtraKind
  105874. * @param 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
  105875. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  105876. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  105877. */
  105878. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  105879. /**
  105880. * Returns the mesh VertexBuffer object from the requested `kind`
  105881. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105882. * - VertexBuffer.PositionKind
  105883. * - VertexBuffer.NormalKind
  105884. * - VertexBuffer.UVKind
  105885. * - VertexBuffer.UV2Kind
  105886. * - VertexBuffer.UV3Kind
  105887. * - VertexBuffer.UV4Kind
  105888. * - VertexBuffer.UV5Kind
  105889. * - VertexBuffer.UV6Kind
  105890. * - VertexBuffer.ColorKind
  105891. * - VertexBuffer.MatricesIndicesKind
  105892. * - VertexBuffer.MatricesIndicesExtraKind
  105893. * - VertexBuffer.MatricesWeightsKind
  105894. * - VertexBuffer.MatricesWeightsExtraKind
  105895. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  105896. */
  105897. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  105898. /**
  105899. * Tests if a specific vertex buffer is associated with this mesh
  105900. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105901. * - VertexBuffer.PositionKind
  105902. * - VertexBuffer.NormalKind
  105903. * - VertexBuffer.UVKind
  105904. * - VertexBuffer.UV2Kind
  105905. * - VertexBuffer.UV3Kind
  105906. * - VertexBuffer.UV4Kind
  105907. * - VertexBuffer.UV5Kind
  105908. * - VertexBuffer.UV6Kind
  105909. * - VertexBuffer.ColorKind
  105910. * - VertexBuffer.MatricesIndicesKind
  105911. * - VertexBuffer.MatricesIndicesExtraKind
  105912. * - VertexBuffer.MatricesWeightsKind
  105913. * - VertexBuffer.MatricesWeightsExtraKind
  105914. * @returns a boolean
  105915. */
  105916. isVerticesDataPresent(kind: string): boolean;
  105917. /**
  105918. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  105919. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  105920. * - VertexBuffer.PositionKind
  105921. * - VertexBuffer.UVKind
  105922. * - VertexBuffer.UV2Kind
  105923. * - VertexBuffer.UV3Kind
  105924. * - VertexBuffer.UV4Kind
  105925. * - VertexBuffer.UV5Kind
  105926. * - VertexBuffer.UV6Kind
  105927. * - VertexBuffer.ColorKind
  105928. * - VertexBuffer.MatricesIndicesKind
  105929. * - VertexBuffer.MatricesIndicesExtraKind
  105930. * - VertexBuffer.MatricesWeightsKind
  105931. * - VertexBuffer.MatricesWeightsExtraKind
  105932. * @returns a boolean
  105933. */
  105934. isVertexBufferUpdatable(kind: string): boolean;
  105935. /**
  105936. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  105937. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  105938. * - VertexBuffer.PositionKind
  105939. * - VertexBuffer.NormalKind
  105940. * - VertexBuffer.UVKind
  105941. * - VertexBuffer.UV2Kind
  105942. * - VertexBuffer.UV3Kind
  105943. * - VertexBuffer.UV4Kind
  105944. * - VertexBuffer.UV5Kind
  105945. * - VertexBuffer.UV6Kind
  105946. * - VertexBuffer.ColorKind
  105947. * - VertexBuffer.MatricesIndicesKind
  105948. * - VertexBuffer.MatricesIndicesExtraKind
  105949. * - VertexBuffer.MatricesWeightsKind
  105950. * - VertexBuffer.MatricesWeightsExtraKind
  105951. * @returns an array of strings
  105952. */
  105953. getVerticesDataKinds(): string[];
  105954. /**
  105955. * Returns a positive integer : the total number of indices in this mesh geometry.
  105956. * @returns the numner of indices or zero if the mesh has no geometry.
  105957. */
  105958. getTotalIndices(): number;
  105959. /**
  105960. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  105961. * @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.
  105962. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  105963. * @returns the indices array or an empty array if the mesh has no geometry
  105964. */
  105965. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  105966. get isBlocked(): boolean;
  105967. /**
  105968. * Determine if the current mesh is ready to be rendered
  105969. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  105970. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  105971. * @returns true if all associated assets are ready (material, textures, shaders)
  105972. */
  105973. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  105974. /**
  105975. * 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.
  105976. */
  105977. get areNormalsFrozen(): boolean;
  105978. /**
  105979. * 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.
  105980. * @returns the current mesh
  105981. */
  105982. freezeNormals(): Mesh;
  105983. /**
  105984. * 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
  105985. * @returns the current mesh
  105986. */
  105987. unfreezeNormals(): Mesh;
  105988. /**
  105989. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  105990. */
  105991. set overridenInstanceCount(count: number);
  105992. /** @hidden */
  105993. _preActivate(): Mesh;
  105994. /** @hidden */
  105995. _preActivateForIntermediateRendering(renderId: number): Mesh;
  105996. /** @hidden */
  105997. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  105998. protected _afterComputeWorldMatrix(): void;
  105999. /** @hidden */
  106000. _postActivate(): void;
  106001. /**
  106002. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  106003. * This means the mesh underlying bounding box and sphere are recomputed.
  106004. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  106005. * @returns the current mesh
  106006. */
  106007. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  106008. /** @hidden */
  106009. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  106010. /**
  106011. * This function will subdivide the mesh into multiple submeshes
  106012. * @param count defines the expected number of submeshes
  106013. */
  106014. subdivide(count: number): void;
  106015. /**
  106016. * Copy a FloatArray into a specific associated vertex buffer
  106017. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106018. * - VertexBuffer.PositionKind
  106019. * - VertexBuffer.UVKind
  106020. * - VertexBuffer.UV2Kind
  106021. * - VertexBuffer.UV3Kind
  106022. * - VertexBuffer.UV4Kind
  106023. * - VertexBuffer.UV5Kind
  106024. * - VertexBuffer.UV6Kind
  106025. * - VertexBuffer.ColorKind
  106026. * - VertexBuffer.MatricesIndicesKind
  106027. * - VertexBuffer.MatricesIndicesExtraKind
  106028. * - VertexBuffer.MatricesWeightsKind
  106029. * - VertexBuffer.MatricesWeightsExtraKind
  106030. * @param data defines the data source
  106031. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106032. * @param stride defines the data stride size (can be null)
  106033. * @returns the current mesh
  106034. */
  106035. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  106036. /**
  106037. * Delete a vertex buffer associated with this mesh
  106038. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  106039. * - VertexBuffer.PositionKind
  106040. * - VertexBuffer.UVKind
  106041. * - VertexBuffer.UV2Kind
  106042. * - VertexBuffer.UV3Kind
  106043. * - VertexBuffer.UV4Kind
  106044. * - VertexBuffer.UV5Kind
  106045. * - VertexBuffer.UV6Kind
  106046. * - VertexBuffer.ColorKind
  106047. * - VertexBuffer.MatricesIndicesKind
  106048. * - VertexBuffer.MatricesIndicesExtraKind
  106049. * - VertexBuffer.MatricesWeightsKind
  106050. * - VertexBuffer.MatricesWeightsExtraKind
  106051. */
  106052. removeVerticesData(kind: string): void;
  106053. /**
  106054. * Flags an associated vertex buffer as updatable
  106055. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  106056. * - VertexBuffer.PositionKind
  106057. * - VertexBuffer.UVKind
  106058. * - VertexBuffer.UV2Kind
  106059. * - VertexBuffer.UV3Kind
  106060. * - VertexBuffer.UV4Kind
  106061. * - VertexBuffer.UV5Kind
  106062. * - VertexBuffer.UV6Kind
  106063. * - VertexBuffer.ColorKind
  106064. * - VertexBuffer.MatricesIndicesKind
  106065. * - VertexBuffer.MatricesIndicesExtraKind
  106066. * - VertexBuffer.MatricesWeightsKind
  106067. * - VertexBuffer.MatricesWeightsExtraKind
  106068. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  106069. */
  106070. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  106071. /**
  106072. * Sets the mesh global Vertex Buffer
  106073. * @param buffer defines the buffer to use
  106074. * @returns the current mesh
  106075. */
  106076. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  106077. /**
  106078. * Update a specific associated vertex buffer
  106079. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106080. * - VertexBuffer.PositionKind
  106081. * - VertexBuffer.UVKind
  106082. * - VertexBuffer.UV2Kind
  106083. * - VertexBuffer.UV3Kind
  106084. * - VertexBuffer.UV4Kind
  106085. * - VertexBuffer.UV5Kind
  106086. * - VertexBuffer.UV6Kind
  106087. * - VertexBuffer.ColorKind
  106088. * - VertexBuffer.MatricesIndicesKind
  106089. * - VertexBuffer.MatricesIndicesExtraKind
  106090. * - VertexBuffer.MatricesWeightsKind
  106091. * - VertexBuffer.MatricesWeightsExtraKind
  106092. * @param data defines the data source
  106093. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106094. * @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)
  106095. * @returns the current mesh
  106096. */
  106097. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  106098. /**
  106099. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  106100. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  106101. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  106102. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  106103. * @returns the current mesh
  106104. */
  106105. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  106106. /**
  106107. * Creates a un-shared specific occurence of the geometry for the mesh.
  106108. * @returns the current mesh
  106109. */
  106110. makeGeometryUnique(): Mesh;
  106111. /**
  106112. * Set the index buffer of this mesh
  106113. * @param indices defines the source data
  106114. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  106115. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  106116. * @returns the current mesh
  106117. */
  106118. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  106119. /**
  106120. * Update the current index buffer
  106121. * @param indices defines the source data
  106122. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  106123. * @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)
  106124. * @returns the current mesh
  106125. */
  106126. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  106127. /**
  106128. * Invert the geometry to move from a right handed system to a left handed one.
  106129. * @returns the current mesh
  106130. */
  106131. toLeftHanded(): Mesh;
  106132. /** @hidden */
  106133. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  106134. /** @hidden */
  106135. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  106136. /**
  106137. * Registers for this mesh a javascript function called just before the rendering process
  106138. * @param func defines the function to call before rendering this mesh
  106139. * @returns the current mesh
  106140. */
  106141. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106142. /**
  106143. * Disposes a previously registered javascript function called before the rendering
  106144. * @param func defines the function to remove
  106145. * @returns the current mesh
  106146. */
  106147. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  106148. /**
  106149. * Registers for this mesh a javascript function called just after the rendering is complete
  106150. * @param func defines the function to call after rendering this mesh
  106151. * @returns the current mesh
  106152. */
  106153. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  106154. /**
  106155. * Disposes a previously registered javascript function called after the rendering.
  106156. * @param func defines the function to remove
  106157. * @returns the current mesh
  106158. */
  106159. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  106160. /** @hidden */
  106161. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  106162. /** @hidden */
  106163. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  106164. /** @hidden */
  106165. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  106166. /** @hidden */
  106167. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  106168. /** @hidden */
  106169. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  106170. /** @hidden */
  106171. _rebuild(): void;
  106172. /** @hidden */
  106173. _freeze(): void;
  106174. /** @hidden */
  106175. _unFreeze(): void;
  106176. /**
  106177. * 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
  106178. * @param subMesh defines the subMesh to render
  106179. * @param enableAlphaMode defines if alpha mode can be changed
  106180. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  106181. * @returns the current mesh
  106182. */
  106183. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  106184. private _onBeforeDraw;
  106185. /**
  106186. * Renormalize the mesh and patch it up if there are no weights
  106187. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  106188. * However in the case of zero weights then we set just a single influence to 1.
  106189. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  106190. */
  106191. cleanMatrixWeights(): void;
  106192. private normalizeSkinFourWeights;
  106193. private normalizeSkinWeightsAndExtra;
  106194. /**
  106195. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  106196. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  106197. * the user know there was an issue with importing the mesh
  106198. * @returns a validation object with skinned, valid and report string
  106199. */
  106200. validateSkinning(): {
  106201. skinned: boolean;
  106202. valid: boolean;
  106203. report: string;
  106204. };
  106205. /** @hidden */
  106206. _checkDelayState(): Mesh;
  106207. private _queueLoad;
  106208. /**
  106209. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  106210. * A mesh is in the frustum if its bounding box intersects the frustum
  106211. * @param frustumPlanes defines the frustum to test
  106212. * @returns true if the mesh is in the frustum planes
  106213. */
  106214. isInFrustum(frustumPlanes: Plane[]): boolean;
  106215. /**
  106216. * Sets the mesh material by the material or multiMaterial `id` property
  106217. * @param id is a string identifying the material or the multiMaterial
  106218. * @returns the current mesh
  106219. */
  106220. setMaterialByID(id: string): Mesh;
  106221. /**
  106222. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  106223. * @returns an array of IAnimatable
  106224. */
  106225. getAnimatables(): IAnimatable[];
  106226. /**
  106227. * Modifies the mesh geometry according to the passed transformation matrix.
  106228. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  106229. * The mesh normals are modified using the same transformation.
  106230. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106231. * @param transform defines the transform matrix to use
  106232. * @see https://doc.babylonjs.com/resources/baking_transformations
  106233. * @returns the current mesh
  106234. */
  106235. bakeTransformIntoVertices(transform: Matrix): Mesh;
  106236. /**
  106237. * Modifies the mesh geometry according to its own current World Matrix.
  106238. * The mesh World Matrix is then reset.
  106239. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  106240. * Note that, under the hood, this method sets a new VertexBuffer each call.
  106241. * @see https://doc.babylonjs.com/resources/baking_transformations
  106242. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  106243. * @returns the current mesh
  106244. */
  106245. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  106246. /** @hidden */
  106247. get _positions(): Nullable<Vector3[]>;
  106248. /** @hidden */
  106249. _resetPointsArrayCache(): Mesh;
  106250. /** @hidden */
  106251. _generatePointsArray(): boolean;
  106252. /**
  106253. * Returns a new Mesh object generated from the current mesh properties.
  106254. * This method must not get confused with createInstance()
  106255. * @param name is a string, the name given to the new mesh
  106256. * @param newParent can be any Node object (default `null`)
  106257. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  106258. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  106259. * @returns a new mesh
  106260. */
  106261. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  106262. /**
  106263. * Releases resources associated with this mesh.
  106264. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106265. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106266. */
  106267. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106268. /** @hidden */
  106269. _disposeInstanceSpecificData(): void;
  106270. /** @hidden */
  106271. _disposeThinInstanceSpecificData(): void;
  106272. /**
  106273. * Modifies the mesh geometry according to a displacement map.
  106274. * 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.
  106275. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106276. * @param url is a string, the URL from the image file is to be downloaded.
  106277. * @param minHeight is the lower limit of the displacement.
  106278. * @param maxHeight is the upper limit of the displacement.
  106279. * @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.
  106280. * @param uvOffset is an optional vector2 used to offset UV.
  106281. * @param uvScale is an optional vector2 used to scale UV.
  106282. * @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.
  106283. * @returns the Mesh.
  106284. */
  106285. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106286. /**
  106287. * Modifies the mesh geometry according to a displacementMap buffer.
  106288. * 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.
  106289. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  106290. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  106291. * @param heightMapWidth is the width of the buffer image.
  106292. * @param heightMapHeight is the height of the buffer image.
  106293. * @param minHeight is the lower limit of the displacement.
  106294. * @param maxHeight is the upper limit of the displacement.
  106295. * @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.
  106296. * @param uvOffset is an optional vector2 used to offset UV.
  106297. * @param uvScale is an optional vector2 used to scale UV.
  106298. * @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.
  106299. * @returns the Mesh.
  106300. */
  106301. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  106302. /**
  106303. * Modify the mesh to get a flat shading rendering.
  106304. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  106305. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  106306. * @returns current mesh
  106307. */
  106308. convertToFlatShadedMesh(): Mesh;
  106309. /**
  106310. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  106311. * In other words, more vertices, no more indices and a single bigger VBO.
  106312. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  106313. * @returns current mesh
  106314. */
  106315. convertToUnIndexedMesh(): Mesh;
  106316. /**
  106317. * Inverses facet orientations.
  106318. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106319. * @param flipNormals will also inverts the normals
  106320. * @returns current mesh
  106321. */
  106322. flipFaces(flipNormals?: boolean): Mesh;
  106323. /**
  106324. * Increase the number of facets and hence vertices in a mesh
  106325. * Vertex normals are interpolated from existing vertex normals
  106326. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106327. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  106328. */
  106329. increaseVertices(numberPerEdge: number): void;
  106330. /**
  106331. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  106332. * This will undo any application of covertToFlatShadedMesh
  106333. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  106334. */
  106335. forceSharedVertices(): void;
  106336. /** @hidden */
  106337. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  106338. /** @hidden */
  106339. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  106340. /**
  106341. * Creates a new InstancedMesh object from the mesh model.
  106342. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  106343. * @param name defines the name of the new instance
  106344. * @returns a new InstancedMesh
  106345. */
  106346. createInstance(name: string): InstancedMesh;
  106347. /**
  106348. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  106349. * After this call, all the mesh instances have the same submeshes than the current mesh.
  106350. * @returns the current mesh
  106351. */
  106352. synchronizeInstances(): Mesh;
  106353. /**
  106354. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  106355. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  106356. * This should be used together with the simplification to avoid disappearing triangles.
  106357. * @param successCallback an optional success callback to be called after the optimization finished.
  106358. * @returns the current mesh
  106359. */
  106360. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  106361. /**
  106362. * Serialize current mesh
  106363. * @param serializationObject defines the object which will receive the serialization data
  106364. */
  106365. serialize(serializationObject: any): void;
  106366. /** @hidden */
  106367. _syncGeometryWithMorphTargetManager(): void;
  106368. /** @hidden */
  106369. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  106370. /**
  106371. * Returns a new Mesh object parsed from the source provided.
  106372. * @param parsedMesh is the source
  106373. * @param scene defines the hosting scene
  106374. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  106375. * @returns a new Mesh
  106376. */
  106377. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  106378. /**
  106379. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  106380. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106381. * @param name defines the name of the mesh to create
  106382. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  106383. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  106384. * @param closePath creates a seam between the first and the last points of each path of the path array
  106385. * @param offset is taken in account only if the `pathArray` is containing a single path
  106386. * @param scene defines the hosting scene
  106387. * @param updatable defines if the mesh must be flagged as updatable
  106388. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106389. * @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)
  106390. * @returns a new Mesh
  106391. */
  106392. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106393. /**
  106394. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  106395. * @param name defines the name of the mesh to create
  106396. * @param radius sets the radius size (float) of the polygon (default 0.5)
  106397. * @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
  106398. * @param scene defines the hosting scene
  106399. * @param updatable defines if the mesh must be flagged as updatable
  106400. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106401. * @returns a new Mesh
  106402. */
  106403. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106404. /**
  106405. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  106406. * @param name defines the name of the mesh to create
  106407. * @param size sets the size (float) of each box side (default 1)
  106408. * @param scene defines the hosting scene
  106409. * @param updatable defines if the mesh must be flagged as updatable
  106410. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106411. * @returns a new Mesh
  106412. */
  106413. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  106414. /**
  106415. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  106416. * @param name defines the name of the mesh to create
  106417. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106418. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106419. * @param scene defines the hosting scene
  106420. * @param updatable defines if the mesh must be flagged as updatable
  106421. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106422. * @returns a new Mesh
  106423. */
  106424. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106425. /**
  106426. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  106427. * @param name defines the name of the mesh to create
  106428. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  106429. * @param diameter sets the diameter size (float) of the sphere (default 1)
  106430. * @param scene defines the hosting scene
  106431. * @returns a new Mesh
  106432. */
  106433. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  106434. /**
  106435. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  106436. * @param name defines the name of the mesh to create
  106437. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  106438. * @param diameterTop set the top cap diameter (floats, default 1)
  106439. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  106440. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  106441. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  106442. * @param scene defines the hosting scene
  106443. * @param updatable defines if the mesh must be flagged as updatable
  106444. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106445. * @returns a new Mesh
  106446. */
  106447. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  106448. /**
  106449. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  106450. * @param name defines the name of the mesh to create
  106451. * @param diameter sets the diameter size (float) of the torus (default 1)
  106452. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  106453. * @param tessellation sets the number of torus sides (postive integer, default 16)
  106454. * @param scene defines the hosting scene
  106455. * @param updatable defines if the mesh must be flagged as updatable
  106456. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106457. * @returns a new Mesh
  106458. */
  106459. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106460. /**
  106461. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  106462. * @param name defines the name of the mesh to create
  106463. * @param radius sets the global radius size (float) of the torus knot (default 2)
  106464. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  106465. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  106466. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  106467. * @param p the number of windings on X axis (positive integers, default 2)
  106468. * @param q the number of windings on Y axis (positive integers, default 3)
  106469. * @param scene defines the hosting scene
  106470. * @param updatable defines if the mesh must be flagged as updatable
  106471. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106472. * @returns a new Mesh
  106473. */
  106474. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106475. /**
  106476. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  106477. * @param name defines the name of the mesh to create
  106478. * @param points is an array successive Vector3
  106479. * @param scene defines the hosting scene
  106480. * @param updatable defines if the mesh must be flagged as updatable
  106481. * @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).
  106482. * @returns a new Mesh
  106483. */
  106484. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  106485. /**
  106486. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  106487. * @param name defines the name of the mesh to create
  106488. * @param points is an array successive Vector3
  106489. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  106490. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  106491. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  106492. * @param scene defines the hosting scene
  106493. * @param updatable defines if the mesh must be flagged as updatable
  106494. * @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)
  106495. * @returns a new Mesh
  106496. */
  106497. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  106498. /**
  106499. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  106500. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  106501. * 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.
  106502. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106503. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  106504. * Remember you can only change the shape positions, not their number when updating a polygon.
  106505. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  106506. * @param name defines the name of the mesh to create
  106507. * @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
  106508. * @param scene defines the hosting scene
  106509. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106510. * @param updatable defines if the mesh must be flagged as updatable
  106511. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106512. * @param earcutInjection can be used to inject your own earcut reference
  106513. * @returns a new Mesh
  106514. */
  106515. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106516. /**
  106517. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  106518. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  106519. * @param name defines the name of the mesh to create
  106520. * @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
  106521. * @param depth defines the height of extrusion
  106522. * @param scene defines the hosting scene
  106523. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  106524. * @param updatable defines if the mesh must be flagged as updatable
  106525. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106526. * @param earcutInjection can be used to inject your own earcut reference
  106527. * @returns a new Mesh
  106528. */
  106529. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  106530. /**
  106531. * Creates an extruded shape mesh.
  106532. * 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
  106533. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106535. * @param name defines the name of the mesh to create
  106536. * @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
  106537. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106538. * @param scale is the value to scale the shape
  106539. * @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
  106540. * @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
  106541. * @param scene defines the hosting scene
  106542. * @param updatable defines if the mesh must be flagged as updatable
  106543. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106544. * @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)
  106545. * @returns a new Mesh
  106546. */
  106547. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106548. /**
  106549. * Creates an custom extruded shape mesh.
  106550. * The custom extrusion is a parametric shape.
  106551. * It has no predefined shape. Its final shape will depend on the input parameters.
  106552. * Please consider using the same method from the MeshBuilder class instead
  106553. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  106554. * @param name defines the name of the mesh to create
  106555. * @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
  106556. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  106557. * @param scaleFunction is a custom Javascript function called on each path point
  106558. * @param rotationFunction is a custom Javascript function called on each path point
  106559. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  106560. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  106561. * @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
  106562. * @param scene defines the hosting scene
  106563. * @param updatable defines if the mesh must be flagged as updatable
  106564. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106565. * @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)
  106566. * @returns a new Mesh
  106567. */
  106568. 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;
  106569. /**
  106570. * Creates lathe mesh.
  106571. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  106572. * Please consider using the same method from the MeshBuilder class instead
  106573. * @param name defines the name of the mesh to create
  106574. * @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
  106575. * @param radius is the radius value of the lathe
  106576. * @param tessellation is the side number of the lathe.
  106577. * @param scene defines the hosting scene
  106578. * @param updatable defines if the mesh must be flagged as updatable
  106579. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106580. * @returns a new Mesh
  106581. */
  106582. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106583. /**
  106584. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  106585. * @param name defines the name of the mesh to create
  106586. * @param size sets the size (float) of both sides of the plane at once (default 1)
  106587. * @param scene defines the hosting scene
  106588. * @param updatable defines if the mesh must be flagged as updatable
  106589. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106590. * @returns a new Mesh
  106591. */
  106592. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  106593. /**
  106594. * Creates a ground mesh.
  106595. * Please consider using the same method from the MeshBuilder class instead
  106596. * @param name defines the name of the mesh to create
  106597. * @param width set the width of the ground
  106598. * @param height set the height of the ground
  106599. * @param subdivisions sets the number of subdivisions per side
  106600. * @param scene defines the hosting scene
  106601. * @param updatable defines if the mesh must be flagged as updatable
  106602. * @returns a new Mesh
  106603. */
  106604. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  106605. /**
  106606. * Creates a tiled ground mesh.
  106607. * Please consider using the same method from the MeshBuilder class instead
  106608. * @param name defines the name of the mesh to create
  106609. * @param xmin set the ground minimum X coordinate
  106610. * @param zmin set the ground minimum Y coordinate
  106611. * @param xmax set the ground maximum X coordinate
  106612. * @param zmax set the ground maximum Z coordinate
  106613. * @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
  106614. * @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
  106615. * @param scene defines the hosting scene
  106616. * @param updatable defines if the mesh must be flagged as updatable
  106617. * @returns a new Mesh
  106618. */
  106619. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  106620. w: number;
  106621. h: number;
  106622. }, precision: {
  106623. w: number;
  106624. h: number;
  106625. }, scene: Scene, updatable?: boolean): Mesh;
  106626. /**
  106627. * Creates a ground mesh from a height map.
  106628. * Please consider using the same method from the MeshBuilder class instead
  106629. * @see https://doc.babylonjs.com/babylon101/height_map
  106630. * @param name defines the name of the mesh to create
  106631. * @param url sets the URL of the height map image resource
  106632. * @param width set the ground width size
  106633. * @param height set the ground height size
  106634. * @param subdivisions sets the number of subdivision per side
  106635. * @param minHeight is the minimum altitude on the ground
  106636. * @param maxHeight is the maximum altitude on the ground
  106637. * @param scene defines the hosting scene
  106638. * @param updatable defines if the mesh must be flagged as updatable
  106639. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  106640. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  106641. * @returns a new Mesh
  106642. */
  106643. 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;
  106644. /**
  106645. * Creates a tube mesh.
  106646. * The tube is a parametric shape.
  106647. * It has no predefined shape. Its final shape will depend on the input parameters.
  106648. * Please consider using the same method from the MeshBuilder class instead
  106649. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  106650. * @param name defines the name of the mesh to create
  106651. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  106652. * @param radius sets the tube radius size
  106653. * @param tessellation is the number of sides on the tubular surface
  106654. * @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
  106655. * @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
  106656. * @param scene defines the hosting scene
  106657. * @param updatable defines if the mesh must be flagged as updatable
  106658. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  106659. * @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)
  106660. * @returns a new Mesh
  106661. */
  106662. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  106663. (i: number, distance: number): number;
  106664. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  106665. /**
  106666. * Creates a polyhedron mesh.
  106667. * Please consider using the same method from the MeshBuilder class instead.
  106668. * * 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
  106669. * * The parameter `size` (positive float, default 1) sets the polygon size
  106670. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  106671. * * 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`
  106672. * * 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
  106673. * * 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)`)
  106674. * * 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
  106675. * * 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
  106676. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106677. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106678. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106679. * @param name defines the name of the mesh to create
  106680. * @param options defines the options used to create the mesh
  106681. * @param scene defines the hosting scene
  106682. * @returns a new Mesh
  106683. */
  106684. static CreatePolyhedron(name: string, options: {
  106685. type?: number;
  106686. size?: number;
  106687. sizeX?: number;
  106688. sizeY?: number;
  106689. sizeZ?: number;
  106690. custom?: any;
  106691. faceUV?: Vector4[];
  106692. faceColors?: Color4[];
  106693. updatable?: boolean;
  106694. sideOrientation?: number;
  106695. }, scene: Scene): Mesh;
  106696. /**
  106697. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  106698. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  106699. * * 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`)
  106700. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  106701. * * 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
  106702. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  106704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  106705. * @param name defines the name of the mesh
  106706. * @param options defines the options used to create the mesh
  106707. * @param scene defines the hosting scene
  106708. * @returns a new Mesh
  106709. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  106710. */
  106711. static CreateIcoSphere(name: string, options: {
  106712. radius?: number;
  106713. flat?: boolean;
  106714. subdivisions?: number;
  106715. sideOrientation?: number;
  106716. updatable?: boolean;
  106717. }, scene: Scene): Mesh;
  106718. /**
  106719. * Creates a decal mesh.
  106720. * Please consider using the same method from the MeshBuilder class instead.
  106721. * A decal is a mesh usually applied as a model onto the surface of another mesh
  106722. * @param name defines the name of the mesh
  106723. * @param sourceMesh defines the mesh receiving the decal
  106724. * @param position sets the position of the decal in world coordinates
  106725. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  106726. * @param size sets the decal scaling
  106727. * @param angle sets the angle to rotate the decal
  106728. * @returns a new Mesh
  106729. */
  106730. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  106731. /**
  106732. * Prepare internal position array for software CPU skinning
  106733. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  106734. */
  106735. setPositionsForCPUSkinning(): Float32Array;
  106736. /**
  106737. * Prepare internal normal array for software CPU skinning
  106738. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  106739. */
  106740. setNormalsForCPUSkinning(): Float32Array;
  106741. /**
  106742. * Updates the vertex buffer by applying transformation from the bones
  106743. * @param skeleton defines the skeleton to apply to current mesh
  106744. * @returns the current mesh
  106745. */
  106746. applySkeleton(skeleton: Skeleton): Mesh;
  106747. /**
  106748. * 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
  106749. * @param meshes defines the list of meshes to scan
  106750. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  106751. */
  106752. static MinMax(meshes: AbstractMesh[]): {
  106753. min: Vector3;
  106754. max: Vector3;
  106755. };
  106756. /**
  106757. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  106758. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  106759. * @returns a vector3
  106760. */
  106761. static Center(meshesOrMinMaxVector: {
  106762. min: Vector3;
  106763. max: Vector3;
  106764. } | AbstractMesh[]): Vector3;
  106765. /**
  106766. * Merge the array of meshes into a single mesh for performance reasons.
  106767. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  106768. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  106769. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  106770. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  106771. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  106772. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  106773. * @returns a new mesh
  106774. */
  106775. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  106776. /** @hidden */
  106777. addInstance(instance: InstancedMesh): void;
  106778. /** @hidden */
  106779. removeInstance(instance: InstancedMesh): void;
  106780. }
  106781. }
  106782. declare module BABYLON {
  106783. /**
  106784. * This is the base class of all the camera used in the application.
  106785. * @see https://doc.babylonjs.com/features/cameras
  106786. */
  106787. export class Camera extends Node {
  106788. /** @hidden */
  106789. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  106790. /**
  106791. * This is the default projection mode used by the cameras.
  106792. * It helps recreating a feeling of perspective and better appreciate depth.
  106793. * This is the best way to simulate real life cameras.
  106794. */
  106795. static readonly PERSPECTIVE_CAMERA: number;
  106796. /**
  106797. * This helps creating camera with an orthographic mode.
  106798. * 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.
  106799. */
  106800. static readonly ORTHOGRAPHIC_CAMERA: number;
  106801. /**
  106802. * This is the default FOV mode for perspective cameras.
  106803. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  106804. */
  106805. static readonly FOVMODE_VERTICAL_FIXED: number;
  106806. /**
  106807. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  106808. */
  106809. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  106810. /**
  106811. * This specifies ther is no need for a camera rig.
  106812. * Basically only one eye is rendered corresponding to the camera.
  106813. */
  106814. static readonly RIG_MODE_NONE: number;
  106815. /**
  106816. * Simulates a camera Rig with one blue eye and one red eye.
  106817. * This can be use with 3d blue and red glasses.
  106818. */
  106819. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  106820. /**
  106821. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  106822. */
  106823. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  106824. /**
  106825. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  106826. */
  106827. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  106828. /**
  106829. * Defines that both eyes of the camera will be rendered over under each other.
  106830. */
  106831. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  106832. /**
  106833. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  106834. */
  106835. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  106836. /**
  106837. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  106838. */
  106839. static readonly RIG_MODE_VR: number;
  106840. /**
  106841. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  106842. */
  106843. static readonly RIG_MODE_WEBVR: number;
  106844. /**
  106845. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  106846. */
  106847. static readonly RIG_MODE_CUSTOM: number;
  106848. /**
  106849. * Defines if by default attaching controls should prevent the default javascript event to continue.
  106850. */
  106851. static ForceAttachControlToAlwaysPreventDefault: boolean;
  106852. /**
  106853. * Define the input manager associated with the camera.
  106854. */
  106855. inputs: CameraInputsManager<Camera>;
  106856. /** @hidden */
  106857. _position: Vector3;
  106858. /**
  106859. * Define the current local position of the camera in the scene
  106860. */
  106861. get position(): Vector3;
  106862. set position(newPosition: Vector3);
  106863. /**
  106864. * The vector the camera should consider as up.
  106865. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  106866. */
  106867. upVector: Vector3;
  106868. /**
  106869. * Define the current limit on the left side for an orthographic camera
  106870. * In scene unit
  106871. */
  106872. orthoLeft: Nullable<number>;
  106873. /**
  106874. * Define the current limit on the right side for an orthographic camera
  106875. * In scene unit
  106876. */
  106877. orthoRight: Nullable<number>;
  106878. /**
  106879. * Define the current limit on the bottom side for an orthographic camera
  106880. * In scene unit
  106881. */
  106882. orthoBottom: Nullable<number>;
  106883. /**
  106884. * Define the current limit on the top side for an orthographic camera
  106885. * In scene unit
  106886. */
  106887. orthoTop: Nullable<number>;
  106888. /**
  106889. * Field Of View is set in Radians. (default is 0.8)
  106890. */
  106891. fov: number;
  106892. /**
  106893. * Define the minimum distance the camera can see from.
  106894. * This is important to note that the depth buffer are not infinite and the closer it starts
  106895. * the more your scene might encounter depth fighting issue.
  106896. */
  106897. minZ: number;
  106898. /**
  106899. * Define the maximum distance the camera can see to.
  106900. * This is important to note that the depth buffer are not infinite and the further it end
  106901. * the more your scene might encounter depth fighting issue.
  106902. */
  106903. maxZ: number;
  106904. /**
  106905. * Define the default inertia of the camera.
  106906. * This helps giving a smooth feeling to the camera movement.
  106907. */
  106908. inertia: number;
  106909. /**
  106910. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  106911. */
  106912. mode: number;
  106913. /**
  106914. * Define whether the camera is intermediate.
  106915. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  106916. */
  106917. isIntermediate: boolean;
  106918. /**
  106919. * Define the viewport of the camera.
  106920. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  106921. */
  106922. viewport: Viewport;
  106923. /**
  106924. * Restricts the camera to viewing objects with the same layerMask.
  106925. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  106926. */
  106927. layerMask: number;
  106928. /**
  106929. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  106930. */
  106931. fovMode: number;
  106932. /**
  106933. * Rig mode of the camera.
  106934. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  106935. * This is normally controlled byt the camera themselves as internal use.
  106936. */
  106937. cameraRigMode: number;
  106938. /**
  106939. * Defines the distance between both "eyes" in case of a RIG
  106940. */
  106941. interaxialDistance: number;
  106942. /**
  106943. * Defines if stereoscopic rendering is done side by side or over under.
  106944. */
  106945. isStereoscopicSideBySide: boolean;
  106946. /**
  106947. * 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
  106948. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  106949. * else in the scene. (Eg. security camera)
  106950. *
  106951. * 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)
  106952. */
  106953. customRenderTargets: RenderTargetTexture[];
  106954. /**
  106955. * When set, the camera will render to this render target instead of the default canvas
  106956. *
  106957. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  106958. */
  106959. outputRenderTarget: Nullable<RenderTargetTexture>;
  106960. /**
  106961. * Observable triggered when the camera view matrix has changed.
  106962. */
  106963. onViewMatrixChangedObservable: Observable<Camera>;
  106964. /**
  106965. * Observable triggered when the camera Projection matrix has changed.
  106966. */
  106967. onProjectionMatrixChangedObservable: Observable<Camera>;
  106968. /**
  106969. * Observable triggered when the inputs have been processed.
  106970. */
  106971. onAfterCheckInputsObservable: Observable<Camera>;
  106972. /**
  106973. * Observable triggered when reset has been called and applied to the camera.
  106974. */
  106975. onRestoreStateObservable: Observable<Camera>;
  106976. /**
  106977. * Is this camera a part of a rig system?
  106978. */
  106979. isRigCamera: boolean;
  106980. /**
  106981. * If isRigCamera set to true this will be set with the parent camera.
  106982. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  106983. */
  106984. rigParent?: Camera;
  106985. /** @hidden */
  106986. _cameraRigParams: any;
  106987. /** @hidden */
  106988. _rigCameras: Camera[];
  106989. /** @hidden */
  106990. _rigPostProcess: Nullable<PostProcess>;
  106991. protected _webvrViewMatrix: Matrix;
  106992. /** @hidden */
  106993. _skipRendering: boolean;
  106994. /** @hidden */
  106995. _projectionMatrix: Matrix;
  106996. /** @hidden */
  106997. _postProcesses: Nullable<PostProcess>[];
  106998. /** @hidden */
  106999. _activeMeshes: SmartArray<AbstractMesh>;
  107000. protected _globalPosition: Vector3;
  107001. /** @hidden */
  107002. _computedViewMatrix: Matrix;
  107003. private _doNotComputeProjectionMatrix;
  107004. private _transformMatrix;
  107005. private _frustumPlanes;
  107006. private _refreshFrustumPlanes;
  107007. private _storedFov;
  107008. private _stateStored;
  107009. /**
  107010. * Instantiates a new camera object.
  107011. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  107012. * @see https://doc.babylonjs.com/features/cameras
  107013. * @param name Defines the name of the camera in the scene
  107014. * @param position Defines the position of the camera
  107015. * @param scene Defines the scene the camera belongs too
  107016. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  107017. */
  107018. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  107019. /**
  107020. * Store current camera state (fov, position, etc..)
  107021. * @returns the camera
  107022. */
  107023. storeState(): Camera;
  107024. /**
  107025. * Restores the camera state values if it has been stored. You must call storeState() first
  107026. */
  107027. protected _restoreStateValues(): boolean;
  107028. /**
  107029. * Restored camera state. You must call storeState() first.
  107030. * @returns true if restored and false otherwise
  107031. */
  107032. restoreState(): boolean;
  107033. /**
  107034. * Gets the class name of the camera.
  107035. * @returns the class name
  107036. */
  107037. getClassName(): string;
  107038. /** @hidden */
  107039. readonly _isCamera: boolean;
  107040. /**
  107041. * Gets a string representation of the camera useful for debug purpose.
  107042. * @param fullDetails Defines that a more verboe level of logging is required
  107043. * @returns the string representation
  107044. */
  107045. toString(fullDetails?: boolean): string;
  107046. /**
  107047. * Gets the current world space position of the camera.
  107048. */
  107049. get globalPosition(): Vector3;
  107050. /**
  107051. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  107052. * @returns the active meshe list
  107053. */
  107054. getActiveMeshes(): SmartArray<AbstractMesh>;
  107055. /**
  107056. * Check whether a mesh is part of the current active mesh list of the camera
  107057. * @param mesh Defines the mesh to check
  107058. * @returns true if active, false otherwise
  107059. */
  107060. isActiveMesh(mesh: Mesh): boolean;
  107061. /**
  107062. * Is this camera ready to be used/rendered
  107063. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  107064. * @return true if the camera is ready
  107065. */
  107066. isReady(completeCheck?: boolean): boolean;
  107067. /** @hidden */
  107068. _initCache(): void;
  107069. /** @hidden */
  107070. _updateCache(ignoreParentClass?: boolean): void;
  107071. /** @hidden */
  107072. _isSynchronized(): boolean;
  107073. /** @hidden */
  107074. _isSynchronizedViewMatrix(): boolean;
  107075. /** @hidden */
  107076. _isSynchronizedProjectionMatrix(): boolean;
  107077. /**
  107078. * Attach the input controls to a specific dom element to get the input from.
  107079. * @param element Defines the element the controls should be listened from
  107080. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  107081. */
  107082. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  107083. /**
  107084. * Detach the current controls from the specified dom element.
  107085. * @param element Defines the element to stop listening the inputs from
  107086. */
  107087. detachControl(element: HTMLElement): void;
  107088. /**
  107089. * Update the camera state according to the different inputs gathered during the frame.
  107090. */
  107091. update(): void;
  107092. /** @hidden */
  107093. _checkInputs(): void;
  107094. /** @hidden */
  107095. get rigCameras(): Camera[];
  107096. /**
  107097. * Gets the post process used by the rig cameras
  107098. */
  107099. get rigPostProcess(): Nullable<PostProcess>;
  107100. /**
  107101. * Internal, gets the first post proces.
  107102. * @returns the first post process to be run on this camera.
  107103. */
  107104. _getFirstPostProcess(): Nullable<PostProcess>;
  107105. private _cascadePostProcessesToRigCams;
  107106. /**
  107107. * Attach a post process to the camera.
  107108. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107109. * @param postProcess The post process to attach to the camera
  107110. * @param insertAt The position of the post process in case several of them are in use in the scene
  107111. * @returns the position the post process has been inserted at
  107112. */
  107113. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  107114. /**
  107115. * Detach a post process to the camera.
  107116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  107117. * @param postProcess The post process to detach from the camera
  107118. */
  107119. detachPostProcess(postProcess: PostProcess): void;
  107120. /**
  107121. * Gets the current world matrix of the camera
  107122. */
  107123. getWorldMatrix(): Matrix;
  107124. /** @hidden */
  107125. _getViewMatrix(): Matrix;
  107126. /**
  107127. * Gets the current view matrix of the camera.
  107128. * @param force forces the camera to recompute the matrix without looking at the cached state
  107129. * @returns the view matrix
  107130. */
  107131. getViewMatrix(force?: boolean): Matrix;
  107132. /**
  107133. * Freeze the projection matrix.
  107134. * It will prevent the cache check of the camera projection compute and can speed up perf
  107135. * if no parameter of the camera are meant to change
  107136. * @param projection Defines manually a projection if necessary
  107137. */
  107138. freezeProjectionMatrix(projection?: Matrix): void;
  107139. /**
  107140. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  107141. */
  107142. unfreezeProjectionMatrix(): void;
  107143. /**
  107144. * Gets the current projection matrix of the camera.
  107145. * @param force forces the camera to recompute the matrix without looking at the cached state
  107146. * @returns the projection matrix
  107147. */
  107148. getProjectionMatrix(force?: boolean): Matrix;
  107149. /**
  107150. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  107151. * @returns a Matrix
  107152. */
  107153. getTransformationMatrix(): Matrix;
  107154. private _updateFrustumPlanes;
  107155. /**
  107156. * Checks if a cullable object (mesh...) is in the camera frustum
  107157. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  107158. * @param target The object to check
  107159. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  107160. * @returns true if the object is in frustum otherwise false
  107161. */
  107162. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  107163. /**
  107164. * Checks if a cullable object (mesh...) is in the camera frustum
  107165. * Unlike isInFrustum this cheks the full bounding box
  107166. * @param target The object to check
  107167. * @returns true if the object is in frustum otherwise false
  107168. */
  107169. isCompletelyInFrustum(target: ICullable): boolean;
  107170. /**
  107171. * Gets a ray in the forward direction from the camera.
  107172. * @param length Defines the length of the ray to create
  107173. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  107174. * @param origin Defines the start point of the ray which defaults to the camera position
  107175. * @returns the forward ray
  107176. */
  107177. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  107178. /**
  107179. * Releases resources associated with this node.
  107180. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  107181. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  107182. */
  107183. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  107184. /** @hidden */
  107185. _isLeftCamera: boolean;
  107186. /**
  107187. * Gets the left camera of a rig setup in case of Rigged Camera
  107188. */
  107189. get isLeftCamera(): boolean;
  107190. /** @hidden */
  107191. _isRightCamera: boolean;
  107192. /**
  107193. * Gets the right camera of a rig setup in case of Rigged Camera
  107194. */
  107195. get isRightCamera(): boolean;
  107196. /**
  107197. * Gets the left camera of a rig setup in case of Rigged Camera
  107198. */
  107199. get leftCamera(): Nullable<FreeCamera>;
  107200. /**
  107201. * Gets the right camera of a rig setup in case of Rigged Camera
  107202. */
  107203. get rightCamera(): Nullable<FreeCamera>;
  107204. /**
  107205. * Gets the left camera target of a rig setup in case of Rigged Camera
  107206. * @returns the target position
  107207. */
  107208. getLeftTarget(): Nullable<Vector3>;
  107209. /**
  107210. * Gets the right camera target of a rig setup in case of Rigged Camera
  107211. * @returns the target position
  107212. */
  107213. getRightTarget(): Nullable<Vector3>;
  107214. /**
  107215. * @hidden
  107216. */
  107217. setCameraRigMode(mode: number, rigParams: any): void;
  107218. /** @hidden */
  107219. static _setStereoscopicRigMode(camera: Camera): void;
  107220. /** @hidden */
  107221. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  107222. /** @hidden */
  107223. static _setVRRigMode(camera: Camera, rigParams: any): void;
  107224. /** @hidden */
  107225. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  107226. /** @hidden */
  107227. _getVRProjectionMatrix(): Matrix;
  107228. protected _updateCameraRotationMatrix(): void;
  107229. protected _updateWebVRCameraRotationMatrix(): void;
  107230. /**
  107231. * This function MUST be overwritten by the different WebVR cameras available.
  107232. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107233. * @hidden
  107234. */
  107235. _getWebVRProjectionMatrix(): Matrix;
  107236. /**
  107237. * This function MUST be overwritten by the different WebVR cameras available.
  107238. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  107239. * @hidden
  107240. */
  107241. _getWebVRViewMatrix(): Matrix;
  107242. /** @hidden */
  107243. setCameraRigParameter(name: string, value: any): void;
  107244. /**
  107245. * needs to be overridden by children so sub has required properties to be copied
  107246. * @hidden
  107247. */
  107248. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  107249. /**
  107250. * May need to be overridden by children
  107251. * @hidden
  107252. */
  107253. _updateRigCameras(): void;
  107254. /** @hidden */
  107255. _setupInputs(): void;
  107256. /**
  107257. * Serialiaze the camera setup to a json represention
  107258. * @returns the JSON representation
  107259. */
  107260. serialize(): any;
  107261. /**
  107262. * Clones the current camera.
  107263. * @param name The cloned camera name
  107264. * @returns the cloned camera
  107265. */
  107266. clone(name: string): Camera;
  107267. /**
  107268. * Gets the direction of the camera relative to a given local axis.
  107269. * @param localAxis Defines the reference axis to provide a relative direction.
  107270. * @return the direction
  107271. */
  107272. getDirection(localAxis: Vector3): Vector3;
  107273. /**
  107274. * Returns the current camera absolute rotation
  107275. */
  107276. get absoluteRotation(): Quaternion;
  107277. /**
  107278. * Gets the direction of the camera relative to a given local axis into a passed vector.
  107279. * @param localAxis Defines the reference axis to provide a relative direction.
  107280. * @param result Defines the vector to store the result in
  107281. */
  107282. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  107283. /**
  107284. * Gets a camera constructor for a given camera type
  107285. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  107286. * @param name The name of the camera the result will be able to instantiate
  107287. * @param scene The scene the result will construct the camera in
  107288. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  107289. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  107290. * @returns a factory method to construc the camera
  107291. */
  107292. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  107293. /**
  107294. * Compute the world matrix of the camera.
  107295. * @returns the camera world matrix
  107296. */
  107297. computeWorldMatrix(): Matrix;
  107298. /**
  107299. * Parse a JSON and creates the camera from the parsed information
  107300. * @param parsedCamera The JSON to parse
  107301. * @param scene The scene to instantiate the camera in
  107302. * @returns the newly constructed camera
  107303. */
  107304. static Parse(parsedCamera: any, scene: Scene): Camera;
  107305. }
  107306. }
  107307. declare module BABYLON {
  107308. /**
  107309. * Class containing static functions to help procedurally build meshes
  107310. */
  107311. export class DiscBuilder {
  107312. /**
  107313. * Creates a plane polygonal mesh. By default, this is a disc
  107314. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  107315. * * 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
  107316. * * 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
  107317. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107318. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107319. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107320. * @param name defines the name of the mesh
  107321. * @param options defines the options used to create the mesh
  107322. * @param scene defines the hosting scene
  107323. * @returns the plane polygonal mesh
  107324. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  107325. */
  107326. static CreateDisc(name: string, options: {
  107327. radius?: number;
  107328. tessellation?: number;
  107329. arc?: number;
  107330. updatable?: boolean;
  107331. sideOrientation?: number;
  107332. frontUVs?: Vector4;
  107333. backUVs?: Vector4;
  107334. }, scene?: Nullable<Scene>): Mesh;
  107335. }
  107336. }
  107337. declare module BABYLON {
  107338. /**
  107339. * Options to be used when creating a FresnelParameters.
  107340. */
  107341. export type IFresnelParametersCreationOptions = {
  107342. /**
  107343. * Define the color used on edges (grazing angle)
  107344. */
  107345. leftColor?: Color3;
  107346. /**
  107347. * Define the color used on center
  107348. */
  107349. rightColor?: Color3;
  107350. /**
  107351. * Define bias applied to computed fresnel term
  107352. */
  107353. bias?: number;
  107354. /**
  107355. * Defined the power exponent applied to fresnel term
  107356. */
  107357. power?: number;
  107358. /**
  107359. * Define if the fresnel effect is enable or not.
  107360. */
  107361. isEnabled?: boolean;
  107362. };
  107363. /**
  107364. * Serialized format for FresnelParameters.
  107365. */
  107366. export type IFresnelParametersSerialized = {
  107367. /**
  107368. * Define the color used on edges (grazing angle) [as an array]
  107369. */
  107370. leftColor: number[];
  107371. /**
  107372. * Define the color used on center [as an array]
  107373. */
  107374. rightColor: number[];
  107375. /**
  107376. * Define bias applied to computed fresnel term
  107377. */
  107378. bias: number;
  107379. /**
  107380. * Defined the power exponent applied to fresnel term
  107381. */
  107382. power?: number;
  107383. /**
  107384. * Define if the fresnel effect is enable or not.
  107385. */
  107386. isEnabled: boolean;
  107387. };
  107388. /**
  107389. * This represents all the required information to add a fresnel effect on a material:
  107390. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107391. */
  107392. export class FresnelParameters {
  107393. private _isEnabled;
  107394. /**
  107395. * Define if the fresnel effect is enable or not.
  107396. */
  107397. get isEnabled(): boolean;
  107398. set isEnabled(value: boolean);
  107399. /**
  107400. * Define the color used on edges (grazing angle)
  107401. */
  107402. leftColor: Color3;
  107403. /**
  107404. * Define the color used on center
  107405. */
  107406. rightColor: Color3;
  107407. /**
  107408. * Define bias applied to computed fresnel term
  107409. */
  107410. bias: number;
  107411. /**
  107412. * Defined the power exponent applied to fresnel term
  107413. */
  107414. power: number;
  107415. /**
  107416. * Creates a new FresnelParameters object.
  107417. *
  107418. * @param options provide your own settings to optionally to override defaults
  107419. */
  107420. constructor(options?: IFresnelParametersCreationOptions);
  107421. /**
  107422. * Clones the current fresnel and its valuues
  107423. * @returns a clone fresnel configuration
  107424. */
  107425. clone(): FresnelParameters;
  107426. /**
  107427. * Determines equality between FresnelParameters objects
  107428. * @param otherFresnelParameters defines the second operand
  107429. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  107430. */
  107431. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  107432. /**
  107433. * Serializes the current fresnel parameters to a JSON representation.
  107434. * @return the JSON serialization
  107435. */
  107436. serialize(): IFresnelParametersSerialized;
  107437. /**
  107438. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  107439. * @param parsedFresnelParameters Define the JSON representation
  107440. * @returns the parsed parameters
  107441. */
  107442. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  107443. }
  107444. }
  107445. declare module BABYLON {
  107446. /**
  107447. * This groups all the flags used to control the materials channel.
  107448. */
  107449. export class MaterialFlags {
  107450. private static _DiffuseTextureEnabled;
  107451. /**
  107452. * Are diffuse textures enabled in the application.
  107453. */
  107454. static get DiffuseTextureEnabled(): boolean;
  107455. static set DiffuseTextureEnabled(value: boolean);
  107456. private static _DetailTextureEnabled;
  107457. /**
  107458. * Are detail textures enabled in the application.
  107459. */
  107460. static get DetailTextureEnabled(): boolean;
  107461. static set DetailTextureEnabled(value: boolean);
  107462. private static _AmbientTextureEnabled;
  107463. /**
  107464. * Are ambient textures enabled in the application.
  107465. */
  107466. static get AmbientTextureEnabled(): boolean;
  107467. static set AmbientTextureEnabled(value: boolean);
  107468. private static _OpacityTextureEnabled;
  107469. /**
  107470. * Are opacity textures enabled in the application.
  107471. */
  107472. static get OpacityTextureEnabled(): boolean;
  107473. static set OpacityTextureEnabled(value: boolean);
  107474. private static _ReflectionTextureEnabled;
  107475. /**
  107476. * Are reflection textures enabled in the application.
  107477. */
  107478. static get ReflectionTextureEnabled(): boolean;
  107479. static set ReflectionTextureEnabled(value: boolean);
  107480. private static _EmissiveTextureEnabled;
  107481. /**
  107482. * Are emissive textures enabled in the application.
  107483. */
  107484. static get EmissiveTextureEnabled(): boolean;
  107485. static set EmissiveTextureEnabled(value: boolean);
  107486. private static _SpecularTextureEnabled;
  107487. /**
  107488. * Are specular textures enabled in the application.
  107489. */
  107490. static get SpecularTextureEnabled(): boolean;
  107491. static set SpecularTextureEnabled(value: boolean);
  107492. private static _BumpTextureEnabled;
  107493. /**
  107494. * Are bump textures enabled in the application.
  107495. */
  107496. static get BumpTextureEnabled(): boolean;
  107497. static set BumpTextureEnabled(value: boolean);
  107498. private static _LightmapTextureEnabled;
  107499. /**
  107500. * Are lightmap textures enabled in the application.
  107501. */
  107502. static get LightmapTextureEnabled(): boolean;
  107503. static set LightmapTextureEnabled(value: boolean);
  107504. private static _RefractionTextureEnabled;
  107505. /**
  107506. * Are refraction textures enabled in the application.
  107507. */
  107508. static get RefractionTextureEnabled(): boolean;
  107509. static set RefractionTextureEnabled(value: boolean);
  107510. private static _ColorGradingTextureEnabled;
  107511. /**
  107512. * Are color grading textures enabled in the application.
  107513. */
  107514. static get ColorGradingTextureEnabled(): boolean;
  107515. static set ColorGradingTextureEnabled(value: boolean);
  107516. private static _FresnelEnabled;
  107517. /**
  107518. * Are fresnels enabled in the application.
  107519. */
  107520. static get FresnelEnabled(): boolean;
  107521. static set FresnelEnabled(value: boolean);
  107522. private static _ClearCoatTextureEnabled;
  107523. /**
  107524. * Are clear coat textures enabled in the application.
  107525. */
  107526. static get ClearCoatTextureEnabled(): boolean;
  107527. static set ClearCoatTextureEnabled(value: boolean);
  107528. private static _ClearCoatBumpTextureEnabled;
  107529. /**
  107530. * Are clear coat bump textures enabled in the application.
  107531. */
  107532. static get ClearCoatBumpTextureEnabled(): boolean;
  107533. static set ClearCoatBumpTextureEnabled(value: boolean);
  107534. private static _ClearCoatTintTextureEnabled;
  107535. /**
  107536. * Are clear coat tint textures enabled in the application.
  107537. */
  107538. static get ClearCoatTintTextureEnabled(): boolean;
  107539. static set ClearCoatTintTextureEnabled(value: boolean);
  107540. private static _SheenTextureEnabled;
  107541. /**
  107542. * Are sheen textures enabled in the application.
  107543. */
  107544. static get SheenTextureEnabled(): boolean;
  107545. static set SheenTextureEnabled(value: boolean);
  107546. private static _AnisotropicTextureEnabled;
  107547. /**
  107548. * Are anisotropic textures enabled in the application.
  107549. */
  107550. static get AnisotropicTextureEnabled(): boolean;
  107551. static set AnisotropicTextureEnabled(value: boolean);
  107552. private static _ThicknessTextureEnabled;
  107553. /**
  107554. * Are thickness textures enabled in the application.
  107555. */
  107556. static get ThicknessTextureEnabled(): boolean;
  107557. static set ThicknessTextureEnabled(value: boolean);
  107558. }
  107559. }
  107560. declare module BABYLON {
  107561. /** @hidden */
  107562. export var defaultFragmentDeclaration: {
  107563. name: string;
  107564. shader: string;
  107565. };
  107566. }
  107567. declare module BABYLON {
  107568. /** @hidden */
  107569. export var defaultUboDeclaration: {
  107570. name: string;
  107571. shader: string;
  107572. };
  107573. }
  107574. declare module BABYLON {
  107575. /** @hidden */
  107576. export var prePassDeclaration: {
  107577. name: string;
  107578. shader: string;
  107579. };
  107580. }
  107581. declare module BABYLON {
  107582. /** @hidden */
  107583. export var lightFragmentDeclaration: {
  107584. name: string;
  107585. shader: string;
  107586. };
  107587. }
  107588. declare module BABYLON {
  107589. /** @hidden */
  107590. export var lightUboDeclaration: {
  107591. name: string;
  107592. shader: string;
  107593. };
  107594. }
  107595. declare module BABYLON {
  107596. /** @hidden */
  107597. export var lightsFragmentFunctions: {
  107598. name: string;
  107599. shader: string;
  107600. };
  107601. }
  107602. declare module BABYLON {
  107603. /** @hidden */
  107604. export var shadowsFragmentFunctions: {
  107605. name: string;
  107606. shader: string;
  107607. };
  107608. }
  107609. declare module BABYLON {
  107610. /** @hidden */
  107611. export var fresnelFunction: {
  107612. name: string;
  107613. shader: string;
  107614. };
  107615. }
  107616. declare module BABYLON {
  107617. /** @hidden */
  107618. export var bumpFragmentMainFunctions: {
  107619. name: string;
  107620. shader: string;
  107621. };
  107622. }
  107623. declare module BABYLON {
  107624. /** @hidden */
  107625. export var bumpFragmentFunctions: {
  107626. name: string;
  107627. shader: string;
  107628. };
  107629. }
  107630. declare module BABYLON {
  107631. /** @hidden */
  107632. export var logDepthDeclaration: {
  107633. name: string;
  107634. shader: string;
  107635. };
  107636. }
  107637. declare module BABYLON {
  107638. /** @hidden */
  107639. export var bumpFragment: {
  107640. name: string;
  107641. shader: string;
  107642. };
  107643. }
  107644. declare module BABYLON {
  107645. /** @hidden */
  107646. export var depthPrePass: {
  107647. name: string;
  107648. shader: string;
  107649. };
  107650. }
  107651. declare module BABYLON {
  107652. /** @hidden */
  107653. export var lightFragment: {
  107654. name: string;
  107655. shader: string;
  107656. };
  107657. }
  107658. declare module BABYLON {
  107659. /** @hidden */
  107660. export var logDepthFragment: {
  107661. name: string;
  107662. shader: string;
  107663. };
  107664. }
  107665. declare module BABYLON {
  107666. /** @hidden */
  107667. export var defaultPixelShader: {
  107668. name: string;
  107669. shader: string;
  107670. };
  107671. }
  107672. declare module BABYLON {
  107673. /** @hidden */
  107674. export var defaultVertexDeclaration: {
  107675. name: string;
  107676. shader: string;
  107677. };
  107678. }
  107679. declare module BABYLON {
  107680. /** @hidden */
  107681. export var bumpVertexDeclaration: {
  107682. name: string;
  107683. shader: string;
  107684. };
  107685. }
  107686. declare module BABYLON {
  107687. /** @hidden */
  107688. export var bumpVertex: {
  107689. name: string;
  107690. shader: string;
  107691. };
  107692. }
  107693. declare module BABYLON {
  107694. /** @hidden */
  107695. export var fogVertex: {
  107696. name: string;
  107697. shader: string;
  107698. };
  107699. }
  107700. declare module BABYLON {
  107701. /** @hidden */
  107702. export var shadowsVertex: {
  107703. name: string;
  107704. shader: string;
  107705. };
  107706. }
  107707. declare module BABYLON {
  107708. /** @hidden */
  107709. export var pointCloudVertex: {
  107710. name: string;
  107711. shader: string;
  107712. };
  107713. }
  107714. declare module BABYLON {
  107715. /** @hidden */
  107716. export var logDepthVertex: {
  107717. name: string;
  107718. shader: string;
  107719. };
  107720. }
  107721. declare module BABYLON {
  107722. /** @hidden */
  107723. export var defaultVertexShader: {
  107724. name: string;
  107725. shader: string;
  107726. };
  107727. }
  107728. declare module BABYLON {
  107729. /**
  107730. * @hidden
  107731. */
  107732. export interface IMaterialDetailMapDefines {
  107733. DETAIL: boolean;
  107734. DETAILDIRECTUV: number;
  107735. DETAIL_NORMALBLENDMETHOD: number;
  107736. /** @hidden */
  107737. _areTexturesDirty: boolean;
  107738. }
  107739. /**
  107740. * Define the code related to the detail map parameters of a material
  107741. *
  107742. * Inspired from:
  107743. * 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
  107744. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  107745. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  107746. */
  107747. export class DetailMapConfiguration {
  107748. private _texture;
  107749. /**
  107750. * The detail texture of the material.
  107751. */
  107752. texture: Nullable<BaseTexture>;
  107753. /**
  107754. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  107755. * Bigger values mean stronger blending
  107756. */
  107757. diffuseBlendLevel: number;
  107758. /**
  107759. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  107760. * Bigger values mean stronger blending. Only used with PBR materials
  107761. */
  107762. roughnessBlendLevel: number;
  107763. /**
  107764. * Defines how strong the bump effect from the detail map is
  107765. * Bigger values mean stronger effect
  107766. */
  107767. bumpLevel: number;
  107768. private _normalBlendMethod;
  107769. /**
  107770. * The method used to blend the bump and detail normals together
  107771. */
  107772. normalBlendMethod: number;
  107773. private _isEnabled;
  107774. /**
  107775. * Enable or disable the detail map on this material
  107776. */
  107777. isEnabled: boolean;
  107778. /** @hidden */
  107779. private _internalMarkAllSubMeshesAsTexturesDirty;
  107780. /** @hidden */
  107781. _markAllSubMeshesAsTexturesDirty(): void;
  107782. /**
  107783. * Instantiate a new detail map
  107784. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  107785. */
  107786. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  107787. /**
  107788. * Gets whether the submesh is ready to be used or not.
  107789. * @param defines the list of "defines" to update.
  107790. * @param scene defines the scene the material belongs to.
  107791. * @returns - boolean indicating that the submesh is ready or not.
  107792. */
  107793. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  107794. /**
  107795. * Update the defines for detail map usage
  107796. * @param defines the list of "defines" to update.
  107797. * @param scene defines the scene the material belongs to.
  107798. */
  107799. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  107800. /**
  107801. * Binds the material data.
  107802. * @param uniformBuffer defines the Uniform buffer to fill in.
  107803. * @param scene defines the scene the material belongs to.
  107804. * @param isFrozen defines whether the material is frozen or not.
  107805. */
  107806. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  107807. /**
  107808. * Checks to see if a texture is used in the material.
  107809. * @param texture - Base texture to use.
  107810. * @returns - Boolean specifying if a texture is used in the material.
  107811. */
  107812. hasTexture(texture: BaseTexture): boolean;
  107813. /**
  107814. * Returns an array of the actively used textures.
  107815. * @param activeTextures Array of BaseTextures
  107816. */
  107817. getActiveTextures(activeTextures: BaseTexture[]): void;
  107818. /**
  107819. * Returns the animatable textures.
  107820. * @param animatables Array of animatable textures.
  107821. */
  107822. getAnimatables(animatables: IAnimatable[]): void;
  107823. /**
  107824. * Disposes the resources of the material.
  107825. * @param forceDisposeTextures - Forces the disposal of all textures.
  107826. */
  107827. dispose(forceDisposeTextures?: boolean): void;
  107828. /**
  107829. * Get the current class name useful for serialization or dynamic coding.
  107830. * @returns "DetailMap"
  107831. */
  107832. getClassName(): string;
  107833. /**
  107834. * Add the required uniforms to the current list.
  107835. * @param uniforms defines the current uniform list.
  107836. */
  107837. static AddUniforms(uniforms: string[]): void;
  107838. /**
  107839. * Add the required samplers to the current list.
  107840. * @param samplers defines the current sampler list.
  107841. */
  107842. static AddSamplers(samplers: string[]): void;
  107843. /**
  107844. * Add the required uniforms to the current buffer.
  107845. * @param uniformBuffer defines the current uniform buffer.
  107846. */
  107847. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107848. /**
  107849. * Makes a duplicate of the current instance into another one.
  107850. * @param detailMap define the instance where to copy the info
  107851. */
  107852. copyTo(detailMap: DetailMapConfiguration): void;
  107853. /**
  107854. * Serializes this detail map instance
  107855. * @returns - An object with the serialized instance.
  107856. */
  107857. serialize(): any;
  107858. /**
  107859. * Parses a detail map setting from a serialized object.
  107860. * @param source - Serialized object.
  107861. * @param scene Defines the scene we are parsing for
  107862. * @param rootUrl Defines the rootUrl to load from
  107863. */
  107864. parse(source: any, scene: Scene, rootUrl: string): void;
  107865. }
  107866. }
  107867. declare module BABYLON {
  107868. /** @hidden */
  107869. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  107870. MAINUV1: boolean;
  107871. MAINUV2: boolean;
  107872. DIFFUSE: boolean;
  107873. DIFFUSEDIRECTUV: number;
  107874. DETAIL: boolean;
  107875. DETAILDIRECTUV: number;
  107876. DETAIL_NORMALBLENDMETHOD: number;
  107877. AMBIENT: boolean;
  107878. AMBIENTDIRECTUV: number;
  107879. OPACITY: boolean;
  107880. OPACITYDIRECTUV: number;
  107881. OPACITYRGB: boolean;
  107882. REFLECTION: boolean;
  107883. EMISSIVE: boolean;
  107884. EMISSIVEDIRECTUV: number;
  107885. SPECULAR: boolean;
  107886. SPECULARDIRECTUV: number;
  107887. BUMP: boolean;
  107888. BUMPDIRECTUV: number;
  107889. PARALLAX: boolean;
  107890. PARALLAXOCCLUSION: boolean;
  107891. SPECULAROVERALPHA: boolean;
  107892. CLIPPLANE: boolean;
  107893. CLIPPLANE2: boolean;
  107894. CLIPPLANE3: boolean;
  107895. CLIPPLANE4: boolean;
  107896. CLIPPLANE5: boolean;
  107897. CLIPPLANE6: boolean;
  107898. ALPHATEST: boolean;
  107899. DEPTHPREPASS: boolean;
  107900. ALPHAFROMDIFFUSE: boolean;
  107901. POINTSIZE: boolean;
  107902. FOG: boolean;
  107903. SPECULARTERM: boolean;
  107904. DIFFUSEFRESNEL: boolean;
  107905. OPACITYFRESNEL: boolean;
  107906. REFLECTIONFRESNEL: boolean;
  107907. REFRACTIONFRESNEL: boolean;
  107908. EMISSIVEFRESNEL: boolean;
  107909. FRESNEL: boolean;
  107910. NORMAL: boolean;
  107911. UV1: boolean;
  107912. UV2: boolean;
  107913. VERTEXCOLOR: boolean;
  107914. VERTEXALPHA: boolean;
  107915. NUM_BONE_INFLUENCERS: number;
  107916. BonesPerMesh: number;
  107917. BONETEXTURE: boolean;
  107918. INSTANCES: boolean;
  107919. THIN_INSTANCES: boolean;
  107920. GLOSSINESS: boolean;
  107921. ROUGHNESS: boolean;
  107922. EMISSIVEASILLUMINATION: boolean;
  107923. LINKEMISSIVEWITHDIFFUSE: boolean;
  107924. REFLECTIONFRESNELFROMSPECULAR: boolean;
  107925. LIGHTMAP: boolean;
  107926. LIGHTMAPDIRECTUV: number;
  107927. OBJECTSPACE_NORMALMAP: boolean;
  107928. USELIGHTMAPASSHADOWMAP: boolean;
  107929. REFLECTIONMAP_3D: boolean;
  107930. REFLECTIONMAP_SPHERICAL: boolean;
  107931. REFLECTIONMAP_PLANAR: boolean;
  107932. REFLECTIONMAP_CUBIC: boolean;
  107933. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107934. REFLECTIONMAP_PROJECTION: boolean;
  107935. REFLECTIONMAP_SKYBOX: boolean;
  107936. REFLECTIONMAP_EXPLICIT: boolean;
  107937. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107938. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107939. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107940. INVERTCUBICMAP: boolean;
  107941. LOGARITHMICDEPTH: boolean;
  107942. REFRACTION: boolean;
  107943. REFRACTIONMAP_3D: boolean;
  107944. REFLECTIONOVERALPHA: boolean;
  107945. TWOSIDEDLIGHTING: boolean;
  107946. SHADOWFLOAT: boolean;
  107947. MORPHTARGETS: boolean;
  107948. MORPHTARGETS_NORMAL: boolean;
  107949. MORPHTARGETS_TANGENT: boolean;
  107950. MORPHTARGETS_UV: boolean;
  107951. NUM_MORPH_INFLUENCERS: number;
  107952. NONUNIFORMSCALING: boolean;
  107953. PREMULTIPLYALPHA: boolean;
  107954. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  107955. ALPHABLEND: boolean;
  107956. PREPASS: boolean;
  107957. SCENE_MRT_COUNT: number;
  107958. RGBDLIGHTMAP: boolean;
  107959. RGBDREFLECTION: boolean;
  107960. RGBDREFRACTION: boolean;
  107961. IMAGEPROCESSING: boolean;
  107962. VIGNETTE: boolean;
  107963. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107964. VIGNETTEBLENDMODEOPAQUE: boolean;
  107965. TONEMAPPING: boolean;
  107966. TONEMAPPING_ACES: boolean;
  107967. CONTRAST: boolean;
  107968. COLORCURVES: boolean;
  107969. COLORGRADING: boolean;
  107970. COLORGRADING3D: boolean;
  107971. SAMPLER3DGREENDEPTH: boolean;
  107972. SAMPLER3DBGRMAP: boolean;
  107973. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107974. MULTIVIEW: boolean;
  107975. /**
  107976. * If the reflection texture on this material is in linear color space
  107977. * @hidden
  107978. */
  107979. IS_REFLECTION_LINEAR: boolean;
  107980. /**
  107981. * If the refraction texture on this material is in linear color space
  107982. * @hidden
  107983. */
  107984. IS_REFRACTION_LINEAR: boolean;
  107985. EXPOSURE: boolean;
  107986. constructor();
  107987. setReflectionMode(modeToEnable: string): void;
  107988. }
  107989. /**
  107990. * This is the default material used in Babylon. It is the best trade off between quality
  107991. * and performances.
  107992. * @see https://doc.babylonjs.com/babylon101/materials
  107993. */
  107994. export class StandardMaterial extends PushMaterial {
  107995. private _diffuseTexture;
  107996. /**
  107997. * The basic texture of the material as viewed under a light.
  107998. */
  107999. diffuseTexture: Nullable<BaseTexture>;
  108000. private _ambientTexture;
  108001. /**
  108002. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  108003. */
  108004. ambientTexture: Nullable<BaseTexture>;
  108005. private _opacityTexture;
  108006. /**
  108007. * Define the transparency of the material from a texture.
  108008. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  108009. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  108010. */
  108011. opacityTexture: Nullable<BaseTexture>;
  108012. private _reflectionTexture;
  108013. /**
  108014. * Define the texture used to display the reflection.
  108015. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108016. */
  108017. reflectionTexture: Nullable<BaseTexture>;
  108018. private _emissiveTexture;
  108019. /**
  108020. * Define texture of the material as if self lit.
  108021. * This will be mixed in the final result even in the absence of light.
  108022. */
  108023. emissiveTexture: Nullable<BaseTexture>;
  108024. private _specularTexture;
  108025. /**
  108026. * Define how the color and intensity of the highlight given by the light in the material.
  108027. */
  108028. specularTexture: Nullable<BaseTexture>;
  108029. private _bumpTexture;
  108030. /**
  108031. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  108032. * 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.
  108033. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  108034. */
  108035. bumpTexture: Nullable<BaseTexture>;
  108036. private _lightmapTexture;
  108037. /**
  108038. * Complex lighting can be computationally expensive to compute at runtime.
  108039. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  108040. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  108041. */
  108042. lightmapTexture: Nullable<BaseTexture>;
  108043. private _refractionTexture;
  108044. /**
  108045. * Define the texture used to display the refraction.
  108046. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108047. */
  108048. refractionTexture: Nullable<BaseTexture>;
  108049. /**
  108050. * The color of the material lit by the environmental background lighting.
  108051. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  108052. */
  108053. ambientColor: Color3;
  108054. /**
  108055. * The basic color of the material as viewed under a light.
  108056. */
  108057. diffuseColor: Color3;
  108058. /**
  108059. * Define how the color and intensity of the highlight given by the light in the material.
  108060. */
  108061. specularColor: Color3;
  108062. /**
  108063. * Define the color of the material as if self lit.
  108064. * This will be mixed in the final result even in the absence of light.
  108065. */
  108066. emissiveColor: Color3;
  108067. /**
  108068. * Defines how sharp are the highlights in the material.
  108069. * The bigger the value the sharper giving a more glossy feeling to the result.
  108070. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  108071. */
  108072. specularPower: number;
  108073. private _useAlphaFromDiffuseTexture;
  108074. /**
  108075. * Does the transparency come from the diffuse texture alpha channel.
  108076. */
  108077. useAlphaFromDiffuseTexture: boolean;
  108078. private _useEmissiveAsIllumination;
  108079. /**
  108080. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  108081. */
  108082. useEmissiveAsIllumination: boolean;
  108083. private _linkEmissiveWithDiffuse;
  108084. /**
  108085. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  108086. * the emissive level when the final color is close to one.
  108087. */
  108088. linkEmissiveWithDiffuse: boolean;
  108089. private _useSpecularOverAlpha;
  108090. /**
  108091. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108092. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108093. */
  108094. useSpecularOverAlpha: boolean;
  108095. private _useReflectionOverAlpha;
  108096. /**
  108097. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108098. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108099. */
  108100. useReflectionOverAlpha: boolean;
  108101. private _disableLighting;
  108102. /**
  108103. * Does lights from the scene impacts this material.
  108104. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  108105. */
  108106. disableLighting: boolean;
  108107. private _useObjectSpaceNormalMap;
  108108. /**
  108109. * Allows using an object space normal map (instead of tangent space).
  108110. */
  108111. useObjectSpaceNormalMap: boolean;
  108112. private _useParallax;
  108113. /**
  108114. * Is parallax enabled or not.
  108115. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108116. */
  108117. useParallax: boolean;
  108118. private _useParallaxOcclusion;
  108119. /**
  108120. * Is parallax occlusion enabled or not.
  108121. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  108122. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  108123. */
  108124. useParallaxOcclusion: boolean;
  108125. /**
  108126. * 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.
  108127. */
  108128. parallaxScaleBias: number;
  108129. private _roughness;
  108130. /**
  108131. * Helps to define how blurry the reflections should appears in the material.
  108132. */
  108133. roughness: number;
  108134. /**
  108135. * In case of refraction, define the value of the index of refraction.
  108136. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108137. */
  108138. indexOfRefraction: number;
  108139. /**
  108140. * Invert the refraction texture alongside the y axis.
  108141. * It can be useful with procedural textures or probe for instance.
  108142. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  108143. */
  108144. invertRefractionY: boolean;
  108145. /**
  108146. * Defines the alpha limits in alpha test mode.
  108147. */
  108148. alphaCutOff: number;
  108149. private _useLightmapAsShadowmap;
  108150. /**
  108151. * In case of light mapping, define whether the map contains light or shadow informations.
  108152. */
  108153. useLightmapAsShadowmap: boolean;
  108154. private _diffuseFresnelParameters;
  108155. /**
  108156. * Define the diffuse fresnel parameters of the material.
  108157. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108158. */
  108159. diffuseFresnelParameters: FresnelParameters;
  108160. private _opacityFresnelParameters;
  108161. /**
  108162. * Define the opacity fresnel parameters of the material.
  108163. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108164. */
  108165. opacityFresnelParameters: FresnelParameters;
  108166. private _reflectionFresnelParameters;
  108167. /**
  108168. * Define the reflection fresnel parameters of the material.
  108169. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108170. */
  108171. reflectionFresnelParameters: FresnelParameters;
  108172. private _refractionFresnelParameters;
  108173. /**
  108174. * Define the refraction fresnel parameters of the material.
  108175. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108176. */
  108177. refractionFresnelParameters: FresnelParameters;
  108178. private _emissiveFresnelParameters;
  108179. /**
  108180. * Define the emissive fresnel parameters of the material.
  108181. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108182. */
  108183. emissiveFresnelParameters: FresnelParameters;
  108184. private _useReflectionFresnelFromSpecular;
  108185. /**
  108186. * If true automatically deducts the fresnels values from the material specularity.
  108187. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  108188. */
  108189. useReflectionFresnelFromSpecular: boolean;
  108190. private _useGlossinessFromSpecularMapAlpha;
  108191. /**
  108192. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  108193. */
  108194. useGlossinessFromSpecularMapAlpha: boolean;
  108195. private _maxSimultaneousLights;
  108196. /**
  108197. * Defines the maximum number of lights that can be used in the material
  108198. */
  108199. maxSimultaneousLights: number;
  108200. private _invertNormalMapX;
  108201. /**
  108202. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108203. */
  108204. invertNormalMapX: boolean;
  108205. private _invertNormalMapY;
  108206. /**
  108207. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108208. */
  108209. invertNormalMapY: boolean;
  108210. private _twoSidedLighting;
  108211. /**
  108212. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108213. */
  108214. twoSidedLighting: boolean;
  108215. /**
  108216. * Default configuration related to image processing available in the standard Material.
  108217. */
  108218. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108219. /**
  108220. * Gets the image processing configuration used either in this material.
  108221. */
  108222. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108223. /**
  108224. * Sets the Default image processing configuration used either in the this material.
  108225. *
  108226. * If sets to null, the scene one is in use.
  108227. */
  108228. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  108229. /**
  108230. * Keep track of the image processing observer to allow dispose and replace.
  108231. */
  108232. private _imageProcessingObserver;
  108233. /**
  108234. * Attaches a new image processing configuration to the Standard Material.
  108235. * @param configuration
  108236. */
  108237. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  108238. /**
  108239. * Gets wether the color curves effect is enabled.
  108240. */
  108241. get cameraColorCurvesEnabled(): boolean;
  108242. /**
  108243. * Sets wether the color curves effect is enabled.
  108244. */
  108245. set cameraColorCurvesEnabled(value: boolean);
  108246. /**
  108247. * Gets wether the color grading effect is enabled.
  108248. */
  108249. get cameraColorGradingEnabled(): boolean;
  108250. /**
  108251. * Gets wether the color grading effect is enabled.
  108252. */
  108253. set cameraColorGradingEnabled(value: boolean);
  108254. /**
  108255. * Gets wether tonemapping is enabled or not.
  108256. */
  108257. get cameraToneMappingEnabled(): boolean;
  108258. /**
  108259. * Sets wether tonemapping is enabled or not
  108260. */
  108261. set cameraToneMappingEnabled(value: boolean);
  108262. /**
  108263. * The camera exposure used on this material.
  108264. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108265. * This corresponds to a photographic exposure.
  108266. */
  108267. get cameraExposure(): number;
  108268. /**
  108269. * The camera exposure used on this material.
  108270. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108271. * This corresponds to a photographic exposure.
  108272. */
  108273. set cameraExposure(value: number);
  108274. /**
  108275. * Gets The camera contrast used on this material.
  108276. */
  108277. get cameraContrast(): number;
  108278. /**
  108279. * Sets The camera contrast used on this material.
  108280. */
  108281. set cameraContrast(value: number);
  108282. /**
  108283. * Gets the Color Grading 2D Lookup Texture.
  108284. */
  108285. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  108286. /**
  108287. * Sets the Color Grading 2D Lookup Texture.
  108288. */
  108289. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  108290. /**
  108291. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108292. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108293. * 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;
  108294. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108295. */
  108296. get cameraColorCurves(): Nullable<ColorCurves>;
  108297. /**
  108298. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108299. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108300. * 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;
  108301. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108302. */
  108303. set cameraColorCurves(value: Nullable<ColorCurves>);
  108304. /**
  108305. * Should this material render to several textures at once
  108306. */
  108307. get shouldRenderToMRT(): boolean;
  108308. /**
  108309. * Defines the detail map parameters for the material.
  108310. */
  108311. readonly detailMap: DetailMapConfiguration;
  108312. protected _renderTargets: SmartArray<RenderTargetTexture>;
  108313. protected _worldViewProjectionMatrix: Matrix;
  108314. protected _globalAmbientColor: Color3;
  108315. protected _useLogarithmicDepth: boolean;
  108316. protected _rebuildInParallel: boolean;
  108317. /**
  108318. * Instantiates a new standard material.
  108319. * This is the default material used in Babylon. It is the best trade off between quality
  108320. * and performances.
  108321. * @see https://doc.babylonjs.com/babylon101/materials
  108322. * @param name Define the name of the material in the scene
  108323. * @param scene Define the scene the material belong to
  108324. */
  108325. constructor(name: string, scene: Scene);
  108326. /**
  108327. * Gets a boolean indicating that current material needs to register RTT
  108328. */
  108329. get hasRenderTargetTextures(): boolean;
  108330. /**
  108331. * Gets the current class name of the material e.g. "StandardMaterial"
  108332. * Mainly use in serialization.
  108333. * @returns the class name
  108334. */
  108335. getClassName(): string;
  108336. /**
  108337. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  108338. * You can try switching to logarithmic depth.
  108339. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  108340. */
  108341. get useLogarithmicDepth(): boolean;
  108342. set useLogarithmicDepth(value: boolean);
  108343. /**
  108344. * Specifies if the material will require alpha blending
  108345. * @returns a boolean specifying if alpha blending is needed
  108346. */
  108347. needAlphaBlending(): boolean;
  108348. /**
  108349. * Specifies if this material should be rendered in alpha test mode
  108350. * @returns a boolean specifying if an alpha test is needed.
  108351. */
  108352. needAlphaTesting(): boolean;
  108353. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  108354. /**
  108355. * Get the texture used for alpha test purpose.
  108356. * @returns the diffuse texture in case of the standard material.
  108357. */
  108358. getAlphaTestTexture(): Nullable<BaseTexture>;
  108359. /**
  108360. * Get if the submesh is ready to be used and all its information available.
  108361. * Child classes can use it to update shaders
  108362. * @param mesh defines the mesh to check
  108363. * @param subMesh defines which submesh to check
  108364. * @param useInstances specifies that instances should be used
  108365. * @returns a boolean indicating that the submesh is ready or not
  108366. */
  108367. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  108368. /**
  108369. * Builds the material UBO layouts.
  108370. * Used internally during the effect preparation.
  108371. */
  108372. buildUniformLayout(): void;
  108373. /**
  108374. * Unbinds the material from the mesh
  108375. */
  108376. unbind(): void;
  108377. /**
  108378. * Binds the submesh to this material by preparing the effect and shader to draw
  108379. * @param world defines the world transformation matrix
  108380. * @param mesh defines the mesh containing the submesh
  108381. * @param subMesh defines the submesh to bind the material to
  108382. */
  108383. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  108384. /**
  108385. * Get the list of animatables in the material.
  108386. * @returns the list of animatables object used in the material
  108387. */
  108388. getAnimatables(): IAnimatable[];
  108389. /**
  108390. * Gets the active textures from the material
  108391. * @returns an array of textures
  108392. */
  108393. getActiveTextures(): BaseTexture[];
  108394. /**
  108395. * Specifies if the material uses a texture
  108396. * @param texture defines the texture to check against the material
  108397. * @returns a boolean specifying if the material uses the texture
  108398. */
  108399. hasTexture(texture: BaseTexture): boolean;
  108400. /**
  108401. * Disposes the material
  108402. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  108403. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  108404. */
  108405. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  108406. /**
  108407. * Makes a duplicate of the material, and gives it a new name
  108408. * @param name defines the new name for the duplicated material
  108409. * @returns the cloned material
  108410. */
  108411. clone(name: string): StandardMaterial;
  108412. /**
  108413. * Serializes this material in a JSON representation
  108414. * @returns the serialized material object
  108415. */
  108416. serialize(): any;
  108417. /**
  108418. * Creates a standard material from parsed material data
  108419. * @param source defines the JSON representation of the material
  108420. * @param scene defines the hosting scene
  108421. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  108422. * @returns a new standard material
  108423. */
  108424. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  108425. /**
  108426. * Are diffuse textures enabled in the application.
  108427. */
  108428. static get DiffuseTextureEnabled(): boolean;
  108429. static set DiffuseTextureEnabled(value: boolean);
  108430. /**
  108431. * Are detail textures enabled in the application.
  108432. */
  108433. static get DetailTextureEnabled(): boolean;
  108434. static set DetailTextureEnabled(value: boolean);
  108435. /**
  108436. * Are ambient textures enabled in the application.
  108437. */
  108438. static get AmbientTextureEnabled(): boolean;
  108439. static set AmbientTextureEnabled(value: boolean);
  108440. /**
  108441. * Are opacity textures enabled in the application.
  108442. */
  108443. static get OpacityTextureEnabled(): boolean;
  108444. static set OpacityTextureEnabled(value: boolean);
  108445. /**
  108446. * Are reflection textures enabled in the application.
  108447. */
  108448. static get ReflectionTextureEnabled(): boolean;
  108449. static set ReflectionTextureEnabled(value: boolean);
  108450. /**
  108451. * Are emissive textures enabled in the application.
  108452. */
  108453. static get EmissiveTextureEnabled(): boolean;
  108454. static set EmissiveTextureEnabled(value: boolean);
  108455. /**
  108456. * Are specular textures enabled in the application.
  108457. */
  108458. static get SpecularTextureEnabled(): boolean;
  108459. static set SpecularTextureEnabled(value: boolean);
  108460. /**
  108461. * Are bump textures enabled in the application.
  108462. */
  108463. static get BumpTextureEnabled(): boolean;
  108464. static set BumpTextureEnabled(value: boolean);
  108465. /**
  108466. * Are lightmap textures enabled in the application.
  108467. */
  108468. static get LightmapTextureEnabled(): boolean;
  108469. static set LightmapTextureEnabled(value: boolean);
  108470. /**
  108471. * Are refraction textures enabled in the application.
  108472. */
  108473. static get RefractionTextureEnabled(): boolean;
  108474. static set RefractionTextureEnabled(value: boolean);
  108475. /**
  108476. * Are color grading textures enabled in the application.
  108477. */
  108478. static get ColorGradingTextureEnabled(): boolean;
  108479. static set ColorGradingTextureEnabled(value: boolean);
  108480. /**
  108481. * Are fresnels enabled in the application.
  108482. */
  108483. static get FresnelEnabled(): boolean;
  108484. static set FresnelEnabled(value: boolean);
  108485. }
  108486. }
  108487. declare module BABYLON {
  108488. /**
  108489. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108490. *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.
  108491. * The SPS is also a particle system. It provides some methods to manage the particles.
  108492. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108493. *
  108494. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  108495. */
  108496. export class SolidParticleSystem implements IDisposable {
  108497. /**
  108498. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108499. * Example : var p = SPS.particles[i];
  108500. */
  108501. particles: SolidParticle[];
  108502. /**
  108503. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108504. */
  108505. nbParticles: number;
  108506. /**
  108507. * If the particles must ever face the camera (default false). Useful for planar particles.
  108508. */
  108509. billboard: boolean;
  108510. /**
  108511. * Recompute normals when adding a shape
  108512. */
  108513. recomputeNormals: boolean;
  108514. /**
  108515. * This a counter ofr your own usage. It's not set by any SPS functions.
  108516. */
  108517. counter: number;
  108518. /**
  108519. * The SPS name. This name is also given to the underlying mesh.
  108520. */
  108521. name: string;
  108522. /**
  108523. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  108524. */
  108525. mesh: Mesh;
  108526. /**
  108527. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108528. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  108529. */
  108530. vars: any;
  108531. /**
  108532. * This array is populated when the SPS is set as 'pickable'.
  108533. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  108534. * Each element of this array is an object `{idx: int, faceId: int}`.
  108535. * `idx` is the picked particle index in the `SPS.particles` array
  108536. * `faceId` is the picked face index counted within this particle.
  108537. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  108538. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  108539. * Use the method SPS.pickedParticle(pickingInfo) instead.
  108540. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108541. */
  108542. pickedParticles: {
  108543. idx: number;
  108544. faceId: number;
  108545. }[];
  108546. /**
  108547. * This array is populated when the SPS is set as 'pickable'
  108548. * Each key of this array is a submesh index.
  108549. * Each element of this array is a second array defined like this :
  108550. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  108551. * Each element of this second array is an object `{idx: int, faceId: int}`.
  108552. * `idx` is the picked particle index in the `SPS.particles` array
  108553. * `faceId` is the picked face index counted within this particle.
  108554. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  108555. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  108556. */
  108557. pickedBySubMesh: {
  108558. idx: number;
  108559. faceId: number;
  108560. }[][];
  108561. /**
  108562. * This array is populated when `enableDepthSort` is set to true.
  108563. * Each element of this array is an instance of the class DepthSortedParticle.
  108564. */
  108565. depthSortedParticles: DepthSortedParticle[];
  108566. /**
  108567. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108568. * @hidden
  108569. */
  108570. _bSphereOnly: boolean;
  108571. /**
  108572. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108573. * @hidden
  108574. */
  108575. _bSphereRadiusFactor: number;
  108576. private _scene;
  108577. private _positions;
  108578. private _indices;
  108579. private _normals;
  108580. private _colors;
  108581. private _uvs;
  108582. private _indices32;
  108583. private _positions32;
  108584. private _normals32;
  108585. private _fixedNormal32;
  108586. private _colors32;
  108587. private _uvs32;
  108588. private _index;
  108589. private _updatable;
  108590. private _pickable;
  108591. private _isVisibilityBoxLocked;
  108592. private _alwaysVisible;
  108593. private _depthSort;
  108594. private _expandable;
  108595. private _shapeCounter;
  108596. private _copy;
  108597. private _color;
  108598. private _computeParticleColor;
  108599. private _computeParticleTexture;
  108600. private _computeParticleRotation;
  108601. private _computeParticleVertex;
  108602. private _computeBoundingBox;
  108603. private _depthSortParticles;
  108604. private _camera;
  108605. private _mustUnrotateFixedNormals;
  108606. private _particlesIntersect;
  108607. private _needs32Bits;
  108608. private _isNotBuilt;
  108609. private _lastParticleId;
  108610. private _idxOfId;
  108611. private _multimaterialEnabled;
  108612. private _useModelMaterial;
  108613. private _indicesByMaterial;
  108614. private _materialIndexes;
  108615. private _depthSortFunction;
  108616. private _materialSortFunction;
  108617. private _materials;
  108618. private _multimaterial;
  108619. private _materialIndexesById;
  108620. private _defaultMaterial;
  108621. private _autoUpdateSubMeshes;
  108622. private _tmpVertex;
  108623. /**
  108624. * Creates a SPS (Solid Particle System) object.
  108625. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108626. * @param scene (Scene) is the scene in which the SPS is added.
  108627. * @param options defines the options of the sps e.g.
  108628. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108629. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108630. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108631. * * 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.
  108632. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  108633. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  108634. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108635. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108636. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108637. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108638. */
  108639. constructor(name: string, scene: Scene, options?: {
  108640. updatable?: boolean;
  108641. isPickable?: boolean;
  108642. enableDepthSort?: boolean;
  108643. particleIntersection?: boolean;
  108644. boundingSphereOnly?: boolean;
  108645. bSphereRadiusFactor?: number;
  108646. expandable?: boolean;
  108647. useModelMaterial?: boolean;
  108648. enableMultiMaterial?: boolean;
  108649. });
  108650. /**
  108651. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108652. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108653. * @returns the created mesh
  108654. */
  108655. buildMesh(): Mesh;
  108656. /**
  108657. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108658. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108659. * Thus the particles generated from `digest()` have their property `position` set yet.
  108660. * @param mesh ( Mesh ) is the mesh to be digested
  108661. * @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
  108662. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108663. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108664. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108665. * @returns the current SPS
  108666. */
  108667. digest(mesh: Mesh, options?: {
  108668. facetNb?: number;
  108669. number?: number;
  108670. delta?: number;
  108671. storage?: [];
  108672. }): SolidParticleSystem;
  108673. /**
  108674. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108675. * @hidden
  108676. */
  108677. private _unrotateFixedNormals;
  108678. /**
  108679. * Resets the temporary working copy particle
  108680. * @hidden
  108681. */
  108682. private _resetCopy;
  108683. /**
  108684. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  108685. * @param p the current index in the positions array to be updated
  108686. * @param ind the current index in the indices array
  108687. * @param shape a Vector3 array, the shape geometry
  108688. * @param positions the positions array to be updated
  108689. * @param meshInd the shape indices array
  108690. * @param indices the indices array to be updated
  108691. * @param meshUV the shape uv array
  108692. * @param uvs the uv array to be updated
  108693. * @param meshCol the shape color array
  108694. * @param colors the color array to be updated
  108695. * @param meshNor the shape normals array
  108696. * @param normals the normals array to be updated
  108697. * @param idx the particle index
  108698. * @param idxInShape the particle index in its shape
  108699. * @param options the addShape() method passed options
  108700. * @model the particle model
  108701. * @hidden
  108702. */
  108703. private _meshBuilder;
  108704. /**
  108705. * Returns a shape Vector3 array from positions float array
  108706. * @param positions float array
  108707. * @returns a vector3 array
  108708. * @hidden
  108709. */
  108710. private _posToShape;
  108711. /**
  108712. * Returns a shapeUV array from a float uvs (array deep copy)
  108713. * @param uvs as a float array
  108714. * @returns a shapeUV array
  108715. * @hidden
  108716. */
  108717. private _uvsToShapeUV;
  108718. /**
  108719. * Adds a new particle object in the particles array
  108720. * @param idx particle index in particles array
  108721. * @param id particle id
  108722. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  108723. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  108724. * @param model particle ModelShape object
  108725. * @param shapeId model shape identifier
  108726. * @param idxInShape index of the particle in the current model
  108727. * @param bInfo model bounding info object
  108728. * @param storage target storage array, if any
  108729. * @hidden
  108730. */
  108731. private _addParticle;
  108732. /**
  108733. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108734. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  108735. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108736. * @param nb (positive integer) the number of particles to be created from this model
  108737. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108738. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108739. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  108740. * @returns the number of shapes in the system
  108741. */
  108742. addShape(mesh: Mesh, nb: number, options?: {
  108743. positionFunction?: any;
  108744. vertexFunction?: any;
  108745. storage?: [];
  108746. }): number;
  108747. /**
  108748. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108749. * @hidden
  108750. */
  108751. private _rebuildParticle;
  108752. /**
  108753. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  108754. * @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.
  108755. * @returns the SPS.
  108756. */
  108757. rebuildMesh(reset?: boolean): SolidParticleSystem;
  108758. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  108759. * Returns an array with the removed particles.
  108760. * 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.
  108761. * The SPS can't be empty so at least one particle needs to remain in place.
  108762. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  108763. * @param start index of the first particle to remove
  108764. * @param end index of the last particle to remove (included)
  108765. * @returns an array populated with the removed particles
  108766. */
  108767. removeParticles(start: number, end: number): SolidParticle[];
  108768. /**
  108769. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  108770. * @param solidParticleArray an array populated with Solid Particles objects
  108771. * @returns the SPS
  108772. */
  108773. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  108774. /**
  108775. * Creates a new particle and modifies the SPS mesh geometry :
  108776. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  108777. * - calls _addParticle() to populate the particle array
  108778. * factorized code from addShape() and insertParticlesFromArray()
  108779. * @param idx particle index in the particles array
  108780. * @param i particle index in its shape
  108781. * @param modelShape particle ModelShape object
  108782. * @param shape shape vertex array
  108783. * @param meshInd shape indices array
  108784. * @param meshUV shape uv array
  108785. * @param meshCol shape color array
  108786. * @param meshNor shape normals array
  108787. * @param bbInfo shape bounding info
  108788. * @param storage target particle storage
  108789. * @options addShape() passed options
  108790. * @hidden
  108791. */
  108792. private _insertNewParticle;
  108793. /**
  108794. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  108795. * This method calls `updateParticle()` for each particle of the SPS.
  108796. * For an animated SPS, it is usually called within the render loop.
  108797. * 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.
  108798. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  108799. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  108800. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  108801. * @returns the SPS.
  108802. */
  108803. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  108804. /**
  108805. * Disposes the SPS.
  108806. */
  108807. dispose(): void;
  108808. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  108809. * idx is the particle index in the SPS
  108810. * faceId is the picked face index counted within this particle.
  108811. * Returns null if the pickInfo can't identify a picked particle.
  108812. * @param pickingInfo (PickingInfo object)
  108813. * @returns {idx: number, faceId: number} or null
  108814. */
  108815. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  108816. idx: number;
  108817. faceId: number;
  108818. }>;
  108819. /**
  108820. * Returns a SolidParticle object from its identifier : particle.id
  108821. * @param id (integer) the particle Id
  108822. * @returns the searched particle or null if not found in the SPS.
  108823. */
  108824. getParticleById(id: number): Nullable<SolidParticle>;
  108825. /**
  108826. * Returns a new array populated with the particles having the passed shapeId.
  108827. * @param shapeId (integer) the shape identifier
  108828. * @returns a new solid particle array
  108829. */
  108830. getParticlesByShapeId(shapeId: number): SolidParticle[];
  108831. /**
  108832. * Populates the passed array "ref" with the particles having the passed shapeId.
  108833. * @param shapeId the shape identifier
  108834. * @returns the SPS
  108835. * @param ref
  108836. */
  108837. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  108838. /**
  108839. * Computes the required SubMeshes according the materials assigned to the particles.
  108840. * @returns the solid particle system.
  108841. * Does nothing if called before the SPS mesh is built.
  108842. */
  108843. computeSubMeshes(): SolidParticleSystem;
  108844. /**
  108845. * Sorts the solid particles by material when MultiMaterial is enabled.
  108846. * Updates the indices32 array.
  108847. * Updates the indicesByMaterial array.
  108848. * Updates the mesh indices array.
  108849. * @returns the SPS
  108850. * @hidden
  108851. */
  108852. private _sortParticlesByMaterial;
  108853. /**
  108854. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  108855. * @hidden
  108856. */
  108857. private _setMaterialIndexesById;
  108858. /**
  108859. * Returns an array with unique values of Materials from the passed array
  108860. * @param array the material array to be checked and filtered
  108861. * @hidden
  108862. */
  108863. private _filterUniqueMaterialId;
  108864. /**
  108865. * Sets a new Standard Material as _defaultMaterial if not already set.
  108866. * @hidden
  108867. */
  108868. private _setDefaultMaterial;
  108869. /**
  108870. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  108871. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108872. * @returns the SPS.
  108873. */
  108874. refreshVisibleSize(): SolidParticleSystem;
  108875. /**
  108876. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  108877. * @param size the size (float) of the visibility box
  108878. * note : this doesn't lock the SPS mesh bounding box.
  108879. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108880. */
  108881. setVisibilityBox(size: number): void;
  108882. /**
  108883. * Gets whether the SPS as always visible or not
  108884. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108885. */
  108886. get isAlwaysVisible(): boolean;
  108887. /**
  108888. * Sets the SPS as always visible or not
  108889. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108890. */
  108891. set isAlwaysVisible(val: boolean);
  108892. /**
  108893. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108894. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108895. */
  108896. set isVisibilityBoxLocked(val: boolean);
  108897. /**
  108898. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  108899. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  108900. */
  108901. get isVisibilityBoxLocked(): boolean;
  108902. /**
  108903. * Tells to `setParticles()` to compute the particle rotations or not.
  108904. * Default value : true. The SPS is faster when it's set to false.
  108905. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108906. */
  108907. set computeParticleRotation(val: boolean);
  108908. /**
  108909. * Tells to `setParticles()` to compute the particle colors or not.
  108910. * Default value : true. The SPS is faster when it's set to false.
  108911. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108912. */
  108913. set computeParticleColor(val: boolean);
  108914. set computeParticleTexture(val: boolean);
  108915. /**
  108916. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  108917. * Default value : false. The SPS is faster when it's set to false.
  108918. * Note : the particle custom vertex positions aren't stored values.
  108919. */
  108920. set computeParticleVertex(val: boolean);
  108921. /**
  108922. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  108923. */
  108924. set computeBoundingBox(val: boolean);
  108925. /**
  108926. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  108927. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108928. * Default : `true`
  108929. */
  108930. set depthSortParticles(val: boolean);
  108931. /**
  108932. * Gets if `setParticles()` computes the particle rotations or not.
  108933. * Default value : true. The SPS is faster when it's set to false.
  108934. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  108935. */
  108936. get computeParticleRotation(): boolean;
  108937. /**
  108938. * Gets if `setParticles()` computes the particle colors or not.
  108939. * Default value : true. The SPS is faster when it's set to false.
  108940. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  108941. */
  108942. get computeParticleColor(): boolean;
  108943. /**
  108944. * Gets if `setParticles()` computes the particle textures or not.
  108945. * Default value : true. The SPS is faster when it's set to false.
  108946. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  108947. */
  108948. get computeParticleTexture(): boolean;
  108949. /**
  108950. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  108951. * Default value : false. The SPS is faster when it's set to false.
  108952. * Note : the particle custom vertex positions aren't stored values.
  108953. */
  108954. get computeParticleVertex(): boolean;
  108955. /**
  108956. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  108957. */
  108958. get computeBoundingBox(): boolean;
  108959. /**
  108960. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  108961. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  108962. * Default : `true`
  108963. */
  108964. get depthSortParticles(): boolean;
  108965. /**
  108966. * Gets if the SPS is created as expandable at construction time.
  108967. * Default : `false`
  108968. */
  108969. get expandable(): boolean;
  108970. /**
  108971. * Gets if the SPS supports the Multi Materials
  108972. */
  108973. get multimaterialEnabled(): boolean;
  108974. /**
  108975. * Gets if the SPS uses the model materials for its own multimaterial.
  108976. */
  108977. get useModelMaterial(): boolean;
  108978. /**
  108979. * The SPS used material array.
  108980. */
  108981. get materials(): Material[];
  108982. /**
  108983. * Sets the SPS MultiMaterial from the passed materials.
  108984. * Note : the passed array is internally copied and not used then by reference.
  108985. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  108986. */
  108987. setMultiMaterial(materials: Material[]): void;
  108988. /**
  108989. * The SPS computed multimaterial object
  108990. */
  108991. get multimaterial(): MultiMaterial;
  108992. set multimaterial(mm: MultiMaterial);
  108993. /**
  108994. * If the subMeshes must be updated on the next call to setParticles()
  108995. */
  108996. get autoUpdateSubMeshes(): boolean;
  108997. set autoUpdateSubMeshes(val: boolean);
  108998. /**
  108999. * This function does nothing. It may be overwritten to set all the particle first values.
  109000. * The SPS doesn't call this function, you may have to call it by your own.
  109001. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109002. */
  109003. initParticles(): void;
  109004. /**
  109005. * This function does nothing. It may be overwritten to recycle a particle.
  109006. * The SPS doesn't call this function, you may have to call it by your own.
  109007. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109008. * @param particle The particle to recycle
  109009. * @returns the recycled particle
  109010. */
  109011. recycleParticle(particle: SolidParticle): SolidParticle;
  109012. /**
  109013. * Updates a particle : this function should be overwritten by the user.
  109014. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  109015. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  109016. * @example : just set a particle position or velocity and recycle conditions
  109017. * @param particle The particle to update
  109018. * @returns the updated particle
  109019. */
  109020. updateParticle(particle: SolidParticle): SolidParticle;
  109021. /**
  109022. * Updates a vertex of a particle : it can be overwritten by the user.
  109023. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  109024. * @param particle the current particle
  109025. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  109026. * @param pt the index of the current vertex in the particle shape
  109027. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  109028. * @example : just set a vertex particle position or color
  109029. * @returns the sps
  109030. */
  109031. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  109032. /**
  109033. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  109034. * This does nothing and may be overwritten by the user.
  109035. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109036. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109037. * @param update the boolean update value actually passed to setParticles()
  109038. */
  109039. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109040. /**
  109041. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  109042. * This will be passed three parameters.
  109043. * This does nothing and may be overwritten by the user.
  109044. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109045. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109046. * @param update the boolean update value actually passed to setParticles()
  109047. */
  109048. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  109049. }
  109050. }
  109051. declare module BABYLON {
  109052. /**
  109053. * Represents one particle of a solid particle system.
  109054. */
  109055. export class SolidParticle {
  109056. /**
  109057. * particle global index
  109058. */
  109059. idx: number;
  109060. /**
  109061. * particle identifier
  109062. */
  109063. id: number;
  109064. /**
  109065. * The color of the particle
  109066. */
  109067. color: Nullable<Color4>;
  109068. /**
  109069. * The world space position of the particle.
  109070. */
  109071. position: Vector3;
  109072. /**
  109073. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  109074. */
  109075. rotation: Vector3;
  109076. /**
  109077. * The world space rotation quaternion of the particle.
  109078. */
  109079. rotationQuaternion: Nullable<Quaternion>;
  109080. /**
  109081. * The scaling of the particle.
  109082. */
  109083. scaling: Vector3;
  109084. /**
  109085. * The uvs of the particle.
  109086. */
  109087. uvs: Vector4;
  109088. /**
  109089. * The current speed of the particle.
  109090. */
  109091. velocity: Vector3;
  109092. /**
  109093. * The pivot point in the particle local space.
  109094. */
  109095. pivot: Vector3;
  109096. /**
  109097. * Must the particle be translated from its pivot point in its local space ?
  109098. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  109099. * Default : false
  109100. */
  109101. translateFromPivot: boolean;
  109102. /**
  109103. * Is the particle active or not ?
  109104. */
  109105. alive: boolean;
  109106. /**
  109107. * Is the particle visible or not ?
  109108. */
  109109. isVisible: boolean;
  109110. /**
  109111. * Index of this particle in the global "positions" array (Internal use)
  109112. * @hidden
  109113. */
  109114. _pos: number;
  109115. /**
  109116. * @hidden Index of this particle in the global "indices" array (Internal use)
  109117. */
  109118. _ind: number;
  109119. /**
  109120. * @hidden ModelShape of this particle (Internal use)
  109121. */
  109122. _model: ModelShape;
  109123. /**
  109124. * ModelShape id of this particle
  109125. */
  109126. shapeId: number;
  109127. /**
  109128. * Index of the particle in its shape id
  109129. */
  109130. idxInShape: number;
  109131. /**
  109132. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  109133. */
  109134. _modelBoundingInfo: BoundingInfo;
  109135. /**
  109136. * @hidden Particle BoundingInfo object (Internal use)
  109137. */
  109138. _boundingInfo: BoundingInfo;
  109139. /**
  109140. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  109141. */
  109142. _sps: SolidParticleSystem;
  109143. /**
  109144. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  109145. */
  109146. _stillInvisible: boolean;
  109147. /**
  109148. * @hidden Last computed particle rotation matrix
  109149. */
  109150. _rotationMatrix: number[];
  109151. /**
  109152. * Parent particle Id, if any.
  109153. * Default null.
  109154. */
  109155. parentId: Nullable<number>;
  109156. /**
  109157. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  109158. */
  109159. materialIndex: Nullable<number>;
  109160. /**
  109161. * Custom object or properties.
  109162. */
  109163. props: Nullable<any>;
  109164. /**
  109165. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  109166. * The possible values are :
  109167. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109168. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109169. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109170. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109171. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109172. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  109173. * */
  109174. cullingStrategy: number;
  109175. /**
  109176. * @hidden Internal global position in the SPS.
  109177. */
  109178. _globalPosition: Vector3;
  109179. /**
  109180. * Creates a Solid Particle object.
  109181. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  109182. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  109183. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  109184. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  109185. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  109186. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  109187. * @param shapeId (integer) is the model shape identifier in the SPS.
  109188. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  109189. * @param sps defines the sps it is associated to
  109190. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  109191. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  109192. */
  109193. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  109194. /**
  109195. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  109196. * @param target the particle target
  109197. * @returns the current particle
  109198. */
  109199. copyToRef(target: SolidParticle): SolidParticle;
  109200. /**
  109201. * Legacy support, changed scale to scaling
  109202. */
  109203. get scale(): Vector3;
  109204. /**
  109205. * Legacy support, changed scale to scaling
  109206. */
  109207. set scale(scale: Vector3);
  109208. /**
  109209. * Legacy support, changed quaternion to rotationQuaternion
  109210. */
  109211. get quaternion(): Nullable<Quaternion>;
  109212. /**
  109213. * Legacy support, changed quaternion to rotationQuaternion
  109214. */
  109215. set quaternion(q: Nullable<Quaternion>);
  109216. /**
  109217. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  109218. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  109219. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  109220. * @returns true if it intersects
  109221. */
  109222. intersectsMesh(target: Mesh | SolidParticle): boolean;
  109223. /**
  109224. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  109225. * A particle is in the frustum if its bounding box intersects the frustum
  109226. * @param frustumPlanes defines the frustum to test
  109227. * @returns true if the particle is in the frustum planes
  109228. */
  109229. isInFrustum(frustumPlanes: Plane[]): boolean;
  109230. /**
  109231. * get the rotation matrix of the particle
  109232. * @hidden
  109233. */
  109234. getRotationMatrix(m: Matrix): void;
  109235. }
  109236. /**
  109237. * Represents the shape of the model used by one particle of a solid particle system.
  109238. * SPS internal tool, don't use it manually.
  109239. */
  109240. export class ModelShape {
  109241. /**
  109242. * The shape id
  109243. * @hidden
  109244. */
  109245. shapeID: number;
  109246. /**
  109247. * flat array of model positions (internal use)
  109248. * @hidden
  109249. */
  109250. _shape: Vector3[];
  109251. /**
  109252. * flat array of model UVs (internal use)
  109253. * @hidden
  109254. */
  109255. _shapeUV: number[];
  109256. /**
  109257. * color array of the model
  109258. * @hidden
  109259. */
  109260. _shapeColors: number[];
  109261. /**
  109262. * indices array of the model
  109263. * @hidden
  109264. */
  109265. _indices: number[];
  109266. /**
  109267. * normals array of the model
  109268. * @hidden
  109269. */
  109270. _normals: number[];
  109271. /**
  109272. * length of the shape in the model indices array (internal use)
  109273. * @hidden
  109274. */
  109275. _indicesLength: number;
  109276. /**
  109277. * Custom position function (internal use)
  109278. * @hidden
  109279. */
  109280. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  109281. /**
  109282. * Custom vertex function (internal use)
  109283. * @hidden
  109284. */
  109285. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  109286. /**
  109287. * Model material (internal use)
  109288. * @hidden
  109289. */
  109290. _material: Nullable<Material>;
  109291. /**
  109292. * 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.
  109293. * SPS internal tool, don't use it manually.
  109294. * @hidden
  109295. */
  109296. 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>);
  109297. }
  109298. /**
  109299. * Represents a Depth Sorted Particle in the solid particle system.
  109300. * @hidden
  109301. */
  109302. export class DepthSortedParticle {
  109303. /**
  109304. * Particle index
  109305. */
  109306. idx: number;
  109307. /**
  109308. * Index of the particle in the "indices" array
  109309. */
  109310. ind: number;
  109311. /**
  109312. * Length of the particle shape in the "indices" array
  109313. */
  109314. indicesLength: number;
  109315. /**
  109316. * Squared distance from the particle to the camera
  109317. */
  109318. sqDistance: number;
  109319. /**
  109320. * Material index when used with MultiMaterials
  109321. */
  109322. materialIndex: number;
  109323. /**
  109324. * Creates a new sorted particle
  109325. * @param materialIndex
  109326. */
  109327. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  109328. }
  109329. /**
  109330. * Represents a solid particle vertex
  109331. */
  109332. export class SolidParticleVertex {
  109333. /**
  109334. * Vertex position
  109335. */
  109336. position: Vector3;
  109337. /**
  109338. * Vertex color
  109339. */
  109340. color: Color4;
  109341. /**
  109342. * Vertex UV
  109343. */
  109344. uv: Vector2;
  109345. /**
  109346. * Creates a new solid particle vertex
  109347. */
  109348. constructor();
  109349. /** Vertex x coordinate */
  109350. get x(): number;
  109351. set x(val: number);
  109352. /** Vertex y coordinate */
  109353. get y(): number;
  109354. set y(val: number);
  109355. /** Vertex z coordinate */
  109356. get z(): number;
  109357. set z(val: number);
  109358. }
  109359. }
  109360. declare module BABYLON {
  109361. /**
  109362. * @hidden
  109363. */
  109364. export class _MeshCollisionData {
  109365. _checkCollisions: boolean;
  109366. _collisionMask: number;
  109367. _collisionGroup: number;
  109368. _surroundingMeshes: Nullable<AbstractMesh[]>;
  109369. _collider: Nullable<Collider>;
  109370. _oldPositionForCollisions: Vector3;
  109371. _diffPositionForCollisions: Vector3;
  109372. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  109373. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  109374. }
  109375. }
  109376. declare module BABYLON {
  109377. /** @hidden */
  109378. class _FacetDataStorage {
  109379. facetPositions: Vector3[];
  109380. facetNormals: Vector3[];
  109381. facetPartitioning: number[][];
  109382. facetNb: number;
  109383. partitioningSubdivisions: number;
  109384. partitioningBBoxRatio: number;
  109385. facetDataEnabled: boolean;
  109386. facetParameters: any;
  109387. bbSize: Vector3;
  109388. subDiv: {
  109389. max: number;
  109390. X: number;
  109391. Y: number;
  109392. Z: number;
  109393. };
  109394. facetDepthSort: boolean;
  109395. facetDepthSortEnabled: boolean;
  109396. depthSortedIndices: IndicesArray;
  109397. depthSortedFacets: {
  109398. ind: number;
  109399. sqDistance: number;
  109400. }[];
  109401. facetDepthSortFunction: (f1: {
  109402. ind: number;
  109403. sqDistance: number;
  109404. }, f2: {
  109405. ind: number;
  109406. sqDistance: number;
  109407. }) => number;
  109408. facetDepthSortFrom: Vector3;
  109409. facetDepthSortOrigin: Vector3;
  109410. invertedMatrix: Matrix;
  109411. }
  109412. /**
  109413. * @hidden
  109414. **/
  109415. class _InternalAbstractMeshDataInfo {
  109416. _hasVertexAlpha: boolean;
  109417. _useVertexColors: boolean;
  109418. _numBoneInfluencers: number;
  109419. _applyFog: boolean;
  109420. _receiveShadows: boolean;
  109421. _facetData: _FacetDataStorage;
  109422. _visibility: number;
  109423. _skeleton: Nullable<Skeleton>;
  109424. _layerMask: number;
  109425. _computeBonesUsingShaders: boolean;
  109426. _isActive: boolean;
  109427. _onlyForInstances: boolean;
  109428. _isActiveIntermediate: boolean;
  109429. _onlyForInstancesIntermediate: boolean;
  109430. _actAsRegularMesh: boolean;
  109431. }
  109432. /**
  109433. * Class used to store all common mesh properties
  109434. */
  109435. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  109436. /** No occlusion */
  109437. static OCCLUSION_TYPE_NONE: number;
  109438. /** Occlusion set to optimisitic */
  109439. static OCCLUSION_TYPE_OPTIMISTIC: number;
  109440. /** Occlusion set to strict */
  109441. static OCCLUSION_TYPE_STRICT: number;
  109442. /** Use an accurante occlusion algorithm */
  109443. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  109444. /** Use a conservative occlusion algorithm */
  109445. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  109446. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  109447. * Test order :
  109448. * Is the bounding sphere outside the frustum ?
  109449. * If not, are the bounding box vertices outside the frustum ?
  109450. * It not, then the cullable object is in the frustum.
  109451. */
  109452. static readonly CULLINGSTRATEGY_STANDARD: number;
  109453. /** Culling strategy : Bounding Sphere Only.
  109454. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  109455. * It's also less accurate than the standard because some not visible objects can still be selected.
  109456. * Test : is the bounding sphere outside the frustum ?
  109457. * If not, then the cullable object is in the frustum.
  109458. */
  109459. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  109460. /** Culling strategy : Optimistic Inclusion.
  109461. * This in an inclusion test first, then the standard exclusion test.
  109462. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  109463. * 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.
  109464. * Anyway, it's as accurate as the standard strategy.
  109465. * Test :
  109466. * Is the cullable object bounding sphere center in the frustum ?
  109467. * If not, apply the default culling strategy.
  109468. */
  109469. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  109470. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  109471. * This in an inclusion test first, then the bounding sphere only exclusion test.
  109472. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  109473. * 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.
  109474. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  109475. * Test :
  109476. * Is the cullable object bounding sphere center in the frustum ?
  109477. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  109478. */
  109479. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  109480. /**
  109481. * No billboard
  109482. */
  109483. static get BILLBOARDMODE_NONE(): number;
  109484. /** Billboard on X axis */
  109485. static get BILLBOARDMODE_X(): number;
  109486. /** Billboard on Y axis */
  109487. static get BILLBOARDMODE_Y(): number;
  109488. /** Billboard on Z axis */
  109489. static get BILLBOARDMODE_Z(): number;
  109490. /** Billboard on all axes */
  109491. static get BILLBOARDMODE_ALL(): number;
  109492. /** Billboard on using position instead of orientation */
  109493. static get BILLBOARDMODE_USE_POSITION(): number;
  109494. /** @hidden */
  109495. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  109496. /**
  109497. * The culling strategy to use to check whether the mesh must be rendered or not.
  109498. * This value can be changed at any time and will be used on the next render mesh selection.
  109499. * The possible values are :
  109500. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  109501. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  109502. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  109503. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  109504. * Please read each static variable documentation to get details about the culling process.
  109505. * */
  109506. cullingStrategy: number;
  109507. /**
  109508. * Gets the number of facets in the mesh
  109509. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109510. */
  109511. get facetNb(): number;
  109512. /**
  109513. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  109514. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109515. */
  109516. get partitioningSubdivisions(): number;
  109517. set partitioningSubdivisions(nb: number);
  109518. /**
  109519. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  109520. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  109521. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  109522. */
  109523. get partitioningBBoxRatio(): number;
  109524. set partitioningBBoxRatio(ratio: number);
  109525. /**
  109526. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  109527. * Works only for updatable meshes.
  109528. * Doesn't work with multi-materials
  109529. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109530. */
  109531. get mustDepthSortFacets(): boolean;
  109532. set mustDepthSortFacets(sort: boolean);
  109533. /**
  109534. * The location (Vector3) where the facet depth sort must be computed from.
  109535. * By default, the active camera position.
  109536. * Used only when facet depth sort is enabled
  109537. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  109538. */
  109539. get facetDepthSortFrom(): Vector3;
  109540. set facetDepthSortFrom(location: Vector3);
  109541. /**
  109542. * gets a boolean indicating if facetData is enabled
  109543. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  109544. */
  109545. get isFacetDataEnabled(): boolean;
  109546. /** @hidden */
  109547. _updateNonUniformScalingState(value: boolean): boolean;
  109548. /**
  109549. * An event triggered when this mesh collides with another one
  109550. */
  109551. onCollideObservable: Observable<AbstractMesh>;
  109552. /** Set a function to call when this mesh collides with another one */
  109553. set onCollide(callback: () => void);
  109554. /**
  109555. * An event triggered when the collision's position changes
  109556. */
  109557. onCollisionPositionChangeObservable: Observable<Vector3>;
  109558. /** Set a function to call when the collision's position changes */
  109559. set onCollisionPositionChange(callback: () => void);
  109560. /**
  109561. * An event triggered when material is changed
  109562. */
  109563. onMaterialChangedObservable: Observable<AbstractMesh>;
  109564. /**
  109565. * Gets or sets the orientation for POV movement & rotation
  109566. */
  109567. definedFacingForward: boolean;
  109568. /** @hidden */
  109569. _occlusionQuery: Nullable<WebGLQuery>;
  109570. /** @hidden */
  109571. _renderingGroup: Nullable<RenderingGroup>;
  109572. /**
  109573. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109574. */
  109575. get visibility(): number;
  109576. /**
  109577. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  109578. */
  109579. set visibility(value: number);
  109580. /** Gets or sets the alpha index used to sort transparent meshes
  109581. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  109582. */
  109583. alphaIndex: number;
  109584. /**
  109585. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  109586. */
  109587. isVisible: boolean;
  109588. /**
  109589. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  109590. */
  109591. isPickable: boolean;
  109592. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  109593. showSubMeshesBoundingBox: boolean;
  109594. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  109595. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  109596. */
  109597. isBlocker: boolean;
  109598. /**
  109599. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  109600. */
  109601. enablePointerMoveEvents: boolean;
  109602. /**
  109603. * Specifies the rendering group id for this mesh (0 by default)
  109604. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  109605. */
  109606. renderingGroupId: number;
  109607. private _material;
  109608. /** Gets or sets current material */
  109609. get material(): Nullable<Material>;
  109610. set material(value: Nullable<Material>);
  109611. /**
  109612. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  109613. * @see https://doc.babylonjs.com/babylon101/shadows
  109614. */
  109615. get receiveShadows(): boolean;
  109616. set receiveShadows(value: boolean);
  109617. /** Defines color to use when rendering outline */
  109618. outlineColor: Color3;
  109619. /** Define width to use when rendering outline */
  109620. outlineWidth: number;
  109621. /** Defines color to use when rendering overlay */
  109622. overlayColor: Color3;
  109623. /** Defines alpha to use when rendering overlay */
  109624. overlayAlpha: number;
  109625. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  109626. get hasVertexAlpha(): boolean;
  109627. set hasVertexAlpha(value: boolean);
  109628. /** 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) */
  109629. get useVertexColors(): boolean;
  109630. set useVertexColors(value: boolean);
  109631. /**
  109632. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  109633. */
  109634. get computeBonesUsingShaders(): boolean;
  109635. set computeBonesUsingShaders(value: boolean);
  109636. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  109637. get numBoneInfluencers(): number;
  109638. set numBoneInfluencers(value: number);
  109639. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  109640. get applyFog(): boolean;
  109641. set applyFog(value: boolean);
  109642. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  109643. useOctreeForRenderingSelection: boolean;
  109644. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  109645. useOctreeForPicking: boolean;
  109646. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  109647. useOctreeForCollisions: boolean;
  109648. /**
  109649. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  109650. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  109651. */
  109652. get layerMask(): number;
  109653. set layerMask(value: number);
  109654. /**
  109655. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  109656. */
  109657. alwaysSelectAsActiveMesh: boolean;
  109658. /**
  109659. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  109660. */
  109661. doNotSyncBoundingInfo: boolean;
  109662. /**
  109663. * Gets or sets the current action manager
  109664. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  109665. */
  109666. actionManager: Nullable<AbstractActionManager>;
  109667. private _meshCollisionData;
  109668. /**
  109669. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  109670. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109671. */
  109672. ellipsoid: Vector3;
  109673. /**
  109674. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  109675. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  109676. */
  109677. ellipsoidOffset: Vector3;
  109678. /**
  109679. * Gets or sets a collision mask used to mask collisions (default is -1).
  109680. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109681. */
  109682. get collisionMask(): number;
  109683. set collisionMask(mask: number);
  109684. /**
  109685. * Gets or sets the current collision group mask (-1 by default).
  109686. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  109687. */
  109688. get collisionGroup(): number;
  109689. set collisionGroup(mask: number);
  109690. /**
  109691. * Gets or sets current surrounding meshes (null by default).
  109692. *
  109693. * By default collision detection is tested against every mesh in the scene.
  109694. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  109695. * meshes will be tested for the collision.
  109696. *
  109697. * Note: if set to an empty array no collision will happen when this mesh is moved.
  109698. */
  109699. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  109700. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  109701. /**
  109702. * Defines edge width used when edgesRenderer is enabled
  109703. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109704. */
  109705. edgesWidth: number;
  109706. /**
  109707. * Defines edge color used when edgesRenderer is enabled
  109708. * @see https://www.babylonjs-playground.com/#10OJSG#13
  109709. */
  109710. edgesColor: Color4;
  109711. /** @hidden */
  109712. _edgesRenderer: Nullable<IEdgesRenderer>;
  109713. /** @hidden */
  109714. _masterMesh: Nullable<AbstractMesh>;
  109715. /** @hidden */
  109716. _boundingInfo: Nullable<BoundingInfo>;
  109717. /** @hidden */
  109718. _renderId: number;
  109719. /**
  109720. * Gets or sets the list of subMeshes
  109721. * @see https://doc.babylonjs.com/how_to/multi_materials
  109722. */
  109723. subMeshes: SubMesh[];
  109724. /** @hidden */
  109725. _intersectionsInProgress: AbstractMesh[];
  109726. /** @hidden */
  109727. _unIndexed: boolean;
  109728. /** @hidden */
  109729. _lightSources: Light[];
  109730. /** Gets the list of lights affecting that mesh */
  109731. get lightSources(): Light[];
  109732. /** @hidden */
  109733. get _positions(): Nullable<Vector3[]>;
  109734. /** @hidden */
  109735. _waitingData: {
  109736. lods: Nullable<any>;
  109737. actions: Nullable<any>;
  109738. freezeWorldMatrix: Nullable<boolean>;
  109739. };
  109740. /** @hidden */
  109741. _bonesTransformMatrices: Nullable<Float32Array>;
  109742. /** @hidden */
  109743. _transformMatrixTexture: Nullable<RawTexture>;
  109744. /**
  109745. * Gets or sets a skeleton to apply skining transformations
  109746. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  109747. */
  109748. set skeleton(value: Nullable<Skeleton>);
  109749. get skeleton(): Nullable<Skeleton>;
  109750. /**
  109751. * An event triggered when the mesh is rebuilt.
  109752. */
  109753. onRebuildObservable: Observable<AbstractMesh>;
  109754. /**
  109755. * Creates a new AbstractMesh
  109756. * @param name defines the name of the mesh
  109757. * @param scene defines the hosting scene
  109758. */
  109759. constructor(name: string, scene?: Nullable<Scene>);
  109760. /**
  109761. * Returns the string "AbstractMesh"
  109762. * @returns "AbstractMesh"
  109763. */
  109764. getClassName(): string;
  109765. /**
  109766. * Gets a string representation of the current mesh
  109767. * @param fullDetails defines a boolean indicating if full details must be included
  109768. * @returns a string representation of the current mesh
  109769. */
  109770. toString(fullDetails?: boolean): string;
  109771. /**
  109772. * @hidden
  109773. */
  109774. protected _getEffectiveParent(): Nullable<Node>;
  109775. /** @hidden */
  109776. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  109777. /** @hidden */
  109778. _rebuild(): void;
  109779. /** @hidden */
  109780. _resyncLightSources(): void;
  109781. /** @hidden */
  109782. _resyncLightSource(light: Light): void;
  109783. /** @hidden */
  109784. _unBindEffect(): void;
  109785. /** @hidden */
  109786. _removeLightSource(light: Light, dispose: boolean): void;
  109787. private _markSubMeshesAsDirty;
  109788. /** @hidden */
  109789. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  109790. /** @hidden */
  109791. _markSubMeshesAsAttributesDirty(): void;
  109792. /** @hidden */
  109793. _markSubMeshesAsMiscDirty(): void;
  109794. /**
  109795. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  109796. */
  109797. get scaling(): Vector3;
  109798. set scaling(newScaling: Vector3);
  109799. /**
  109800. * Returns true if the mesh is blocked. Implemented by child classes
  109801. */
  109802. get isBlocked(): boolean;
  109803. /**
  109804. * Returns the mesh itself by default. Implemented by child classes
  109805. * @param camera defines the camera to use to pick the right LOD level
  109806. * @returns the currentAbstractMesh
  109807. */
  109808. getLOD(camera: Camera): Nullable<AbstractMesh>;
  109809. /**
  109810. * Returns 0 by default. Implemented by child classes
  109811. * @returns an integer
  109812. */
  109813. getTotalVertices(): number;
  109814. /**
  109815. * Returns a positive integer : the total number of indices in this mesh geometry.
  109816. * @returns the numner of indices or zero if the mesh has no geometry.
  109817. */
  109818. getTotalIndices(): number;
  109819. /**
  109820. * Returns null by default. Implemented by child classes
  109821. * @returns null
  109822. */
  109823. getIndices(): Nullable<IndicesArray>;
  109824. /**
  109825. * Returns the array of the requested vertex data kind. Implemented by child classes
  109826. * @param kind defines the vertex data kind to use
  109827. * @returns null
  109828. */
  109829. getVerticesData(kind: string): Nullable<FloatArray>;
  109830. /**
  109831. * Sets the vertex data of the mesh geometry for the requested `kind`.
  109832. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  109833. * Note that a new underlying VertexBuffer object is created each call.
  109834. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  109835. * @param kind defines vertex data kind:
  109836. * * VertexBuffer.PositionKind
  109837. * * VertexBuffer.UVKind
  109838. * * VertexBuffer.UV2Kind
  109839. * * VertexBuffer.UV3Kind
  109840. * * VertexBuffer.UV4Kind
  109841. * * VertexBuffer.UV5Kind
  109842. * * VertexBuffer.UV6Kind
  109843. * * VertexBuffer.ColorKind
  109844. * * VertexBuffer.MatricesIndicesKind
  109845. * * VertexBuffer.MatricesIndicesExtraKind
  109846. * * VertexBuffer.MatricesWeightsKind
  109847. * * VertexBuffer.MatricesWeightsExtraKind
  109848. * @param data defines the data source
  109849. * @param updatable defines if the data must be flagged as updatable (or static)
  109850. * @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
  109851. * @returns the current mesh
  109852. */
  109853. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109854. /**
  109855. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  109856. * If the mesh has no geometry, it is simply returned as it is.
  109857. * @param kind defines vertex data kind:
  109858. * * VertexBuffer.PositionKind
  109859. * * VertexBuffer.UVKind
  109860. * * VertexBuffer.UV2Kind
  109861. * * VertexBuffer.UV3Kind
  109862. * * VertexBuffer.UV4Kind
  109863. * * VertexBuffer.UV5Kind
  109864. * * VertexBuffer.UV6Kind
  109865. * * VertexBuffer.ColorKind
  109866. * * VertexBuffer.MatricesIndicesKind
  109867. * * VertexBuffer.MatricesIndicesExtraKind
  109868. * * VertexBuffer.MatricesWeightsKind
  109869. * * VertexBuffer.MatricesWeightsExtraKind
  109870. * @param data defines the data source
  109871. * @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
  109872. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  109873. * @returns the current mesh
  109874. */
  109875. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109876. /**
  109877. * Sets the mesh indices,
  109878. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  109879. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  109880. * @param totalVertices Defines the total number of vertices
  109881. * @returns the current mesh
  109882. */
  109883. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  109884. /**
  109885. * Gets a boolean indicating if specific vertex data is present
  109886. * @param kind defines the vertex data kind to use
  109887. * @returns true is data kind is present
  109888. */
  109889. isVerticesDataPresent(kind: string): boolean;
  109890. /**
  109891. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  109892. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  109893. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  109894. * @returns a BoundingInfo
  109895. */
  109896. getBoundingInfo(): BoundingInfo;
  109897. /**
  109898. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  109899. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  109900. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  109901. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  109902. * @returns the current mesh
  109903. */
  109904. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  109905. /**
  109906. * Overwrite the current bounding info
  109907. * @param boundingInfo defines the new bounding info
  109908. * @returns the current mesh
  109909. */
  109910. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  109911. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  109912. get useBones(): boolean;
  109913. /** @hidden */
  109914. _preActivate(): void;
  109915. /** @hidden */
  109916. _preActivateForIntermediateRendering(renderId: number): void;
  109917. /** @hidden */
  109918. _activate(renderId: number, intermediateRendering: boolean): boolean;
  109919. /** @hidden */
  109920. _postActivate(): void;
  109921. /** @hidden */
  109922. _freeze(): void;
  109923. /** @hidden */
  109924. _unFreeze(): void;
  109925. /**
  109926. * Gets the current world matrix
  109927. * @returns a Matrix
  109928. */
  109929. getWorldMatrix(): Matrix;
  109930. /** @hidden */
  109931. _getWorldMatrixDeterminant(): number;
  109932. /**
  109933. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  109934. */
  109935. get isAnInstance(): boolean;
  109936. /**
  109937. * Gets a boolean indicating if this mesh has instances
  109938. */
  109939. get hasInstances(): boolean;
  109940. /**
  109941. * Gets a boolean indicating if this mesh has thin instances
  109942. */
  109943. get hasThinInstances(): boolean;
  109944. /**
  109945. * Perform relative position change from the point of view of behind the front of the mesh.
  109946. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109947. * Supports definition of mesh facing forward or backward
  109948. * @param amountRight defines the distance on the right axis
  109949. * @param amountUp defines the distance on the up axis
  109950. * @param amountForward defines the distance on the forward axis
  109951. * @returns the current mesh
  109952. */
  109953. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  109954. /**
  109955. * Calculate relative position change from the point of view of behind the front of the mesh.
  109956. * This is performed taking into account the meshes current rotation, so you do not have to care.
  109957. * Supports definition of mesh facing forward or backward
  109958. * @param amountRight defines the distance on the right axis
  109959. * @param amountUp defines the distance on the up axis
  109960. * @param amountForward defines the distance on the forward axis
  109961. * @returns the new displacement vector
  109962. */
  109963. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  109964. /**
  109965. * Perform relative rotation change from the point of view of behind the front of the mesh.
  109966. * Supports definition of mesh facing forward or backward
  109967. * @param flipBack defines the flip
  109968. * @param twirlClockwise defines the twirl
  109969. * @param tiltRight defines the tilt
  109970. * @returns the current mesh
  109971. */
  109972. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  109973. /**
  109974. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  109975. * Supports definition of mesh facing forward or backward.
  109976. * @param flipBack defines the flip
  109977. * @param twirlClockwise defines the twirl
  109978. * @param tiltRight defines the tilt
  109979. * @returns the new rotation vector
  109980. */
  109981. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  109982. /**
  109983. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109984. * This means the mesh underlying bounding box and sphere are recomputed.
  109985. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109986. * @returns the current mesh
  109987. */
  109988. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  109989. /** @hidden */
  109990. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  109991. /** @hidden */
  109992. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  109993. /** @hidden */
  109994. _updateBoundingInfo(): AbstractMesh;
  109995. /** @hidden */
  109996. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  109997. /** @hidden */
  109998. protected _afterComputeWorldMatrix(): void;
  109999. /** @hidden */
  110000. get _effectiveMesh(): AbstractMesh;
  110001. /**
  110002. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  110003. * A mesh is in the frustum if its bounding box intersects the frustum
  110004. * @param frustumPlanes defines the frustum to test
  110005. * @returns true if the mesh is in the frustum planes
  110006. */
  110007. isInFrustum(frustumPlanes: Plane[]): boolean;
  110008. /**
  110009. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  110010. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  110011. * @param frustumPlanes defines the frustum to test
  110012. * @returns true if the mesh is completely in the frustum planes
  110013. */
  110014. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  110015. /**
  110016. * True if the mesh intersects another mesh or a SolidParticle object
  110017. * @param mesh defines a target mesh or SolidParticle to test
  110018. * @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)
  110019. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  110020. * @returns true if there is an intersection
  110021. */
  110022. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  110023. /**
  110024. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  110025. * @param point defines the point to test
  110026. * @returns true if there is an intersection
  110027. */
  110028. intersectsPoint(point: Vector3): boolean;
  110029. /**
  110030. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  110031. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110032. */
  110033. get checkCollisions(): boolean;
  110034. set checkCollisions(collisionEnabled: boolean);
  110035. /**
  110036. * Gets Collider object used to compute collisions (not physics)
  110037. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110038. */
  110039. get collider(): Nullable<Collider>;
  110040. /**
  110041. * Move the mesh using collision engine
  110042. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110043. * @param displacement defines the requested displacement vector
  110044. * @returns the current mesh
  110045. */
  110046. moveWithCollisions(displacement: Vector3): AbstractMesh;
  110047. private _onCollisionPositionChange;
  110048. /** @hidden */
  110049. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  110050. /** @hidden */
  110051. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  110052. /** @hidden */
  110053. _checkCollision(collider: Collider): AbstractMesh;
  110054. /** @hidden */
  110055. _generatePointsArray(): boolean;
  110056. /**
  110057. * Checks if the passed Ray intersects with the mesh
  110058. * @param ray defines the ray to use
  110059. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  110060. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110061. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  110062. * @returns the picking info
  110063. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  110064. */
  110065. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean): PickingInfo;
  110066. /**
  110067. * Clones the current mesh
  110068. * @param name defines the mesh name
  110069. * @param newParent defines the new mesh parent
  110070. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  110071. * @returns the new mesh
  110072. */
  110073. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  110074. /**
  110075. * Disposes all the submeshes of the current meshnp
  110076. * @returns the current mesh
  110077. */
  110078. releaseSubMeshes(): AbstractMesh;
  110079. /**
  110080. * Releases resources associated with this abstract mesh.
  110081. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110082. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110083. */
  110084. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110085. /**
  110086. * Adds the passed mesh as a child to the current mesh
  110087. * @param mesh defines the child mesh
  110088. * @returns the current mesh
  110089. */
  110090. addChild(mesh: AbstractMesh): AbstractMesh;
  110091. /**
  110092. * Removes the passed mesh from the current mesh children list
  110093. * @param mesh defines the child mesh
  110094. * @returns the current mesh
  110095. */
  110096. removeChild(mesh: AbstractMesh): AbstractMesh;
  110097. /** @hidden */
  110098. private _initFacetData;
  110099. /**
  110100. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  110101. * This method can be called within the render loop.
  110102. * 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
  110103. * @returns the current mesh
  110104. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110105. */
  110106. updateFacetData(): AbstractMesh;
  110107. /**
  110108. * Returns the facetLocalNormals array.
  110109. * The normals are expressed in the mesh local spac
  110110. * @returns an array of Vector3
  110111. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110112. */
  110113. getFacetLocalNormals(): Vector3[];
  110114. /**
  110115. * Returns the facetLocalPositions array.
  110116. * The facet positions are expressed in the mesh local space
  110117. * @returns an array of Vector3
  110118. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110119. */
  110120. getFacetLocalPositions(): Vector3[];
  110121. /**
  110122. * Returns the facetLocalPartioning array
  110123. * @returns an array of array of numbers
  110124. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110125. */
  110126. getFacetLocalPartitioning(): number[][];
  110127. /**
  110128. * Returns the i-th facet position in the world system.
  110129. * This method allocates a new Vector3 per call
  110130. * @param i defines the facet index
  110131. * @returns a new Vector3
  110132. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110133. */
  110134. getFacetPosition(i: number): Vector3;
  110135. /**
  110136. * Sets the reference Vector3 with the i-th facet position in the world system
  110137. * @param i defines the facet index
  110138. * @param ref defines the target vector
  110139. * @returns the current mesh
  110140. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110141. */
  110142. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  110143. /**
  110144. * Returns the i-th facet normal in the world system.
  110145. * This method allocates a new Vector3 per call
  110146. * @param i defines the facet index
  110147. * @returns a new Vector3
  110148. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110149. */
  110150. getFacetNormal(i: number): Vector3;
  110151. /**
  110152. * Sets the reference Vector3 with the i-th facet normal in the world system
  110153. * @param i defines the facet index
  110154. * @param ref defines the target vector
  110155. * @returns the current mesh
  110156. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110157. */
  110158. getFacetNormalToRef(i: number, ref: Vector3): this;
  110159. /**
  110160. * 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)
  110161. * @param x defines x coordinate
  110162. * @param y defines y coordinate
  110163. * @param z defines z coordinate
  110164. * @returns the array of facet indexes
  110165. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110166. */
  110167. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  110168. /**
  110169. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  110170. * @param projected sets as the (x,y,z) world projection on the facet
  110171. * @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
  110172. * @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
  110173. * @param x defines x coordinate
  110174. * @param y defines y coordinate
  110175. * @param z defines z coordinate
  110176. * @returns the face index if found (or null instead)
  110177. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110178. */
  110179. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  110180. /**
  110181. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  110182. * @param projected sets as the (x,y,z) local projection on the facet
  110183. * @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
  110184. * @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
  110185. * @param x defines x coordinate
  110186. * @param y defines y coordinate
  110187. * @param z defines z coordinate
  110188. * @returns the face index if found (or null instead)
  110189. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110190. */
  110191. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  110192. /**
  110193. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  110194. * @returns the parameters
  110195. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110196. */
  110197. getFacetDataParameters(): any;
  110198. /**
  110199. * Disables the feature FacetData and frees the related memory
  110200. * @returns the current mesh
  110201. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  110202. */
  110203. disableFacetData(): AbstractMesh;
  110204. /**
  110205. * Updates the AbstractMesh indices array
  110206. * @param indices defines the data source
  110207. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  110208. * @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)
  110209. * @returns the current mesh
  110210. */
  110211. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  110212. /**
  110213. * Creates new normals data for the mesh
  110214. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  110215. * @returns the current mesh
  110216. */
  110217. createNormals(updatable: boolean): AbstractMesh;
  110218. /**
  110219. * Align the mesh with a normal
  110220. * @param normal defines the normal to use
  110221. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  110222. * @returns the current mesh
  110223. */
  110224. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  110225. /** @hidden */
  110226. _checkOcclusionQuery(): boolean;
  110227. /**
  110228. * Disables the mesh edge rendering mode
  110229. * @returns the currentAbstractMesh
  110230. */
  110231. disableEdgesRendering(): AbstractMesh;
  110232. /**
  110233. * Enables the edge rendering mode on the mesh.
  110234. * This mode makes the mesh edges visible
  110235. * @param epsilon defines the maximal distance between two angles to detect a face
  110236. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  110237. * @returns the currentAbstractMesh
  110238. * @see https://www.babylonjs-playground.com/#19O9TU#0
  110239. */
  110240. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  110241. /**
  110242. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  110243. * @returns an array of particle systems in the scene that use the mesh as an emitter
  110244. */
  110245. getConnectedParticleSystems(): IParticleSystem[];
  110246. }
  110247. }
  110248. declare module BABYLON {
  110249. /**
  110250. * Interface used to define ActionEvent
  110251. */
  110252. export interface IActionEvent {
  110253. /** The mesh or sprite that triggered the action */
  110254. source: any;
  110255. /** The X mouse cursor position at the time of the event */
  110256. pointerX: number;
  110257. /** The Y mouse cursor position at the time of the event */
  110258. pointerY: number;
  110259. /** The mesh that is currently pointed at (can be null) */
  110260. meshUnderPointer: Nullable<AbstractMesh>;
  110261. /** the original (browser) event that triggered the ActionEvent */
  110262. sourceEvent?: any;
  110263. /** additional data for the event */
  110264. additionalData?: any;
  110265. }
  110266. /**
  110267. * ActionEvent is the event being sent when an action is triggered.
  110268. */
  110269. export class ActionEvent implements IActionEvent {
  110270. /** The mesh or sprite that triggered the action */
  110271. source: any;
  110272. /** The X mouse cursor position at the time of the event */
  110273. pointerX: number;
  110274. /** The Y mouse cursor position at the time of the event */
  110275. pointerY: number;
  110276. /** The mesh that is currently pointed at (can be null) */
  110277. meshUnderPointer: Nullable<AbstractMesh>;
  110278. /** the original (browser) event that triggered the ActionEvent */
  110279. sourceEvent?: any;
  110280. /** additional data for the event */
  110281. additionalData?: any;
  110282. /**
  110283. * Creates a new ActionEvent
  110284. * @param source The mesh or sprite that triggered the action
  110285. * @param pointerX The X mouse cursor position at the time of the event
  110286. * @param pointerY The Y mouse cursor position at the time of the event
  110287. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  110288. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  110289. * @param additionalData additional data for the event
  110290. */
  110291. constructor(
  110292. /** The mesh or sprite that triggered the action */
  110293. source: any,
  110294. /** The X mouse cursor position at the time of the event */
  110295. pointerX: number,
  110296. /** The Y mouse cursor position at the time of the event */
  110297. pointerY: number,
  110298. /** The mesh that is currently pointed at (can be null) */
  110299. meshUnderPointer: Nullable<AbstractMesh>,
  110300. /** the original (browser) event that triggered the ActionEvent */
  110301. sourceEvent?: any,
  110302. /** additional data for the event */
  110303. additionalData?: any);
  110304. /**
  110305. * Helper function to auto-create an ActionEvent from a source mesh.
  110306. * @param source The source mesh that triggered the event
  110307. * @param evt The original (browser) event
  110308. * @param additionalData additional data for the event
  110309. * @returns the new ActionEvent
  110310. */
  110311. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  110312. /**
  110313. * Helper function to auto-create an ActionEvent from a source sprite
  110314. * @param source The source sprite that triggered the event
  110315. * @param scene Scene associated with the sprite
  110316. * @param evt The original (browser) event
  110317. * @param additionalData additional data for the event
  110318. * @returns the new ActionEvent
  110319. */
  110320. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  110321. /**
  110322. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  110323. * @param scene the scene where the event occurred
  110324. * @param evt The original (browser) event
  110325. * @returns the new ActionEvent
  110326. */
  110327. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  110328. /**
  110329. * Helper function to auto-create an ActionEvent from a primitive
  110330. * @param prim defines the target primitive
  110331. * @param pointerPos defines the pointer position
  110332. * @param evt The original (browser) event
  110333. * @param additionalData additional data for the event
  110334. * @returns the new ActionEvent
  110335. */
  110336. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  110337. }
  110338. }
  110339. declare module BABYLON {
  110340. /**
  110341. * Abstract class used to decouple action Manager from scene and meshes.
  110342. * Do not instantiate.
  110343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  110344. */
  110345. export abstract class AbstractActionManager implements IDisposable {
  110346. /** Gets the list of active triggers */
  110347. static Triggers: {
  110348. [key: string]: number;
  110349. };
  110350. /** Gets the cursor to use when hovering items */
  110351. hoverCursor: string;
  110352. /** Gets the list of actions */
  110353. actions: IAction[];
  110354. /**
  110355. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  110356. */
  110357. isRecursive: boolean;
  110358. /**
  110359. * Releases all associated resources
  110360. */
  110361. abstract dispose(): void;
  110362. /**
  110363. * Does this action manager has pointer triggers
  110364. */
  110365. abstract get hasPointerTriggers(): boolean;
  110366. /**
  110367. * Does this action manager has pick triggers
  110368. */
  110369. abstract get hasPickTriggers(): boolean;
  110370. /**
  110371. * Process a specific trigger
  110372. * @param trigger defines the trigger to process
  110373. * @param evt defines the event details to be processed
  110374. */
  110375. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  110376. /**
  110377. * Does this action manager handles actions of any of the given triggers
  110378. * @param triggers defines the triggers to be tested
  110379. * @return a boolean indicating whether one (or more) of the triggers is handled
  110380. */
  110381. abstract hasSpecificTriggers(triggers: number[]): boolean;
  110382. /**
  110383. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  110384. * speed.
  110385. * @param triggerA defines the trigger to be tested
  110386. * @param triggerB defines the trigger to be tested
  110387. * @return a boolean indicating whether one (or more) of the triggers is handled
  110388. */
  110389. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  110390. /**
  110391. * Does this action manager handles actions of a given trigger
  110392. * @param trigger defines the trigger to be tested
  110393. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  110394. * @return whether the trigger is handled
  110395. */
  110396. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  110397. /**
  110398. * Serialize this manager to a JSON object
  110399. * @param name defines the property name to store this manager
  110400. * @returns a JSON representation of this manager
  110401. */
  110402. abstract serialize(name: string): any;
  110403. /**
  110404. * Registers an action to this action manager
  110405. * @param action defines the action to be registered
  110406. * @return the action amended (prepared) after registration
  110407. */
  110408. abstract registerAction(action: IAction): Nullable<IAction>;
  110409. /**
  110410. * Unregisters an action to this action manager
  110411. * @param action defines the action to be unregistered
  110412. * @return a boolean indicating whether the action has been unregistered
  110413. */
  110414. abstract unregisterAction(action: IAction): Boolean;
  110415. /**
  110416. * Does exist one action manager with at least one trigger
  110417. **/
  110418. static get HasTriggers(): boolean;
  110419. /**
  110420. * Does exist one action manager with at least one pick trigger
  110421. **/
  110422. static get HasPickTriggers(): boolean;
  110423. /**
  110424. * Does exist one action manager that handles actions of a given trigger
  110425. * @param trigger defines the trigger to be tested
  110426. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  110427. **/
  110428. static HasSpecificTrigger(trigger: number): boolean;
  110429. }
  110430. }
  110431. declare module BABYLON {
  110432. /**
  110433. * Defines how a node can be built from a string name.
  110434. */
  110435. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  110436. /**
  110437. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  110438. */
  110439. export class Node implements IBehaviorAware<Node> {
  110440. /** @hidden */
  110441. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  110442. private static _NodeConstructors;
  110443. /**
  110444. * Add a new node constructor
  110445. * @param type defines the type name of the node to construct
  110446. * @param constructorFunc defines the constructor function
  110447. */
  110448. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  110449. /**
  110450. * Returns a node constructor based on type name
  110451. * @param type defines the type name
  110452. * @param name defines the new node name
  110453. * @param scene defines the hosting scene
  110454. * @param options defines optional options to transmit to constructors
  110455. * @returns the new constructor or null
  110456. */
  110457. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  110458. /**
  110459. * Gets or sets the name of the node
  110460. */
  110461. name: string;
  110462. /**
  110463. * Gets or sets the id of the node
  110464. */
  110465. id: string;
  110466. /**
  110467. * Gets or sets the unique id of the node
  110468. */
  110469. uniqueId: number;
  110470. /**
  110471. * Gets or sets a string used to store user defined state for the node
  110472. */
  110473. state: string;
  110474. /**
  110475. * Gets or sets an object used to store user defined information for the node
  110476. */
  110477. metadata: any;
  110478. /**
  110479. * For internal use only. Please do not use.
  110480. */
  110481. reservedDataStore: any;
  110482. /**
  110483. * List of inspectable custom properties (used by the Inspector)
  110484. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  110485. */
  110486. inspectableCustomProperties: IInspectable[];
  110487. private _doNotSerialize;
  110488. /**
  110489. * Gets or sets a boolean used to define if the node must be serialized
  110490. */
  110491. get doNotSerialize(): boolean;
  110492. set doNotSerialize(value: boolean);
  110493. /** @hidden */
  110494. _isDisposed: boolean;
  110495. /**
  110496. * Gets a list of Animations associated with the node
  110497. */
  110498. animations: Animation[];
  110499. protected _ranges: {
  110500. [name: string]: Nullable<AnimationRange>;
  110501. };
  110502. /**
  110503. * Callback raised when the node is ready to be used
  110504. */
  110505. onReady: Nullable<(node: Node) => void>;
  110506. private _isEnabled;
  110507. private _isParentEnabled;
  110508. private _isReady;
  110509. /** @hidden */
  110510. _currentRenderId: number;
  110511. private _parentUpdateId;
  110512. /** @hidden */
  110513. _childUpdateId: number;
  110514. /** @hidden */
  110515. _waitingParentId: Nullable<string>;
  110516. /** @hidden */
  110517. _scene: Scene;
  110518. /** @hidden */
  110519. _cache: any;
  110520. private _parentNode;
  110521. private _children;
  110522. /** @hidden */
  110523. _worldMatrix: Matrix;
  110524. /** @hidden */
  110525. _worldMatrixDeterminant: number;
  110526. /** @hidden */
  110527. _worldMatrixDeterminantIsDirty: boolean;
  110528. /** @hidden */
  110529. private _sceneRootNodesIndex;
  110530. /**
  110531. * Gets a boolean indicating if the node has been disposed
  110532. * @returns true if the node was disposed
  110533. */
  110534. isDisposed(): boolean;
  110535. /**
  110536. * Gets or sets the parent of the node (without keeping the current position in the scene)
  110537. * @see https://doc.babylonjs.com/how_to/parenting
  110538. */
  110539. set parent(parent: Nullable<Node>);
  110540. get parent(): Nullable<Node>;
  110541. /** @hidden */
  110542. _addToSceneRootNodes(): void;
  110543. /** @hidden */
  110544. _removeFromSceneRootNodes(): void;
  110545. private _animationPropertiesOverride;
  110546. /**
  110547. * Gets or sets the animation properties override
  110548. */
  110549. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  110550. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  110551. /**
  110552. * Gets a string idenfifying the name of the class
  110553. * @returns "Node" string
  110554. */
  110555. getClassName(): string;
  110556. /** @hidden */
  110557. readonly _isNode: boolean;
  110558. /**
  110559. * An event triggered when the mesh is disposed
  110560. */
  110561. onDisposeObservable: Observable<Node>;
  110562. private _onDisposeObserver;
  110563. /**
  110564. * Sets a callback that will be raised when the node will be disposed
  110565. */
  110566. set onDispose(callback: () => void);
  110567. /**
  110568. * Creates a new Node
  110569. * @param name the name and id to be given to this node
  110570. * @param scene the scene this node will be added to
  110571. */
  110572. constructor(name: string, scene?: Nullable<Scene>);
  110573. /**
  110574. * Gets the scene of the node
  110575. * @returns a scene
  110576. */
  110577. getScene(): Scene;
  110578. /**
  110579. * Gets the engine of the node
  110580. * @returns a Engine
  110581. */
  110582. getEngine(): Engine;
  110583. private _behaviors;
  110584. /**
  110585. * Attach a behavior to the node
  110586. * @see https://doc.babylonjs.com/features/behaviour
  110587. * @param behavior defines the behavior to attach
  110588. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  110589. * @returns the current Node
  110590. */
  110591. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  110592. /**
  110593. * Remove an attached behavior
  110594. * @see https://doc.babylonjs.com/features/behaviour
  110595. * @param behavior defines the behavior to attach
  110596. * @returns the current Node
  110597. */
  110598. removeBehavior(behavior: Behavior<Node>): Node;
  110599. /**
  110600. * Gets the list of attached behaviors
  110601. * @see https://doc.babylonjs.com/features/behaviour
  110602. */
  110603. get behaviors(): Behavior<Node>[];
  110604. /**
  110605. * Gets an attached behavior by name
  110606. * @param name defines the name of the behavior to look for
  110607. * @see https://doc.babylonjs.com/features/behaviour
  110608. * @returns null if behavior was not found else the requested behavior
  110609. */
  110610. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  110611. /**
  110612. * Returns the latest update of the World matrix
  110613. * @returns a Matrix
  110614. */
  110615. getWorldMatrix(): Matrix;
  110616. /** @hidden */
  110617. _getWorldMatrixDeterminant(): number;
  110618. /**
  110619. * Returns directly the latest state of the mesh World matrix.
  110620. * A Matrix is returned.
  110621. */
  110622. get worldMatrixFromCache(): Matrix;
  110623. /** @hidden */
  110624. _initCache(): void;
  110625. /** @hidden */
  110626. updateCache(force?: boolean): void;
  110627. /** @hidden */
  110628. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  110629. /** @hidden */
  110630. _updateCache(ignoreParentClass?: boolean): void;
  110631. /** @hidden */
  110632. _isSynchronized(): boolean;
  110633. /** @hidden */
  110634. _markSyncedWithParent(): void;
  110635. /** @hidden */
  110636. isSynchronizedWithParent(): boolean;
  110637. /** @hidden */
  110638. isSynchronized(): boolean;
  110639. /**
  110640. * Is this node ready to be used/rendered
  110641. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  110642. * @return true if the node is ready
  110643. */
  110644. isReady(completeCheck?: boolean): boolean;
  110645. /**
  110646. * Is this node enabled?
  110647. * 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
  110648. * @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
  110649. * @return whether this node (and its parent) is enabled
  110650. */
  110651. isEnabled(checkAncestors?: boolean): boolean;
  110652. /** @hidden */
  110653. protected _syncParentEnabledState(): void;
  110654. /**
  110655. * Set the enabled state of this node
  110656. * @param value defines the new enabled state
  110657. */
  110658. setEnabled(value: boolean): void;
  110659. /**
  110660. * Is this node a descendant of the given node?
  110661. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  110662. * @param ancestor defines the parent node to inspect
  110663. * @returns a boolean indicating if this node is a descendant of the given node
  110664. */
  110665. isDescendantOf(ancestor: Node): boolean;
  110666. /** @hidden */
  110667. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  110668. /**
  110669. * Will return all nodes that have this node as ascendant
  110670. * @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
  110671. * @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
  110672. * @return all children nodes of all types
  110673. */
  110674. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  110675. /**
  110676. * Get all child-meshes of this node
  110677. * @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)
  110678. * @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
  110679. * @returns an array of AbstractMesh
  110680. */
  110681. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  110682. /**
  110683. * Get all direct children of this node
  110684. * @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
  110685. * @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)
  110686. * @returns an array of Node
  110687. */
  110688. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  110689. /** @hidden */
  110690. _setReady(state: boolean): void;
  110691. /**
  110692. * Get an animation by name
  110693. * @param name defines the name of the animation to look for
  110694. * @returns null if not found else the requested animation
  110695. */
  110696. getAnimationByName(name: string): Nullable<Animation>;
  110697. /**
  110698. * Creates an animation range for this node
  110699. * @param name defines the name of the range
  110700. * @param from defines the starting key
  110701. * @param to defines the end key
  110702. */
  110703. createAnimationRange(name: string, from: number, to: number): void;
  110704. /**
  110705. * Delete a specific animation range
  110706. * @param name defines the name of the range to delete
  110707. * @param deleteFrames defines if animation frames from the range must be deleted as well
  110708. */
  110709. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  110710. /**
  110711. * Get an animation range by name
  110712. * @param name defines the name of the animation range to look for
  110713. * @returns null if not found else the requested animation range
  110714. */
  110715. getAnimationRange(name: string): Nullable<AnimationRange>;
  110716. /**
  110717. * Gets the list of all animation ranges defined on this node
  110718. * @returns an array
  110719. */
  110720. getAnimationRanges(): Nullable<AnimationRange>[];
  110721. /**
  110722. * Will start the animation sequence
  110723. * @param name defines the range frames for animation sequence
  110724. * @param loop defines if the animation should loop (false by default)
  110725. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  110726. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  110727. * @returns the object created for this animation. If range does not exist, it will return null
  110728. */
  110729. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  110730. /**
  110731. * Serialize animation ranges into a JSON compatible object
  110732. * @returns serialization object
  110733. */
  110734. serializeAnimationRanges(): any;
  110735. /**
  110736. * Computes the world matrix of the node
  110737. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  110738. * @returns the world matrix
  110739. */
  110740. computeWorldMatrix(force?: boolean): Matrix;
  110741. /**
  110742. * Releases resources associated with this node.
  110743. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110744. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110745. */
  110746. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110747. /**
  110748. * Parse animation range data from a serialization object and store them into a given node
  110749. * @param node defines where to store the animation ranges
  110750. * @param parsedNode defines the serialization object to read data from
  110751. * @param scene defines the hosting scene
  110752. */
  110753. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  110754. /**
  110755. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  110756. * @param includeDescendants Include bounding info from descendants as well (true by default)
  110757. * @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
  110758. * @returns the new bounding vectors
  110759. */
  110760. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  110761. min: Vector3;
  110762. max: Vector3;
  110763. };
  110764. }
  110765. }
  110766. declare module BABYLON {
  110767. /**
  110768. * @hidden
  110769. */
  110770. export class _IAnimationState {
  110771. key: number;
  110772. repeatCount: number;
  110773. workValue?: any;
  110774. loopMode?: number;
  110775. offsetValue?: any;
  110776. highLimitValue?: any;
  110777. }
  110778. /**
  110779. * Class used to store any kind of animation
  110780. */
  110781. export class Animation {
  110782. /**Name of the animation */
  110783. name: string;
  110784. /**Property to animate */
  110785. targetProperty: string;
  110786. /**The frames per second of the animation */
  110787. framePerSecond: number;
  110788. /**The data type of the animation */
  110789. dataType: number;
  110790. /**The loop mode of the animation */
  110791. loopMode?: number | undefined;
  110792. /**Specifies if blending should be enabled */
  110793. enableBlending?: boolean | undefined;
  110794. /**
  110795. * Use matrix interpolation instead of using direct key value when animating matrices
  110796. */
  110797. static AllowMatricesInterpolation: boolean;
  110798. /**
  110799. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  110800. */
  110801. static AllowMatrixDecomposeForInterpolation: boolean;
  110802. /** Define the Url to load snippets */
  110803. static SnippetUrl: string;
  110804. /** Snippet ID if the animation was created from the snippet server */
  110805. snippetId: string;
  110806. /**
  110807. * Stores the key frames of the animation
  110808. */
  110809. private _keys;
  110810. /**
  110811. * Stores the easing function of the animation
  110812. */
  110813. private _easingFunction;
  110814. /**
  110815. * @hidden Internal use only
  110816. */
  110817. _runtimeAnimations: RuntimeAnimation[];
  110818. /**
  110819. * The set of event that will be linked to this animation
  110820. */
  110821. private _events;
  110822. /**
  110823. * Stores an array of target property paths
  110824. */
  110825. targetPropertyPath: string[];
  110826. /**
  110827. * Stores the blending speed of the animation
  110828. */
  110829. blendingSpeed: number;
  110830. /**
  110831. * Stores the animation ranges for the animation
  110832. */
  110833. private _ranges;
  110834. /**
  110835. * @hidden Internal use
  110836. */
  110837. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  110838. /**
  110839. * Sets up an animation
  110840. * @param property The property to animate
  110841. * @param animationType The animation type to apply
  110842. * @param framePerSecond The frames per second of the animation
  110843. * @param easingFunction The easing function used in the animation
  110844. * @returns The created animation
  110845. */
  110846. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  110847. /**
  110848. * Create and start an animation on a node
  110849. * @param name defines the name of the global animation that will be run on all nodes
  110850. * @param node defines the root node where the animation will take place
  110851. * @param targetProperty defines property to animate
  110852. * @param framePerSecond defines the number of frame per second yo use
  110853. * @param totalFrame defines the number of frames in total
  110854. * @param from defines the initial value
  110855. * @param to defines the final value
  110856. * @param loopMode defines which loop mode you want to use (off by default)
  110857. * @param easingFunction defines the easing function to use (linear by default)
  110858. * @param onAnimationEnd defines the callback to call when animation end
  110859. * @returns the animatable created for this animation
  110860. */
  110861. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110862. /**
  110863. * Create and start an animation on a node and its descendants
  110864. * @param name defines the name of the global animation that will be run on all nodes
  110865. * @param node defines the root node where the animation will take place
  110866. * @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
  110867. * @param targetProperty defines property to animate
  110868. * @param framePerSecond defines the number of frame per second to use
  110869. * @param totalFrame defines the number of frames in total
  110870. * @param from defines the initial value
  110871. * @param to defines the final value
  110872. * @param loopMode defines which loop mode you want to use (off by default)
  110873. * @param easingFunction defines the easing function to use (linear by default)
  110874. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  110875. * @returns the list of animatables created for all nodes
  110876. * @example https://www.babylonjs-playground.com/#MH0VLI
  110877. */
  110878. 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[]>;
  110879. /**
  110880. * Creates a new animation, merges it with the existing animations and starts it
  110881. * @param name Name of the animation
  110882. * @param node Node which contains the scene that begins the animations
  110883. * @param targetProperty Specifies which property to animate
  110884. * @param framePerSecond The frames per second of the animation
  110885. * @param totalFrame The total number of frames
  110886. * @param from The frame at the beginning of the animation
  110887. * @param to The frame at the end of the animation
  110888. * @param loopMode Specifies the loop mode of the animation
  110889. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  110890. * @param onAnimationEnd Callback to run once the animation is complete
  110891. * @returns Nullable animation
  110892. */
  110893. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  110894. /**
  110895. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  110896. * @param sourceAnimation defines the Animation containing keyframes to convert
  110897. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  110898. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  110899. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  110900. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  110901. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  110902. */
  110903. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  110904. /**
  110905. * Transition property of an host to the target Value
  110906. * @param property The property to transition
  110907. * @param targetValue The target Value of the property
  110908. * @param host The object where the property to animate belongs
  110909. * @param scene Scene used to run the animation
  110910. * @param frameRate Framerate (in frame/s) to use
  110911. * @param transition The transition type we want to use
  110912. * @param duration The duration of the animation, in milliseconds
  110913. * @param onAnimationEnd Callback trigger at the end of the animation
  110914. * @returns Nullable animation
  110915. */
  110916. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  110917. /**
  110918. * Return the array of runtime animations currently using this animation
  110919. */
  110920. get runtimeAnimations(): RuntimeAnimation[];
  110921. /**
  110922. * Specifies if any of the runtime animations are currently running
  110923. */
  110924. get hasRunningRuntimeAnimations(): boolean;
  110925. /**
  110926. * Initializes the animation
  110927. * @param name Name of the animation
  110928. * @param targetProperty Property to animate
  110929. * @param framePerSecond The frames per second of the animation
  110930. * @param dataType The data type of the animation
  110931. * @param loopMode The loop mode of the animation
  110932. * @param enableBlending Specifies if blending should be enabled
  110933. */
  110934. constructor(
  110935. /**Name of the animation */
  110936. name: string,
  110937. /**Property to animate */
  110938. targetProperty: string,
  110939. /**The frames per second of the animation */
  110940. framePerSecond: number,
  110941. /**The data type of the animation */
  110942. dataType: number,
  110943. /**The loop mode of the animation */
  110944. loopMode?: number | undefined,
  110945. /**Specifies if blending should be enabled */
  110946. enableBlending?: boolean | undefined);
  110947. /**
  110948. * Converts the animation to a string
  110949. * @param fullDetails support for multiple levels of logging within scene loading
  110950. * @returns String form of the animation
  110951. */
  110952. toString(fullDetails?: boolean): string;
  110953. /**
  110954. * Add an event to this animation
  110955. * @param event Event to add
  110956. */
  110957. addEvent(event: AnimationEvent): void;
  110958. /**
  110959. * Remove all events found at the given frame
  110960. * @param frame The frame to remove events from
  110961. */
  110962. removeEvents(frame: number): void;
  110963. /**
  110964. * Retrieves all the events from the animation
  110965. * @returns Events from the animation
  110966. */
  110967. getEvents(): AnimationEvent[];
  110968. /**
  110969. * Creates an animation range
  110970. * @param name Name of the animation range
  110971. * @param from Starting frame of the animation range
  110972. * @param to Ending frame of the animation
  110973. */
  110974. createRange(name: string, from: number, to: number): void;
  110975. /**
  110976. * Deletes an animation range by name
  110977. * @param name Name of the animation range to delete
  110978. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  110979. */
  110980. deleteRange(name: string, deleteFrames?: boolean): void;
  110981. /**
  110982. * Gets the animation range by name, or null if not defined
  110983. * @param name Name of the animation range
  110984. * @returns Nullable animation range
  110985. */
  110986. getRange(name: string): Nullable<AnimationRange>;
  110987. /**
  110988. * Gets the key frames from the animation
  110989. * @returns The key frames of the animation
  110990. */
  110991. getKeys(): Array<IAnimationKey>;
  110992. /**
  110993. * Gets the highest frame rate of the animation
  110994. * @returns Highest frame rate of the animation
  110995. */
  110996. getHighestFrame(): number;
  110997. /**
  110998. * Gets the easing function of the animation
  110999. * @returns Easing function of the animation
  111000. */
  111001. getEasingFunction(): IEasingFunction;
  111002. /**
  111003. * Sets the easing function of the animation
  111004. * @param easingFunction A custom mathematical formula for animation
  111005. */
  111006. setEasingFunction(easingFunction: EasingFunction): void;
  111007. /**
  111008. * Interpolates a scalar linearly
  111009. * @param startValue Start value of the animation curve
  111010. * @param endValue End value of the animation curve
  111011. * @param gradient Scalar amount to interpolate
  111012. * @returns Interpolated scalar value
  111013. */
  111014. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  111015. /**
  111016. * Interpolates a scalar cubically
  111017. * @param startValue Start value of the animation curve
  111018. * @param outTangent End tangent of the animation
  111019. * @param endValue End value of the animation curve
  111020. * @param inTangent Start tangent of the animation curve
  111021. * @param gradient Scalar amount to interpolate
  111022. * @returns Interpolated scalar value
  111023. */
  111024. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  111025. /**
  111026. * Interpolates a quaternion using a spherical linear interpolation
  111027. * @param startValue Start value of the animation curve
  111028. * @param endValue End value of the animation curve
  111029. * @param gradient Scalar amount to interpolate
  111030. * @returns Interpolated quaternion value
  111031. */
  111032. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  111033. /**
  111034. * Interpolates a quaternion cubically
  111035. * @param startValue Start value of the animation curve
  111036. * @param outTangent End tangent of the animation curve
  111037. * @param endValue End value of the animation curve
  111038. * @param inTangent Start tangent of the animation curve
  111039. * @param gradient Scalar amount to interpolate
  111040. * @returns Interpolated quaternion value
  111041. */
  111042. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  111043. /**
  111044. * Interpolates a Vector3 linearl
  111045. * @param startValue Start value of the animation curve
  111046. * @param endValue End value of the animation curve
  111047. * @param gradient Scalar amount to interpolate
  111048. * @returns Interpolated scalar value
  111049. */
  111050. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  111051. /**
  111052. * Interpolates a Vector3 cubically
  111053. * @param startValue Start value of the animation curve
  111054. * @param outTangent End tangent of the animation
  111055. * @param endValue End value of the animation curve
  111056. * @param inTangent Start tangent of the animation curve
  111057. * @param gradient Scalar amount to interpolate
  111058. * @returns InterpolatedVector3 value
  111059. */
  111060. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  111061. /**
  111062. * Interpolates a Vector2 linearly
  111063. * @param startValue Start value of the animation curve
  111064. * @param endValue End value of the animation curve
  111065. * @param gradient Scalar amount to interpolate
  111066. * @returns Interpolated Vector2 value
  111067. */
  111068. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  111069. /**
  111070. * Interpolates a Vector2 cubically
  111071. * @param startValue Start value of the animation curve
  111072. * @param outTangent End tangent of the animation
  111073. * @param endValue End value of the animation curve
  111074. * @param inTangent Start tangent of the animation curve
  111075. * @param gradient Scalar amount to interpolate
  111076. * @returns Interpolated Vector2 value
  111077. */
  111078. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  111079. /**
  111080. * Interpolates a size linearly
  111081. * @param startValue Start value of the animation curve
  111082. * @param endValue End value of the animation curve
  111083. * @param gradient Scalar amount to interpolate
  111084. * @returns Interpolated Size value
  111085. */
  111086. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  111087. /**
  111088. * Interpolates a Color3 linearly
  111089. * @param startValue Start value of the animation curve
  111090. * @param endValue End value of the animation curve
  111091. * @param gradient Scalar amount to interpolate
  111092. * @returns Interpolated Color3 value
  111093. */
  111094. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  111095. /**
  111096. * Interpolates a Color4 linearly
  111097. * @param startValue Start value of the animation curve
  111098. * @param endValue End value of the animation curve
  111099. * @param gradient Scalar amount to interpolate
  111100. * @returns Interpolated Color3 value
  111101. */
  111102. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  111103. /**
  111104. * @hidden Internal use only
  111105. */
  111106. _getKeyValue(value: any): any;
  111107. /**
  111108. * @hidden Internal use only
  111109. */
  111110. _interpolate(currentFrame: number, state: _IAnimationState): any;
  111111. /**
  111112. * Defines the function to use to interpolate matrices
  111113. * @param startValue defines the start matrix
  111114. * @param endValue defines the end matrix
  111115. * @param gradient defines the gradient between both matrices
  111116. * @param result defines an optional target matrix where to store the interpolation
  111117. * @returns the interpolated matrix
  111118. */
  111119. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  111120. /**
  111121. * Makes a copy of the animation
  111122. * @returns Cloned animation
  111123. */
  111124. clone(): Animation;
  111125. /**
  111126. * Sets the key frames of the animation
  111127. * @param values The animation key frames to set
  111128. */
  111129. setKeys(values: Array<IAnimationKey>): void;
  111130. /**
  111131. * Serializes the animation to an object
  111132. * @returns Serialized object
  111133. */
  111134. serialize(): any;
  111135. /**
  111136. * Float animation type
  111137. */
  111138. static readonly ANIMATIONTYPE_FLOAT: number;
  111139. /**
  111140. * Vector3 animation type
  111141. */
  111142. static readonly ANIMATIONTYPE_VECTOR3: number;
  111143. /**
  111144. * Quaternion animation type
  111145. */
  111146. static readonly ANIMATIONTYPE_QUATERNION: number;
  111147. /**
  111148. * Matrix animation type
  111149. */
  111150. static readonly ANIMATIONTYPE_MATRIX: number;
  111151. /**
  111152. * Color3 animation type
  111153. */
  111154. static readonly ANIMATIONTYPE_COLOR3: number;
  111155. /**
  111156. * Color3 animation type
  111157. */
  111158. static readonly ANIMATIONTYPE_COLOR4: number;
  111159. /**
  111160. * Vector2 animation type
  111161. */
  111162. static readonly ANIMATIONTYPE_VECTOR2: number;
  111163. /**
  111164. * Size animation type
  111165. */
  111166. static readonly ANIMATIONTYPE_SIZE: number;
  111167. /**
  111168. * Relative Loop Mode
  111169. */
  111170. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  111171. /**
  111172. * Cycle Loop Mode
  111173. */
  111174. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  111175. /**
  111176. * Constant Loop Mode
  111177. */
  111178. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  111179. /** @hidden */
  111180. static _UniversalLerp(left: any, right: any, amount: number): any;
  111181. /**
  111182. * Parses an animation object and creates an animation
  111183. * @param parsedAnimation Parsed animation object
  111184. * @returns Animation object
  111185. */
  111186. static Parse(parsedAnimation: any): Animation;
  111187. /**
  111188. * Appends the serialized animations from the source animations
  111189. * @param source Source containing the animations
  111190. * @param destination Target to store the animations
  111191. */
  111192. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111193. /**
  111194. * Creates a new animation or an array of animations from a snippet saved in a remote file
  111195. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  111196. * @param url defines the url to load from
  111197. * @returns a promise that will resolve to the new animation or an array of animations
  111198. */
  111199. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  111200. /**
  111201. * Creates an animation or an array of animations from a snippet saved by the Inspector
  111202. * @param snippetId defines the snippet to load
  111203. * @returns a promise that will resolve to the new animation or a new array of animations
  111204. */
  111205. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  111206. }
  111207. }
  111208. declare module BABYLON {
  111209. /**
  111210. * Interface containing an array of animations
  111211. */
  111212. export interface IAnimatable {
  111213. /**
  111214. * Array of animations
  111215. */
  111216. animations: Nullable<Array<Animation>>;
  111217. }
  111218. }
  111219. declare module BABYLON {
  111220. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  111221. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111222. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111223. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111224. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111225. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111226. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111227. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111228. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111229. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111230. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111231. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111232. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111233. /**
  111234. * Decorator used to define property that can be serialized as reference to a camera
  111235. * @param sourceName defines the name of the property to decorate
  111236. */
  111237. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  111238. /**
  111239. * Class used to help serialization objects
  111240. */
  111241. export class SerializationHelper {
  111242. /** @hidden */
  111243. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  111244. /** @hidden */
  111245. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  111246. /** @hidden */
  111247. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  111248. /** @hidden */
  111249. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  111250. /**
  111251. * Appends the serialized animations from the source animations
  111252. * @param source Source containing the animations
  111253. * @param destination Target to store the animations
  111254. */
  111255. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  111256. /**
  111257. * Static function used to serialized a specific entity
  111258. * @param entity defines the entity to serialize
  111259. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  111260. * @returns a JSON compatible object representing the serialization of the entity
  111261. */
  111262. static Serialize<T>(entity: T, serializationObject?: any): any;
  111263. /**
  111264. * Creates a new entity from a serialization data object
  111265. * @param creationFunction defines a function used to instanciated the new entity
  111266. * @param source defines the source serialization data
  111267. * @param scene defines the hosting scene
  111268. * @param rootUrl defines the root url for resources
  111269. * @returns a new entity
  111270. */
  111271. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  111272. /**
  111273. * Clones an object
  111274. * @param creationFunction defines the function used to instanciate the new object
  111275. * @param source defines the source object
  111276. * @returns the cloned object
  111277. */
  111278. static Clone<T>(creationFunction: () => T, source: T): T;
  111279. /**
  111280. * Instanciates a new object based on a source one (some data will be shared between both object)
  111281. * @param creationFunction defines the function used to instanciate the new object
  111282. * @param source defines the source object
  111283. * @returns the new object
  111284. */
  111285. static Instanciate<T>(creationFunction: () => T, source: T): T;
  111286. }
  111287. }
  111288. declare module BABYLON {
  111289. /**
  111290. * Base class of all the textures in babylon.
  111291. * It groups all the common properties the materials, post process, lights... might need
  111292. * in order to make a correct use of the texture.
  111293. */
  111294. export class BaseTexture implements IAnimatable {
  111295. /**
  111296. * Default anisotropic filtering level for the application.
  111297. * It is set to 4 as a good tradeoff between perf and quality.
  111298. */
  111299. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  111300. /**
  111301. * Gets or sets the unique id of the texture
  111302. */
  111303. uniqueId: number;
  111304. /**
  111305. * Define the name of the texture.
  111306. */
  111307. name: string;
  111308. /**
  111309. * Gets or sets an object used to store user defined information.
  111310. */
  111311. metadata: any;
  111312. /**
  111313. * For internal use only. Please do not use.
  111314. */
  111315. reservedDataStore: any;
  111316. private _hasAlpha;
  111317. /**
  111318. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  111319. */
  111320. set hasAlpha(value: boolean);
  111321. get hasAlpha(): boolean;
  111322. /**
  111323. * Defines if the alpha value should be determined via the rgb values.
  111324. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  111325. */
  111326. getAlphaFromRGB: boolean;
  111327. /**
  111328. * Intensity or strength of the texture.
  111329. * It is commonly used by materials to fine tune the intensity of the texture
  111330. */
  111331. level: number;
  111332. /**
  111333. * Define the UV chanel to use starting from 0 and defaulting to 0.
  111334. * This is part of the texture as textures usually maps to one uv set.
  111335. */
  111336. coordinatesIndex: number;
  111337. private _coordinatesMode;
  111338. /**
  111339. * How a texture is mapped.
  111340. *
  111341. * | Value | Type | Description |
  111342. * | ----- | ----------------------------------- | ----------- |
  111343. * | 0 | EXPLICIT_MODE | |
  111344. * | 1 | SPHERICAL_MODE | |
  111345. * | 2 | PLANAR_MODE | |
  111346. * | 3 | CUBIC_MODE | |
  111347. * | 4 | PROJECTION_MODE | |
  111348. * | 5 | SKYBOX_MODE | |
  111349. * | 6 | INVCUBIC_MODE | |
  111350. * | 7 | EQUIRECTANGULAR_MODE | |
  111351. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  111352. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  111353. */
  111354. set coordinatesMode(value: number);
  111355. get coordinatesMode(): number;
  111356. /**
  111357. * | Value | Type | Description |
  111358. * | ----- | ------------------ | ----------- |
  111359. * | 0 | CLAMP_ADDRESSMODE | |
  111360. * | 1 | WRAP_ADDRESSMODE | |
  111361. * | 2 | MIRROR_ADDRESSMODE | |
  111362. */
  111363. wrapU: number;
  111364. /**
  111365. * | Value | Type | Description |
  111366. * | ----- | ------------------ | ----------- |
  111367. * | 0 | CLAMP_ADDRESSMODE | |
  111368. * | 1 | WRAP_ADDRESSMODE | |
  111369. * | 2 | MIRROR_ADDRESSMODE | |
  111370. */
  111371. wrapV: number;
  111372. /**
  111373. * | Value | Type | Description |
  111374. * | ----- | ------------------ | ----------- |
  111375. * | 0 | CLAMP_ADDRESSMODE | |
  111376. * | 1 | WRAP_ADDRESSMODE | |
  111377. * | 2 | MIRROR_ADDRESSMODE | |
  111378. */
  111379. wrapR: number;
  111380. /**
  111381. * With compliant hardware and browser (supporting anisotropic filtering)
  111382. * this defines the level of anisotropic filtering in the texture.
  111383. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  111384. */
  111385. anisotropicFilteringLevel: number;
  111386. /**
  111387. * Define if the texture is a cube texture or if false a 2d texture.
  111388. */
  111389. get isCube(): boolean;
  111390. set isCube(value: boolean);
  111391. /**
  111392. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  111393. */
  111394. get is3D(): boolean;
  111395. set is3D(value: boolean);
  111396. /**
  111397. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  111398. */
  111399. get is2DArray(): boolean;
  111400. set is2DArray(value: boolean);
  111401. /**
  111402. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  111403. * HDR texture are usually stored in linear space.
  111404. * This only impacts the PBR and Background materials
  111405. */
  111406. gammaSpace: boolean;
  111407. /**
  111408. * Gets or sets whether or not the texture contains RGBD data.
  111409. */
  111410. get isRGBD(): boolean;
  111411. set isRGBD(value: boolean);
  111412. /**
  111413. * Is Z inverted in the texture (useful in a cube texture).
  111414. */
  111415. invertZ: boolean;
  111416. /**
  111417. * Are mip maps generated for this texture or not.
  111418. */
  111419. get noMipmap(): boolean;
  111420. /**
  111421. * @hidden
  111422. */
  111423. lodLevelInAlpha: boolean;
  111424. /**
  111425. * With prefiltered texture, defined the offset used during the prefiltering steps.
  111426. */
  111427. get lodGenerationOffset(): number;
  111428. set lodGenerationOffset(value: number);
  111429. /**
  111430. * With prefiltered texture, defined the scale used during the prefiltering steps.
  111431. */
  111432. get lodGenerationScale(): number;
  111433. set lodGenerationScale(value: number);
  111434. /**
  111435. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  111436. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  111437. * average roughness values.
  111438. */
  111439. get linearSpecularLOD(): boolean;
  111440. set linearSpecularLOD(value: boolean);
  111441. /**
  111442. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  111443. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  111444. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  111445. */
  111446. get irradianceTexture(): Nullable<BaseTexture>;
  111447. set irradianceTexture(value: Nullable<BaseTexture>);
  111448. /**
  111449. * Define if the texture is a render target.
  111450. */
  111451. isRenderTarget: boolean;
  111452. /**
  111453. * Define the unique id of the texture in the scene.
  111454. */
  111455. get uid(): string;
  111456. /** @hidden */
  111457. _prefiltered: boolean;
  111458. /**
  111459. * Return a string representation of the texture.
  111460. * @returns the texture as a string
  111461. */
  111462. toString(): string;
  111463. /**
  111464. * Get the class name of the texture.
  111465. * @returns "BaseTexture"
  111466. */
  111467. getClassName(): string;
  111468. /**
  111469. * Define the list of animation attached to the texture.
  111470. */
  111471. animations: Animation[];
  111472. /**
  111473. * An event triggered when the texture is disposed.
  111474. */
  111475. onDisposeObservable: Observable<BaseTexture>;
  111476. private _onDisposeObserver;
  111477. /**
  111478. * Callback triggered when the texture has been disposed.
  111479. * Kept for back compatibility, you can use the onDisposeObservable instead.
  111480. */
  111481. set onDispose(callback: () => void);
  111482. /**
  111483. * Define the current state of the loading sequence when in delayed load mode.
  111484. */
  111485. delayLoadState: number;
  111486. private _scene;
  111487. private _engine;
  111488. /** @hidden */
  111489. _texture: Nullable<InternalTexture>;
  111490. private _uid;
  111491. /**
  111492. * Define if the texture is preventinga material to render or not.
  111493. * If not and the texture is not ready, the engine will use a default black texture instead.
  111494. */
  111495. get isBlocking(): boolean;
  111496. /**
  111497. * Instantiates a new BaseTexture.
  111498. * Base class of all the textures in babylon.
  111499. * It groups all the common properties the materials, post process, lights... might need
  111500. * in order to make a correct use of the texture.
  111501. * @param sceneOrEngine Define the scene or engine the texture blongs to
  111502. */
  111503. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  111504. /**
  111505. * Get the scene the texture belongs to.
  111506. * @returns the scene or null if undefined
  111507. */
  111508. getScene(): Nullable<Scene>;
  111509. /** @hidden */
  111510. protected _getEngine(): Nullable<ThinEngine>;
  111511. /**
  111512. * Get the texture transform matrix used to offset tile the texture for istance.
  111513. * @returns the transformation matrix
  111514. */
  111515. getTextureMatrix(): Matrix;
  111516. /**
  111517. * Get the texture reflection matrix used to rotate/transform the reflection.
  111518. * @returns the reflection matrix
  111519. */
  111520. getReflectionTextureMatrix(): Matrix;
  111521. /**
  111522. * Get the underlying lower level texture from Babylon.
  111523. * @returns the insternal texture
  111524. */
  111525. getInternalTexture(): Nullable<InternalTexture>;
  111526. /**
  111527. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  111528. * @returns true if ready or not blocking
  111529. */
  111530. isReadyOrNotBlocking(): boolean;
  111531. /**
  111532. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  111533. * @returns true if fully ready
  111534. */
  111535. isReady(): boolean;
  111536. private _cachedSize;
  111537. /**
  111538. * Get the size of the texture.
  111539. * @returns the texture size.
  111540. */
  111541. getSize(): ISize;
  111542. /**
  111543. * Get the base size of the texture.
  111544. * It can be different from the size if the texture has been resized for POT for instance
  111545. * @returns the base size
  111546. */
  111547. getBaseSize(): ISize;
  111548. /**
  111549. * Update the sampling mode of the texture.
  111550. * Default is Trilinear mode.
  111551. *
  111552. * | Value | Type | Description |
  111553. * | ----- | ------------------ | ----------- |
  111554. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  111555. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  111556. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  111557. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  111558. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  111559. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  111560. * | 7 | NEAREST_LINEAR | |
  111561. * | 8 | NEAREST_NEAREST | |
  111562. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  111563. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  111564. * | 11 | LINEAR_LINEAR | |
  111565. * | 12 | LINEAR_NEAREST | |
  111566. *
  111567. * > _mag_: magnification filter (close to the viewer)
  111568. * > _min_: minification filter (far from the viewer)
  111569. * > _mip_: filter used between mip map levels
  111570. *@param samplingMode Define the new sampling mode of the texture
  111571. */
  111572. updateSamplingMode(samplingMode: number): void;
  111573. /**
  111574. * Scales the texture if is `canRescale()`
  111575. * @param ratio the resize factor we want to use to rescale
  111576. */
  111577. scale(ratio: number): void;
  111578. /**
  111579. * Get if the texture can rescale.
  111580. */
  111581. get canRescale(): boolean;
  111582. /** @hidden */
  111583. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  111584. /** @hidden */
  111585. _rebuild(): void;
  111586. /**
  111587. * Triggers the load sequence in delayed load mode.
  111588. */
  111589. delayLoad(): void;
  111590. /**
  111591. * Clones the texture.
  111592. * @returns the cloned texture
  111593. */
  111594. clone(): Nullable<BaseTexture>;
  111595. /**
  111596. * Get the texture underlying type (INT, FLOAT...)
  111597. */
  111598. get textureType(): number;
  111599. /**
  111600. * Get the texture underlying format (RGB, RGBA...)
  111601. */
  111602. get textureFormat(): number;
  111603. /**
  111604. * Indicates that textures need to be re-calculated for all materials
  111605. */
  111606. protected _markAllSubMeshesAsTexturesDirty(): void;
  111607. /**
  111608. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  111609. * This will returns an RGBA array buffer containing either in values (0-255) or
  111610. * float values (0-1) depending of the underlying buffer type.
  111611. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  111612. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  111613. * @param buffer defines a user defined buffer to fill with data (can be null)
  111614. * @returns The Array buffer containing the pixels data.
  111615. */
  111616. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  111617. /**
  111618. * Release and destroy the underlying lower level texture aka internalTexture.
  111619. */
  111620. releaseInternalTexture(): void;
  111621. /** @hidden */
  111622. get _lodTextureHigh(): Nullable<BaseTexture>;
  111623. /** @hidden */
  111624. get _lodTextureMid(): Nullable<BaseTexture>;
  111625. /** @hidden */
  111626. get _lodTextureLow(): Nullable<BaseTexture>;
  111627. /**
  111628. * Dispose the texture and release its associated resources.
  111629. */
  111630. dispose(): void;
  111631. /**
  111632. * Serialize the texture into a JSON representation that can be parsed later on.
  111633. * @returns the JSON representation of the texture
  111634. */
  111635. serialize(): any;
  111636. /**
  111637. * Helper function to be called back once a list of texture contains only ready textures.
  111638. * @param textures Define the list of textures to wait for
  111639. * @param callback Define the callback triggered once the entire list will be ready
  111640. */
  111641. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  111642. private static _isScene;
  111643. }
  111644. }
  111645. declare module BABYLON {
  111646. /**
  111647. * Options to be used when creating an effect.
  111648. */
  111649. export interface IEffectCreationOptions {
  111650. /**
  111651. * Atrributes that will be used in the shader.
  111652. */
  111653. attributes: string[];
  111654. /**
  111655. * Uniform varible names that will be set in the shader.
  111656. */
  111657. uniformsNames: string[];
  111658. /**
  111659. * Uniform buffer variable names that will be set in the shader.
  111660. */
  111661. uniformBuffersNames: string[];
  111662. /**
  111663. * Sampler texture variable names that will be set in the shader.
  111664. */
  111665. samplers: string[];
  111666. /**
  111667. * Define statements that will be set in the shader.
  111668. */
  111669. defines: any;
  111670. /**
  111671. * Possible fallbacks for this effect to improve performance when needed.
  111672. */
  111673. fallbacks: Nullable<IEffectFallbacks>;
  111674. /**
  111675. * Callback that will be called when the shader is compiled.
  111676. */
  111677. onCompiled: Nullable<(effect: Effect) => void>;
  111678. /**
  111679. * Callback that will be called if an error occurs during shader compilation.
  111680. */
  111681. onError: Nullable<(effect: Effect, errors: string) => void>;
  111682. /**
  111683. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111684. */
  111685. indexParameters?: any;
  111686. /**
  111687. * Max number of lights that can be used in the shader.
  111688. */
  111689. maxSimultaneousLights?: number;
  111690. /**
  111691. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  111692. */
  111693. transformFeedbackVaryings?: Nullable<string[]>;
  111694. /**
  111695. * 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
  111696. */
  111697. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  111698. /**
  111699. * Is this effect rendering to several color attachments ?
  111700. */
  111701. multiTarget?: boolean;
  111702. }
  111703. /**
  111704. * Effect containing vertex and fragment shader that can be executed on an object.
  111705. */
  111706. export class Effect implements IDisposable {
  111707. /**
  111708. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  111709. */
  111710. static ShadersRepository: string;
  111711. /**
  111712. * Enable logging of the shader code when a compilation error occurs
  111713. */
  111714. static LogShaderCodeOnCompilationError: boolean;
  111715. /**
  111716. * Name of the effect.
  111717. */
  111718. name: any;
  111719. /**
  111720. * String container all the define statements that should be set on the shader.
  111721. */
  111722. defines: string;
  111723. /**
  111724. * Callback that will be called when the shader is compiled.
  111725. */
  111726. onCompiled: Nullable<(effect: Effect) => void>;
  111727. /**
  111728. * Callback that will be called if an error occurs during shader compilation.
  111729. */
  111730. onError: Nullable<(effect: Effect, errors: string) => void>;
  111731. /**
  111732. * Callback that will be called when effect is bound.
  111733. */
  111734. onBind: Nullable<(effect: Effect) => void>;
  111735. /**
  111736. * Unique ID of the effect.
  111737. */
  111738. uniqueId: number;
  111739. /**
  111740. * Observable that will be called when the shader is compiled.
  111741. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  111742. */
  111743. onCompileObservable: Observable<Effect>;
  111744. /**
  111745. * Observable that will be called if an error occurs during shader compilation.
  111746. */
  111747. onErrorObservable: Observable<Effect>;
  111748. /** @hidden */
  111749. _onBindObservable: Nullable<Observable<Effect>>;
  111750. /**
  111751. * @hidden
  111752. * Specifies if the effect was previously ready
  111753. */
  111754. _wasPreviouslyReady: boolean;
  111755. /**
  111756. * Observable that will be called when effect is bound.
  111757. */
  111758. get onBindObservable(): Observable<Effect>;
  111759. /** @hidden */
  111760. _bonesComputationForcedToCPU: boolean;
  111761. /** @hidden */
  111762. _multiTarget: boolean;
  111763. private static _uniqueIdSeed;
  111764. private _engine;
  111765. private _uniformBuffersNames;
  111766. private _uniformBuffersNamesList;
  111767. private _uniformsNames;
  111768. private _samplerList;
  111769. private _samplers;
  111770. private _isReady;
  111771. private _compilationError;
  111772. private _allFallbacksProcessed;
  111773. private _attributesNames;
  111774. private _attributes;
  111775. private _attributeLocationByName;
  111776. private _uniforms;
  111777. /**
  111778. * Key for the effect.
  111779. * @hidden
  111780. */
  111781. _key: string;
  111782. private _indexParameters;
  111783. private _fallbacks;
  111784. private _vertexSourceCode;
  111785. private _fragmentSourceCode;
  111786. private _vertexSourceCodeOverride;
  111787. private _fragmentSourceCodeOverride;
  111788. private _transformFeedbackVaryings;
  111789. /**
  111790. * Compiled shader to webGL program.
  111791. * @hidden
  111792. */
  111793. _pipelineContext: Nullable<IPipelineContext>;
  111794. private _valueCache;
  111795. private static _baseCache;
  111796. /**
  111797. * Instantiates an effect.
  111798. * An effect can be used to create/manage/execute vertex and fragment shaders.
  111799. * @param baseName Name of the effect.
  111800. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  111801. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  111802. * @param samplers List of sampler variables that will be passed to the shader.
  111803. * @param engine Engine to be used to render the effect
  111804. * @param defines Define statements to be added to the shader.
  111805. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  111806. * @param onCompiled Callback that will be called when the shader is compiled.
  111807. * @param onError Callback that will be called if an error occurs during shader compilation.
  111808. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  111809. */
  111810. 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);
  111811. private _useFinalCode;
  111812. /**
  111813. * Unique key for this effect
  111814. */
  111815. get key(): string;
  111816. /**
  111817. * If the effect has been compiled and prepared.
  111818. * @returns if the effect is compiled and prepared.
  111819. */
  111820. isReady(): boolean;
  111821. private _isReadyInternal;
  111822. /**
  111823. * The engine the effect was initialized with.
  111824. * @returns the engine.
  111825. */
  111826. getEngine(): Engine;
  111827. /**
  111828. * The pipeline context for this effect
  111829. * @returns the associated pipeline context
  111830. */
  111831. getPipelineContext(): Nullable<IPipelineContext>;
  111832. /**
  111833. * The set of names of attribute variables for the shader.
  111834. * @returns An array of attribute names.
  111835. */
  111836. getAttributesNames(): string[];
  111837. /**
  111838. * Returns the attribute at the given index.
  111839. * @param index The index of the attribute.
  111840. * @returns The location of the attribute.
  111841. */
  111842. getAttributeLocation(index: number): number;
  111843. /**
  111844. * Returns the attribute based on the name of the variable.
  111845. * @param name of the attribute to look up.
  111846. * @returns the attribute location.
  111847. */
  111848. getAttributeLocationByName(name: string): number;
  111849. /**
  111850. * The number of attributes.
  111851. * @returns the numnber of attributes.
  111852. */
  111853. getAttributesCount(): number;
  111854. /**
  111855. * Gets the index of a uniform variable.
  111856. * @param uniformName of the uniform to look up.
  111857. * @returns the index.
  111858. */
  111859. getUniformIndex(uniformName: string): number;
  111860. /**
  111861. * Returns the attribute based on the name of the variable.
  111862. * @param uniformName of the uniform to look up.
  111863. * @returns the location of the uniform.
  111864. */
  111865. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  111866. /**
  111867. * Returns an array of sampler variable names
  111868. * @returns The array of sampler variable names.
  111869. */
  111870. getSamplers(): string[];
  111871. /**
  111872. * Returns an array of uniform variable names
  111873. * @returns The array of uniform variable names.
  111874. */
  111875. getUniformNames(): string[];
  111876. /**
  111877. * Returns an array of uniform buffer variable names
  111878. * @returns The array of uniform buffer variable names.
  111879. */
  111880. getUniformBuffersNames(): string[];
  111881. /**
  111882. * Returns the index parameters used to create the effect
  111883. * @returns The index parameters object
  111884. */
  111885. getIndexParameters(): any;
  111886. /**
  111887. * The error from the last compilation.
  111888. * @returns the error string.
  111889. */
  111890. getCompilationError(): string;
  111891. /**
  111892. * Gets a boolean indicating that all fallbacks were used during compilation
  111893. * @returns true if all fallbacks were used
  111894. */
  111895. allFallbacksProcessed(): boolean;
  111896. /**
  111897. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  111898. * @param func The callback to be used.
  111899. */
  111900. executeWhenCompiled(func: (effect: Effect) => void): void;
  111901. private _checkIsReady;
  111902. private _loadShader;
  111903. /**
  111904. * Gets the vertex shader source code of this effect
  111905. */
  111906. get vertexSourceCode(): string;
  111907. /**
  111908. * Gets the fragment shader source code of this effect
  111909. */
  111910. get fragmentSourceCode(): string;
  111911. /**
  111912. * Recompiles the webGL program
  111913. * @param vertexSourceCode The source code for the vertex shader.
  111914. * @param fragmentSourceCode The source code for the fragment shader.
  111915. * @param onCompiled Callback called when completed.
  111916. * @param onError Callback called on error.
  111917. * @hidden
  111918. */
  111919. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  111920. /**
  111921. * Prepares the effect
  111922. * @hidden
  111923. */
  111924. _prepareEffect(): void;
  111925. private _getShaderCodeAndErrorLine;
  111926. private _processCompilationErrors;
  111927. /**
  111928. * Checks if the effect is supported. (Must be called after compilation)
  111929. */
  111930. get isSupported(): boolean;
  111931. /**
  111932. * Binds a texture to the engine to be used as output of the shader.
  111933. * @param channel Name of the output variable.
  111934. * @param texture Texture to bind.
  111935. * @hidden
  111936. */
  111937. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  111938. /**
  111939. * Sets a texture on the engine to be used in the shader.
  111940. * @param channel Name of the sampler variable.
  111941. * @param texture Texture to set.
  111942. */
  111943. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  111944. /**
  111945. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  111946. * @param channel Name of the sampler variable.
  111947. * @param texture Texture to set.
  111948. */
  111949. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  111950. /**
  111951. * Sets an array of textures on the engine to be used in the shader.
  111952. * @param channel Name of the variable.
  111953. * @param textures Textures to set.
  111954. */
  111955. setTextureArray(channel: string, textures: BaseTexture[]): void;
  111956. /**
  111957. * 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)
  111958. * @param channel Name of the sampler variable.
  111959. * @param postProcess Post process to get the input texture from.
  111960. */
  111961. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  111962. /**
  111963. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  111964. * 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)
  111965. * @param channel Name of the sampler variable.
  111966. * @param postProcess Post process to get the output texture from.
  111967. */
  111968. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  111969. /** @hidden */
  111970. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  111971. /** @hidden */
  111972. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  111973. /** @hidden */
  111974. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  111975. /** @hidden */
  111976. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  111977. /**
  111978. * Binds a buffer to a uniform.
  111979. * @param buffer Buffer to bind.
  111980. * @param name Name of the uniform variable to bind to.
  111981. */
  111982. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  111983. /**
  111984. * Binds block to a uniform.
  111985. * @param blockName Name of the block to bind.
  111986. * @param index Index to bind.
  111987. */
  111988. bindUniformBlock(blockName: string, index: number): void;
  111989. /**
  111990. * Sets an interger value on a uniform variable.
  111991. * @param uniformName Name of the variable.
  111992. * @param value Value to be set.
  111993. * @returns this effect.
  111994. */
  111995. setInt(uniformName: string, value: number): Effect;
  111996. /**
  111997. * Sets an int array on a uniform variable.
  111998. * @param uniformName Name of the variable.
  111999. * @param array array to be set.
  112000. * @returns this effect.
  112001. */
  112002. setIntArray(uniformName: string, array: Int32Array): Effect;
  112003. /**
  112004. * 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)
  112005. * @param uniformName Name of the variable.
  112006. * @param array array to be set.
  112007. * @returns this effect.
  112008. */
  112009. setIntArray2(uniformName: string, array: Int32Array): Effect;
  112010. /**
  112011. * 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)
  112012. * @param uniformName Name of the variable.
  112013. * @param array array to be set.
  112014. * @returns this effect.
  112015. */
  112016. setIntArray3(uniformName: string, array: Int32Array): Effect;
  112017. /**
  112018. * 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)
  112019. * @param uniformName Name of the variable.
  112020. * @param array array to be set.
  112021. * @returns this effect.
  112022. */
  112023. setIntArray4(uniformName: string, array: Int32Array): Effect;
  112024. /**
  112025. * Sets an float array on a uniform variable.
  112026. * @param uniformName Name of the variable.
  112027. * @param array array to be set.
  112028. * @returns this effect.
  112029. */
  112030. setFloatArray(uniformName: string, array: Float32Array): Effect;
  112031. /**
  112032. * 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)
  112033. * @param uniformName Name of the variable.
  112034. * @param array array to be set.
  112035. * @returns this effect.
  112036. */
  112037. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  112038. /**
  112039. * 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)
  112040. * @param uniformName Name of the variable.
  112041. * @param array array to be set.
  112042. * @returns this effect.
  112043. */
  112044. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  112045. /**
  112046. * 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)
  112047. * @param uniformName Name of the variable.
  112048. * @param array array to be set.
  112049. * @returns this effect.
  112050. */
  112051. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  112052. /**
  112053. * Sets an array on a uniform variable.
  112054. * @param uniformName Name of the variable.
  112055. * @param array array to be set.
  112056. * @returns this effect.
  112057. */
  112058. setArray(uniformName: string, array: number[]): Effect;
  112059. /**
  112060. * 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)
  112061. * @param uniformName Name of the variable.
  112062. * @param array array to be set.
  112063. * @returns this effect.
  112064. */
  112065. setArray2(uniformName: string, array: number[]): Effect;
  112066. /**
  112067. * 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)
  112068. * @param uniformName Name of the variable.
  112069. * @param array array to be set.
  112070. * @returns this effect.
  112071. */
  112072. setArray3(uniformName: string, array: number[]): Effect;
  112073. /**
  112074. * 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)
  112075. * @param uniformName Name of the variable.
  112076. * @param array array to be set.
  112077. * @returns this effect.
  112078. */
  112079. setArray4(uniformName: string, array: number[]): Effect;
  112080. /**
  112081. * Sets matrices on a uniform variable.
  112082. * @param uniformName Name of the variable.
  112083. * @param matrices matrices to be set.
  112084. * @returns this effect.
  112085. */
  112086. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  112087. /**
  112088. * Sets matrix on a uniform variable.
  112089. * @param uniformName Name of the variable.
  112090. * @param matrix matrix to be set.
  112091. * @returns this effect.
  112092. */
  112093. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  112094. /**
  112095. * 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)
  112096. * @param uniformName Name of the variable.
  112097. * @param matrix matrix to be set.
  112098. * @returns this effect.
  112099. */
  112100. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  112101. /**
  112102. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  112103. * @param uniformName Name of the variable.
  112104. * @param matrix matrix to be set.
  112105. * @returns this effect.
  112106. */
  112107. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  112108. /**
  112109. * Sets a float on a uniform variable.
  112110. * @param uniformName Name of the variable.
  112111. * @param value value to be set.
  112112. * @returns this effect.
  112113. */
  112114. setFloat(uniformName: string, value: number): Effect;
  112115. /**
  112116. * Sets a boolean on a uniform variable.
  112117. * @param uniformName Name of the variable.
  112118. * @param bool value to be set.
  112119. * @returns this effect.
  112120. */
  112121. setBool(uniformName: string, bool: boolean): Effect;
  112122. /**
  112123. * Sets a Vector2 on a uniform variable.
  112124. * @param uniformName Name of the variable.
  112125. * @param vector2 vector2 to be set.
  112126. * @returns this effect.
  112127. */
  112128. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  112129. /**
  112130. * Sets a float2 on a uniform variable.
  112131. * @param uniformName Name of the variable.
  112132. * @param x First float in float2.
  112133. * @param y Second float in float2.
  112134. * @returns this effect.
  112135. */
  112136. setFloat2(uniformName: string, x: number, y: number): Effect;
  112137. /**
  112138. * Sets a Vector3 on a uniform variable.
  112139. * @param uniformName Name of the variable.
  112140. * @param vector3 Value to be set.
  112141. * @returns this effect.
  112142. */
  112143. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  112144. /**
  112145. * Sets a float3 on a uniform variable.
  112146. * @param uniformName Name of the variable.
  112147. * @param x First float in float3.
  112148. * @param y Second float in float3.
  112149. * @param z Third float in float3.
  112150. * @returns this effect.
  112151. */
  112152. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  112153. /**
  112154. * Sets a Vector4 on a uniform variable.
  112155. * @param uniformName Name of the variable.
  112156. * @param vector4 Value to be set.
  112157. * @returns this effect.
  112158. */
  112159. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  112160. /**
  112161. * Sets a float4 on a uniform variable.
  112162. * @param uniformName Name of the variable.
  112163. * @param x First float in float4.
  112164. * @param y Second float in float4.
  112165. * @param z Third float in float4.
  112166. * @param w Fourth float in float4.
  112167. * @returns this effect.
  112168. */
  112169. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  112170. /**
  112171. * Sets a Color3 on a uniform variable.
  112172. * @param uniformName Name of the variable.
  112173. * @param color3 Value to be set.
  112174. * @returns this effect.
  112175. */
  112176. setColor3(uniformName: string, color3: IColor3Like): Effect;
  112177. /**
  112178. * Sets a Color4 on a uniform variable.
  112179. * @param uniformName Name of the variable.
  112180. * @param color3 Value to be set.
  112181. * @param alpha Alpha value to be set.
  112182. * @returns this effect.
  112183. */
  112184. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  112185. /**
  112186. * Sets a Color4 on a uniform variable
  112187. * @param uniformName defines the name of the variable
  112188. * @param color4 defines the value to be set
  112189. * @returns this effect.
  112190. */
  112191. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  112192. /** Release all associated resources */
  112193. dispose(): void;
  112194. /**
  112195. * This function will add a new shader to the shader store
  112196. * @param name the name of the shader
  112197. * @param pixelShader optional pixel shader content
  112198. * @param vertexShader optional vertex shader content
  112199. */
  112200. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  112201. /**
  112202. * Store of each shader (The can be looked up using effect.key)
  112203. */
  112204. static ShadersStore: {
  112205. [key: string]: string;
  112206. };
  112207. /**
  112208. * Store of each included file for a shader (The can be looked up using effect.key)
  112209. */
  112210. static IncludesShadersStore: {
  112211. [key: string]: string;
  112212. };
  112213. /**
  112214. * Resets the cache of effects.
  112215. */
  112216. static ResetCache(): void;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * Interface used to describe the capabilities of the engine relatively to the current browser
  112222. */
  112223. export interface EngineCapabilities {
  112224. /** Maximum textures units per fragment shader */
  112225. maxTexturesImageUnits: number;
  112226. /** Maximum texture units per vertex shader */
  112227. maxVertexTextureImageUnits: number;
  112228. /** Maximum textures units in the entire pipeline */
  112229. maxCombinedTexturesImageUnits: number;
  112230. /** Maximum texture size */
  112231. maxTextureSize: number;
  112232. /** Maximum texture samples */
  112233. maxSamples?: number;
  112234. /** Maximum cube texture size */
  112235. maxCubemapTextureSize: number;
  112236. /** Maximum render texture size */
  112237. maxRenderTextureSize: number;
  112238. /** Maximum number of vertex attributes */
  112239. maxVertexAttribs: number;
  112240. /** Maximum number of varyings */
  112241. maxVaryingVectors: number;
  112242. /** Maximum number of uniforms per vertex shader */
  112243. maxVertexUniformVectors: number;
  112244. /** Maximum number of uniforms per fragment shader */
  112245. maxFragmentUniformVectors: number;
  112246. /** Defines if standard derivates (dx/dy) are supported */
  112247. standardDerivatives: boolean;
  112248. /** Defines if s3tc texture compression is supported */
  112249. s3tc?: WEBGL_compressed_texture_s3tc;
  112250. /** Defines if pvrtc texture compression is supported */
  112251. pvrtc: any;
  112252. /** Defines if etc1 texture compression is supported */
  112253. etc1: any;
  112254. /** Defines if etc2 texture compression is supported */
  112255. etc2: any;
  112256. /** Defines if astc texture compression is supported */
  112257. astc: any;
  112258. /** Defines if float textures are supported */
  112259. textureFloat: boolean;
  112260. /** Defines if vertex array objects are supported */
  112261. vertexArrayObject: boolean;
  112262. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  112263. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  112264. /** Gets the maximum level of anisotropy supported */
  112265. maxAnisotropy: number;
  112266. /** Defines if instancing is supported */
  112267. instancedArrays: boolean;
  112268. /** Defines if 32 bits indices are supported */
  112269. uintIndices: boolean;
  112270. /** Defines if high precision shaders are supported */
  112271. highPrecisionShaderSupported: boolean;
  112272. /** Defines if depth reading in the fragment shader is supported */
  112273. fragmentDepthSupported: boolean;
  112274. /** Defines if float texture linear filtering is supported*/
  112275. textureFloatLinearFiltering: boolean;
  112276. /** Defines if rendering to float textures is supported */
  112277. textureFloatRender: boolean;
  112278. /** Defines if half float textures are supported*/
  112279. textureHalfFloat: boolean;
  112280. /** Defines if half float texture linear filtering is supported*/
  112281. textureHalfFloatLinearFiltering: boolean;
  112282. /** Defines if rendering to half float textures is supported */
  112283. textureHalfFloatRender: boolean;
  112284. /** Defines if textureLOD shader command is supported */
  112285. textureLOD: boolean;
  112286. /** Defines if draw buffers extension is supported */
  112287. drawBuffersExtension: boolean;
  112288. /** Defines if depth textures are supported */
  112289. depthTextureExtension: boolean;
  112290. /** Defines if float color buffer are supported */
  112291. colorBufferFloat: boolean;
  112292. /** Gets disjoint timer query extension (null if not supported) */
  112293. timerQuery?: EXT_disjoint_timer_query;
  112294. /** Defines if timestamp can be used with timer query */
  112295. canUseTimestampForTimerQuery: boolean;
  112296. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  112297. multiview?: any;
  112298. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  112299. oculusMultiview?: any;
  112300. /** Function used to let the system compiles shaders in background */
  112301. parallelShaderCompile?: {
  112302. COMPLETION_STATUS_KHR: number;
  112303. };
  112304. /** Max number of texture samples for MSAA */
  112305. maxMSAASamples: number;
  112306. /** Defines if the blend min max extension is supported */
  112307. blendMinMax: boolean;
  112308. }
  112309. }
  112310. declare module BABYLON {
  112311. /**
  112312. * @hidden
  112313. **/
  112314. export class DepthCullingState {
  112315. private _isDepthTestDirty;
  112316. private _isDepthMaskDirty;
  112317. private _isDepthFuncDirty;
  112318. private _isCullFaceDirty;
  112319. private _isCullDirty;
  112320. private _isZOffsetDirty;
  112321. private _isFrontFaceDirty;
  112322. private _depthTest;
  112323. private _depthMask;
  112324. private _depthFunc;
  112325. private _cull;
  112326. private _cullFace;
  112327. private _zOffset;
  112328. private _frontFace;
  112329. /**
  112330. * Initializes the state.
  112331. */
  112332. constructor();
  112333. get isDirty(): boolean;
  112334. get zOffset(): number;
  112335. set zOffset(value: number);
  112336. get cullFace(): Nullable<number>;
  112337. set cullFace(value: Nullable<number>);
  112338. get cull(): Nullable<boolean>;
  112339. set cull(value: Nullable<boolean>);
  112340. get depthFunc(): Nullable<number>;
  112341. set depthFunc(value: Nullable<number>);
  112342. get depthMask(): boolean;
  112343. set depthMask(value: boolean);
  112344. get depthTest(): boolean;
  112345. set depthTest(value: boolean);
  112346. get frontFace(): Nullable<number>;
  112347. set frontFace(value: Nullable<number>);
  112348. reset(): void;
  112349. apply(gl: WebGLRenderingContext): void;
  112350. }
  112351. }
  112352. declare module BABYLON {
  112353. /**
  112354. * @hidden
  112355. **/
  112356. export class StencilState {
  112357. /** 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 */
  112358. static readonly ALWAYS: number;
  112359. /** Passed to stencilOperation to specify that stencil value must be kept */
  112360. static readonly KEEP: number;
  112361. /** Passed to stencilOperation to specify that stencil value must be replaced */
  112362. static readonly REPLACE: number;
  112363. private _isStencilTestDirty;
  112364. private _isStencilMaskDirty;
  112365. private _isStencilFuncDirty;
  112366. private _isStencilOpDirty;
  112367. private _stencilTest;
  112368. private _stencilMask;
  112369. private _stencilFunc;
  112370. private _stencilFuncRef;
  112371. private _stencilFuncMask;
  112372. private _stencilOpStencilFail;
  112373. private _stencilOpDepthFail;
  112374. private _stencilOpStencilDepthPass;
  112375. get isDirty(): boolean;
  112376. get stencilFunc(): number;
  112377. set stencilFunc(value: number);
  112378. get stencilFuncRef(): number;
  112379. set stencilFuncRef(value: number);
  112380. get stencilFuncMask(): number;
  112381. set stencilFuncMask(value: number);
  112382. get stencilOpStencilFail(): number;
  112383. set stencilOpStencilFail(value: number);
  112384. get stencilOpDepthFail(): number;
  112385. set stencilOpDepthFail(value: number);
  112386. get stencilOpStencilDepthPass(): number;
  112387. set stencilOpStencilDepthPass(value: number);
  112388. get stencilMask(): number;
  112389. set stencilMask(value: number);
  112390. get stencilTest(): boolean;
  112391. set stencilTest(value: boolean);
  112392. constructor();
  112393. reset(): void;
  112394. apply(gl: WebGLRenderingContext): void;
  112395. }
  112396. }
  112397. declare module BABYLON {
  112398. /**
  112399. * @hidden
  112400. **/
  112401. export class AlphaState {
  112402. private _isAlphaBlendDirty;
  112403. private _isBlendFunctionParametersDirty;
  112404. private _isBlendEquationParametersDirty;
  112405. private _isBlendConstantsDirty;
  112406. private _alphaBlend;
  112407. private _blendFunctionParameters;
  112408. private _blendEquationParameters;
  112409. private _blendConstants;
  112410. /**
  112411. * Initializes the state.
  112412. */
  112413. constructor();
  112414. get isDirty(): boolean;
  112415. get alphaBlend(): boolean;
  112416. set alphaBlend(value: boolean);
  112417. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  112418. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  112419. setAlphaEquationParameters(rgb: number, alpha: number): void;
  112420. reset(): void;
  112421. apply(gl: WebGLRenderingContext): void;
  112422. }
  112423. }
  112424. declare module BABYLON {
  112425. /** @hidden */
  112426. export class WebGL2ShaderProcessor implements IShaderProcessor {
  112427. attributeProcessor(attribute: string): string;
  112428. varyingProcessor(varying: string, isFragment: boolean): string;
  112429. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  112430. }
  112431. }
  112432. declare module BABYLON {
  112433. /**
  112434. * Interface for attribute information associated with buffer instanciation
  112435. */
  112436. export interface InstancingAttributeInfo {
  112437. /**
  112438. * Name of the GLSL attribute
  112439. * if attribute index is not specified, this is used to retrieve the index from the effect
  112440. */
  112441. attributeName: string;
  112442. /**
  112443. * Index/offset of the attribute in the vertex shader
  112444. * if not specified, this will be computes from the name.
  112445. */
  112446. index?: number;
  112447. /**
  112448. * size of the attribute, 1, 2, 3 or 4
  112449. */
  112450. attributeSize: number;
  112451. /**
  112452. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  112453. */
  112454. offset: number;
  112455. /**
  112456. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  112457. * default to 1
  112458. */
  112459. divisor?: number;
  112460. /**
  112461. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  112462. * default is FLOAT
  112463. */
  112464. attributeType?: number;
  112465. /**
  112466. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  112467. */
  112468. normalized?: boolean;
  112469. }
  112470. }
  112471. declare module BABYLON {
  112472. interface ThinEngine {
  112473. /**
  112474. * Update a video texture
  112475. * @param texture defines the texture to update
  112476. * @param video defines the video element to use
  112477. * @param invertY defines if data must be stored with Y axis inverted
  112478. */
  112479. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  112480. }
  112481. }
  112482. declare module BABYLON {
  112483. interface ThinEngine {
  112484. /**
  112485. * Creates a dynamic texture
  112486. * @param width defines the width of the texture
  112487. * @param height defines the height of the texture
  112488. * @param generateMipMaps defines if the engine should generate the mip levels
  112489. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  112490. * @returns the dynamic texture inside an InternalTexture
  112491. */
  112492. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  112493. /**
  112494. * Update the content of a dynamic texture
  112495. * @param texture defines the texture to update
  112496. * @param canvas defines the canvas containing the source
  112497. * @param invertY defines if data must be stored with Y axis inverted
  112498. * @param premulAlpha defines if alpha is stored as premultiplied
  112499. * @param format defines the format of the data
  112500. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  112501. */
  112502. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  112503. }
  112504. }
  112505. declare module BABYLON {
  112506. /**
  112507. * Settings for finer control over video usage
  112508. */
  112509. export interface VideoTextureSettings {
  112510. /**
  112511. * Applies `autoplay` to video, if specified
  112512. */
  112513. autoPlay?: boolean;
  112514. /**
  112515. * Applies `loop` to video, if specified
  112516. */
  112517. loop?: boolean;
  112518. /**
  112519. * Automatically updates internal texture from video at every frame in the render loop
  112520. */
  112521. autoUpdateTexture: boolean;
  112522. /**
  112523. * Image src displayed during the video loading or until the user interacts with the video.
  112524. */
  112525. poster?: string;
  112526. }
  112527. /**
  112528. * If you want to display a video in your scene, this is the special texture for that.
  112529. * This special texture works similar to other textures, with the exception of a few parameters.
  112530. * @see https://doc.babylonjs.com/how_to/video_texture
  112531. */
  112532. export class VideoTexture extends Texture {
  112533. /**
  112534. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  112535. */
  112536. readonly autoUpdateTexture: boolean;
  112537. /**
  112538. * The video instance used by the texture internally
  112539. */
  112540. readonly video: HTMLVideoElement;
  112541. private _onUserActionRequestedObservable;
  112542. /**
  112543. * Event triggerd when a dom action is required by the user to play the video.
  112544. * This happens due to recent changes in browser policies preventing video to auto start.
  112545. */
  112546. get onUserActionRequestedObservable(): Observable<Texture>;
  112547. private _generateMipMaps;
  112548. private _stillImageCaptured;
  112549. private _displayingPosterTexture;
  112550. private _settings;
  112551. private _createInternalTextureOnEvent;
  112552. private _frameId;
  112553. private _currentSrc;
  112554. /**
  112555. * Creates a video texture.
  112556. * If you want to display a video in your scene, this is the special texture for that.
  112557. * This special texture works similar to other textures, with the exception of a few parameters.
  112558. * @see https://doc.babylonjs.com/how_to/video_texture
  112559. * @param name optional name, will detect from video source, if not defined
  112560. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  112561. * @param scene is obviously the current scene.
  112562. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  112563. * @param invertY is false by default but can be used to invert video on Y axis
  112564. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  112565. * @param settings allows finer control over video usage
  112566. */
  112567. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  112568. private _getName;
  112569. private _getVideo;
  112570. private _createInternalTexture;
  112571. private reset;
  112572. /**
  112573. * @hidden Internal method to initiate `update`.
  112574. */
  112575. _rebuild(): void;
  112576. /**
  112577. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  112578. */
  112579. update(): void;
  112580. /**
  112581. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  112582. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  112583. */
  112584. updateTexture(isVisible: boolean): void;
  112585. protected _updateInternalTexture: () => void;
  112586. /**
  112587. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  112588. * @param url New url.
  112589. */
  112590. updateURL(url: string): void;
  112591. /**
  112592. * Clones the texture.
  112593. * @returns the cloned texture
  112594. */
  112595. clone(): VideoTexture;
  112596. /**
  112597. * Dispose the texture and release its associated resources.
  112598. */
  112599. dispose(): void;
  112600. /**
  112601. * Creates a video texture straight from a stream.
  112602. * @param scene Define the scene the texture should be created in
  112603. * @param stream Define the stream the texture should be created from
  112604. * @returns The created video texture as a promise
  112605. */
  112606. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  112607. /**
  112608. * Creates a video texture straight from your WebCam video feed.
  112609. * @param scene Define the scene the texture should be created in
  112610. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112611. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112612. * @returns The created video texture as a promise
  112613. */
  112614. static CreateFromWebCamAsync(scene: Scene, constraints: {
  112615. minWidth: number;
  112616. maxWidth: number;
  112617. minHeight: number;
  112618. maxHeight: number;
  112619. deviceId: string;
  112620. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  112621. /**
  112622. * Creates a video texture straight from your WebCam video feed.
  112623. * @param scene Define the scene the texture should be created in
  112624. * @param onReady Define a callback to triggered once the texture will be ready
  112625. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  112626. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  112627. */
  112628. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  112629. minWidth: number;
  112630. maxWidth: number;
  112631. minHeight: number;
  112632. maxHeight: number;
  112633. deviceId: string;
  112634. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  112635. }
  112636. }
  112637. declare module BABYLON {
  112638. /**
  112639. * Defines the interface used by objects working like Scene
  112640. * @hidden
  112641. */
  112642. export interface ISceneLike {
  112643. _addPendingData(data: any): void;
  112644. _removePendingData(data: any): void;
  112645. offlineProvider: IOfflineProvider;
  112646. }
  112647. /** Interface defining initialization parameters for Engine class */
  112648. export interface EngineOptions extends WebGLContextAttributes {
  112649. /**
  112650. * Defines if the engine should no exceed a specified device ratio
  112651. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  112652. */
  112653. limitDeviceRatio?: number;
  112654. /**
  112655. * Defines if webvr should be enabled automatically
  112656. * @see https://doc.babylonjs.com/how_to/webvr_camera
  112657. */
  112658. autoEnableWebVR?: boolean;
  112659. /**
  112660. * Defines if webgl2 should be turned off even if supported
  112661. * @see https://doc.babylonjs.com/features/webgl2
  112662. */
  112663. disableWebGL2Support?: boolean;
  112664. /**
  112665. * Defines if webaudio should be initialized as well
  112666. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  112667. */
  112668. audioEngine?: boolean;
  112669. /**
  112670. * Defines if animations should run using a deterministic lock step
  112671. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  112672. */
  112673. deterministicLockstep?: boolean;
  112674. /** Defines the maximum steps to use with deterministic lock step mode */
  112675. lockstepMaxSteps?: number;
  112676. /** Defines the seconds between each deterministic lock step */
  112677. timeStep?: number;
  112678. /**
  112679. * Defines that engine should ignore context lost events
  112680. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  112681. */
  112682. doNotHandleContextLost?: boolean;
  112683. /**
  112684. * Defines that engine should ignore modifying touch action attribute and style
  112685. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  112686. */
  112687. doNotHandleTouchAction?: boolean;
  112688. /**
  112689. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  112690. */
  112691. useHighPrecisionFloats?: boolean;
  112692. /**
  112693. * Make the canvas XR Compatible for XR sessions
  112694. */
  112695. xrCompatible?: boolean;
  112696. }
  112697. /**
  112698. * The base engine class (root of all engines)
  112699. */
  112700. export class ThinEngine {
  112701. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  112702. static ExceptionList: ({
  112703. key: string;
  112704. capture: string;
  112705. captureConstraint: number;
  112706. targets: string[];
  112707. } | {
  112708. key: string;
  112709. capture: null;
  112710. captureConstraint: null;
  112711. targets: string[];
  112712. })[];
  112713. /** @hidden */
  112714. static _TextureLoaders: IInternalTextureLoader[];
  112715. /**
  112716. * Returns the current npm package of the sdk
  112717. */
  112718. static get NpmPackage(): string;
  112719. /**
  112720. * Returns the current version of the framework
  112721. */
  112722. static get Version(): string;
  112723. /**
  112724. * Returns a string describing the current engine
  112725. */
  112726. get description(): string;
  112727. /**
  112728. * Gets or sets the epsilon value used by collision engine
  112729. */
  112730. static CollisionsEpsilon: number;
  112731. /**
  112732. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  112733. */
  112734. static get ShadersRepository(): string;
  112735. static set ShadersRepository(value: string);
  112736. /** @hidden */
  112737. _shaderProcessor: IShaderProcessor;
  112738. /**
  112739. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  112740. */
  112741. forcePOTTextures: boolean;
  112742. /**
  112743. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  112744. */
  112745. isFullscreen: boolean;
  112746. /**
  112747. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  112748. */
  112749. cullBackFaces: boolean;
  112750. /**
  112751. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  112752. */
  112753. renderEvenInBackground: boolean;
  112754. /**
  112755. * Gets or sets a boolean indicating that cache can be kept between frames
  112756. */
  112757. preventCacheWipeBetweenFrames: boolean;
  112758. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  112759. validateShaderPrograms: boolean;
  112760. /**
  112761. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  112762. * This can provide greater z depth for distant objects.
  112763. */
  112764. useReverseDepthBuffer: boolean;
  112765. /**
  112766. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  112767. */
  112768. disableUniformBuffers: boolean;
  112769. /** @hidden */
  112770. _uniformBuffers: UniformBuffer[];
  112771. /**
  112772. * Gets a boolean indicating that the engine supports uniform buffers
  112773. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  112774. */
  112775. get supportsUniformBuffers(): boolean;
  112776. /** @hidden */
  112777. _gl: WebGLRenderingContext;
  112778. /** @hidden */
  112779. _webGLVersion: number;
  112780. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  112781. protected _windowIsBackground: boolean;
  112782. protected _creationOptions: EngineOptions;
  112783. protected _highPrecisionShadersAllowed: boolean;
  112784. /** @hidden */
  112785. get _shouldUseHighPrecisionShader(): boolean;
  112786. /**
  112787. * Gets a boolean indicating that only power of 2 textures are supported
  112788. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  112789. */
  112790. get needPOTTextures(): boolean;
  112791. /** @hidden */
  112792. _badOS: boolean;
  112793. /** @hidden */
  112794. _badDesktopOS: boolean;
  112795. private _hardwareScalingLevel;
  112796. /** @hidden */
  112797. _caps: EngineCapabilities;
  112798. private _isStencilEnable;
  112799. private _glVersion;
  112800. private _glRenderer;
  112801. private _glVendor;
  112802. /** @hidden */
  112803. _videoTextureSupported: boolean;
  112804. protected _renderingQueueLaunched: boolean;
  112805. protected _activeRenderLoops: (() => void)[];
  112806. /**
  112807. * Observable signaled when a context lost event is raised
  112808. */
  112809. onContextLostObservable: Observable<ThinEngine>;
  112810. /**
  112811. * Observable signaled when a context restored event is raised
  112812. */
  112813. onContextRestoredObservable: Observable<ThinEngine>;
  112814. private _onContextLost;
  112815. private _onContextRestored;
  112816. protected _contextWasLost: boolean;
  112817. /** @hidden */
  112818. _doNotHandleContextLost: boolean;
  112819. /**
  112820. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  112821. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  112822. */
  112823. get doNotHandleContextLost(): boolean;
  112824. set doNotHandleContextLost(value: boolean);
  112825. /**
  112826. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  112827. */
  112828. disableVertexArrayObjects: boolean;
  112829. /** @hidden */
  112830. protected _colorWrite: boolean;
  112831. /** @hidden */
  112832. protected _colorWriteChanged: boolean;
  112833. /** @hidden */
  112834. protected _depthCullingState: DepthCullingState;
  112835. /** @hidden */
  112836. protected _stencilState: StencilState;
  112837. /** @hidden */
  112838. _alphaState: AlphaState;
  112839. /** @hidden */
  112840. _alphaMode: number;
  112841. /** @hidden */
  112842. _alphaEquation: number;
  112843. /** @hidden */
  112844. _internalTexturesCache: InternalTexture[];
  112845. /** @hidden */
  112846. protected _activeChannel: number;
  112847. private _currentTextureChannel;
  112848. /** @hidden */
  112849. protected _boundTexturesCache: {
  112850. [key: string]: Nullable<InternalTexture>;
  112851. };
  112852. /** @hidden */
  112853. protected _currentEffect: Nullable<Effect>;
  112854. /** @hidden */
  112855. protected _currentProgram: Nullable<WebGLProgram>;
  112856. private _compiledEffects;
  112857. private _vertexAttribArraysEnabled;
  112858. /** @hidden */
  112859. protected _cachedViewport: Nullable<IViewportLike>;
  112860. private _cachedVertexArrayObject;
  112861. /** @hidden */
  112862. protected _cachedVertexBuffers: any;
  112863. /** @hidden */
  112864. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  112865. /** @hidden */
  112866. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  112867. /** @hidden */
  112868. _currentRenderTarget: Nullable<InternalTexture>;
  112869. private _uintIndicesCurrentlySet;
  112870. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  112871. /** @hidden */
  112872. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  112873. /** @hidden */
  112874. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  112875. private _currentBufferPointers;
  112876. private _currentInstanceLocations;
  112877. private _currentInstanceBuffers;
  112878. private _textureUnits;
  112879. /** @hidden */
  112880. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  112881. /** @hidden */
  112882. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  112883. /** @hidden */
  112884. _boundRenderFunction: any;
  112885. private _vaoRecordInProgress;
  112886. private _mustWipeVertexAttributes;
  112887. private _emptyTexture;
  112888. private _emptyCubeTexture;
  112889. private _emptyTexture3D;
  112890. private _emptyTexture2DArray;
  112891. /** @hidden */
  112892. _frameHandler: number;
  112893. private _nextFreeTextureSlots;
  112894. private _maxSimultaneousTextures;
  112895. private _activeRequests;
  112896. /** @hidden */
  112897. _transformTextureUrl: Nullable<(url: string) => string>;
  112898. protected get _supportsHardwareTextureRescaling(): boolean;
  112899. private _framebufferDimensionsObject;
  112900. /**
  112901. * sets the object from which width and height will be taken from when getting render width and height
  112902. * Will fallback to the gl object
  112903. * @param dimensions the framebuffer width and height that will be used.
  112904. */
  112905. set framebufferDimensionsObject(dimensions: Nullable<{
  112906. framebufferWidth: number;
  112907. framebufferHeight: number;
  112908. }>);
  112909. /**
  112910. * Gets the current viewport
  112911. */
  112912. get currentViewport(): Nullable<IViewportLike>;
  112913. /**
  112914. * Gets the default empty texture
  112915. */
  112916. get emptyTexture(): InternalTexture;
  112917. /**
  112918. * Gets the default empty 3D texture
  112919. */
  112920. get emptyTexture3D(): InternalTexture;
  112921. /**
  112922. * Gets the default empty 2D array texture
  112923. */
  112924. get emptyTexture2DArray(): InternalTexture;
  112925. /**
  112926. * Gets the default empty cube texture
  112927. */
  112928. get emptyCubeTexture(): InternalTexture;
  112929. /**
  112930. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  112931. */
  112932. readonly premultipliedAlpha: boolean;
  112933. /**
  112934. * Observable event triggered before each texture is initialized
  112935. */
  112936. onBeforeTextureInitObservable: Observable<Texture>;
  112937. /**
  112938. * Creates a new engine
  112939. * @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
  112940. * @param antialias defines enable antialiasing (default: false)
  112941. * @param options defines further options to be sent to the getContext() function
  112942. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  112943. */
  112944. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  112945. private _rebuildInternalTextures;
  112946. private _rebuildEffects;
  112947. /**
  112948. * Gets a boolean indicating if all created effects are ready
  112949. * @returns true if all effects are ready
  112950. */
  112951. areAllEffectsReady(): boolean;
  112952. protected _rebuildBuffers(): void;
  112953. protected _initGLContext(): void;
  112954. /**
  112955. * Gets version of the current webGL context
  112956. */
  112957. get webGLVersion(): number;
  112958. /**
  112959. * Gets a string idenfifying the name of the class
  112960. * @returns "Engine" string
  112961. */
  112962. getClassName(): string;
  112963. /**
  112964. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  112965. */
  112966. get isStencilEnable(): boolean;
  112967. /** @hidden */
  112968. _prepareWorkingCanvas(): void;
  112969. /**
  112970. * Reset the texture cache to empty state
  112971. */
  112972. resetTextureCache(): void;
  112973. /**
  112974. * Gets an object containing information about the current webGL context
  112975. * @returns an object containing the vender, the renderer and the version of the current webGL context
  112976. */
  112977. getGlInfo(): {
  112978. vendor: string;
  112979. renderer: string;
  112980. version: string;
  112981. };
  112982. /**
  112983. * Defines the hardware scaling level.
  112984. * By default the hardware scaling level is computed from the window device ratio.
  112985. * 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.
  112986. * @param level defines the level to use
  112987. */
  112988. setHardwareScalingLevel(level: number): void;
  112989. /**
  112990. * Gets the current hardware scaling level.
  112991. * By default the hardware scaling level is computed from the window device ratio.
  112992. * 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.
  112993. * @returns a number indicating the current hardware scaling level
  112994. */
  112995. getHardwareScalingLevel(): number;
  112996. /**
  112997. * Gets the list of loaded textures
  112998. * @returns an array containing all loaded textures
  112999. */
  113000. getLoadedTexturesCache(): InternalTexture[];
  113001. /**
  113002. * Gets the object containing all engine capabilities
  113003. * @returns the EngineCapabilities object
  113004. */
  113005. getCaps(): EngineCapabilities;
  113006. /**
  113007. * stop executing a render loop function and remove it from the execution array
  113008. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  113009. */
  113010. stopRenderLoop(renderFunction?: () => void): void;
  113011. /** @hidden */
  113012. _renderLoop(): void;
  113013. /**
  113014. * Gets the HTML canvas attached with the current webGL context
  113015. * @returns a HTML canvas
  113016. */
  113017. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  113018. /**
  113019. * Gets host window
  113020. * @returns the host window object
  113021. */
  113022. getHostWindow(): Nullable<Window>;
  113023. /**
  113024. * Gets the current render width
  113025. * @param useScreen defines if screen size must be used (or the current render target if any)
  113026. * @returns a number defining the current render width
  113027. */
  113028. getRenderWidth(useScreen?: boolean): number;
  113029. /**
  113030. * Gets the current render height
  113031. * @param useScreen defines if screen size must be used (or the current render target if any)
  113032. * @returns a number defining the current render height
  113033. */
  113034. getRenderHeight(useScreen?: boolean): number;
  113035. /**
  113036. * Can be used to override the current requestAnimationFrame requester.
  113037. * @hidden
  113038. */
  113039. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  113040. /**
  113041. * Register and execute a render loop. The engine can have more than one render function
  113042. * @param renderFunction defines the function to continuously execute
  113043. */
  113044. runRenderLoop(renderFunction: () => void): void;
  113045. /**
  113046. * Clear the current render buffer or the current render target (if any is set up)
  113047. * @param color defines the color to use
  113048. * @param backBuffer defines if the back buffer must be cleared
  113049. * @param depth defines if the depth buffer must be cleared
  113050. * @param stencil defines if the stencil buffer must be cleared
  113051. */
  113052. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  113053. private _viewportCached;
  113054. /** @hidden */
  113055. _viewport(x: number, y: number, width: number, height: number): void;
  113056. /**
  113057. * Set the WebGL's viewport
  113058. * @param viewport defines the viewport element to be used
  113059. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  113060. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  113061. */
  113062. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  113063. /**
  113064. * Begin a new frame
  113065. */
  113066. beginFrame(): void;
  113067. /**
  113068. * Enf the current frame
  113069. */
  113070. endFrame(): void;
  113071. /**
  113072. * Resize the view according to the canvas' size
  113073. */
  113074. resize(): void;
  113075. /**
  113076. * Force a specific size of the canvas
  113077. * @param width defines the new canvas' width
  113078. * @param height defines the new canvas' height
  113079. * @returns true if the size was changed
  113080. */
  113081. setSize(width: number, height: number): boolean;
  113082. /**
  113083. * Binds the frame buffer to the specified texture.
  113084. * @param texture The texture to render to or null for the default canvas
  113085. * @param faceIndex The face of the texture to render to in case of cube texture
  113086. * @param requiredWidth The width of the target to render to
  113087. * @param requiredHeight The height of the target to render to
  113088. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  113089. * @param lodLevel defines the lod level to bind to the frame buffer
  113090. * @param layer defines the 2d array index to bind to frame buffer to
  113091. */
  113092. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  113093. /** @hidden */
  113094. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  113095. /**
  113096. * Unbind the current render target texture from the webGL context
  113097. * @param texture defines the render target texture to unbind
  113098. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  113099. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  113100. */
  113101. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  113102. /**
  113103. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  113104. */
  113105. flushFramebuffer(): void;
  113106. /**
  113107. * Unbind the current render target and bind the default framebuffer
  113108. */
  113109. restoreDefaultFramebuffer(): void;
  113110. /** @hidden */
  113111. protected _resetVertexBufferBinding(): void;
  113112. /**
  113113. * Creates a vertex buffer
  113114. * @param data the data for the vertex buffer
  113115. * @returns the new WebGL static buffer
  113116. */
  113117. createVertexBuffer(data: DataArray): DataBuffer;
  113118. private _createVertexBuffer;
  113119. /**
  113120. * Creates a dynamic vertex buffer
  113121. * @param data the data for the dynamic vertex buffer
  113122. * @returns the new WebGL dynamic buffer
  113123. */
  113124. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  113125. protected _resetIndexBufferBinding(): void;
  113126. /**
  113127. * Creates a new index buffer
  113128. * @param indices defines the content of the index buffer
  113129. * @param updatable defines if the index buffer must be updatable
  113130. * @returns a new webGL buffer
  113131. */
  113132. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  113133. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  113134. /**
  113135. * Bind a webGL buffer to the webGL context
  113136. * @param buffer defines the buffer to bind
  113137. */
  113138. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  113139. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  113140. private bindBuffer;
  113141. /**
  113142. * update the bound buffer with the given data
  113143. * @param data defines the data to update
  113144. */
  113145. updateArrayBuffer(data: Float32Array): void;
  113146. private _vertexAttribPointer;
  113147. /** @hidden */
  113148. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  113149. private _bindVertexBuffersAttributes;
  113150. /**
  113151. * Records a vertex array object
  113152. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  113153. * @param vertexBuffers defines the list of vertex buffers to store
  113154. * @param indexBuffer defines the index buffer to store
  113155. * @param effect defines the effect to store
  113156. * @returns the new vertex array object
  113157. */
  113158. recordVertexArrayObject(vertexBuffers: {
  113159. [key: string]: VertexBuffer;
  113160. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  113161. /**
  113162. * Bind a specific vertex array object
  113163. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  113164. * @param vertexArrayObject defines the vertex array object to bind
  113165. * @param indexBuffer defines the index buffer to bind
  113166. */
  113167. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  113168. /**
  113169. * Bind webGl buffers directly to the webGL context
  113170. * @param vertexBuffer defines the vertex buffer to bind
  113171. * @param indexBuffer defines the index buffer to bind
  113172. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  113173. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  113174. * @param effect defines the effect associated with the vertex buffer
  113175. */
  113176. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  113177. private _unbindVertexArrayObject;
  113178. /**
  113179. * Bind a list of vertex buffers to the webGL context
  113180. * @param vertexBuffers defines the list of vertex buffers to bind
  113181. * @param indexBuffer defines the index buffer to bind
  113182. * @param effect defines the effect associated with the vertex buffers
  113183. */
  113184. bindBuffers(vertexBuffers: {
  113185. [key: string]: Nullable<VertexBuffer>;
  113186. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  113187. /**
  113188. * Unbind all instance attributes
  113189. */
  113190. unbindInstanceAttributes(): void;
  113191. /**
  113192. * Release and free the memory of a vertex array object
  113193. * @param vao defines the vertex array object to delete
  113194. */
  113195. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  113196. /** @hidden */
  113197. _releaseBuffer(buffer: DataBuffer): boolean;
  113198. protected _deleteBuffer(buffer: DataBuffer): void;
  113199. /**
  113200. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  113201. * @param instancesBuffer defines the webGL buffer to update and bind
  113202. * @param data defines the data to store in the buffer
  113203. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  113204. */
  113205. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  113206. /**
  113207. * Bind the content of a webGL buffer used with instantiation
  113208. * @param instancesBuffer defines the webGL buffer to bind
  113209. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  113210. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  113211. */
  113212. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  113213. /**
  113214. * Disable the instance attribute corresponding to the name in parameter
  113215. * @param name defines the name of the attribute to disable
  113216. */
  113217. disableInstanceAttributeByName(name: string): void;
  113218. /**
  113219. * Disable the instance attribute corresponding to the location in parameter
  113220. * @param attributeLocation defines the attribute location of the attribute to disable
  113221. */
  113222. disableInstanceAttribute(attributeLocation: number): void;
  113223. /**
  113224. * Disable the attribute corresponding to the location in parameter
  113225. * @param attributeLocation defines the attribute location of the attribute to disable
  113226. */
  113227. disableAttributeByIndex(attributeLocation: number): void;
  113228. /**
  113229. * Send a draw order
  113230. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113231. * @param indexStart defines the starting index
  113232. * @param indexCount defines the number of index to draw
  113233. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113234. */
  113235. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  113236. /**
  113237. * Draw a list of points
  113238. * @param verticesStart defines the index of first vertex to draw
  113239. * @param verticesCount defines the count of vertices to draw
  113240. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113241. */
  113242. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113243. /**
  113244. * Draw a list of unindexed primitives
  113245. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  113246. * @param verticesStart defines the index of first vertex to draw
  113247. * @param verticesCount defines the count of vertices to draw
  113248. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113249. */
  113250. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113251. /**
  113252. * Draw a list of indexed primitives
  113253. * @param fillMode defines the primitive to use
  113254. * @param indexStart defines the starting index
  113255. * @param indexCount defines the number of index to draw
  113256. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113257. */
  113258. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  113259. /**
  113260. * Draw a list of unindexed primitives
  113261. * @param fillMode defines the primitive to use
  113262. * @param verticesStart defines the index of first vertex to draw
  113263. * @param verticesCount defines the count of vertices to draw
  113264. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  113265. */
  113266. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  113267. private _drawMode;
  113268. /** @hidden */
  113269. protected _reportDrawCall(): void;
  113270. /** @hidden */
  113271. _releaseEffect(effect: Effect): void;
  113272. /** @hidden */
  113273. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  113274. /**
  113275. * Create a new effect (used to store vertex/fragment shaders)
  113276. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  113277. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  113278. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  113279. * @param samplers defines an array of string used to represent textures
  113280. * @param defines defines the string containing the defines to use to compile the shaders
  113281. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  113282. * @param onCompiled defines a function to call when the effect creation is successful
  113283. * @param onError defines a function to call when the effect creation has failed
  113284. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  113285. * @returns the new Effect
  113286. */
  113287. 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;
  113288. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  113289. private _compileShader;
  113290. private _compileRawShader;
  113291. /** @hidden */
  113292. _getShaderSource(shader: WebGLShader): Nullable<string>;
  113293. /**
  113294. * Directly creates a webGL program
  113295. * @param pipelineContext defines the pipeline context to attach to
  113296. * @param vertexCode defines the vertex shader code to use
  113297. * @param fragmentCode defines the fragment shader code to use
  113298. * @param context defines the webGL context to use (if not set, the current one will be used)
  113299. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113300. * @returns the new webGL program
  113301. */
  113302. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113303. /**
  113304. * Creates a webGL program
  113305. * @param pipelineContext defines the pipeline context to attach to
  113306. * @param vertexCode defines the vertex shader code to use
  113307. * @param fragmentCode defines the fragment shader code to use
  113308. * @param defines defines the string containing the defines to use to compile the shaders
  113309. * @param context defines the webGL context to use (if not set, the current one will be used)
  113310. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  113311. * @returns the new webGL program
  113312. */
  113313. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113314. /**
  113315. * Creates a new pipeline context
  113316. * @returns the new pipeline
  113317. */
  113318. createPipelineContext(): IPipelineContext;
  113319. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  113320. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  113321. /** @hidden */
  113322. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  113323. /** @hidden */
  113324. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  113325. /** @hidden */
  113326. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  113327. /**
  113328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  113329. * @param pipelineContext defines the pipeline context to use
  113330. * @param uniformsNames defines the list of uniform names
  113331. * @returns an array of webGL uniform locations
  113332. */
  113333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  113334. /**
  113335. * Gets the lsit of active attributes for a given webGL program
  113336. * @param pipelineContext defines the pipeline context to use
  113337. * @param attributesNames defines the list of attribute names to get
  113338. * @returns an array of indices indicating the offset of each attribute
  113339. */
  113340. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  113341. /**
  113342. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  113343. * @param effect defines the effect to activate
  113344. */
  113345. enableEffect(effect: Nullable<Effect>): void;
  113346. /**
  113347. * Set the value of an uniform to a number (int)
  113348. * @param uniform defines the webGL uniform location where to store the value
  113349. * @param value defines the int number to store
  113350. */
  113351. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113352. /**
  113353. * Set the value of an uniform to an array of int32
  113354. * @param uniform defines the webGL uniform location where to store the value
  113355. * @param array defines the array of int32 to store
  113356. */
  113357. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113358. /**
  113359. * Set the value of an uniform to an array of int32 (stored as vec2)
  113360. * @param uniform defines the webGL uniform location where to store the value
  113361. * @param array defines the array of int32 to store
  113362. */
  113363. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113364. /**
  113365. * Set the value of an uniform to an array of int32 (stored as vec3)
  113366. * @param uniform defines the webGL uniform location where to store the value
  113367. * @param array defines the array of int32 to store
  113368. */
  113369. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113370. /**
  113371. * Set the value of an uniform to an array of int32 (stored as vec4)
  113372. * @param uniform defines the webGL uniform location where to store the value
  113373. * @param array defines the array of int32 to store
  113374. */
  113375. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  113376. /**
  113377. * Set the value of an uniform to an array of number
  113378. * @param uniform defines the webGL uniform location where to store the value
  113379. * @param array defines the array of number to store
  113380. */
  113381. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113382. /**
  113383. * Set the value of an uniform to an array of number (stored as vec2)
  113384. * @param uniform defines the webGL uniform location where to store the value
  113385. * @param array defines the array of number to store
  113386. */
  113387. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113388. /**
  113389. * Set the value of an uniform to an array of number (stored as vec3)
  113390. * @param uniform defines the webGL uniform location where to store the value
  113391. * @param array defines the array of number to store
  113392. */
  113393. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113394. /**
  113395. * Set the value of an uniform to an array of number (stored as vec4)
  113396. * @param uniform defines the webGL uniform location where to store the value
  113397. * @param array defines the array of number to store
  113398. */
  113399. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  113400. /**
  113401. * Set the value of an uniform to an array of float32 (stored as matrices)
  113402. * @param uniform defines the webGL uniform location where to store the value
  113403. * @param matrices defines the array of float32 to store
  113404. */
  113405. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  113406. /**
  113407. * Set the value of an uniform to a matrix (3x3)
  113408. * @param uniform defines the webGL uniform location where to store the value
  113409. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  113410. */
  113411. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113412. /**
  113413. * Set the value of an uniform to a matrix (2x2)
  113414. * @param uniform defines the webGL uniform location where to store the value
  113415. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  113416. */
  113417. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  113418. /**
  113419. * Set the value of an uniform to a number (float)
  113420. * @param uniform defines the webGL uniform location where to store the value
  113421. * @param value defines the float number to store
  113422. */
  113423. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  113424. /**
  113425. * Set the value of an uniform to a vec2
  113426. * @param uniform defines the webGL uniform location where to store the value
  113427. * @param x defines the 1st component of the value
  113428. * @param y defines the 2nd component of the value
  113429. */
  113430. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  113431. /**
  113432. * Set the value of an uniform to a vec3
  113433. * @param uniform defines the webGL uniform location where to store the value
  113434. * @param x defines the 1st component of the value
  113435. * @param y defines the 2nd component of the value
  113436. * @param z defines the 3rd component of the value
  113437. */
  113438. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  113439. /**
  113440. * Set the value of an uniform to a vec4
  113441. * @param uniform defines the webGL uniform location where to store the value
  113442. * @param x defines the 1st component of the value
  113443. * @param y defines the 2nd component of the value
  113444. * @param z defines the 3rd component of the value
  113445. * @param w defines the 4th component of the value
  113446. */
  113447. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  113448. /**
  113449. * Apply all cached states (depth, culling, stencil and alpha)
  113450. */
  113451. applyStates(): void;
  113452. /**
  113453. * Enable or disable color writing
  113454. * @param enable defines the state to set
  113455. */
  113456. setColorWrite(enable: boolean): void;
  113457. /**
  113458. * Gets a boolean indicating if color writing is enabled
  113459. * @returns the current color writing state
  113460. */
  113461. getColorWrite(): boolean;
  113462. /**
  113463. * Gets the depth culling state manager
  113464. */
  113465. get depthCullingState(): DepthCullingState;
  113466. /**
  113467. * Gets the alpha state manager
  113468. */
  113469. get alphaState(): AlphaState;
  113470. /**
  113471. * Gets the stencil state manager
  113472. */
  113473. get stencilState(): StencilState;
  113474. /**
  113475. * Clears the list of texture accessible through engine.
  113476. * This can help preventing texture load conflict due to name collision.
  113477. */
  113478. clearInternalTexturesCache(): void;
  113479. /**
  113480. * Force the entire cache to be cleared
  113481. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  113482. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  113483. */
  113484. wipeCaches(bruteForce?: boolean): void;
  113485. /** @hidden */
  113486. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  113487. min: number;
  113488. mag: number;
  113489. };
  113490. /** @hidden */
  113491. _createTexture(): WebGLTexture;
  113492. /**
  113493. * Usually called from Texture.ts.
  113494. * Passed information to create a WebGLTexture
  113495. * @param url defines a value which contains one of the following:
  113496. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  113497. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  113498. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  113499. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  113500. * @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)
  113501. * @param scene needed for loading to the correct scene
  113502. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  113503. * @param onLoad optional callback to be called upon successful completion
  113504. * @param onError optional callback to be called upon failure
  113505. * @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
  113506. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  113507. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  113508. * @param forcedExtension defines the extension to use to pick the right loader
  113509. * @param mimeType defines an optional mime type
  113510. * @returns a InternalTexture for assignment back into BABYLON.Texture
  113511. */
  113512. 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;
  113513. /**
  113514. * Loads an image as an HTMLImageElement.
  113515. * @param input url string, ArrayBuffer, or Blob to load
  113516. * @param onLoad callback called when the image successfully loads
  113517. * @param onError callback called when the image fails to load
  113518. * @param offlineProvider offline provider for caching
  113519. * @param mimeType optional mime type
  113520. * @returns the HTMLImageElement of the loaded image
  113521. * @hidden
  113522. */
  113523. 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>;
  113524. /**
  113525. * @hidden
  113526. */
  113527. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  113528. private _unpackFlipYCached;
  113529. /**
  113530. * In case you are sharing the context with other applications, it might
  113531. * be interested to not cache the unpack flip y state to ensure a consistent
  113532. * value would be set.
  113533. */
  113534. enableUnpackFlipYCached: boolean;
  113535. /** @hidden */
  113536. _unpackFlipY(value: boolean): void;
  113537. /** @hidden */
  113538. _getUnpackAlignement(): number;
  113539. private _getTextureTarget;
  113540. /**
  113541. * Update the sampling mode of a given texture
  113542. * @param samplingMode defines the required sampling mode
  113543. * @param texture defines the texture to update
  113544. * @param generateMipMaps defines whether to generate mipmaps for the texture
  113545. */
  113546. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  113547. /**
  113548. * Update the sampling mode of a given texture
  113549. * @param texture defines the texture to update
  113550. * @param wrapU defines the texture wrap mode of the u coordinates
  113551. * @param wrapV defines the texture wrap mode of the v coordinates
  113552. * @param wrapR defines the texture wrap mode of the r coordinates
  113553. */
  113554. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  113555. /** @hidden */
  113556. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  113557. width: number;
  113558. height: number;
  113559. layers?: number;
  113560. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  113561. /** @hidden */
  113562. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113563. /** @hidden */
  113564. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  113565. /**
  113566. * Update a portion of an internal texture
  113567. * @param texture defines the texture to update
  113568. * @param imageData defines the data to store into the texture
  113569. * @param xOffset defines the x coordinates of the update rectangle
  113570. * @param yOffset defines the y coordinates of the update rectangle
  113571. * @param width defines the width of the update rectangle
  113572. * @param height defines the height of the update rectangle
  113573. * @param faceIndex defines the face index if texture is a cube (0 by default)
  113574. * @param lod defines the lod level to update (0 by default)
  113575. */
  113576. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  113577. /** @hidden */
  113578. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  113579. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  113580. private _prepareWebGLTexture;
  113581. /** @hidden */
  113582. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  113583. private _getDepthStencilBuffer;
  113584. /** @hidden */
  113585. _releaseFramebufferObjects(texture: InternalTexture): void;
  113586. /** @hidden */
  113587. _releaseTexture(texture: InternalTexture): void;
  113588. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  113589. protected _setProgram(program: WebGLProgram): void;
  113590. protected _boundUniforms: {
  113591. [key: number]: WebGLUniformLocation;
  113592. };
  113593. /**
  113594. * Binds an effect to the webGL context
  113595. * @param effect defines the effect to bind
  113596. */
  113597. bindSamplers(effect: Effect): void;
  113598. private _activateCurrentTexture;
  113599. /** @hidden */
  113600. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  113601. /** @hidden */
  113602. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  113603. /**
  113604. * Unbind all textures from the webGL context
  113605. */
  113606. unbindAllTextures(): void;
  113607. /**
  113608. * Sets a texture to the according uniform.
  113609. * @param channel The texture channel
  113610. * @param uniform The uniform to set
  113611. * @param texture The texture to apply
  113612. */
  113613. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  113614. private _bindSamplerUniformToChannel;
  113615. private _getTextureWrapMode;
  113616. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  113617. /**
  113618. * Sets an array of texture to the webGL context
  113619. * @param channel defines the channel where the texture array must be set
  113620. * @param uniform defines the associated uniform location
  113621. * @param textures defines the array of textures to bind
  113622. */
  113623. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  113624. /** @hidden */
  113625. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  113626. private _setTextureParameterFloat;
  113627. private _setTextureParameterInteger;
  113628. /**
  113629. * Unbind all vertex attributes from the webGL context
  113630. */
  113631. unbindAllAttributes(): void;
  113632. /**
  113633. * 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
  113634. */
  113635. releaseEffects(): void;
  113636. /**
  113637. * Dispose and release all associated resources
  113638. */
  113639. dispose(): void;
  113640. /**
  113641. * Attach a new callback raised when context lost event is fired
  113642. * @param callback defines the callback to call
  113643. */
  113644. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113645. /**
  113646. * Attach a new callback raised when context restored event is fired
  113647. * @param callback defines the callback to call
  113648. */
  113649. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  113650. /**
  113651. * Get the current error code of the webGL context
  113652. * @returns the error code
  113653. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  113654. */
  113655. getError(): number;
  113656. private _canRenderToFloatFramebuffer;
  113657. private _canRenderToHalfFloatFramebuffer;
  113658. private _canRenderToFramebuffer;
  113659. /** @hidden */
  113660. _getWebGLTextureType(type: number): number;
  113661. /** @hidden */
  113662. _getInternalFormat(format: number): number;
  113663. /** @hidden */
  113664. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  113665. /** @hidden */
  113666. _getRGBAMultiSampleBufferFormat(type: number): number;
  113667. /** @hidden */
  113668. _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;
  113669. /**
  113670. * Loads a file from a url
  113671. * @param url url to load
  113672. * @param onSuccess callback called when the file successfully loads
  113673. * @param onProgress callback called while file is loading (if the server supports this mode)
  113674. * @param offlineProvider defines the offline provider for caching
  113675. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  113676. * @param onError callback called when the file fails to load
  113677. * @returns a file request object
  113678. * @hidden
  113679. */
  113680. 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;
  113681. /**
  113682. * Reads pixels from the current frame buffer. Please note that this function can be slow
  113683. * @param x defines the x coordinate of the rectangle where pixels must be read
  113684. * @param y defines the y coordinate of the rectangle where pixels must be read
  113685. * @param width defines the width of the rectangle where pixels must be read
  113686. * @param height defines the height of the rectangle where pixels must be read
  113687. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  113688. * @returns a Uint8Array containing RGBA colors
  113689. */
  113690. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  113691. private static _isSupported;
  113692. /**
  113693. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  113694. * @returns true if the engine can be created
  113695. * @ignorenaming
  113696. */
  113697. static isSupported(): boolean;
  113698. /**
  113699. * Find the next highest power of two.
  113700. * @param x Number to start search from.
  113701. * @return Next highest power of two.
  113702. */
  113703. static CeilingPOT(x: number): number;
  113704. /**
  113705. * Find the next lowest power of two.
  113706. * @param x Number to start search from.
  113707. * @return Next lowest power of two.
  113708. */
  113709. static FloorPOT(x: number): number;
  113710. /**
  113711. * Find the nearest power of two.
  113712. * @param x Number to start search from.
  113713. * @return Next nearest power of two.
  113714. */
  113715. static NearestPOT(x: number): number;
  113716. /**
  113717. * Get the closest exponent of two
  113718. * @param value defines the value to approximate
  113719. * @param max defines the maximum value to return
  113720. * @param mode defines how to define the closest value
  113721. * @returns closest exponent of two of the given value
  113722. */
  113723. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  113724. /**
  113725. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  113726. * @param func - the function to be called
  113727. * @param requester - the object that will request the next frame. Falls back to window.
  113728. * @returns frame number
  113729. */
  113730. static QueueNewFrame(func: () => void, requester?: any): number;
  113731. /**
  113732. * Gets host document
  113733. * @returns the host document object
  113734. */
  113735. getHostDocument(): Nullable<Document>;
  113736. }
  113737. }
  113738. declare module BABYLON {
  113739. /**
  113740. * Class representing spherical harmonics coefficients to the 3rd degree
  113741. */
  113742. export class SphericalHarmonics {
  113743. /**
  113744. * Defines whether or not the harmonics have been prescaled for rendering.
  113745. */
  113746. preScaled: boolean;
  113747. /**
  113748. * The l0,0 coefficients of the spherical harmonics
  113749. */
  113750. l00: Vector3;
  113751. /**
  113752. * The l1,-1 coefficients of the spherical harmonics
  113753. */
  113754. l1_1: Vector3;
  113755. /**
  113756. * The l1,0 coefficients of the spherical harmonics
  113757. */
  113758. l10: Vector3;
  113759. /**
  113760. * The l1,1 coefficients of the spherical harmonics
  113761. */
  113762. l11: Vector3;
  113763. /**
  113764. * The l2,-2 coefficients of the spherical harmonics
  113765. */
  113766. l2_2: Vector3;
  113767. /**
  113768. * The l2,-1 coefficients of the spherical harmonics
  113769. */
  113770. l2_1: Vector3;
  113771. /**
  113772. * The l2,0 coefficients of the spherical harmonics
  113773. */
  113774. l20: Vector3;
  113775. /**
  113776. * The l2,1 coefficients of the spherical harmonics
  113777. */
  113778. l21: Vector3;
  113779. /**
  113780. * The l2,2 coefficients of the spherical harmonics
  113781. */
  113782. l22: Vector3;
  113783. /**
  113784. * Adds a light to the spherical harmonics
  113785. * @param direction the direction of the light
  113786. * @param color the color of the light
  113787. * @param deltaSolidAngle the delta solid angle of the light
  113788. */
  113789. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  113790. /**
  113791. * Scales the spherical harmonics by the given amount
  113792. * @param scale the amount to scale
  113793. */
  113794. scaleInPlace(scale: number): void;
  113795. /**
  113796. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  113797. *
  113798. * ```
  113799. * E_lm = A_l * L_lm
  113800. * ```
  113801. *
  113802. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  113803. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  113804. * the scaling factors are given in equation 9.
  113805. */
  113806. convertIncidentRadianceToIrradiance(): void;
  113807. /**
  113808. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  113809. *
  113810. * ```
  113811. * L = (1/pi) * E * rho
  113812. * ```
  113813. *
  113814. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  113815. */
  113816. convertIrradianceToLambertianRadiance(): void;
  113817. /**
  113818. * Integrates the reconstruction coefficients directly in to the SH preventing further
  113819. * required operations at run time.
  113820. *
  113821. * This is simply done by scaling back the SH with Ylm constants parameter.
  113822. * The trigonometric part being applied by the shader at run time.
  113823. */
  113824. preScaleForRendering(): void;
  113825. /**
  113826. * Constructs a spherical harmonics from an array.
  113827. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  113828. * @returns the spherical harmonics
  113829. */
  113830. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  113831. /**
  113832. * Gets the spherical harmonics from polynomial
  113833. * @param polynomial the spherical polynomial
  113834. * @returns the spherical harmonics
  113835. */
  113836. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  113837. }
  113838. /**
  113839. * Class representing spherical polynomial coefficients to the 3rd degree
  113840. */
  113841. export class SphericalPolynomial {
  113842. private _harmonics;
  113843. /**
  113844. * The spherical harmonics used to create the polynomials.
  113845. */
  113846. get preScaledHarmonics(): SphericalHarmonics;
  113847. /**
  113848. * The x coefficients of the spherical polynomial
  113849. */
  113850. x: Vector3;
  113851. /**
  113852. * The y coefficients of the spherical polynomial
  113853. */
  113854. y: Vector3;
  113855. /**
  113856. * The z coefficients of the spherical polynomial
  113857. */
  113858. z: Vector3;
  113859. /**
  113860. * The xx coefficients of the spherical polynomial
  113861. */
  113862. xx: Vector3;
  113863. /**
  113864. * The yy coefficients of the spherical polynomial
  113865. */
  113866. yy: Vector3;
  113867. /**
  113868. * The zz coefficients of the spherical polynomial
  113869. */
  113870. zz: Vector3;
  113871. /**
  113872. * The xy coefficients of the spherical polynomial
  113873. */
  113874. xy: Vector3;
  113875. /**
  113876. * The yz coefficients of the spherical polynomial
  113877. */
  113878. yz: Vector3;
  113879. /**
  113880. * The zx coefficients of the spherical polynomial
  113881. */
  113882. zx: Vector3;
  113883. /**
  113884. * Adds an ambient color to the spherical polynomial
  113885. * @param color the color to add
  113886. */
  113887. addAmbient(color: Color3): void;
  113888. /**
  113889. * Scales the spherical polynomial by the given amount
  113890. * @param scale the amount to scale
  113891. */
  113892. scaleInPlace(scale: number): void;
  113893. /**
  113894. * Gets the spherical polynomial from harmonics
  113895. * @param harmonics the spherical harmonics
  113896. * @returns the spherical polynomial
  113897. */
  113898. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  113899. /**
  113900. * Constructs a spherical polynomial from an array.
  113901. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  113902. * @returns the spherical polynomial
  113903. */
  113904. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  113905. }
  113906. }
  113907. declare module BABYLON {
  113908. /**
  113909. * Defines the source of the internal texture
  113910. */
  113911. export enum InternalTextureSource {
  113912. /**
  113913. * The source of the texture data is unknown
  113914. */
  113915. Unknown = 0,
  113916. /**
  113917. * Texture data comes from an URL
  113918. */
  113919. Url = 1,
  113920. /**
  113921. * Texture data is only used for temporary storage
  113922. */
  113923. Temp = 2,
  113924. /**
  113925. * Texture data comes from raw data (ArrayBuffer)
  113926. */
  113927. Raw = 3,
  113928. /**
  113929. * Texture content is dynamic (video or dynamic texture)
  113930. */
  113931. Dynamic = 4,
  113932. /**
  113933. * Texture content is generated by rendering to it
  113934. */
  113935. RenderTarget = 5,
  113936. /**
  113937. * Texture content is part of a multi render target process
  113938. */
  113939. MultiRenderTarget = 6,
  113940. /**
  113941. * Texture data comes from a cube data file
  113942. */
  113943. Cube = 7,
  113944. /**
  113945. * Texture data comes from a raw cube data
  113946. */
  113947. CubeRaw = 8,
  113948. /**
  113949. * Texture data come from a prefiltered cube data file
  113950. */
  113951. CubePrefiltered = 9,
  113952. /**
  113953. * Texture content is raw 3D data
  113954. */
  113955. Raw3D = 10,
  113956. /**
  113957. * Texture content is raw 2D array data
  113958. */
  113959. Raw2DArray = 11,
  113960. /**
  113961. * Texture content is a depth texture
  113962. */
  113963. Depth = 12,
  113964. /**
  113965. * Texture data comes from a raw cube data encoded with RGBD
  113966. */
  113967. CubeRawRGBD = 13
  113968. }
  113969. /**
  113970. * Class used to store data associated with WebGL texture data for the engine
  113971. * This class should not be used directly
  113972. */
  113973. export class InternalTexture {
  113974. /** @hidden */
  113975. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  113976. /**
  113977. * Defines if the texture is ready
  113978. */
  113979. isReady: boolean;
  113980. /**
  113981. * Defines if the texture is a cube texture
  113982. */
  113983. isCube: boolean;
  113984. /**
  113985. * Defines if the texture contains 3D data
  113986. */
  113987. is3D: boolean;
  113988. /**
  113989. * Defines if the texture contains 2D array data
  113990. */
  113991. is2DArray: boolean;
  113992. /**
  113993. * Defines if the texture contains multiview data
  113994. */
  113995. isMultiview: boolean;
  113996. /**
  113997. * Gets the URL used to load this texture
  113998. */
  113999. url: string;
  114000. /**
  114001. * Gets the sampling mode of the texture
  114002. */
  114003. samplingMode: number;
  114004. /**
  114005. * Gets a boolean indicating if the texture needs mipmaps generation
  114006. */
  114007. generateMipMaps: boolean;
  114008. /**
  114009. * Gets the number of samples used by the texture (WebGL2+ only)
  114010. */
  114011. samples: number;
  114012. /**
  114013. * Gets the type of the texture (int, float...)
  114014. */
  114015. type: number;
  114016. /**
  114017. * Gets the format of the texture (RGB, RGBA...)
  114018. */
  114019. format: number;
  114020. /**
  114021. * Observable called when the texture is loaded
  114022. */
  114023. onLoadedObservable: Observable<InternalTexture>;
  114024. /**
  114025. * Gets the width of the texture
  114026. */
  114027. width: number;
  114028. /**
  114029. * Gets the height of the texture
  114030. */
  114031. height: number;
  114032. /**
  114033. * Gets the depth of the texture
  114034. */
  114035. depth: number;
  114036. /**
  114037. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  114038. */
  114039. baseWidth: number;
  114040. /**
  114041. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  114042. */
  114043. baseHeight: number;
  114044. /**
  114045. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  114046. */
  114047. baseDepth: number;
  114048. /**
  114049. * Gets a boolean indicating if the texture is inverted on Y axis
  114050. */
  114051. invertY: boolean;
  114052. /** @hidden */
  114053. _invertVScale: boolean;
  114054. /** @hidden */
  114055. _associatedChannel: number;
  114056. /** @hidden */
  114057. _source: InternalTextureSource;
  114058. /** @hidden */
  114059. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  114060. /** @hidden */
  114061. _bufferView: Nullable<ArrayBufferView>;
  114062. /** @hidden */
  114063. _bufferViewArray: Nullable<ArrayBufferView[]>;
  114064. /** @hidden */
  114065. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  114066. /** @hidden */
  114067. _size: number;
  114068. /** @hidden */
  114069. _extension: string;
  114070. /** @hidden */
  114071. _files: Nullable<string[]>;
  114072. /** @hidden */
  114073. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  114074. /** @hidden */
  114075. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  114076. /** @hidden */
  114077. _framebuffer: Nullable<WebGLFramebuffer>;
  114078. /** @hidden */
  114079. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  114080. /** @hidden */
  114081. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  114082. /** @hidden */
  114083. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  114084. /** @hidden */
  114085. _attachments: Nullable<number[]>;
  114086. /** @hidden */
  114087. _textureArray: Nullable<InternalTexture[]>;
  114088. /** @hidden */
  114089. _cachedCoordinatesMode: Nullable<number>;
  114090. /** @hidden */
  114091. _cachedWrapU: Nullable<number>;
  114092. /** @hidden */
  114093. _cachedWrapV: Nullable<number>;
  114094. /** @hidden */
  114095. _cachedWrapR: Nullable<number>;
  114096. /** @hidden */
  114097. _cachedAnisotropicFilteringLevel: Nullable<number>;
  114098. /** @hidden */
  114099. _isDisabled: boolean;
  114100. /** @hidden */
  114101. _compression: Nullable<string>;
  114102. /** @hidden */
  114103. _generateStencilBuffer: boolean;
  114104. /** @hidden */
  114105. _generateDepthBuffer: boolean;
  114106. /** @hidden */
  114107. _comparisonFunction: number;
  114108. /** @hidden */
  114109. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  114110. /** @hidden */
  114111. _lodGenerationScale: number;
  114112. /** @hidden */
  114113. _lodGenerationOffset: number;
  114114. /** @hidden */
  114115. _depthStencilTexture: Nullable<InternalTexture>;
  114116. /** @hidden */
  114117. _colorTextureArray: Nullable<WebGLTexture>;
  114118. /** @hidden */
  114119. _depthStencilTextureArray: Nullable<WebGLTexture>;
  114120. /** @hidden */
  114121. _lodTextureHigh: Nullable<BaseTexture>;
  114122. /** @hidden */
  114123. _lodTextureMid: Nullable<BaseTexture>;
  114124. /** @hidden */
  114125. _lodTextureLow: Nullable<BaseTexture>;
  114126. /** @hidden */
  114127. _isRGBD: boolean;
  114128. /** @hidden */
  114129. _linearSpecularLOD: boolean;
  114130. /** @hidden */
  114131. _irradianceTexture: Nullable<BaseTexture>;
  114132. /** @hidden */
  114133. _webGLTexture: Nullable<WebGLTexture>;
  114134. /** @hidden */
  114135. _references: number;
  114136. private _engine;
  114137. /**
  114138. * Gets the Engine the texture belongs to.
  114139. * @returns The babylon engine
  114140. */
  114141. getEngine(): ThinEngine;
  114142. /**
  114143. * Gets the data source type of the texture
  114144. */
  114145. get source(): InternalTextureSource;
  114146. /**
  114147. * Creates a new InternalTexture
  114148. * @param engine defines the engine to use
  114149. * @param source defines the type of data that will be used
  114150. * @param delayAllocation if the texture allocation should be delayed (default: false)
  114151. */
  114152. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  114153. /**
  114154. * Increments the number of references (ie. the number of Texture that point to it)
  114155. */
  114156. incrementReferences(): void;
  114157. /**
  114158. * Change the size of the texture (not the size of the content)
  114159. * @param width defines the new width
  114160. * @param height defines the new height
  114161. * @param depth defines the new depth (1 by default)
  114162. */
  114163. updateSize(width: int, height: int, depth?: int): void;
  114164. /** @hidden */
  114165. _rebuild(): void;
  114166. /** @hidden */
  114167. _swapAndDie(target: InternalTexture): void;
  114168. /**
  114169. * Dispose the current allocated resources
  114170. */
  114171. dispose(): void;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * Class used to work with sound analyzer using fast fourier transform (FFT)
  114177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114178. */
  114179. export class Analyser {
  114180. /**
  114181. * Gets or sets the smoothing
  114182. * @ignorenaming
  114183. */
  114184. SMOOTHING: number;
  114185. /**
  114186. * Gets or sets the FFT table size
  114187. * @ignorenaming
  114188. */
  114189. FFT_SIZE: number;
  114190. /**
  114191. * Gets or sets the bar graph amplitude
  114192. * @ignorenaming
  114193. */
  114194. BARGRAPHAMPLITUDE: number;
  114195. /**
  114196. * Gets or sets the position of the debug canvas
  114197. * @ignorenaming
  114198. */
  114199. DEBUGCANVASPOS: {
  114200. x: number;
  114201. y: number;
  114202. };
  114203. /**
  114204. * Gets or sets the debug canvas size
  114205. * @ignorenaming
  114206. */
  114207. DEBUGCANVASSIZE: {
  114208. width: number;
  114209. height: number;
  114210. };
  114211. private _byteFreqs;
  114212. private _byteTime;
  114213. private _floatFreqs;
  114214. private _webAudioAnalyser;
  114215. private _debugCanvas;
  114216. private _debugCanvasContext;
  114217. private _scene;
  114218. private _registerFunc;
  114219. private _audioEngine;
  114220. /**
  114221. * Creates a new analyser
  114222. * @param scene defines hosting scene
  114223. */
  114224. constructor(scene: Scene);
  114225. /**
  114226. * Get the number of data values you will have to play with for the visualization
  114227. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  114228. * @returns a number
  114229. */
  114230. getFrequencyBinCount(): number;
  114231. /**
  114232. * Gets the current frequency data as a byte array
  114233. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114234. * @returns a Uint8Array
  114235. */
  114236. getByteFrequencyData(): Uint8Array;
  114237. /**
  114238. * Gets the current waveform as a byte array
  114239. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  114240. * @returns a Uint8Array
  114241. */
  114242. getByteTimeDomainData(): Uint8Array;
  114243. /**
  114244. * Gets the current frequency data as a float array
  114245. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  114246. * @returns a Float32Array
  114247. */
  114248. getFloatFrequencyData(): Float32Array;
  114249. /**
  114250. * Renders the debug canvas
  114251. */
  114252. drawDebugCanvas(): void;
  114253. /**
  114254. * Stops rendering the debug canvas and removes it
  114255. */
  114256. stopDebugCanvas(): void;
  114257. /**
  114258. * Connects two audio nodes
  114259. * @param inputAudioNode defines first node to connect
  114260. * @param outputAudioNode defines second node to connect
  114261. */
  114262. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  114263. /**
  114264. * Releases all associated resources
  114265. */
  114266. dispose(): void;
  114267. }
  114268. }
  114269. declare module BABYLON {
  114270. /**
  114271. * This represents an audio engine and it is responsible
  114272. * to play, synchronize and analyse sounds throughout the application.
  114273. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114274. */
  114275. export interface IAudioEngine extends IDisposable {
  114276. /**
  114277. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114278. */
  114279. readonly canUseWebAudio: boolean;
  114280. /**
  114281. * Gets the current AudioContext if available.
  114282. */
  114283. readonly audioContext: Nullable<AudioContext>;
  114284. /**
  114285. * The master gain node defines the global audio volume of your audio engine.
  114286. */
  114287. readonly masterGain: GainNode;
  114288. /**
  114289. * Gets whether or not mp3 are supported by your browser.
  114290. */
  114291. readonly isMP3supported: boolean;
  114292. /**
  114293. * Gets whether or not ogg are supported by your browser.
  114294. */
  114295. readonly isOGGsupported: boolean;
  114296. /**
  114297. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114298. * @ignoreNaming
  114299. */
  114300. WarnedWebAudioUnsupported: boolean;
  114301. /**
  114302. * Defines if the audio engine relies on a custom unlocked button.
  114303. * In this case, the embedded button will not be displayed.
  114304. */
  114305. useCustomUnlockedButton: boolean;
  114306. /**
  114307. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  114308. */
  114309. readonly unlocked: boolean;
  114310. /**
  114311. * Event raised when audio has been unlocked on the browser.
  114312. */
  114313. onAudioUnlockedObservable: Observable<AudioEngine>;
  114314. /**
  114315. * Event raised when audio has been locked on the browser.
  114316. */
  114317. onAudioLockedObservable: Observable<AudioEngine>;
  114318. /**
  114319. * Flags the audio engine in Locked state.
  114320. * This happens due to new browser policies preventing audio to autoplay.
  114321. */
  114322. lock(): void;
  114323. /**
  114324. * Unlocks the audio engine once a user action has been done on the dom.
  114325. * This is helpful to resume play once browser policies have been satisfied.
  114326. */
  114327. unlock(): void;
  114328. /**
  114329. * Gets the global volume sets on the master gain.
  114330. * @returns the global volume if set or -1 otherwise
  114331. */
  114332. getGlobalVolume(): number;
  114333. /**
  114334. * Sets the global volume of your experience (sets on the master gain).
  114335. * @param newVolume Defines the new global volume of the application
  114336. */
  114337. setGlobalVolume(newVolume: number): void;
  114338. /**
  114339. * Connect the audio engine to an audio analyser allowing some amazing
  114340. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114341. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114342. * @param analyser The analyser to connect to the engine
  114343. */
  114344. connectToAnalyser(analyser: Analyser): void;
  114345. }
  114346. /**
  114347. * This represents the default audio engine used in babylon.
  114348. * It is responsible to play, synchronize and analyse sounds throughout the application.
  114349. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  114350. */
  114351. export class AudioEngine implements IAudioEngine {
  114352. private _audioContext;
  114353. private _audioContextInitialized;
  114354. private _muteButton;
  114355. private _hostElement;
  114356. /**
  114357. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  114358. */
  114359. canUseWebAudio: boolean;
  114360. /**
  114361. * The master gain node defines the global audio volume of your audio engine.
  114362. */
  114363. masterGain: GainNode;
  114364. /**
  114365. * Defines if Babylon should emit a warning if WebAudio is not supported.
  114366. * @ignoreNaming
  114367. */
  114368. WarnedWebAudioUnsupported: boolean;
  114369. /**
  114370. * Gets whether or not mp3 are supported by your browser.
  114371. */
  114372. isMP3supported: boolean;
  114373. /**
  114374. * Gets whether or not ogg are supported by your browser.
  114375. */
  114376. isOGGsupported: boolean;
  114377. /**
  114378. * Gets whether audio has been unlocked on the device.
  114379. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  114380. * a user interaction has happened.
  114381. */
  114382. unlocked: boolean;
  114383. /**
  114384. * Defines if the audio engine relies on a custom unlocked button.
  114385. * In this case, the embedded button will not be displayed.
  114386. */
  114387. useCustomUnlockedButton: boolean;
  114388. /**
  114389. * Event raised when audio has been unlocked on the browser.
  114390. */
  114391. onAudioUnlockedObservable: Observable<AudioEngine>;
  114392. /**
  114393. * Event raised when audio has been locked on the browser.
  114394. */
  114395. onAudioLockedObservable: Observable<AudioEngine>;
  114396. /**
  114397. * Gets the current AudioContext if available.
  114398. */
  114399. get audioContext(): Nullable<AudioContext>;
  114400. private _connectedAnalyser;
  114401. /**
  114402. * Instantiates a new audio engine.
  114403. *
  114404. * There should be only one per page as some browsers restrict the number
  114405. * of audio contexts you can create.
  114406. * @param hostElement defines the host element where to display the mute icon if necessary
  114407. */
  114408. constructor(hostElement?: Nullable<HTMLElement>);
  114409. /**
  114410. * Flags the audio engine in Locked state.
  114411. * This happens due to new browser policies preventing audio to autoplay.
  114412. */
  114413. lock(): void;
  114414. /**
  114415. * Unlocks the audio engine once a user action has been done on the dom.
  114416. * This is helpful to resume play once browser policies have been satisfied.
  114417. */
  114418. unlock(): void;
  114419. private _resumeAudioContext;
  114420. private _initializeAudioContext;
  114421. private _tryToRun;
  114422. private _triggerRunningState;
  114423. private _triggerSuspendedState;
  114424. private _displayMuteButton;
  114425. private _moveButtonToTopLeft;
  114426. private _onResize;
  114427. private _hideMuteButton;
  114428. /**
  114429. * Destroy and release the resources associated with the audio ccontext.
  114430. */
  114431. dispose(): void;
  114432. /**
  114433. * Gets the global volume sets on the master gain.
  114434. * @returns the global volume if set or -1 otherwise
  114435. */
  114436. getGlobalVolume(): number;
  114437. /**
  114438. * Sets the global volume of your experience (sets on the master gain).
  114439. * @param newVolume Defines the new global volume of the application
  114440. */
  114441. setGlobalVolume(newVolume: number): void;
  114442. /**
  114443. * Connect the audio engine to an audio analyser allowing some amazing
  114444. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  114445. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  114446. * @param analyser The analyser to connect to the engine
  114447. */
  114448. connectToAnalyser(analyser: Analyser): void;
  114449. }
  114450. }
  114451. declare module BABYLON {
  114452. /**
  114453. * Interface used to present a loading screen while loading a scene
  114454. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114455. */
  114456. export interface ILoadingScreen {
  114457. /**
  114458. * Function called to display the loading screen
  114459. */
  114460. displayLoadingUI: () => void;
  114461. /**
  114462. * Function called to hide the loading screen
  114463. */
  114464. hideLoadingUI: () => void;
  114465. /**
  114466. * Gets or sets the color to use for the background
  114467. */
  114468. loadingUIBackgroundColor: string;
  114469. /**
  114470. * Gets or sets the text to display while loading
  114471. */
  114472. loadingUIText: string;
  114473. }
  114474. /**
  114475. * Class used for the default loading screen
  114476. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114477. */
  114478. export class DefaultLoadingScreen implements ILoadingScreen {
  114479. private _renderingCanvas;
  114480. private _loadingText;
  114481. private _loadingDivBackgroundColor;
  114482. private _loadingDiv;
  114483. private _loadingTextDiv;
  114484. /** Gets or sets the logo url to use for the default loading screen */
  114485. static DefaultLogoUrl: string;
  114486. /** Gets or sets the spinner url to use for the default loading screen */
  114487. static DefaultSpinnerUrl: string;
  114488. /**
  114489. * Creates a new default loading screen
  114490. * @param _renderingCanvas defines the canvas used to render the scene
  114491. * @param _loadingText defines the default text to display
  114492. * @param _loadingDivBackgroundColor defines the default background color
  114493. */
  114494. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  114495. /**
  114496. * Function called to display the loading screen
  114497. */
  114498. displayLoadingUI(): void;
  114499. /**
  114500. * Function called to hide the loading screen
  114501. */
  114502. hideLoadingUI(): void;
  114503. /**
  114504. * Gets or sets the text to display while loading
  114505. */
  114506. set loadingUIText(text: string);
  114507. get loadingUIText(): string;
  114508. /**
  114509. * Gets or sets the color to use for the background
  114510. */
  114511. get loadingUIBackgroundColor(): string;
  114512. set loadingUIBackgroundColor(color: string);
  114513. private _resizeLoadingUI;
  114514. }
  114515. }
  114516. declare module BABYLON {
  114517. /**
  114518. * Interface for any object that can request an animation frame
  114519. */
  114520. export interface ICustomAnimationFrameRequester {
  114521. /**
  114522. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  114523. */
  114524. renderFunction?: Function;
  114525. /**
  114526. * Called to request the next frame to render to
  114527. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  114528. */
  114529. requestAnimationFrame: Function;
  114530. /**
  114531. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  114532. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  114533. */
  114534. requestID?: number;
  114535. }
  114536. }
  114537. declare module BABYLON {
  114538. /**
  114539. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  114540. */
  114541. export class PerformanceMonitor {
  114542. private _enabled;
  114543. private _rollingFrameTime;
  114544. private _lastFrameTimeMs;
  114545. /**
  114546. * constructor
  114547. * @param frameSampleSize The number of samples required to saturate the sliding window
  114548. */
  114549. constructor(frameSampleSize?: number);
  114550. /**
  114551. * Samples current frame
  114552. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  114553. */
  114554. sampleFrame(timeMs?: number): void;
  114555. /**
  114556. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114557. */
  114558. get averageFrameTime(): number;
  114559. /**
  114560. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  114561. */
  114562. get averageFrameTimeVariance(): number;
  114563. /**
  114564. * Returns the frame time of the most recent frame
  114565. */
  114566. get instantaneousFrameTime(): number;
  114567. /**
  114568. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  114569. */
  114570. get averageFPS(): number;
  114571. /**
  114572. * Returns the average framerate in frames per second using the most recent frame time
  114573. */
  114574. get instantaneousFPS(): number;
  114575. /**
  114576. * Returns true if enough samples have been taken to completely fill the sliding window
  114577. */
  114578. get isSaturated(): boolean;
  114579. /**
  114580. * Enables contributions to the sliding window sample set
  114581. */
  114582. enable(): void;
  114583. /**
  114584. * Disables contributions to the sliding window sample set
  114585. * Samples will not be interpolated over the disabled period
  114586. */
  114587. disable(): void;
  114588. /**
  114589. * Returns true if sampling is enabled
  114590. */
  114591. get isEnabled(): boolean;
  114592. /**
  114593. * Resets performance monitor
  114594. */
  114595. reset(): void;
  114596. }
  114597. /**
  114598. * RollingAverage
  114599. *
  114600. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  114601. */
  114602. export class RollingAverage {
  114603. /**
  114604. * Current average
  114605. */
  114606. average: number;
  114607. /**
  114608. * Current variance
  114609. */
  114610. variance: number;
  114611. protected _samples: Array<number>;
  114612. protected _sampleCount: number;
  114613. protected _pos: number;
  114614. protected _m2: number;
  114615. /**
  114616. * constructor
  114617. * @param length The number of samples required to saturate the sliding window
  114618. */
  114619. constructor(length: number);
  114620. /**
  114621. * Adds a sample to the sample set
  114622. * @param v The sample value
  114623. */
  114624. add(v: number): void;
  114625. /**
  114626. * Returns previously added values or null if outside of history or outside the sliding window domain
  114627. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  114628. * @return Value previously recorded with add() or null if outside of range
  114629. */
  114630. history(i: number): number;
  114631. /**
  114632. * Returns true if enough samples have been taken to completely fill the sliding window
  114633. * @return true if sample-set saturated
  114634. */
  114635. isSaturated(): boolean;
  114636. /**
  114637. * Resets the rolling average (equivalent to 0 samples taken so far)
  114638. */
  114639. reset(): void;
  114640. /**
  114641. * Wraps a value around the sample range boundaries
  114642. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  114643. * @return Wrapped position in sample range
  114644. */
  114645. protected _wrapPosition(i: number): number;
  114646. }
  114647. }
  114648. declare module BABYLON {
  114649. /**
  114650. * This class is used to track a performance counter which is number based.
  114651. * The user has access to many properties which give statistics of different nature.
  114652. *
  114653. * The implementer can track two kinds of Performance Counter: time and count.
  114654. * 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.
  114655. * 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.
  114656. */
  114657. export class PerfCounter {
  114658. /**
  114659. * Gets or sets a global boolean to turn on and off all the counters
  114660. */
  114661. static Enabled: boolean;
  114662. /**
  114663. * Returns the smallest value ever
  114664. */
  114665. get min(): number;
  114666. /**
  114667. * Returns the biggest value ever
  114668. */
  114669. get max(): number;
  114670. /**
  114671. * Returns the average value since the performance counter is running
  114672. */
  114673. get average(): number;
  114674. /**
  114675. * Returns the average value of the last second the counter was monitored
  114676. */
  114677. get lastSecAverage(): number;
  114678. /**
  114679. * Returns the current value
  114680. */
  114681. get current(): number;
  114682. /**
  114683. * Gets the accumulated total
  114684. */
  114685. get total(): number;
  114686. /**
  114687. * Gets the total value count
  114688. */
  114689. get count(): number;
  114690. /**
  114691. * Creates a new counter
  114692. */
  114693. constructor();
  114694. /**
  114695. * Call this method to start monitoring a new frame.
  114696. * 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.
  114697. */
  114698. fetchNewFrame(): void;
  114699. /**
  114700. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  114701. * @param newCount the count value to add to the monitored count
  114702. * @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.
  114703. */
  114704. addCount(newCount: number, fetchResult: boolean): void;
  114705. /**
  114706. * Start monitoring this performance counter
  114707. */
  114708. beginMonitoring(): void;
  114709. /**
  114710. * Compute the time lapsed since the previous beginMonitoring() call.
  114711. * @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
  114712. */
  114713. endMonitoring(newFrame?: boolean): void;
  114714. private _fetchResult;
  114715. private _startMonitoringTime;
  114716. private _min;
  114717. private _max;
  114718. private _average;
  114719. private _current;
  114720. private _totalValueCount;
  114721. private _totalAccumulated;
  114722. private _lastSecAverage;
  114723. private _lastSecAccumulated;
  114724. private _lastSecTime;
  114725. private _lastSecValueCount;
  114726. }
  114727. }
  114728. declare module BABYLON {
  114729. interface ThinEngine {
  114730. /**
  114731. * Sets alpha constants used by some alpha blending modes
  114732. * @param r defines the red component
  114733. * @param g defines the green component
  114734. * @param b defines the blue component
  114735. * @param a defines the alpha component
  114736. */
  114737. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  114738. /**
  114739. * Sets the current alpha mode
  114740. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  114741. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  114742. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114743. */
  114744. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  114745. /**
  114746. * Gets the current alpha mode
  114747. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  114748. * @returns the current alpha mode
  114749. */
  114750. getAlphaMode(): number;
  114751. /**
  114752. * Sets the current alpha equation
  114753. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  114754. */
  114755. setAlphaEquation(equation: number): void;
  114756. /**
  114757. * Gets the current alpha equation.
  114758. * @returns the current alpha equation
  114759. */
  114760. getAlphaEquation(): number;
  114761. }
  114762. }
  114763. declare module BABYLON {
  114764. interface ThinEngine {
  114765. /** @hidden */
  114766. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  114767. }
  114768. }
  114769. declare module BABYLON {
  114770. /**
  114771. * Defines the interface used by display changed events
  114772. */
  114773. export interface IDisplayChangedEventArgs {
  114774. /** Gets the vrDisplay object (if any) */
  114775. vrDisplay: Nullable<any>;
  114776. /** Gets a boolean indicating if webVR is supported */
  114777. vrSupported: boolean;
  114778. }
  114779. /**
  114780. * Defines the interface used by objects containing a viewport (like a camera)
  114781. */
  114782. interface IViewportOwnerLike {
  114783. /**
  114784. * Gets or sets the viewport
  114785. */
  114786. viewport: IViewportLike;
  114787. }
  114788. /**
  114789. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  114790. */
  114791. export class Engine extends ThinEngine {
  114792. /** Defines that alpha blending is disabled */
  114793. static readonly ALPHA_DISABLE: number;
  114794. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  114795. static readonly ALPHA_ADD: number;
  114796. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  114797. static readonly ALPHA_COMBINE: number;
  114798. /** Defines that alpha blending to DEST - SRC * DEST */
  114799. static readonly ALPHA_SUBTRACT: number;
  114800. /** Defines that alpha blending to SRC * DEST */
  114801. static readonly ALPHA_MULTIPLY: number;
  114802. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  114803. static readonly ALPHA_MAXIMIZED: number;
  114804. /** Defines that alpha blending to SRC + DEST */
  114805. static readonly ALPHA_ONEONE: number;
  114806. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  114807. static readonly ALPHA_PREMULTIPLIED: number;
  114808. /**
  114809. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  114810. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  114811. */
  114812. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  114813. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  114814. static readonly ALPHA_INTERPOLATE: number;
  114815. /**
  114816. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  114817. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  114818. */
  114819. static readonly ALPHA_SCREENMODE: number;
  114820. /** Defines that the ressource is not delayed*/
  114821. static readonly DELAYLOADSTATE_NONE: number;
  114822. /** Defines that the ressource was successfully delay loaded */
  114823. static readonly DELAYLOADSTATE_LOADED: number;
  114824. /** Defines that the ressource is currently delay loading */
  114825. static readonly DELAYLOADSTATE_LOADING: number;
  114826. /** Defines that the ressource is delayed and has not started loading */
  114827. static readonly DELAYLOADSTATE_NOTLOADED: number;
  114828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  114829. static readonly NEVER: number;
  114830. /** 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 */
  114831. static readonly ALWAYS: number;
  114832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  114833. static readonly LESS: number;
  114834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  114835. static readonly EQUAL: number;
  114836. /** 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 */
  114837. static readonly LEQUAL: number;
  114838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  114839. static readonly GREATER: number;
  114840. /** 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 */
  114841. static readonly GEQUAL: number;
  114842. /** 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 */
  114843. static readonly NOTEQUAL: number;
  114844. /** Passed to stencilOperation to specify that stencil value must be kept */
  114845. static readonly KEEP: number;
  114846. /** Passed to stencilOperation to specify that stencil value must be replaced */
  114847. static readonly REPLACE: number;
  114848. /** Passed to stencilOperation to specify that stencil value must be incremented */
  114849. static readonly INCR: number;
  114850. /** Passed to stencilOperation to specify that stencil value must be decremented */
  114851. static readonly DECR: number;
  114852. /** Passed to stencilOperation to specify that stencil value must be inverted */
  114853. static readonly INVERT: number;
  114854. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  114855. static readonly INCR_WRAP: number;
  114856. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  114857. static readonly DECR_WRAP: number;
  114858. /** Texture is not repeating outside of 0..1 UVs */
  114859. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  114860. /** Texture is repeating outside of 0..1 UVs */
  114861. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  114862. /** Texture is repeating and mirrored */
  114863. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  114864. /** ALPHA */
  114865. static readonly TEXTUREFORMAT_ALPHA: number;
  114866. /** LUMINANCE */
  114867. static readonly TEXTUREFORMAT_LUMINANCE: number;
  114868. /** LUMINANCE_ALPHA */
  114869. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  114870. /** RGB */
  114871. static readonly TEXTUREFORMAT_RGB: number;
  114872. /** RGBA */
  114873. static readonly TEXTUREFORMAT_RGBA: number;
  114874. /** RED */
  114875. static readonly TEXTUREFORMAT_RED: number;
  114876. /** RED (2nd reference) */
  114877. static readonly TEXTUREFORMAT_R: number;
  114878. /** RG */
  114879. static readonly TEXTUREFORMAT_RG: number;
  114880. /** RED_INTEGER */
  114881. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  114882. /** RED_INTEGER (2nd reference) */
  114883. static readonly TEXTUREFORMAT_R_INTEGER: number;
  114884. /** RG_INTEGER */
  114885. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  114886. /** RGB_INTEGER */
  114887. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  114888. /** RGBA_INTEGER */
  114889. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  114890. /** UNSIGNED_BYTE */
  114891. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  114892. /** UNSIGNED_BYTE (2nd reference) */
  114893. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  114894. /** FLOAT */
  114895. static readonly TEXTURETYPE_FLOAT: number;
  114896. /** HALF_FLOAT */
  114897. static readonly TEXTURETYPE_HALF_FLOAT: number;
  114898. /** BYTE */
  114899. static readonly TEXTURETYPE_BYTE: number;
  114900. /** SHORT */
  114901. static readonly TEXTURETYPE_SHORT: number;
  114902. /** UNSIGNED_SHORT */
  114903. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  114904. /** INT */
  114905. static readonly TEXTURETYPE_INT: number;
  114906. /** UNSIGNED_INT */
  114907. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  114908. /** UNSIGNED_SHORT_4_4_4_4 */
  114909. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  114910. /** UNSIGNED_SHORT_5_5_5_1 */
  114911. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  114912. /** UNSIGNED_SHORT_5_6_5 */
  114913. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  114914. /** UNSIGNED_INT_2_10_10_10_REV */
  114915. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  114916. /** UNSIGNED_INT_24_8 */
  114917. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  114918. /** UNSIGNED_INT_10F_11F_11F_REV */
  114919. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  114920. /** UNSIGNED_INT_5_9_9_9_REV */
  114921. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  114922. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  114923. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  114924. /** nearest is mag = nearest and min = nearest and mip = linear */
  114925. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  114926. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114927. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  114928. /** Trilinear is mag = linear and min = linear and mip = linear */
  114929. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  114930. /** nearest is mag = nearest and min = nearest and mip = linear */
  114931. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  114932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  114933. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  114934. /** Trilinear is mag = linear and min = linear and mip = linear */
  114935. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  114936. /** mag = nearest and min = nearest and mip = nearest */
  114937. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  114938. /** mag = nearest and min = linear and mip = nearest */
  114939. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  114940. /** mag = nearest and min = linear and mip = linear */
  114941. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  114942. /** mag = nearest and min = linear and mip = none */
  114943. static readonly TEXTURE_NEAREST_LINEAR: number;
  114944. /** mag = nearest and min = nearest and mip = none */
  114945. static readonly TEXTURE_NEAREST_NEAREST: number;
  114946. /** mag = linear and min = nearest and mip = nearest */
  114947. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  114948. /** mag = linear and min = nearest and mip = linear */
  114949. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  114950. /** mag = linear and min = linear and mip = none */
  114951. static readonly TEXTURE_LINEAR_LINEAR: number;
  114952. /** mag = linear and min = nearest and mip = none */
  114953. static readonly TEXTURE_LINEAR_NEAREST: number;
  114954. /** Explicit coordinates mode */
  114955. static readonly TEXTURE_EXPLICIT_MODE: number;
  114956. /** Spherical coordinates mode */
  114957. static readonly TEXTURE_SPHERICAL_MODE: number;
  114958. /** Planar coordinates mode */
  114959. static readonly TEXTURE_PLANAR_MODE: number;
  114960. /** Cubic coordinates mode */
  114961. static readonly TEXTURE_CUBIC_MODE: number;
  114962. /** Projection coordinates mode */
  114963. static readonly TEXTURE_PROJECTION_MODE: number;
  114964. /** Skybox coordinates mode */
  114965. static readonly TEXTURE_SKYBOX_MODE: number;
  114966. /** Inverse Cubic coordinates mode */
  114967. static readonly TEXTURE_INVCUBIC_MODE: number;
  114968. /** Equirectangular coordinates mode */
  114969. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  114970. /** Equirectangular Fixed coordinates mode */
  114971. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  114972. /** Equirectangular Fixed Mirrored coordinates mode */
  114973. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  114974. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  114975. static readonly SCALEMODE_FLOOR: number;
  114976. /** Defines that texture rescaling will look for the nearest power of 2 size */
  114977. static readonly SCALEMODE_NEAREST: number;
  114978. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  114979. static readonly SCALEMODE_CEILING: number;
  114980. /**
  114981. * Returns the current npm package of the sdk
  114982. */
  114983. static get NpmPackage(): string;
  114984. /**
  114985. * Returns the current version of the framework
  114986. */
  114987. static get Version(): string;
  114988. /** Gets the list of created engines */
  114989. static get Instances(): Engine[];
  114990. /**
  114991. * Gets the latest created engine
  114992. */
  114993. static get LastCreatedEngine(): Nullable<Engine>;
  114994. /**
  114995. * Gets the latest created scene
  114996. */
  114997. static get LastCreatedScene(): Nullable<Scene>;
  114998. /**
  114999. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  115000. * @param flag defines which part of the materials must be marked as dirty
  115001. * @param predicate defines a predicate used to filter which materials should be affected
  115002. */
  115003. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  115004. /**
  115005. * Method called to create the default loading screen.
  115006. * This can be overriden in your own app.
  115007. * @param canvas The rendering canvas element
  115008. * @returns The loading screen
  115009. */
  115010. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  115011. /**
  115012. * Method called to create the default rescale post process on each engine.
  115013. */
  115014. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  115015. /**
  115016. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  115017. **/
  115018. enableOfflineSupport: boolean;
  115019. /**
  115020. * 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)
  115021. **/
  115022. disableManifestCheck: boolean;
  115023. /**
  115024. * Gets the list of created scenes
  115025. */
  115026. scenes: Scene[];
  115027. /**
  115028. * Event raised when a new scene is created
  115029. */
  115030. onNewSceneAddedObservable: Observable<Scene>;
  115031. /**
  115032. * Gets the list of created postprocesses
  115033. */
  115034. postProcesses: PostProcess[];
  115035. /**
  115036. * Gets a boolean indicating if the pointer is currently locked
  115037. */
  115038. isPointerLock: boolean;
  115039. /**
  115040. * Observable event triggered each time the rendering canvas is resized
  115041. */
  115042. onResizeObservable: Observable<Engine>;
  115043. /**
  115044. * Observable event triggered each time the canvas loses focus
  115045. */
  115046. onCanvasBlurObservable: Observable<Engine>;
  115047. /**
  115048. * Observable event triggered each time the canvas gains focus
  115049. */
  115050. onCanvasFocusObservable: Observable<Engine>;
  115051. /**
  115052. * Observable event triggered each time the canvas receives pointerout event
  115053. */
  115054. onCanvasPointerOutObservable: Observable<PointerEvent>;
  115055. /**
  115056. * Observable raised when the engine begins a new frame
  115057. */
  115058. onBeginFrameObservable: Observable<Engine>;
  115059. /**
  115060. * If set, will be used to request the next animation frame for the render loop
  115061. */
  115062. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  115063. /**
  115064. * Observable raised when the engine ends the current frame
  115065. */
  115066. onEndFrameObservable: Observable<Engine>;
  115067. /**
  115068. * Observable raised when the engine is about to compile a shader
  115069. */
  115070. onBeforeShaderCompilationObservable: Observable<Engine>;
  115071. /**
  115072. * Observable raised when the engine has jsut compiled a shader
  115073. */
  115074. onAfterShaderCompilationObservable: Observable<Engine>;
  115075. /**
  115076. * Gets the audio engine
  115077. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115078. * @ignorenaming
  115079. */
  115080. static audioEngine: IAudioEngine;
  115081. /**
  115082. * Default AudioEngine factory responsible of creating the Audio Engine.
  115083. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  115084. */
  115085. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  115086. /**
  115087. * Default offline support factory responsible of creating a tool used to store data locally.
  115088. * By default, this will create a Database object if the workload has been embedded.
  115089. */
  115090. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  115091. private _loadingScreen;
  115092. private _pointerLockRequested;
  115093. private _rescalePostProcess;
  115094. private _deterministicLockstep;
  115095. private _lockstepMaxSteps;
  115096. private _timeStep;
  115097. protected get _supportsHardwareTextureRescaling(): boolean;
  115098. private _fps;
  115099. private _deltaTime;
  115100. /** @hidden */
  115101. _drawCalls: PerfCounter;
  115102. /** 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 */
  115103. canvasTabIndex: number;
  115104. /**
  115105. * Turn this value on if you want to pause FPS computation when in background
  115106. */
  115107. disablePerformanceMonitorInBackground: boolean;
  115108. private _performanceMonitor;
  115109. /**
  115110. * Gets the performance monitor attached to this engine
  115111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115112. */
  115113. get performanceMonitor(): PerformanceMonitor;
  115114. private _onFocus;
  115115. private _onBlur;
  115116. private _onCanvasPointerOut;
  115117. private _onCanvasBlur;
  115118. private _onCanvasFocus;
  115119. private _onFullscreenChange;
  115120. private _onPointerLockChange;
  115121. /**
  115122. * Gets the HTML element used to attach event listeners
  115123. * @returns a HTML element
  115124. */
  115125. getInputElement(): Nullable<HTMLElement>;
  115126. /**
  115127. * Creates a new engine
  115128. * @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
  115129. * @param antialias defines enable antialiasing (default: false)
  115130. * @param options defines further options to be sent to the getContext() function
  115131. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115132. */
  115133. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115134. /**
  115135. * Gets current aspect ratio
  115136. * @param viewportOwner defines the camera to use to get the aspect ratio
  115137. * @param useScreen defines if screen size must be used (or the current render target if any)
  115138. * @returns a number defining the aspect ratio
  115139. */
  115140. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  115141. /**
  115142. * Gets current screen aspect ratio
  115143. * @returns a number defining the aspect ratio
  115144. */
  115145. getScreenAspectRatio(): number;
  115146. /**
  115147. * Gets the client rect of the HTML canvas attached with the current webGL context
  115148. * @returns a client rectanglee
  115149. */
  115150. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  115151. /**
  115152. * Gets the client rect of the HTML element used for events
  115153. * @returns a client rectanglee
  115154. */
  115155. getInputElementClientRect(): Nullable<ClientRect>;
  115156. /**
  115157. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  115158. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115159. * @returns true if engine is in deterministic lock step mode
  115160. */
  115161. isDeterministicLockStep(): boolean;
  115162. /**
  115163. * Gets the max steps when engine is running in deterministic lock step
  115164. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115165. * @returns the max steps
  115166. */
  115167. getLockstepMaxSteps(): number;
  115168. /**
  115169. * Returns the time in ms between steps when using deterministic lock step.
  115170. * @returns time step in (ms)
  115171. */
  115172. getTimeStep(): number;
  115173. /**
  115174. * Force the mipmap generation for the given render target texture
  115175. * @param texture defines the render target texture to use
  115176. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  115177. */
  115178. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  115179. /** States */
  115180. /**
  115181. * Set various states to the webGL context
  115182. * @param culling defines backface culling state
  115183. * @param zOffset defines the value to apply to zOffset (0 by default)
  115184. * @param force defines if states must be applied even if cache is up to date
  115185. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  115186. */
  115187. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  115188. /**
  115189. * Set the z offset to apply to current rendering
  115190. * @param value defines the offset to apply
  115191. */
  115192. setZOffset(value: number): void;
  115193. /**
  115194. * Gets the current value of the zOffset
  115195. * @returns the current zOffset state
  115196. */
  115197. getZOffset(): number;
  115198. /**
  115199. * Enable or disable depth buffering
  115200. * @param enable defines the state to set
  115201. */
  115202. setDepthBuffer(enable: boolean): void;
  115203. /**
  115204. * Gets a boolean indicating if depth writing is enabled
  115205. * @returns the current depth writing state
  115206. */
  115207. getDepthWrite(): boolean;
  115208. /**
  115209. * Enable or disable depth writing
  115210. * @param enable defines the state to set
  115211. */
  115212. setDepthWrite(enable: boolean): void;
  115213. /**
  115214. * Gets a boolean indicating if stencil buffer is enabled
  115215. * @returns the current stencil buffer state
  115216. */
  115217. getStencilBuffer(): boolean;
  115218. /**
  115219. * Enable or disable the stencil buffer
  115220. * @param enable defines if the stencil buffer must be enabled or disabled
  115221. */
  115222. setStencilBuffer(enable: boolean): void;
  115223. /**
  115224. * Gets the current stencil mask
  115225. * @returns a number defining the new stencil mask to use
  115226. */
  115227. getStencilMask(): number;
  115228. /**
  115229. * Sets the current stencil mask
  115230. * @param mask defines the new stencil mask to use
  115231. */
  115232. setStencilMask(mask: number): void;
  115233. /**
  115234. * Gets the current stencil function
  115235. * @returns a number defining the stencil function to use
  115236. */
  115237. getStencilFunction(): number;
  115238. /**
  115239. * Gets the current stencil reference value
  115240. * @returns a number defining the stencil reference value to use
  115241. */
  115242. getStencilFunctionReference(): number;
  115243. /**
  115244. * Gets the current stencil mask
  115245. * @returns a number defining the stencil mask to use
  115246. */
  115247. getStencilFunctionMask(): number;
  115248. /**
  115249. * Sets the current stencil function
  115250. * @param stencilFunc defines the new stencil function to use
  115251. */
  115252. setStencilFunction(stencilFunc: number): void;
  115253. /**
  115254. * Sets the current stencil reference
  115255. * @param reference defines the new stencil reference to use
  115256. */
  115257. setStencilFunctionReference(reference: number): void;
  115258. /**
  115259. * Sets the current stencil mask
  115260. * @param mask defines the new stencil mask to use
  115261. */
  115262. setStencilFunctionMask(mask: number): void;
  115263. /**
  115264. * Gets the current stencil operation when stencil fails
  115265. * @returns a number defining stencil operation to use when stencil fails
  115266. */
  115267. getStencilOperationFail(): number;
  115268. /**
  115269. * Gets the current stencil operation when depth fails
  115270. * @returns a number defining stencil operation to use when depth fails
  115271. */
  115272. getStencilOperationDepthFail(): number;
  115273. /**
  115274. * Gets the current stencil operation when stencil passes
  115275. * @returns a number defining stencil operation to use when stencil passes
  115276. */
  115277. getStencilOperationPass(): number;
  115278. /**
  115279. * Sets the stencil operation to use when stencil fails
  115280. * @param operation defines the stencil operation to use when stencil fails
  115281. */
  115282. setStencilOperationFail(operation: number): void;
  115283. /**
  115284. * Sets the stencil operation to use when depth fails
  115285. * @param operation defines the stencil operation to use when depth fails
  115286. */
  115287. setStencilOperationDepthFail(operation: number): void;
  115288. /**
  115289. * Sets the stencil operation to use when stencil passes
  115290. * @param operation defines the stencil operation to use when stencil passes
  115291. */
  115292. setStencilOperationPass(operation: number): void;
  115293. /**
  115294. * Sets a boolean indicating if the dithering state is enabled or disabled
  115295. * @param value defines the dithering state
  115296. */
  115297. setDitheringState(value: boolean): void;
  115298. /**
  115299. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  115300. * @param value defines the rasterizer state
  115301. */
  115302. setRasterizerState(value: boolean): void;
  115303. /**
  115304. * Gets the current depth function
  115305. * @returns a number defining the depth function
  115306. */
  115307. getDepthFunction(): Nullable<number>;
  115308. /**
  115309. * Sets the current depth function
  115310. * @param depthFunc defines the function to use
  115311. */
  115312. setDepthFunction(depthFunc: number): void;
  115313. /**
  115314. * Sets the current depth function to GREATER
  115315. */
  115316. setDepthFunctionToGreater(): void;
  115317. /**
  115318. * Sets the current depth function to GEQUAL
  115319. */
  115320. setDepthFunctionToGreaterOrEqual(): void;
  115321. /**
  115322. * Sets the current depth function to LESS
  115323. */
  115324. setDepthFunctionToLess(): void;
  115325. /**
  115326. * Sets the current depth function to LEQUAL
  115327. */
  115328. setDepthFunctionToLessOrEqual(): void;
  115329. private _cachedStencilBuffer;
  115330. private _cachedStencilFunction;
  115331. private _cachedStencilMask;
  115332. private _cachedStencilOperationPass;
  115333. private _cachedStencilOperationFail;
  115334. private _cachedStencilOperationDepthFail;
  115335. private _cachedStencilReference;
  115336. /**
  115337. * Caches the the state of the stencil buffer
  115338. */
  115339. cacheStencilState(): void;
  115340. /**
  115341. * Restores the state of the stencil buffer
  115342. */
  115343. restoreStencilState(): void;
  115344. /**
  115345. * Directly set the WebGL Viewport
  115346. * @param x defines the x coordinate of the viewport (in screen space)
  115347. * @param y defines the y coordinate of the viewport (in screen space)
  115348. * @param width defines the width of the viewport (in screen space)
  115349. * @param height defines the height of the viewport (in screen space)
  115350. * @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
  115351. */
  115352. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  115353. /**
  115354. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  115355. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115356. * @param y defines the y-coordinate of the corner of the clear rectangle
  115357. * @param width defines the width of the clear rectangle
  115358. * @param height defines the height of the clear rectangle
  115359. * @param clearColor defines the clear color
  115360. */
  115361. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  115362. /**
  115363. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  115364. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  115365. * @param y defines the y-coordinate of the corner of the clear rectangle
  115366. * @param width defines the width of the clear rectangle
  115367. * @param height defines the height of the clear rectangle
  115368. */
  115369. enableScissor(x: number, y: number, width: number, height: number): void;
  115370. /**
  115371. * Disable previously set scissor test rectangle
  115372. */
  115373. disableScissor(): void;
  115374. protected _reportDrawCall(): void;
  115375. /**
  115376. * Initializes a webVR display and starts listening to display change events
  115377. * The onVRDisplayChangedObservable will be notified upon these changes
  115378. * @returns The onVRDisplayChangedObservable
  115379. */
  115380. initWebVR(): Observable<IDisplayChangedEventArgs>;
  115381. /** @hidden */
  115382. _prepareVRComponent(): void;
  115383. /** @hidden */
  115384. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  115385. /** @hidden */
  115386. _submitVRFrame(): void;
  115387. /**
  115388. * Call this function to leave webVR mode
  115389. * Will do nothing if webVR is not supported or if there is no webVR device
  115390. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115391. */
  115392. disableVR(): void;
  115393. /**
  115394. * Gets a boolean indicating that the system is in VR mode and is presenting
  115395. * @returns true if VR mode is engaged
  115396. */
  115397. isVRPresenting(): boolean;
  115398. /** @hidden */
  115399. _requestVRFrame(): void;
  115400. /** @hidden */
  115401. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  115402. /**
  115403. * Gets the source code of the vertex shader associated with a specific webGL program
  115404. * @param program defines the program to use
  115405. * @returns a string containing the source code of the vertex shader associated with the program
  115406. */
  115407. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  115408. /**
  115409. * Gets the source code of the fragment shader associated with a specific webGL program
  115410. * @param program defines the program to use
  115411. * @returns a string containing the source code of the fragment shader associated with the program
  115412. */
  115413. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  115414. /**
  115415. * Sets a depth stencil texture from a render target to the according uniform.
  115416. * @param channel The texture channel
  115417. * @param uniform The uniform to set
  115418. * @param texture The render target texture containing the depth stencil texture to apply
  115419. */
  115420. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  115421. /**
  115422. * Sets a texture to the webGL context from a postprocess
  115423. * @param channel defines the channel to use
  115424. * @param postProcess defines the source postprocess
  115425. */
  115426. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  115427. /**
  115428. * Binds the output of the passed in post process to the texture channel specified
  115429. * @param channel The channel the texture should be bound to
  115430. * @param postProcess The post process which's output should be bound
  115431. */
  115432. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  115433. protected _rebuildBuffers(): void;
  115434. /** @hidden */
  115435. _renderFrame(): void;
  115436. _renderLoop(): void;
  115437. /** @hidden */
  115438. _renderViews(): boolean;
  115439. /**
  115440. * Toggle full screen mode
  115441. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115442. */
  115443. switchFullscreen(requestPointerLock: boolean): void;
  115444. /**
  115445. * Enters full screen mode
  115446. * @param requestPointerLock defines if a pointer lock should be requested from the user
  115447. */
  115448. enterFullscreen(requestPointerLock: boolean): void;
  115449. /**
  115450. * Exits full screen mode
  115451. */
  115452. exitFullscreen(): void;
  115453. /**
  115454. * Enters Pointerlock mode
  115455. */
  115456. enterPointerlock(): void;
  115457. /**
  115458. * Exits Pointerlock mode
  115459. */
  115460. exitPointerlock(): void;
  115461. /**
  115462. * Begin a new frame
  115463. */
  115464. beginFrame(): void;
  115465. /**
  115466. * Enf the current frame
  115467. */
  115468. endFrame(): void;
  115469. resize(): void;
  115470. /**
  115471. * Force a specific size of the canvas
  115472. * @param width defines the new canvas' width
  115473. * @param height defines the new canvas' height
  115474. * @returns true if the size was changed
  115475. */
  115476. setSize(width: number, height: number): boolean;
  115477. /**
  115478. * Updates a dynamic vertex buffer.
  115479. * @param vertexBuffer the vertex buffer to update
  115480. * @param data the data used to update the vertex buffer
  115481. * @param byteOffset the byte offset of the data
  115482. * @param byteLength the byte length of the data
  115483. */
  115484. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  115485. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  115486. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115487. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  115488. _releaseTexture(texture: InternalTexture): void;
  115489. /**
  115490. * @hidden
  115491. * Rescales a texture
  115492. * @param source input texutre
  115493. * @param destination destination texture
  115494. * @param scene scene to use to render the resize
  115495. * @param internalFormat format to use when resizing
  115496. * @param onComplete callback to be called when resize has completed
  115497. */
  115498. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  115499. /**
  115500. * Gets the current framerate
  115501. * @returns a number representing the framerate
  115502. */
  115503. getFps(): number;
  115504. /**
  115505. * Gets the time spent between current and previous frame
  115506. * @returns a number representing the delta time in ms
  115507. */
  115508. getDeltaTime(): number;
  115509. private _measureFps;
  115510. /** @hidden */
  115511. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  115512. /**
  115513. * Update a dynamic index buffer
  115514. * @param indexBuffer defines the target index buffer
  115515. * @param indices defines the data to update
  115516. * @param offset defines the offset in the target index buffer where update should start
  115517. */
  115518. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  115519. /**
  115520. * Updates the sample count of a render target texture
  115521. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  115522. * @param texture defines the texture to update
  115523. * @param samples defines the sample count to set
  115524. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  115525. */
  115526. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  115527. /**
  115528. * Updates a depth texture Comparison Mode and Function.
  115529. * If the comparison Function is equal to 0, the mode will be set to none.
  115530. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  115531. * @param texture The texture to set the comparison function for
  115532. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  115533. */
  115534. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  115535. /**
  115536. * Creates a webGL buffer to use with instanciation
  115537. * @param capacity defines the size of the buffer
  115538. * @returns the webGL buffer
  115539. */
  115540. createInstancesBuffer(capacity: number): DataBuffer;
  115541. /**
  115542. * Delete a webGL buffer used with instanciation
  115543. * @param buffer defines the webGL buffer to delete
  115544. */
  115545. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  115546. private _clientWaitAsync;
  115547. /** @hidden */
  115548. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  115549. dispose(): void;
  115550. private _disableTouchAction;
  115551. /**
  115552. * Display the loading screen
  115553. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115554. */
  115555. displayLoadingUI(): void;
  115556. /**
  115557. * Hide the loading screen
  115558. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115559. */
  115560. hideLoadingUI(): void;
  115561. /**
  115562. * Gets the current loading screen object
  115563. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115564. */
  115565. get loadingScreen(): ILoadingScreen;
  115566. /**
  115567. * Sets the current loading screen object
  115568. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115569. */
  115570. set loadingScreen(loadingScreen: ILoadingScreen);
  115571. /**
  115572. * Sets the current loading screen text
  115573. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115574. */
  115575. set loadingUIText(text: string);
  115576. /**
  115577. * Sets the current loading screen background color
  115578. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  115579. */
  115580. set loadingUIBackgroundColor(color: string);
  115581. /** Pointerlock and fullscreen */
  115582. /**
  115583. * Ask the browser to promote the current element to pointerlock mode
  115584. * @param element defines the DOM element to promote
  115585. */
  115586. static _RequestPointerlock(element: HTMLElement): void;
  115587. /**
  115588. * Asks the browser to exit pointerlock mode
  115589. */
  115590. static _ExitPointerlock(): void;
  115591. /**
  115592. * Ask the browser to promote the current element to fullscreen rendering mode
  115593. * @param element defines the DOM element to promote
  115594. */
  115595. static _RequestFullscreen(element: HTMLElement): void;
  115596. /**
  115597. * Asks the browser to exit fullscreen mode
  115598. */
  115599. static _ExitFullscreen(): void;
  115600. }
  115601. }
  115602. declare module BABYLON {
  115603. /**
  115604. * The engine store class is responsible to hold all the instances of Engine and Scene created
  115605. * during the life time of the application.
  115606. */
  115607. export class EngineStore {
  115608. /** Gets the list of created engines */
  115609. static Instances: Engine[];
  115610. /** @hidden */
  115611. static _LastCreatedScene: Nullable<Scene>;
  115612. /**
  115613. * Gets the latest created engine
  115614. */
  115615. static get LastCreatedEngine(): Nullable<Engine>;
  115616. /**
  115617. * Gets the latest created scene
  115618. */
  115619. static get LastCreatedScene(): Nullable<Scene>;
  115620. /**
  115621. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115622. * @ignorenaming
  115623. */
  115624. static UseFallbackTexture: boolean;
  115625. /**
  115626. * Texture content used if a texture cannot loaded
  115627. * @ignorenaming
  115628. */
  115629. static FallbackTexture: string;
  115630. }
  115631. }
  115632. declare module BABYLON {
  115633. /**
  115634. * Helper class that provides a small promise polyfill
  115635. */
  115636. export class PromisePolyfill {
  115637. /**
  115638. * Static function used to check if the polyfill is required
  115639. * If this is the case then the function will inject the polyfill to window.Promise
  115640. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  115641. */
  115642. static Apply(force?: boolean): void;
  115643. }
  115644. }
  115645. declare module BABYLON {
  115646. /**
  115647. * Interface for screenshot methods with describe argument called `size` as object with options
  115648. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  115649. */
  115650. export interface IScreenshotSize {
  115651. /**
  115652. * number in pixels for canvas height
  115653. */
  115654. height?: number;
  115655. /**
  115656. * multiplier allowing render at a higher or lower resolution
  115657. * If value is defined then height and width will be ignored and taken from camera
  115658. */
  115659. precision?: number;
  115660. /**
  115661. * number in pixels for canvas width
  115662. */
  115663. width?: number;
  115664. }
  115665. }
  115666. declare module BABYLON {
  115667. interface IColor4Like {
  115668. r: float;
  115669. g: float;
  115670. b: float;
  115671. a: float;
  115672. }
  115673. /**
  115674. * Class containing a set of static utilities functions
  115675. */
  115676. export class Tools {
  115677. /**
  115678. * Gets or sets the base URL to use to load assets
  115679. */
  115680. static get BaseUrl(): string;
  115681. static set BaseUrl(value: string);
  115682. /**
  115683. * Enable/Disable Custom HTTP Request Headers globally.
  115684. * default = false
  115685. * @see CustomRequestHeaders
  115686. */
  115687. static UseCustomRequestHeaders: boolean;
  115688. /**
  115689. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  115690. * i.e. when loading files, where the server/service expects an Authorization header
  115691. */
  115692. static CustomRequestHeaders: {
  115693. [key: string]: string;
  115694. };
  115695. /**
  115696. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  115697. */
  115698. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  115699. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  115700. /**
  115701. * Default behaviour for cors in the application.
  115702. * It can be a string if the expected behavior is identical in the entire app.
  115703. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  115704. */
  115705. static get CorsBehavior(): string | ((url: string | string[]) => string);
  115706. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  115707. /**
  115708. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  115709. * @ignorenaming
  115710. */
  115711. static get UseFallbackTexture(): boolean;
  115712. static set UseFallbackTexture(value: boolean);
  115713. /**
  115714. * Use this object to register external classes like custom textures or material
  115715. * to allow the laoders to instantiate them
  115716. */
  115717. static get RegisteredExternalClasses(): {
  115718. [key: string]: Object;
  115719. };
  115720. static set RegisteredExternalClasses(classes: {
  115721. [key: string]: Object;
  115722. });
  115723. /**
  115724. * Texture content used if a texture cannot loaded
  115725. * @ignorenaming
  115726. */
  115727. static get fallbackTexture(): string;
  115728. static set fallbackTexture(value: string);
  115729. /**
  115730. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  115731. * @param u defines the coordinate on X axis
  115732. * @param v defines the coordinate on Y axis
  115733. * @param width defines the width of the source data
  115734. * @param height defines the height of the source data
  115735. * @param pixels defines the source byte array
  115736. * @param color defines the output color
  115737. */
  115738. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  115739. /**
  115740. * Interpolates between a and b via alpha
  115741. * @param a The lower value (returned when alpha = 0)
  115742. * @param b The upper value (returned when alpha = 1)
  115743. * @param alpha The interpolation-factor
  115744. * @return The mixed value
  115745. */
  115746. static Mix(a: number, b: number, alpha: number): number;
  115747. /**
  115748. * Tries to instantiate a new object from a given class name
  115749. * @param className defines the class name to instantiate
  115750. * @returns the new object or null if the system was not able to do the instantiation
  115751. */
  115752. static Instantiate(className: string): any;
  115753. /**
  115754. * Provides a slice function that will work even on IE
  115755. * @param data defines the array to slice
  115756. * @param start defines the start of the data (optional)
  115757. * @param end defines the end of the data (optional)
  115758. * @returns the new sliced array
  115759. */
  115760. static Slice<T>(data: T, start?: number, end?: number): T;
  115761. /**
  115762. * Polyfill for setImmediate
  115763. * @param action defines the action to execute after the current execution block
  115764. */
  115765. static SetImmediate(action: () => void): void;
  115766. /**
  115767. * Function indicating if a number is an exponent of 2
  115768. * @param value defines the value to test
  115769. * @returns true if the value is an exponent of 2
  115770. */
  115771. static IsExponentOfTwo(value: number): boolean;
  115772. private static _tmpFloatArray;
  115773. /**
  115774. * Returns the nearest 32-bit single precision float representation of a Number
  115775. * @param value A Number. If the parameter is of a different type, it will get converted
  115776. * to a number or to NaN if it cannot be converted
  115777. * @returns number
  115778. */
  115779. static FloatRound(value: number): number;
  115780. /**
  115781. * Extracts the filename from a path
  115782. * @param path defines the path to use
  115783. * @returns the filename
  115784. */
  115785. static GetFilename(path: string): string;
  115786. /**
  115787. * Extracts the "folder" part of a path (everything before the filename).
  115788. * @param uri The URI to extract the info from
  115789. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  115790. * @returns The "folder" part of the path
  115791. */
  115792. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  115793. /**
  115794. * Extracts text content from a DOM element hierarchy
  115795. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  115796. */
  115797. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  115798. /**
  115799. * Convert an angle in radians to degrees
  115800. * @param angle defines the angle to convert
  115801. * @returns the angle in degrees
  115802. */
  115803. static ToDegrees(angle: number): number;
  115804. /**
  115805. * Convert an angle in degrees to radians
  115806. * @param angle defines the angle to convert
  115807. * @returns the angle in radians
  115808. */
  115809. static ToRadians(angle: number): number;
  115810. /**
  115811. * Returns an array if obj is not an array
  115812. * @param obj defines the object to evaluate as an array
  115813. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  115814. * @returns either obj directly if obj is an array or a new array containing obj
  115815. */
  115816. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  115817. /**
  115818. * Gets the pointer prefix to use
  115819. * @param engine defines the engine we are finding the prefix for
  115820. * @returns "pointer" if touch is enabled. Else returns "mouse"
  115821. */
  115822. static GetPointerPrefix(engine: Engine): string;
  115823. /**
  115824. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  115825. * @param url define the url we are trying
  115826. * @param element define the dom element where to configure the cors policy
  115827. */
  115828. static SetCorsBehavior(url: string | string[], element: {
  115829. crossOrigin: string | null;
  115830. }): void;
  115831. /**
  115832. * Removes unwanted characters from an url
  115833. * @param url defines the url to clean
  115834. * @returns the cleaned url
  115835. */
  115836. static CleanUrl(url: string): string;
  115837. /**
  115838. * Gets or sets a function used to pre-process url before using them to load assets
  115839. */
  115840. static get PreprocessUrl(): (url: string) => string;
  115841. static set PreprocessUrl(processor: (url: string) => string);
  115842. /**
  115843. * Loads an image as an HTMLImageElement.
  115844. * @param input url string, ArrayBuffer, or Blob to load
  115845. * @param onLoad callback called when the image successfully loads
  115846. * @param onError callback called when the image fails to load
  115847. * @param offlineProvider offline provider for caching
  115848. * @param mimeType optional mime type
  115849. * @returns the HTMLImageElement of the loaded image
  115850. */
  115851. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  115852. /**
  115853. * Loads a file from a url
  115854. * @param url url string, ArrayBuffer, or Blob to load
  115855. * @param onSuccess callback called when the file successfully loads
  115856. * @param onProgress callback called while file is loading (if the server supports this mode)
  115857. * @param offlineProvider defines the offline provider for caching
  115858. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115859. * @param onError callback called when the file fails to load
  115860. * @returns a file request object
  115861. */
  115862. 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;
  115863. /**
  115864. * Loads a file from a url
  115865. * @param url the file url to load
  115866. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  115867. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  115868. */
  115869. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  115870. /**
  115871. * Load a script (identified by an url). When the url returns, the
  115872. * content of this file is added into a new script element, attached to the DOM (body element)
  115873. * @param scriptUrl defines the url of the script to laod
  115874. * @param onSuccess defines the callback called when the script is loaded
  115875. * @param onError defines the callback to call if an error occurs
  115876. * @param scriptId defines the id of the script element
  115877. */
  115878. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  115879. /**
  115880. * Load an asynchronous script (identified by an url). When the url returns, the
  115881. * content of this file is added into a new script element, attached to the DOM (body element)
  115882. * @param scriptUrl defines the url of the script to laod
  115883. * @param scriptId defines the id of the script element
  115884. * @returns a promise request object
  115885. */
  115886. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  115887. /**
  115888. * Loads a file from a blob
  115889. * @param fileToLoad defines the blob to use
  115890. * @param callback defines the callback to call when data is loaded
  115891. * @param progressCallback defines the callback to call during loading process
  115892. * @returns a file request object
  115893. */
  115894. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  115895. /**
  115896. * Reads a file from a File object
  115897. * @param file defines the file to load
  115898. * @param onSuccess defines the callback to call when data is loaded
  115899. * @param onProgress defines the callback to call during loading process
  115900. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  115901. * @param onError defines the callback to call when an error occurs
  115902. * @returns a file request object
  115903. */
  115904. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  115905. /**
  115906. * Creates a data url from a given string content
  115907. * @param content defines the content to convert
  115908. * @returns the new data url link
  115909. */
  115910. static FileAsURL(content: string): string;
  115911. /**
  115912. * Format the given number to a specific decimal format
  115913. * @param value defines the number to format
  115914. * @param decimals defines the number of decimals to use
  115915. * @returns the formatted string
  115916. */
  115917. static Format(value: number, decimals?: number): string;
  115918. /**
  115919. * Tries to copy an object by duplicating every property
  115920. * @param source defines the source object
  115921. * @param destination defines the target object
  115922. * @param doNotCopyList defines a list of properties to avoid
  115923. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  115924. */
  115925. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  115926. /**
  115927. * Gets a boolean indicating if the given object has no own property
  115928. * @param obj defines the object to test
  115929. * @returns true if object has no own property
  115930. */
  115931. static IsEmpty(obj: any): boolean;
  115932. /**
  115933. * Function used to register events at window level
  115934. * @param windowElement defines the Window object to use
  115935. * @param events defines the events to register
  115936. */
  115937. static RegisterTopRootEvents(windowElement: Window, events: {
  115938. name: string;
  115939. handler: Nullable<(e: FocusEvent) => any>;
  115940. }[]): void;
  115941. /**
  115942. * Function used to unregister events from window level
  115943. * @param windowElement defines the Window object to use
  115944. * @param events defines the events to unregister
  115945. */
  115946. static UnregisterTopRootEvents(windowElement: Window, events: {
  115947. name: string;
  115948. handler: Nullable<(e: FocusEvent) => any>;
  115949. }[]): void;
  115950. /**
  115951. * @ignore
  115952. */
  115953. static _ScreenshotCanvas: HTMLCanvasElement;
  115954. /**
  115955. * Dumps the current bound framebuffer
  115956. * @param width defines the rendering width
  115957. * @param height defines the rendering height
  115958. * @param engine defines the hosting engine
  115959. * @param successCallback defines the callback triggered once the data are available
  115960. * @param mimeType defines the mime type of the result
  115961. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  115962. */
  115963. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115964. /**
  115965. * Converts the canvas data to blob.
  115966. * This acts as a polyfill for browsers not supporting the to blob function.
  115967. * @param canvas Defines the canvas to extract the data from
  115968. * @param successCallback Defines the callback triggered once the data are available
  115969. * @param mimeType Defines the mime type of the result
  115970. */
  115971. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  115972. /**
  115973. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  115974. * @param successCallback defines the callback triggered once the data are available
  115975. * @param mimeType defines the mime type of the result
  115976. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  115977. */
  115978. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  115979. /**
  115980. * Downloads a blob in the browser
  115981. * @param blob defines the blob to download
  115982. * @param fileName defines the name of the downloaded file
  115983. */
  115984. static Download(blob: Blob, fileName: string): void;
  115985. /**
  115986. * Captures a screenshot of the current rendering
  115987. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  115988. * @param engine defines the rendering engine
  115989. * @param camera defines the source camera
  115990. * @param size This parameter can be set to a single number or to an object with the
  115991. * following (optional) properties: precision, width, height. If a single number is passed,
  115992. * it will be used for both width and height. If an object is passed, the screenshot size
  115993. * will be derived from the parameters. The precision property is a multiplier allowing
  115994. * rendering at a higher or lower resolution
  115995. * @param successCallback defines the callback receives a single parameter which contains the
  115996. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115997. * src parameter of an <img> to display it
  115998. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115999. * Check your browser for supported MIME types
  116000. */
  116001. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  116002. /**
  116003. * Captures a screenshot of the current rendering
  116004. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116005. * @param engine defines the rendering engine
  116006. * @param camera defines the source camera
  116007. * @param size This parameter can be set to a single number or to an object with the
  116008. * following (optional) properties: precision, width, height. If a single number is passed,
  116009. * it will be used for both width and height. If an object is passed, the screenshot size
  116010. * will be derived from the parameters. The precision property is a multiplier allowing
  116011. * rendering at a higher or lower resolution
  116012. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  116013. * Check your browser for supported MIME types
  116014. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116015. * to the src parameter of an <img> to display it
  116016. */
  116017. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  116018. /**
  116019. * Generates an image screenshot from the specified camera.
  116020. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116021. * @param engine The engine to use for rendering
  116022. * @param camera The camera to use for rendering
  116023. * @param size This parameter can be set to a single number or to an object with the
  116024. * following (optional) properties: precision, width, height. If a single number is passed,
  116025. * it will be used for both width and height. If an object is passed, the screenshot size
  116026. * will be derived from the parameters. The precision property is a multiplier allowing
  116027. * rendering at a higher or lower resolution
  116028. * @param successCallback The callback receives a single parameter which contains the
  116029. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  116030. * src parameter of an <img> to display it
  116031. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116032. * Check your browser for supported MIME types
  116033. * @param samples Texture samples (default: 1)
  116034. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116035. * @param fileName A name for for the downloaded file.
  116036. */
  116037. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  116038. /**
  116039. * Generates an image screenshot from the specified camera.
  116040. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  116041. * @param engine The engine to use for rendering
  116042. * @param camera The camera to use for rendering
  116043. * @param size This parameter can be set to a single number or to an object with the
  116044. * following (optional) properties: precision, width, height. If a single number is passed,
  116045. * it will be used for both width and height. If an object is passed, the screenshot size
  116046. * will be derived from the parameters. The precision property is a multiplier allowing
  116047. * rendering at a higher or lower resolution
  116048. * @param mimeType The MIME type of the screenshot image (default: image/png).
  116049. * Check your browser for supported MIME types
  116050. * @param samples Texture samples (default: 1)
  116051. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  116052. * @param fileName A name for for the downloaded file.
  116053. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  116054. * to the src parameter of an <img> to display it
  116055. */
  116056. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  116057. /**
  116058. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  116059. * Be aware Math.random() could cause collisions, but:
  116060. * "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"
  116061. * @returns a pseudo random id
  116062. */
  116063. static RandomId(): string;
  116064. /**
  116065. * Test if the given uri is a base64 string
  116066. * @param uri The uri to test
  116067. * @return True if the uri is a base64 string or false otherwise
  116068. */
  116069. static IsBase64(uri: string): boolean;
  116070. /**
  116071. * Decode the given base64 uri.
  116072. * @param uri The uri to decode
  116073. * @return The decoded base64 data.
  116074. */
  116075. static DecodeBase64(uri: string): ArrayBuffer;
  116076. /**
  116077. * Gets the absolute url.
  116078. * @param url the input url
  116079. * @return the absolute url
  116080. */
  116081. static GetAbsoluteUrl(url: string): string;
  116082. /**
  116083. * No log
  116084. */
  116085. static readonly NoneLogLevel: number;
  116086. /**
  116087. * Only message logs
  116088. */
  116089. static readonly MessageLogLevel: number;
  116090. /**
  116091. * Only warning logs
  116092. */
  116093. static readonly WarningLogLevel: number;
  116094. /**
  116095. * Only error logs
  116096. */
  116097. static readonly ErrorLogLevel: number;
  116098. /**
  116099. * All logs
  116100. */
  116101. static readonly AllLogLevel: number;
  116102. /**
  116103. * Gets a value indicating the number of loading errors
  116104. * @ignorenaming
  116105. */
  116106. static get errorsCount(): number;
  116107. /**
  116108. * Callback called when a new log is added
  116109. */
  116110. static OnNewCacheEntry: (entry: string) => void;
  116111. /**
  116112. * Log a message to the console
  116113. * @param message defines the message to log
  116114. */
  116115. static Log(message: string): void;
  116116. /**
  116117. * Write a warning message to the console
  116118. * @param message defines the message to log
  116119. */
  116120. static Warn(message: string): void;
  116121. /**
  116122. * Write an error message to the console
  116123. * @param message defines the message to log
  116124. */
  116125. static Error(message: string): void;
  116126. /**
  116127. * Gets current log cache (list of logs)
  116128. */
  116129. static get LogCache(): string;
  116130. /**
  116131. * Clears the log cache
  116132. */
  116133. static ClearLogCache(): void;
  116134. /**
  116135. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  116136. */
  116137. static set LogLevels(level: number);
  116138. /**
  116139. * Checks if the window object exists
  116140. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  116141. */
  116142. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  116143. /**
  116144. * No performance log
  116145. */
  116146. static readonly PerformanceNoneLogLevel: number;
  116147. /**
  116148. * Use user marks to log performance
  116149. */
  116150. static readonly PerformanceUserMarkLogLevel: number;
  116151. /**
  116152. * Log performance to the console
  116153. */
  116154. static readonly PerformanceConsoleLogLevel: number;
  116155. private static _performance;
  116156. /**
  116157. * Sets the current performance log level
  116158. */
  116159. static set PerformanceLogLevel(level: number);
  116160. private static _StartPerformanceCounterDisabled;
  116161. private static _EndPerformanceCounterDisabled;
  116162. private static _StartUserMark;
  116163. private static _EndUserMark;
  116164. private static _StartPerformanceConsole;
  116165. private static _EndPerformanceConsole;
  116166. /**
  116167. * Starts a performance counter
  116168. */
  116169. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  116170. /**
  116171. * Ends a specific performance coutner
  116172. */
  116173. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  116174. /**
  116175. * Gets either window.performance.now() if supported or Date.now() else
  116176. */
  116177. static get Now(): number;
  116178. /**
  116179. * This method will return the name of the class used to create the instance of the given object.
  116180. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  116181. * @param object the object to get the class name from
  116182. * @param isType defines if the object is actually a type
  116183. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  116184. */
  116185. static GetClassName(object: any, isType?: boolean): string;
  116186. /**
  116187. * Gets the first element of an array satisfying a given predicate
  116188. * @param array defines the array to browse
  116189. * @param predicate defines the predicate to use
  116190. * @returns null if not found or the element
  116191. */
  116192. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  116193. /**
  116194. * This method will return the name of the full name of the class, including its owning module (if any).
  116195. * 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).
  116196. * @param object the object to get the class name from
  116197. * @param isType defines if the object is actually a type
  116198. * @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.
  116199. * @ignorenaming
  116200. */
  116201. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  116202. /**
  116203. * Returns a promise that resolves after the given amount of time.
  116204. * @param delay Number of milliseconds to delay
  116205. * @returns Promise that resolves after the given amount of time
  116206. */
  116207. static DelayAsync(delay: number): Promise<void>;
  116208. /**
  116209. * Utility function to detect if the current user agent is Safari
  116210. * @returns whether or not the current user agent is safari
  116211. */
  116212. static IsSafari(): boolean;
  116213. }
  116214. /**
  116215. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  116216. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  116217. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  116218. * @param name The name of the class, case should be preserved
  116219. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  116220. */
  116221. export function className(name: string, module?: string): (target: Object) => void;
  116222. /**
  116223. * An implementation of a loop for asynchronous functions.
  116224. */
  116225. export class AsyncLoop {
  116226. /**
  116227. * Defines the number of iterations for the loop
  116228. */
  116229. iterations: number;
  116230. /**
  116231. * Defines the current index of the loop.
  116232. */
  116233. index: number;
  116234. private _done;
  116235. private _fn;
  116236. private _successCallback;
  116237. /**
  116238. * Constructor.
  116239. * @param iterations the number of iterations.
  116240. * @param func the function to run each iteration
  116241. * @param successCallback the callback that will be called upon succesful execution
  116242. * @param offset starting offset.
  116243. */
  116244. constructor(
  116245. /**
  116246. * Defines the number of iterations for the loop
  116247. */
  116248. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  116249. /**
  116250. * Execute the next iteration. Must be called after the last iteration was finished.
  116251. */
  116252. executeNext(): void;
  116253. /**
  116254. * Break the loop and run the success callback.
  116255. */
  116256. breakLoop(): void;
  116257. /**
  116258. * Create and run an async loop.
  116259. * @param iterations the number of iterations.
  116260. * @param fn the function to run each iteration
  116261. * @param successCallback the callback that will be called upon succesful execution
  116262. * @param offset starting offset.
  116263. * @returns the created async loop object
  116264. */
  116265. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  116266. /**
  116267. * A for-loop that will run a given number of iterations synchronous and the rest async.
  116268. * @param iterations total number of iterations
  116269. * @param syncedIterations number of synchronous iterations in each async iteration.
  116270. * @param fn the function to call each iteration.
  116271. * @param callback a success call back that will be called when iterating stops.
  116272. * @param breakFunction a break condition (optional)
  116273. * @param timeout timeout settings for the setTimeout function. default - 0.
  116274. * @returns the created async loop object
  116275. */
  116276. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  116277. }
  116278. }
  116279. declare module BABYLON {
  116280. /**
  116281. * This class implement a typical dictionary using a string as key and the generic type T as value.
  116282. * The underlying implementation relies on an associative array to ensure the best performances.
  116283. * The value can be anything including 'null' but except 'undefined'
  116284. */
  116285. export class StringDictionary<T> {
  116286. /**
  116287. * This will clear this dictionary and copy the content from the 'source' one.
  116288. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  116289. * @param source the dictionary to take the content from and copy to this dictionary
  116290. */
  116291. copyFrom(source: StringDictionary<T>): void;
  116292. /**
  116293. * Get a value based from its key
  116294. * @param key the given key to get the matching value from
  116295. * @return the value if found, otherwise undefined is returned
  116296. */
  116297. get(key: string): T | undefined;
  116298. /**
  116299. * Get a value from its key or add it if it doesn't exist.
  116300. * This method will ensure you that a given key/data will be present in the dictionary.
  116301. * @param key the given key to get the matching value from
  116302. * @param factory the factory that will create the value if the key is not present in the dictionary.
  116303. * The factory will only be invoked if there's no data for the given key.
  116304. * @return the value corresponding to the key.
  116305. */
  116306. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  116307. /**
  116308. * Get a value from its key if present in the dictionary otherwise add it
  116309. * @param key the key to get the value from
  116310. * @param val if there's no such key/value pair in the dictionary add it with this value
  116311. * @return the value corresponding to the key
  116312. */
  116313. getOrAdd(key: string, val: T): T;
  116314. /**
  116315. * Check if there's a given key in the dictionary
  116316. * @param key the key to check for
  116317. * @return true if the key is present, false otherwise
  116318. */
  116319. contains(key: string): boolean;
  116320. /**
  116321. * Add a new key and its corresponding value
  116322. * @param key the key to add
  116323. * @param value the value corresponding to the key
  116324. * @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
  116325. */
  116326. add(key: string, value: T): boolean;
  116327. /**
  116328. * Update a specific value associated to a key
  116329. * @param key defines the key to use
  116330. * @param value defines the value to store
  116331. * @returns true if the value was updated (or false if the key was not found)
  116332. */
  116333. set(key: string, value: T): boolean;
  116334. /**
  116335. * Get the element of the given key and remove it from the dictionary
  116336. * @param key defines the key to search
  116337. * @returns the value associated with the key or null if not found
  116338. */
  116339. getAndRemove(key: string): Nullable<T>;
  116340. /**
  116341. * Remove a key/value from the dictionary.
  116342. * @param key the key to remove
  116343. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  116344. */
  116345. remove(key: string): boolean;
  116346. /**
  116347. * Clear the whole content of the dictionary
  116348. */
  116349. clear(): void;
  116350. /**
  116351. * Gets the current count
  116352. */
  116353. get count(): number;
  116354. /**
  116355. * Execute a callback on each key/val of the dictionary.
  116356. * Note that you can remove any element in this dictionary in the callback implementation
  116357. * @param callback the callback to execute on a given key/value pair
  116358. */
  116359. forEach(callback: (key: string, val: T) => void): void;
  116360. /**
  116361. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  116362. * If the callback returns null or undefined the method will iterate to the next key/value pair
  116363. * Note that you can remove any element in this dictionary in the callback implementation
  116364. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  116365. * @returns the first item
  116366. */
  116367. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  116368. private _count;
  116369. private _data;
  116370. }
  116371. }
  116372. declare module BABYLON {
  116373. /** @hidden */
  116374. export interface ICollisionCoordinator {
  116375. createCollider(): Collider;
  116376. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116377. init(scene: Scene): void;
  116378. }
  116379. /** @hidden */
  116380. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  116381. private _scene;
  116382. private _scaledPosition;
  116383. private _scaledVelocity;
  116384. private _finalPosition;
  116385. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  116386. createCollider(): Collider;
  116387. init(scene: Scene): void;
  116388. private _collideWithWorld;
  116389. }
  116390. }
  116391. declare module BABYLON {
  116392. /**
  116393. * Class used to manage all inputs for the scene.
  116394. */
  116395. export class InputManager {
  116396. /** The distance in pixel that you have to move to prevent some events */
  116397. static DragMovementThreshold: number;
  116398. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  116399. static LongPressDelay: number;
  116400. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  116401. static DoubleClickDelay: number;
  116402. /** If you need to check double click without raising a single click at first click, enable this flag */
  116403. static ExclusiveDoubleClickMode: boolean;
  116404. private _wheelEventName;
  116405. private _onPointerMove;
  116406. private _onPointerDown;
  116407. private _onPointerUp;
  116408. private _initClickEvent;
  116409. private _initActionManager;
  116410. private _delayedSimpleClick;
  116411. private _delayedSimpleClickTimeout;
  116412. private _previousDelayedSimpleClickTimeout;
  116413. private _meshPickProceed;
  116414. private _previousButtonPressed;
  116415. private _currentPickResult;
  116416. private _previousPickResult;
  116417. private _totalPointersPressed;
  116418. private _doubleClickOccured;
  116419. private _pointerOverMesh;
  116420. private _pickedDownMesh;
  116421. private _pickedUpMesh;
  116422. private _pointerX;
  116423. private _pointerY;
  116424. private _unTranslatedPointerX;
  116425. private _unTranslatedPointerY;
  116426. private _startingPointerPosition;
  116427. private _previousStartingPointerPosition;
  116428. private _startingPointerTime;
  116429. private _previousStartingPointerTime;
  116430. private _pointerCaptures;
  116431. private _onKeyDown;
  116432. private _onKeyUp;
  116433. private _onCanvasFocusObserver;
  116434. private _onCanvasBlurObserver;
  116435. private _scene;
  116436. /**
  116437. * Creates a new InputManager
  116438. * @param scene defines the hosting scene
  116439. */
  116440. constructor(scene: Scene);
  116441. /**
  116442. * Gets the mesh that is currently under the pointer
  116443. */
  116444. get meshUnderPointer(): Nullable<AbstractMesh>;
  116445. /**
  116446. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  116447. */
  116448. get unTranslatedPointer(): Vector2;
  116449. /**
  116450. * Gets or sets the current on-screen X position of the pointer
  116451. */
  116452. get pointerX(): number;
  116453. set pointerX(value: number);
  116454. /**
  116455. * Gets or sets the current on-screen Y position of the pointer
  116456. */
  116457. get pointerY(): number;
  116458. set pointerY(value: number);
  116459. private _updatePointerPosition;
  116460. private _processPointerMove;
  116461. private _setRayOnPointerInfo;
  116462. private _checkPrePointerObservable;
  116463. /**
  116464. * Use this method to simulate a pointer move on a mesh
  116465. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116466. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116467. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116468. */
  116469. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116470. /**
  116471. * Use this method to simulate a pointer down on a mesh
  116472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116475. */
  116476. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  116477. private _processPointerDown;
  116478. /** @hidden */
  116479. _isPointerSwiping(): boolean;
  116480. /**
  116481. * Use this method to simulate a pointer up on a mesh
  116482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  116483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  116484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  116485. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  116486. */
  116487. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  116488. private _processPointerUp;
  116489. /**
  116490. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  116491. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  116492. * @returns true if the pointer was captured
  116493. */
  116494. isPointerCaptured(pointerId?: number): boolean;
  116495. /**
  116496. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  116497. * @param attachUp defines if you want to attach events to pointerup
  116498. * @param attachDown defines if you want to attach events to pointerdown
  116499. * @param attachMove defines if you want to attach events to pointermove
  116500. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  116501. */
  116502. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  116503. /**
  116504. * Detaches all event handlers
  116505. */
  116506. detachControl(): void;
  116507. /**
  116508. * Force the value of meshUnderPointer
  116509. * @param mesh defines the mesh to use
  116510. */
  116511. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  116512. /**
  116513. * Gets the mesh under the pointer
  116514. * @returns a Mesh or null if no mesh is under the pointer
  116515. */
  116516. getPointerOverMesh(): Nullable<AbstractMesh>;
  116517. }
  116518. }
  116519. declare module BABYLON {
  116520. /**
  116521. * This class defines the direct association between an animation and a target
  116522. */
  116523. export class TargetedAnimation {
  116524. /**
  116525. * Animation to perform
  116526. */
  116527. animation: Animation;
  116528. /**
  116529. * Target to animate
  116530. */
  116531. target: any;
  116532. /**
  116533. * Returns the string "TargetedAnimation"
  116534. * @returns "TargetedAnimation"
  116535. */
  116536. getClassName(): string;
  116537. /**
  116538. * Serialize the object
  116539. * @returns the JSON object representing the current entity
  116540. */
  116541. serialize(): any;
  116542. }
  116543. /**
  116544. * Use this class to create coordinated animations on multiple targets
  116545. */
  116546. export class AnimationGroup implements IDisposable {
  116547. /** The name of the animation group */
  116548. name: string;
  116549. private _scene;
  116550. private _targetedAnimations;
  116551. private _animatables;
  116552. private _from;
  116553. private _to;
  116554. private _isStarted;
  116555. private _isPaused;
  116556. private _speedRatio;
  116557. private _loopAnimation;
  116558. private _isAdditive;
  116559. /**
  116560. * Gets or sets the unique id of the node
  116561. */
  116562. uniqueId: number;
  116563. /**
  116564. * This observable will notify when one animation have ended
  116565. */
  116566. onAnimationEndObservable: Observable<TargetedAnimation>;
  116567. /**
  116568. * Observer raised when one animation loops
  116569. */
  116570. onAnimationLoopObservable: Observable<TargetedAnimation>;
  116571. /**
  116572. * Observer raised when all animations have looped
  116573. */
  116574. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  116575. /**
  116576. * This observable will notify when all animations have ended.
  116577. */
  116578. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  116579. /**
  116580. * This observable will notify when all animations have paused.
  116581. */
  116582. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  116583. /**
  116584. * This observable will notify when all animations are playing.
  116585. */
  116586. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  116587. /**
  116588. * Gets the first frame
  116589. */
  116590. get from(): number;
  116591. /**
  116592. * Gets the last frame
  116593. */
  116594. get to(): number;
  116595. /**
  116596. * Define if the animations are started
  116597. */
  116598. get isStarted(): boolean;
  116599. /**
  116600. * Gets a value indicating that the current group is playing
  116601. */
  116602. get isPlaying(): boolean;
  116603. /**
  116604. * Gets or sets the speed ratio to use for all animations
  116605. */
  116606. get speedRatio(): number;
  116607. /**
  116608. * Gets or sets the speed ratio to use for all animations
  116609. */
  116610. set speedRatio(value: number);
  116611. /**
  116612. * Gets or sets if all animations should loop or not
  116613. */
  116614. get loopAnimation(): boolean;
  116615. set loopAnimation(value: boolean);
  116616. /**
  116617. * Gets or sets if all animations should be evaluated additively
  116618. */
  116619. get isAdditive(): boolean;
  116620. set isAdditive(value: boolean);
  116621. /**
  116622. * Gets the targeted animations for this animation group
  116623. */
  116624. get targetedAnimations(): Array<TargetedAnimation>;
  116625. /**
  116626. * returning the list of animatables controlled by this animation group.
  116627. */
  116628. get animatables(): Array<Animatable>;
  116629. /**
  116630. * Gets the list of target animations
  116631. */
  116632. get children(): TargetedAnimation[];
  116633. /**
  116634. * Instantiates a new Animation Group.
  116635. * This helps managing several animations at once.
  116636. * @see https://doc.babylonjs.com/how_to/group
  116637. * @param name Defines the name of the group
  116638. * @param scene Defines the scene the group belongs to
  116639. */
  116640. constructor(
  116641. /** The name of the animation group */
  116642. name: string, scene?: Nullable<Scene>);
  116643. /**
  116644. * Add an animation (with its target) in the group
  116645. * @param animation defines the animation we want to add
  116646. * @param target defines the target of the animation
  116647. * @returns the TargetedAnimation object
  116648. */
  116649. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  116650. /**
  116651. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  116652. * It can add constant keys at begin or end
  116653. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  116654. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  116655. * @returns the animation group
  116656. */
  116657. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  116658. private _animationLoopCount;
  116659. private _animationLoopFlags;
  116660. private _processLoop;
  116661. /**
  116662. * Start all animations on given targets
  116663. * @param loop defines if animations must loop
  116664. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  116665. * @param from defines the from key (optional)
  116666. * @param to defines the to key (optional)
  116667. * @param isAdditive defines the additive state for the resulting animatables (optional)
  116668. * @returns the current animation group
  116669. */
  116670. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  116671. /**
  116672. * Pause all animations
  116673. * @returns the animation group
  116674. */
  116675. pause(): AnimationGroup;
  116676. /**
  116677. * Play all animations to initial state
  116678. * This function will start() the animations if they were not started or will restart() them if they were paused
  116679. * @param loop defines if animations must loop
  116680. * @returns the animation group
  116681. */
  116682. play(loop?: boolean): AnimationGroup;
  116683. /**
  116684. * Reset all animations to initial state
  116685. * @returns the animation group
  116686. */
  116687. reset(): AnimationGroup;
  116688. /**
  116689. * Restart animations from key 0
  116690. * @returns the animation group
  116691. */
  116692. restart(): AnimationGroup;
  116693. /**
  116694. * Stop all animations
  116695. * @returns the animation group
  116696. */
  116697. stop(): AnimationGroup;
  116698. /**
  116699. * Set animation weight for all animatables
  116700. * @param weight defines the weight to use
  116701. * @return the animationGroup
  116702. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116703. */
  116704. setWeightForAllAnimatables(weight: number): AnimationGroup;
  116705. /**
  116706. * Synchronize and normalize all animatables with a source animatable
  116707. * @param root defines the root animatable to synchronize with
  116708. * @return the animationGroup
  116709. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  116710. */
  116711. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  116712. /**
  116713. * Goes to a specific frame in this animation group
  116714. * @param frame the frame number to go to
  116715. * @return the animationGroup
  116716. */
  116717. goToFrame(frame: number): AnimationGroup;
  116718. /**
  116719. * Dispose all associated resources
  116720. */
  116721. dispose(): void;
  116722. private _checkAnimationGroupEnded;
  116723. /**
  116724. * Clone the current animation group and returns a copy
  116725. * @param newName defines the name of the new group
  116726. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  116727. * @returns the new aniamtion group
  116728. */
  116729. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  116730. /**
  116731. * Serializes the animationGroup to an object
  116732. * @returns Serialized object
  116733. */
  116734. serialize(): any;
  116735. /**
  116736. * Returns a new AnimationGroup object parsed from the source provided.
  116737. * @param parsedAnimationGroup defines the source
  116738. * @param scene defines the scene that will receive the animationGroup
  116739. * @returns a new AnimationGroup
  116740. */
  116741. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  116742. /**
  116743. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  116744. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  116745. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  116746. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  116747. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  116748. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  116749. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  116750. */
  116751. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  116752. /**
  116753. * Returns the string "AnimationGroup"
  116754. * @returns "AnimationGroup"
  116755. */
  116756. getClassName(): string;
  116757. /**
  116758. * Creates a detailled string about the object
  116759. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  116760. * @returns a string representing the object
  116761. */
  116762. toString(fullDetails?: boolean): string;
  116763. }
  116764. }
  116765. declare module BABYLON {
  116766. /**
  116767. * Define an interface for all classes that will hold resources
  116768. */
  116769. export interface IDisposable {
  116770. /**
  116771. * Releases all held resources
  116772. */
  116773. dispose(): void;
  116774. }
  116775. /** Interface defining initialization parameters for Scene class */
  116776. export interface SceneOptions {
  116777. /**
  116778. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  116779. * It will improve performance when the number of geometries becomes important.
  116780. */
  116781. useGeometryUniqueIdsMap?: boolean;
  116782. /**
  116783. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  116784. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116785. */
  116786. useMaterialMeshMap?: boolean;
  116787. /**
  116788. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  116789. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  116790. */
  116791. useClonedMeshMap?: boolean;
  116792. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  116793. virtual?: boolean;
  116794. }
  116795. /**
  116796. * Represents a scene to be rendered by the engine.
  116797. * @see https://doc.babylonjs.com/features/scene
  116798. */
  116799. export class Scene extends AbstractScene implements IAnimatable {
  116800. /** The fog is deactivated */
  116801. static readonly FOGMODE_NONE: number;
  116802. /** The fog density is following an exponential function */
  116803. static readonly FOGMODE_EXP: number;
  116804. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  116805. static readonly FOGMODE_EXP2: number;
  116806. /** The fog density is following a linear function. */
  116807. static readonly FOGMODE_LINEAR: number;
  116808. /**
  116809. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  116810. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116811. */
  116812. static MinDeltaTime: number;
  116813. /**
  116814. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  116815. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  116816. */
  116817. static MaxDeltaTime: number;
  116818. /**
  116819. * Factory used to create the default material.
  116820. * @param name The name of the material to create
  116821. * @param scene The scene to create the material for
  116822. * @returns The default material
  116823. */
  116824. static DefaultMaterialFactory(scene: Scene): Material;
  116825. /**
  116826. * Factory used to create the a collision coordinator.
  116827. * @returns The collision coordinator
  116828. */
  116829. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  116830. /** @hidden */
  116831. _inputManager: InputManager;
  116832. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  116833. cameraToUseForPointers: Nullable<Camera>;
  116834. /** @hidden */
  116835. readonly _isScene: boolean;
  116836. /** @hidden */
  116837. _blockEntityCollection: boolean;
  116838. /**
  116839. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  116840. */
  116841. autoClear: boolean;
  116842. /**
  116843. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  116844. */
  116845. autoClearDepthAndStencil: boolean;
  116846. /**
  116847. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  116848. */
  116849. clearColor: Color4;
  116850. /**
  116851. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  116852. */
  116853. ambientColor: Color3;
  116854. /**
  116855. * This is use to store the default BRDF lookup for PBR materials in your scene.
  116856. * It should only be one of the following (if not the default embedded one):
  116857. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  116858. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  116859. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  116860. * The material properties need to be setup according to the type of texture in use.
  116861. */
  116862. environmentBRDFTexture: BaseTexture;
  116863. /** @hidden */
  116864. protected _environmentTexture: Nullable<BaseTexture>;
  116865. /**
  116866. * Texture used in all pbr material as the reflection texture.
  116867. * As in the majority of the scene they are the same (exception for multi room and so on),
  116868. * this is easier to reference from here than from all the materials.
  116869. */
  116870. get environmentTexture(): Nullable<BaseTexture>;
  116871. /**
  116872. * Texture used in all pbr material as the reflection texture.
  116873. * As in the majority of the scene they are the same (exception for multi room and so on),
  116874. * this is easier to set here than in all the materials.
  116875. */
  116876. set environmentTexture(value: Nullable<BaseTexture>);
  116877. /** @hidden */
  116878. protected _environmentIntensity: number;
  116879. /**
  116880. * Intensity of the environment in all pbr material.
  116881. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116882. * As in the majority of the scene they are the same (exception for multi room and so on),
  116883. * this is easier to reference from here than from all the materials.
  116884. */
  116885. get environmentIntensity(): number;
  116886. /**
  116887. * Intensity of the environment in all pbr material.
  116888. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  116889. * As in the majority of the scene they are the same (exception for multi room and so on),
  116890. * this is easier to set here than in all the materials.
  116891. */
  116892. set environmentIntensity(value: number);
  116893. /** @hidden */
  116894. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116895. /**
  116896. * Default image processing configuration used either in the rendering
  116897. * Forward main pass or through the imageProcessingPostProcess if present.
  116898. * As in the majority of the scene they are the same (exception for multi camera),
  116899. * this is easier to reference from here than from all the materials and post process.
  116900. *
  116901. * No setter as we it is a shared configuration, you can set the values instead.
  116902. */
  116903. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116904. private _forceWireframe;
  116905. /**
  116906. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  116907. */
  116908. set forceWireframe(value: boolean);
  116909. get forceWireframe(): boolean;
  116910. private _skipFrustumClipping;
  116911. /**
  116912. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  116913. */
  116914. set skipFrustumClipping(value: boolean);
  116915. get skipFrustumClipping(): boolean;
  116916. private _forcePointsCloud;
  116917. /**
  116918. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  116919. */
  116920. set forcePointsCloud(value: boolean);
  116921. get forcePointsCloud(): boolean;
  116922. /**
  116923. * Gets or sets the active clipplane 1
  116924. */
  116925. clipPlane: Nullable<Plane>;
  116926. /**
  116927. * Gets or sets the active clipplane 2
  116928. */
  116929. clipPlane2: Nullable<Plane>;
  116930. /**
  116931. * Gets or sets the active clipplane 3
  116932. */
  116933. clipPlane3: Nullable<Plane>;
  116934. /**
  116935. * Gets or sets the active clipplane 4
  116936. */
  116937. clipPlane4: Nullable<Plane>;
  116938. /**
  116939. * Gets or sets the active clipplane 5
  116940. */
  116941. clipPlane5: Nullable<Plane>;
  116942. /**
  116943. * Gets or sets the active clipplane 6
  116944. */
  116945. clipPlane6: Nullable<Plane>;
  116946. /**
  116947. * Gets or sets a boolean indicating if animations are enabled
  116948. */
  116949. animationsEnabled: boolean;
  116950. private _animationPropertiesOverride;
  116951. /**
  116952. * Gets or sets the animation properties override
  116953. */
  116954. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  116955. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  116956. /**
  116957. * Gets or sets a boolean indicating if a constant deltatime has to be used
  116958. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  116959. */
  116960. useConstantAnimationDeltaTime: boolean;
  116961. /**
  116962. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  116963. * Please note that it requires to run a ray cast through the scene on every frame
  116964. */
  116965. constantlyUpdateMeshUnderPointer: boolean;
  116966. /**
  116967. * Defines the HTML cursor to use when hovering over interactive elements
  116968. */
  116969. hoverCursor: string;
  116970. /**
  116971. * Defines the HTML default cursor to use (empty by default)
  116972. */
  116973. defaultCursor: string;
  116974. /**
  116975. * Defines whether cursors are handled by the scene.
  116976. */
  116977. doNotHandleCursors: boolean;
  116978. /**
  116979. * This is used to call preventDefault() on pointer down
  116980. * in order to block unwanted artifacts like system double clicks
  116981. */
  116982. preventDefaultOnPointerDown: boolean;
  116983. /**
  116984. * This is used to call preventDefault() on pointer up
  116985. * in order to block unwanted artifacts like system double clicks
  116986. */
  116987. preventDefaultOnPointerUp: boolean;
  116988. /**
  116989. * Gets or sets user defined metadata
  116990. */
  116991. metadata: any;
  116992. /**
  116993. * For internal use only. Please do not use.
  116994. */
  116995. reservedDataStore: any;
  116996. /**
  116997. * Gets the name of the plugin used to load this scene (null by default)
  116998. */
  116999. loadingPluginName: string;
  117000. /**
  117001. * Use this array to add regular expressions used to disable offline support for specific urls
  117002. */
  117003. disableOfflineSupportExceptionRules: RegExp[];
  117004. /**
  117005. * An event triggered when the scene is disposed.
  117006. */
  117007. onDisposeObservable: Observable<Scene>;
  117008. private _onDisposeObserver;
  117009. /** Sets a function to be executed when this scene is disposed. */
  117010. set onDispose(callback: () => void);
  117011. /**
  117012. * An event triggered before rendering the scene (right after animations and physics)
  117013. */
  117014. onBeforeRenderObservable: Observable<Scene>;
  117015. private _onBeforeRenderObserver;
  117016. /** Sets a function to be executed before rendering this scene */
  117017. set beforeRender(callback: Nullable<() => void>);
  117018. /**
  117019. * An event triggered after rendering the scene
  117020. */
  117021. onAfterRenderObservable: Observable<Scene>;
  117022. /**
  117023. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  117024. */
  117025. onAfterRenderCameraObservable: Observable<Camera>;
  117026. private _onAfterRenderObserver;
  117027. /** Sets a function to be executed after rendering this scene */
  117028. set afterRender(callback: Nullable<() => void>);
  117029. /**
  117030. * An event triggered before animating the scene
  117031. */
  117032. onBeforeAnimationsObservable: Observable<Scene>;
  117033. /**
  117034. * An event triggered after animations processing
  117035. */
  117036. onAfterAnimationsObservable: Observable<Scene>;
  117037. /**
  117038. * An event triggered before draw calls are ready to be sent
  117039. */
  117040. onBeforeDrawPhaseObservable: Observable<Scene>;
  117041. /**
  117042. * An event triggered after draw calls have been sent
  117043. */
  117044. onAfterDrawPhaseObservable: Observable<Scene>;
  117045. /**
  117046. * An event triggered when the scene is ready
  117047. */
  117048. onReadyObservable: Observable<Scene>;
  117049. /**
  117050. * An event triggered before rendering a camera
  117051. */
  117052. onBeforeCameraRenderObservable: Observable<Camera>;
  117053. private _onBeforeCameraRenderObserver;
  117054. /** Sets a function to be executed before rendering a camera*/
  117055. set beforeCameraRender(callback: () => void);
  117056. /**
  117057. * An event triggered after rendering a camera
  117058. */
  117059. onAfterCameraRenderObservable: Observable<Camera>;
  117060. private _onAfterCameraRenderObserver;
  117061. /** Sets a function to be executed after rendering a camera*/
  117062. set afterCameraRender(callback: () => void);
  117063. /**
  117064. * An event triggered when active meshes evaluation is about to start
  117065. */
  117066. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  117067. /**
  117068. * An event triggered when active meshes evaluation is done
  117069. */
  117070. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  117071. /**
  117072. * An event triggered when particles rendering is about to start
  117073. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117074. */
  117075. onBeforeParticlesRenderingObservable: Observable<Scene>;
  117076. /**
  117077. * An event triggered when particles rendering is done
  117078. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  117079. */
  117080. onAfterParticlesRenderingObservable: Observable<Scene>;
  117081. /**
  117082. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  117083. */
  117084. onDataLoadedObservable: Observable<Scene>;
  117085. /**
  117086. * An event triggered when a camera is created
  117087. */
  117088. onNewCameraAddedObservable: Observable<Camera>;
  117089. /**
  117090. * An event triggered when a camera is removed
  117091. */
  117092. onCameraRemovedObservable: Observable<Camera>;
  117093. /**
  117094. * An event triggered when a light is created
  117095. */
  117096. onNewLightAddedObservable: Observable<Light>;
  117097. /**
  117098. * An event triggered when a light is removed
  117099. */
  117100. onLightRemovedObservable: Observable<Light>;
  117101. /**
  117102. * An event triggered when a geometry is created
  117103. */
  117104. onNewGeometryAddedObservable: Observable<Geometry>;
  117105. /**
  117106. * An event triggered when a geometry is removed
  117107. */
  117108. onGeometryRemovedObservable: Observable<Geometry>;
  117109. /**
  117110. * An event triggered when a transform node is created
  117111. */
  117112. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  117113. /**
  117114. * An event triggered when a transform node is removed
  117115. */
  117116. onTransformNodeRemovedObservable: Observable<TransformNode>;
  117117. /**
  117118. * An event triggered when a mesh is created
  117119. */
  117120. onNewMeshAddedObservable: Observable<AbstractMesh>;
  117121. /**
  117122. * An event triggered when a mesh is removed
  117123. */
  117124. onMeshRemovedObservable: Observable<AbstractMesh>;
  117125. /**
  117126. * An event triggered when a skeleton is created
  117127. */
  117128. onNewSkeletonAddedObservable: Observable<Skeleton>;
  117129. /**
  117130. * An event triggered when a skeleton is removed
  117131. */
  117132. onSkeletonRemovedObservable: Observable<Skeleton>;
  117133. /**
  117134. * An event triggered when a material is created
  117135. */
  117136. onNewMaterialAddedObservable: Observable<Material>;
  117137. /**
  117138. * An event triggered when a material is removed
  117139. */
  117140. onMaterialRemovedObservable: Observable<Material>;
  117141. /**
  117142. * An event triggered when a texture is created
  117143. */
  117144. onNewTextureAddedObservable: Observable<BaseTexture>;
  117145. /**
  117146. * An event triggered when a texture is removed
  117147. */
  117148. onTextureRemovedObservable: Observable<BaseTexture>;
  117149. /**
  117150. * An event triggered when render targets are about to be rendered
  117151. * Can happen multiple times per frame.
  117152. */
  117153. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  117154. /**
  117155. * An event triggered when render targets were rendered.
  117156. * Can happen multiple times per frame.
  117157. */
  117158. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  117159. /**
  117160. * An event triggered before calculating deterministic simulation step
  117161. */
  117162. onBeforeStepObservable: Observable<Scene>;
  117163. /**
  117164. * An event triggered after calculating deterministic simulation step
  117165. */
  117166. onAfterStepObservable: Observable<Scene>;
  117167. /**
  117168. * An event triggered when the activeCamera property is updated
  117169. */
  117170. onActiveCameraChanged: Observable<Scene>;
  117171. /**
  117172. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  117173. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  117174. * 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)
  117175. */
  117176. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  117177. /**
  117178. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  117179. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  117180. * 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)
  117181. */
  117182. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  117183. /**
  117184. * This Observable will when a mesh has been imported into the scene.
  117185. */
  117186. onMeshImportedObservable: Observable<AbstractMesh>;
  117187. /**
  117188. * This Observable will when an animation file has been imported into the scene.
  117189. */
  117190. onAnimationFileImportedObservable: Observable<Scene>;
  117191. /**
  117192. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  117193. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  117194. */
  117195. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  117196. /** @hidden */
  117197. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  117198. /**
  117199. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  117200. */
  117201. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  117202. /**
  117203. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  117204. */
  117205. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  117206. /**
  117207. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  117208. */
  117209. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  117210. /** Callback called when a pointer move is detected */
  117211. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117212. /** Callback called when a pointer down is detected */
  117213. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  117214. /** Callback called when a pointer up is detected */
  117215. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  117216. /** Callback called when a pointer pick is detected */
  117217. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  117218. /**
  117219. * 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).
  117220. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  117221. */
  117222. onPrePointerObservable: Observable<PointerInfoPre>;
  117223. /**
  117224. * Observable event triggered each time an input event is received from the rendering canvas
  117225. */
  117226. onPointerObservable: Observable<PointerInfo>;
  117227. /**
  117228. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  117229. */
  117230. get unTranslatedPointer(): Vector2;
  117231. /**
  117232. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  117233. */
  117234. static get DragMovementThreshold(): number;
  117235. static set DragMovementThreshold(value: number);
  117236. /**
  117237. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  117238. */
  117239. static get LongPressDelay(): number;
  117240. static set LongPressDelay(value: number);
  117241. /**
  117242. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  117243. */
  117244. static get DoubleClickDelay(): number;
  117245. static set DoubleClickDelay(value: number);
  117246. /** If you need to check double click without raising a single click at first click, enable this flag */
  117247. static get ExclusiveDoubleClickMode(): boolean;
  117248. static set ExclusiveDoubleClickMode(value: boolean);
  117249. /** @hidden */
  117250. _mirroredCameraPosition: Nullable<Vector3>;
  117251. /**
  117252. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  117253. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  117254. */
  117255. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  117256. /**
  117257. * Observable event triggered each time an keyboard event is received from the hosting window
  117258. */
  117259. onKeyboardObservable: Observable<KeyboardInfo>;
  117260. private _useRightHandedSystem;
  117261. /**
  117262. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  117263. */
  117264. set useRightHandedSystem(value: boolean);
  117265. get useRightHandedSystem(): boolean;
  117266. private _timeAccumulator;
  117267. private _currentStepId;
  117268. private _currentInternalStep;
  117269. /**
  117270. * Sets the step Id used by deterministic lock step
  117271. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117272. * @param newStepId defines the step Id
  117273. */
  117274. setStepId(newStepId: number): void;
  117275. /**
  117276. * Gets the step Id used by deterministic lock step
  117277. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117278. * @returns the step Id
  117279. */
  117280. getStepId(): number;
  117281. /**
  117282. * Gets the internal step used by deterministic lock step
  117283. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  117284. * @returns the internal step
  117285. */
  117286. getInternalStep(): number;
  117287. private _fogEnabled;
  117288. /**
  117289. * Gets or sets a boolean indicating if fog is enabled on this scene
  117290. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117291. * (Default is true)
  117292. */
  117293. set fogEnabled(value: boolean);
  117294. get fogEnabled(): boolean;
  117295. private _fogMode;
  117296. /**
  117297. * Gets or sets the fog mode to use
  117298. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117299. * | mode | value |
  117300. * | --- | --- |
  117301. * | FOGMODE_NONE | 0 |
  117302. * | FOGMODE_EXP | 1 |
  117303. * | FOGMODE_EXP2 | 2 |
  117304. * | FOGMODE_LINEAR | 3 |
  117305. */
  117306. set fogMode(value: number);
  117307. get fogMode(): number;
  117308. /**
  117309. * Gets or sets the fog color to use
  117310. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117311. * (Default is Color3(0.2, 0.2, 0.3))
  117312. */
  117313. fogColor: Color3;
  117314. /**
  117315. * Gets or sets the fog density to use
  117316. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117317. * (Default is 0.1)
  117318. */
  117319. fogDensity: number;
  117320. /**
  117321. * Gets or sets the fog start distance to use
  117322. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117323. * (Default is 0)
  117324. */
  117325. fogStart: number;
  117326. /**
  117327. * Gets or sets the fog end distance to use
  117328. * @see https://doc.babylonjs.com/babylon101/environment#fog
  117329. * (Default is 1000)
  117330. */
  117331. fogEnd: number;
  117332. /**
  117333. * Flag indicating that the frame buffer binding is handled by another component
  117334. */
  117335. prePass: boolean;
  117336. private _shadowsEnabled;
  117337. /**
  117338. * Gets or sets a boolean indicating if shadows are enabled on this scene
  117339. */
  117340. set shadowsEnabled(value: boolean);
  117341. get shadowsEnabled(): boolean;
  117342. private _lightsEnabled;
  117343. /**
  117344. * Gets or sets a boolean indicating if lights are enabled on this scene
  117345. */
  117346. set lightsEnabled(value: boolean);
  117347. get lightsEnabled(): boolean;
  117348. /** All of the active cameras added to this scene. */
  117349. activeCameras: Camera[];
  117350. /** @hidden */
  117351. _activeCamera: Nullable<Camera>;
  117352. /** Gets or sets the current active camera */
  117353. get activeCamera(): Nullable<Camera>;
  117354. set activeCamera(value: Nullable<Camera>);
  117355. private _defaultMaterial;
  117356. /** The default material used on meshes when no material is affected */
  117357. get defaultMaterial(): Material;
  117358. /** The default material used on meshes when no material is affected */
  117359. set defaultMaterial(value: Material);
  117360. private _texturesEnabled;
  117361. /**
  117362. * Gets or sets a boolean indicating if textures are enabled on this scene
  117363. */
  117364. set texturesEnabled(value: boolean);
  117365. get texturesEnabled(): boolean;
  117366. /**
  117367. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  117368. */
  117369. physicsEnabled: boolean;
  117370. /**
  117371. * Gets or sets a boolean indicating if particles are enabled on this scene
  117372. */
  117373. particlesEnabled: boolean;
  117374. /**
  117375. * Gets or sets a boolean indicating if sprites are enabled on this scene
  117376. */
  117377. spritesEnabled: boolean;
  117378. private _skeletonsEnabled;
  117379. /**
  117380. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  117381. */
  117382. set skeletonsEnabled(value: boolean);
  117383. get skeletonsEnabled(): boolean;
  117384. /**
  117385. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  117386. */
  117387. lensFlaresEnabled: boolean;
  117388. /**
  117389. * Gets or sets a boolean indicating if collisions are enabled on this scene
  117390. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117391. */
  117392. collisionsEnabled: boolean;
  117393. private _collisionCoordinator;
  117394. /** @hidden */
  117395. get collisionCoordinator(): ICollisionCoordinator;
  117396. /**
  117397. * Defines the gravity applied to this scene (used only for collisions)
  117398. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  117399. */
  117400. gravity: Vector3;
  117401. /**
  117402. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  117403. */
  117404. postProcessesEnabled: boolean;
  117405. /**
  117406. * The list of postprocesses added to the scene
  117407. */
  117408. postProcesses: PostProcess[];
  117409. /**
  117410. * Gets the current postprocess manager
  117411. */
  117412. postProcessManager: PostProcessManager;
  117413. /**
  117414. * Gets or sets a boolean indicating if render targets are enabled on this scene
  117415. */
  117416. renderTargetsEnabled: boolean;
  117417. /**
  117418. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  117419. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  117420. */
  117421. dumpNextRenderTargets: boolean;
  117422. /**
  117423. * The list of user defined render targets added to the scene
  117424. */
  117425. customRenderTargets: RenderTargetTexture[];
  117426. /**
  117427. * Defines if texture loading must be delayed
  117428. * If true, textures will only be loaded when they need to be rendered
  117429. */
  117430. useDelayedTextureLoading: boolean;
  117431. /**
  117432. * Gets the list of meshes imported to the scene through SceneLoader
  117433. */
  117434. importedMeshesFiles: String[];
  117435. /**
  117436. * Gets or sets a boolean indicating if probes are enabled on this scene
  117437. */
  117438. probesEnabled: boolean;
  117439. /**
  117440. * Gets or sets the current offline provider to use to store scene data
  117441. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  117442. */
  117443. offlineProvider: IOfflineProvider;
  117444. /**
  117445. * Gets or sets the action manager associated with the scene
  117446. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  117447. */
  117448. actionManager: AbstractActionManager;
  117449. private _meshesForIntersections;
  117450. /**
  117451. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  117452. */
  117453. proceduralTexturesEnabled: boolean;
  117454. private _engine;
  117455. private _totalVertices;
  117456. /** @hidden */
  117457. _activeIndices: PerfCounter;
  117458. /** @hidden */
  117459. _activeParticles: PerfCounter;
  117460. /** @hidden */
  117461. _activeBones: PerfCounter;
  117462. private _animationRatio;
  117463. /** @hidden */
  117464. _animationTimeLast: number;
  117465. /** @hidden */
  117466. _animationTime: number;
  117467. /**
  117468. * Gets or sets a general scale for animation speed
  117469. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  117470. */
  117471. animationTimeScale: number;
  117472. /** @hidden */
  117473. _cachedMaterial: Nullable<Material>;
  117474. /** @hidden */
  117475. _cachedEffect: Nullable<Effect>;
  117476. /** @hidden */
  117477. _cachedVisibility: Nullable<number>;
  117478. private _renderId;
  117479. private _frameId;
  117480. private _executeWhenReadyTimeoutId;
  117481. private _intermediateRendering;
  117482. private _viewUpdateFlag;
  117483. private _projectionUpdateFlag;
  117484. /** @hidden */
  117485. _toBeDisposed: Nullable<IDisposable>[];
  117486. private _activeRequests;
  117487. /** @hidden */
  117488. _pendingData: any[];
  117489. private _isDisposed;
  117490. /**
  117491. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  117492. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  117493. */
  117494. dispatchAllSubMeshesOfActiveMeshes: boolean;
  117495. private _activeMeshes;
  117496. private _processedMaterials;
  117497. private _renderTargets;
  117498. /** @hidden */
  117499. _activeParticleSystems: SmartArray<IParticleSystem>;
  117500. private _activeSkeletons;
  117501. private _softwareSkinnedMeshes;
  117502. private _renderingManager;
  117503. /** @hidden */
  117504. _activeAnimatables: Animatable[];
  117505. private _transformMatrix;
  117506. private _sceneUbo;
  117507. /** @hidden */
  117508. _viewMatrix: Matrix;
  117509. private _projectionMatrix;
  117510. /** @hidden */
  117511. _forcedViewPosition: Nullable<Vector3>;
  117512. /** @hidden */
  117513. _frustumPlanes: Plane[];
  117514. /**
  117515. * Gets the list of frustum planes (built from the active camera)
  117516. */
  117517. get frustumPlanes(): Plane[];
  117518. /**
  117519. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  117520. * This is useful if there are more lights that the maximum simulteanous authorized
  117521. */
  117522. requireLightSorting: boolean;
  117523. /** @hidden */
  117524. readonly useMaterialMeshMap: boolean;
  117525. /** @hidden */
  117526. readonly useClonedMeshMap: boolean;
  117527. private _externalData;
  117528. private _uid;
  117529. /**
  117530. * @hidden
  117531. * Backing store of defined scene components.
  117532. */
  117533. _components: ISceneComponent[];
  117534. /**
  117535. * @hidden
  117536. * Backing store of defined scene components.
  117537. */
  117538. _serializableComponents: ISceneSerializableComponent[];
  117539. /**
  117540. * List of components to register on the next registration step.
  117541. */
  117542. private _transientComponents;
  117543. /**
  117544. * Registers the transient components if needed.
  117545. */
  117546. private _registerTransientComponents;
  117547. /**
  117548. * @hidden
  117549. * Add a component to the scene.
  117550. * Note that the ccomponent could be registered on th next frame if this is called after
  117551. * the register component stage.
  117552. * @param component Defines the component to add to the scene
  117553. */
  117554. _addComponent(component: ISceneComponent): void;
  117555. /**
  117556. * @hidden
  117557. * Gets a component from the scene.
  117558. * @param name defines the name of the component to retrieve
  117559. * @returns the component or null if not present
  117560. */
  117561. _getComponent(name: string): Nullable<ISceneComponent>;
  117562. /**
  117563. * @hidden
  117564. * Defines the actions happening before camera updates.
  117565. */
  117566. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  117567. /**
  117568. * @hidden
  117569. * Defines the actions happening before clear the canvas.
  117570. */
  117571. _beforeClearStage: Stage<SimpleStageAction>;
  117572. /**
  117573. * @hidden
  117574. * Defines the actions when collecting render targets for the frame.
  117575. */
  117576. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117577. /**
  117578. * @hidden
  117579. * Defines the actions happening for one camera in the frame.
  117580. */
  117581. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  117582. /**
  117583. * @hidden
  117584. * Defines the actions happening during the per mesh ready checks.
  117585. */
  117586. _isReadyForMeshStage: Stage<MeshStageAction>;
  117587. /**
  117588. * @hidden
  117589. * Defines the actions happening before evaluate active mesh checks.
  117590. */
  117591. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  117592. /**
  117593. * @hidden
  117594. * Defines the actions happening during the evaluate sub mesh checks.
  117595. */
  117596. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  117597. /**
  117598. * @hidden
  117599. * Defines the actions happening during the active mesh stage.
  117600. */
  117601. _activeMeshStage: Stage<ActiveMeshStageAction>;
  117602. /**
  117603. * @hidden
  117604. * Defines the actions happening during the per camera render target step.
  117605. */
  117606. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  117607. /**
  117608. * @hidden
  117609. * Defines the actions happening just before the active camera is drawing.
  117610. */
  117611. _beforeCameraDrawStage: Stage<CameraStageAction>;
  117612. /**
  117613. * @hidden
  117614. * Defines the actions happening just before a render target is drawing.
  117615. */
  117616. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117617. /**
  117618. * @hidden
  117619. * Defines the actions happening just before a rendering group is drawing.
  117620. */
  117621. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117622. /**
  117623. * @hidden
  117624. * Defines the actions happening just before a mesh is drawing.
  117625. */
  117626. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117627. /**
  117628. * @hidden
  117629. * Defines the actions happening just after a mesh has been drawn.
  117630. */
  117631. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  117632. /**
  117633. * @hidden
  117634. * Defines the actions happening just after a rendering group has been drawn.
  117635. */
  117636. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  117637. /**
  117638. * @hidden
  117639. * Defines the actions happening just after the active camera has been drawn.
  117640. */
  117641. _afterCameraDrawStage: Stage<CameraStageAction>;
  117642. /**
  117643. * @hidden
  117644. * Defines the actions happening just after a render target has been drawn.
  117645. */
  117646. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  117647. /**
  117648. * @hidden
  117649. * Defines the actions happening just after rendering all cameras and computing intersections.
  117650. */
  117651. _afterRenderStage: Stage<SimpleStageAction>;
  117652. /**
  117653. * @hidden
  117654. * Defines the actions happening when a pointer move event happens.
  117655. */
  117656. _pointerMoveStage: Stage<PointerMoveStageAction>;
  117657. /**
  117658. * @hidden
  117659. * Defines the actions happening when a pointer down event happens.
  117660. */
  117661. _pointerDownStage: Stage<PointerUpDownStageAction>;
  117662. /**
  117663. * @hidden
  117664. * Defines the actions happening when a pointer up event happens.
  117665. */
  117666. _pointerUpStage: Stage<PointerUpDownStageAction>;
  117667. /**
  117668. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  117669. */
  117670. private geometriesByUniqueId;
  117671. /**
  117672. * Creates a new Scene
  117673. * @param engine defines the engine to use to render this scene
  117674. * @param options defines the scene options
  117675. */
  117676. constructor(engine: Engine, options?: SceneOptions);
  117677. /**
  117678. * Gets a string idenfifying the name of the class
  117679. * @returns "Scene" string
  117680. */
  117681. getClassName(): string;
  117682. private _defaultMeshCandidates;
  117683. /**
  117684. * @hidden
  117685. */
  117686. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  117687. private _defaultSubMeshCandidates;
  117688. /**
  117689. * @hidden
  117690. */
  117691. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  117692. /**
  117693. * Sets the default candidate providers for the scene.
  117694. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  117695. * and getCollidingSubMeshCandidates to their default function
  117696. */
  117697. setDefaultCandidateProviders(): void;
  117698. /**
  117699. * Gets the mesh that is currently under the pointer
  117700. */
  117701. get meshUnderPointer(): Nullable<AbstractMesh>;
  117702. /**
  117703. * Gets or sets the current on-screen X position of the pointer
  117704. */
  117705. get pointerX(): number;
  117706. set pointerX(value: number);
  117707. /**
  117708. * Gets or sets the current on-screen Y position of the pointer
  117709. */
  117710. get pointerY(): number;
  117711. set pointerY(value: number);
  117712. /**
  117713. * Gets the cached material (ie. the latest rendered one)
  117714. * @returns the cached material
  117715. */
  117716. getCachedMaterial(): Nullable<Material>;
  117717. /**
  117718. * Gets the cached effect (ie. the latest rendered one)
  117719. * @returns the cached effect
  117720. */
  117721. getCachedEffect(): Nullable<Effect>;
  117722. /**
  117723. * Gets the cached visibility state (ie. the latest rendered one)
  117724. * @returns the cached visibility state
  117725. */
  117726. getCachedVisibility(): Nullable<number>;
  117727. /**
  117728. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  117729. * @param material defines the current material
  117730. * @param effect defines the current effect
  117731. * @param visibility defines the current visibility state
  117732. * @returns true if one parameter is not cached
  117733. */
  117734. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  117735. /**
  117736. * Gets the engine associated with the scene
  117737. * @returns an Engine
  117738. */
  117739. getEngine(): Engine;
  117740. /**
  117741. * Gets the total number of vertices rendered per frame
  117742. * @returns the total number of vertices rendered per frame
  117743. */
  117744. getTotalVertices(): number;
  117745. /**
  117746. * Gets the performance counter for total vertices
  117747. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117748. */
  117749. get totalVerticesPerfCounter(): PerfCounter;
  117750. /**
  117751. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  117752. * @returns the total number of active indices rendered per frame
  117753. */
  117754. getActiveIndices(): number;
  117755. /**
  117756. * Gets the performance counter for active indices
  117757. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117758. */
  117759. get totalActiveIndicesPerfCounter(): PerfCounter;
  117760. /**
  117761. * Gets the total number of active particles rendered per frame
  117762. * @returns the total number of active particles rendered per frame
  117763. */
  117764. getActiveParticles(): number;
  117765. /**
  117766. * Gets the performance counter for active particles
  117767. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117768. */
  117769. get activeParticlesPerfCounter(): PerfCounter;
  117770. /**
  117771. * Gets the total number of active bones rendered per frame
  117772. * @returns the total number of active bones rendered per frame
  117773. */
  117774. getActiveBones(): number;
  117775. /**
  117776. * Gets the performance counter for active bones
  117777. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  117778. */
  117779. get activeBonesPerfCounter(): PerfCounter;
  117780. /**
  117781. * Gets the array of active meshes
  117782. * @returns an array of AbstractMesh
  117783. */
  117784. getActiveMeshes(): SmartArray<AbstractMesh>;
  117785. /**
  117786. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  117787. * @returns a number
  117788. */
  117789. getAnimationRatio(): number;
  117790. /**
  117791. * Gets an unique Id for the current render phase
  117792. * @returns a number
  117793. */
  117794. getRenderId(): number;
  117795. /**
  117796. * Gets an unique Id for the current frame
  117797. * @returns a number
  117798. */
  117799. getFrameId(): number;
  117800. /** Call this function if you want to manually increment the render Id*/
  117801. incrementRenderId(): void;
  117802. private _createUbo;
  117803. /**
  117804. * Use this method to simulate a pointer move on a mesh
  117805. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117806. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117807. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117808. * @returns the current scene
  117809. */
  117810. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117811. /**
  117812. * Use this method to simulate a pointer down on a mesh
  117813. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117814. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117815. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117816. * @returns the current scene
  117817. */
  117818. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  117819. /**
  117820. * Use this method to simulate a pointer up on a mesh
  117821. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  117822. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  117823. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  117824. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  117825. * @returns the current scene
  117826. */
  117827. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  117828. /**
  117829. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  117830. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  117831. * @returns true if the pointer was captured
  117832. */
  117833. isPointerCaptured(pointerId?: number): boolean;
  117834. /**
  117835. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  117836. * @param attachUp defines if you want to attach events to pointerup
  117837. * @param attachDown defines if you want to attach events to pointerdown
  117838. * @param attachMove defines if you want to attach events to pointermove
  117839. */
  117840. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  117841. /** Detaches all event handlers*/
  117842. detachControl(): void;
  117843. /**
  117844. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  117845. * Delay loaded resources are not taking in account
  117846. * @return true if all required resources are ready
  117847. */
  117848. isReady(): boolean;
  117849. /** Resets all cached information relative to material (including effect and visibility) */
  117850. resetCachedMaterial(): void;
  117851. /**
  117852. * Registers a function to be called before every frame render
  117853. * @param func defines the function to register
  117854. */
  117855. registerBeforeRender(func: () => void): void;
  117856. /**
  117857. * Unregisters a function called before every frame render
  117858. * @param func defines the function to unregister
  117859. */
  117860. unregisterBeforeRender(func: () => void): void;
  117861. /**
  117862. * Registers a function to be called after every frame render
  117863. * @param func defines the function to register
  117864. */
  117865. registerAfterRender(func: () => void): void;
  117866. /**
  117867. * Unregisters a function called after every frame render
  117868. * @param func defines the function to unregister
  117869. */
  117870. unregisterAfterRender(func: () => void): void;
  117871. private _executeOnceBeforeRender;
  117872. /**
  117873. * The provided function will run before render once and will be disposed afterwards.
  117874. * A timeout delay can be provided so that the function will be executed in N ms.
  117875. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  117876. * @param func The function to be executed.
  117877. * @param timeout optional delay in ms
  117878. */
  117879. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  117880. /** @hidden */
  117881. _addPendingData(data: any): void;
  117882. /** @hidden */
  117883. _removePendingData(data: any): void;
  117884. /**
  117885. * Returns the number of items waiting to be loaded
  117886. * @returns the number of items waiting to be loaded
  117887. */
  117888. getWaitingItemsCount(): number;
  117889. /**
  117890. * Returns a boolean indicating if the scene is still loading data
  117891. */
  117892. get isLoading(): boolean;
  117893. /**
  117894. * Registers a function to be executed when the scene is ready
  117895. * @param {Function} func - the function to be executed
  117896. */
  117897. executeWhenReady(func: () => void): void;
  117898. /**
  117899. * Returns a promise that resolves when the scene is ready
  117900. * @returns A promise that resolves when the scene is ready
  117901. */
  117902. whenReadyAsync(): Promise<void>;
  117903. /** @hidden */
  117904. _checkIsReady(): void;
  117905. /**
  117906. * Gets all animatable attached to the scene
  117907. */
  117908. get animatables(): Animatable[];
  117909. /**
  117910. * Resets the last animation time frame.
  117911. * Useful to override when animations start running when loading a scene for the first time.
  117912. */
  117913. resetLastAnimationTimeFrame(): void;
  117914. /**
  117915. * Gets the current view matrix
  117916. * @returns a Matrix
  117917. */
  117918. getViewMatrix(): Matrix;
  117919. /**
  117920. * Gets the current projection matrix
  117921. * @returns a Matrix
  117922. */
  117923. getProjectionMatrix(): Matrix;
  117924. /**
  117925. * Gets the current transform matrix
  117926. * @returns a Matrix made of View * Projection
  117927. */
  117928. getTransformMatrix(): Matrix;
  117929. /**
  117930. * Sets the current transform matrix
  117931. * @param viewL defines the View matrix to use
  117932. * @param projectionL defines the Projection matrix to use
  117933. * @param viewR defines the right View matrix to use (if provided)
  117934. * @param projectionR defines the right Projection matrix to use (if provided)
  117935. */
  117936. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  117937. /**
  117938. * Gets the uniform buffer used to store scene data
  117939. * @returns a UniformBuffer
  117940. */
  117941. getSceneUniformBuffer(): UniformBuffer;
  117942. /**
  117943. * Gets an unique (relatively to the current scene) Id
  117944. * @returns an unique number for the scene
  117945. */
  117946. getUniqueId(): number;
  117947. /**
  117948. * Add a mesh to the list of scene's meshes
  117949. * @param newMesh defines the mesh to add
  117950. * @param recursive if all child meshes should also be added to the scene
  117951. */
  117952. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  117953. /**
  117954. * Remove a mesh for the list of scene's meshes
  117955. * @param toRemove defines the mesh to remove
  117956. * @param recursive if all child meshes should also be removed from the scene
  117957. * @returns the index where the mesh was in the mesh list
  117958. */
  117959. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  117960. /**
  117961. * Add a transform node to the list of scene's transform nodes
  117962. * @param newTransformNode defines the transform node to add
  117963. */
  117964. addTransformNode(newTransformNode: TransformNode): void;
  117965. /**
  117966. * Remove a transform node for the list of scene's transform nodes
  117967. * @param toRemove defines the transform node to remove
  117968. * @returns the index where the transform node was in the transform node list
  117969. */
  117970. removeTransformNode(toRemove: TransformNode): number;
  117971. /**
  117972. * Remove a skeleton for the list of scene's skeletons
  117973. * @param toRemove defines the skeleton to remove
  117974. * @returns the index where the skeleton was in the skeleton list
  117975. */
  117976. removeSkeleton(toRemove: Skeleton): number;
  117977. /**
  117978. * Remove a morph target for the list of scene's morph targets
  117979. * @param toRemove defines the morph target to remove
  117980. * @returns the index where the morph target was in the morph target list
  117981. */
  117982. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  117983. /**
  117984. * Remove a light for the list of scene's lights
  117985. * @param toRemove defines the light to remove
  117986. * @returns the index where the light was in the light list
  117987. */
  117988. removeLight(toRemove: Light): number;
  117989. /**
  117990. * Remove a camera for the list of scene's cameras
  117991. * @param toRemove defines the camera to remove
  117992. * @returns the index where the camera was in the camera list
  117993. */
  117994. removeCamera(toRemove: Camera): number;
  117995. /**
  117996. * Remove a particle system for the list of scene's particle systems
  117997. * @param toRemove defines the particle system to remove
  117998. * @returns the index where the particle system was in the particle system list
  117999. */
  118000. removeParticleSystem(toRemove: IParticleSystem): number;
  118001. /**
  118002. * Remove a animation for the list of scene's animations
  118003. * @param toRemove defines the animation to remove
  118004. * @returns the index where the animation was in the animation list
  118005. */
  118006. removeAnimation(toRemove: Animation): number;
  118007. /**
  118008. * Will stop the animation of the given target
  118009. * @param target - the target
  118010. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  118011. * @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)
  118012. */
  118013. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  118014. /**
  118015. * Removes the given animation group from this scene.
  118016. * @param toRemove The animation group to remove
  118017. * @returns The index of the removed animation group
  118018. */
  118019. removeAnimationGroup(toRemove: AnimationGroup): number;
  118020. /**
  118021. * Removes the given multi-material from this scene.
  118022. * @param toRemove The multi-material to remove
  118023. * @returns The index of the removed multi-material
  118024. */
  118025. removeMultiMaterial(toRemove: MultiMaterial): number;
  118026. /**
  118027. * Removes the given material from this scene.
  118028. * @param toRemove The material to remove
  118029. * @returns The index of the removed material
  118030. */
  118031. removeMaterial(toRemove: Material): number;
  118032. /**
  118033. * Removes the given action manager from this scene.
  118034. * @param toRemove The action manager to remove
  118035. * @returns The index of the removed action manager
  118036. */
  118037. removeActionManager(toRemove: AbstractActionManager): number;
  118038. /**
  118039. * Removes the given texture from this scene.
  118040. * @param toRemove The texture to remove
  118041. * @returns The index of the removed texture
  118042. */
  118043. removeTexture(toRemove: BaseTexture): number;
  118044. /**
  118045. * Adds the given light to this scene
  118046. * @param newLight The light to add
  118047. */
  118048. addLight(newLight: Light): void;
  118049. /**
  118050. * Sorts the list list based on light priorities
  118051. */
  118052. sortLightsByPriority(): void;
  118053. /**
  118054. * Adds the given camera to this scene
  118055. * @param newCamera The camera to add
  118056. */
  118057. addCamera(newCamera: Camera): void;
  118058. /**
  118059. * Adds the given skeleton to this scene
  118060. * @param newSkeleton The skeleton to add
  118061. */
  118062. addSkeleton(newSkeleton: Skeleton): void;
  118063. /**
  118064. * Adds the given particle system to this scene
  118065. * @param newParticleSystem The particle system to add
  118066. */
  118067. addParticleSystem(newParticleSystem: IParticleSystem): void;
  118068. /**
  118069. * Adds the given animation to this scene
  118070. * @param newAnimation The animation to add
  118071. */
  118072. addAnimation(newAnimation: Animation): void;
  118073. /**
  118074. * Adds the given animation group to this scene.
  118075. * @param newAnimationGroup The animation group to add
  118076. */
  118077. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  118078. /**
  118079. * Adds the given multi-material to this scene
  118080. * @param newMultiMaterial The multi-material to add
  118081. */
  118082. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  118083. /**
  118084. * Adds the given material to this scene
  118085. * @param newMaterial The material to add
  118086. */
  118087. addMaterial(newMaterial: Material): void;
  118088. /**
  118089. * Adds the given morph target to this scene
  118090. * @param newMorphTargetManager The morph target to add
  118091. */
  118092. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  118093. /**
  118094. * Adds the given geometry to this scene
  118095. * @param newGeometry The geometry to add
  118096. */
  118097. addGeometry(newGeometry: Geometry): void;
  118098. /**
  118099. * Adds the given action manager to this scene
  118100. * @param newActionManager The action manager to add
  118101. */
  118102. addActionManager(newActionManager: AbstractActionManager): void;
  118103. /**
  118104. * Adds the given texture to this scene.
  118105. * @param newTexture The texture to add
  118106. */
  118107. addTexture(newTexture: BaseTexture): void;
  118108. /**
  118109. * Switch active camera
  118110. * @param newCamera defines the new active camera
  118111. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  118112. */
  118113. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  118114. /**
  118115. * sets the active camera of the scene using its ID
  118116. * @param id defines the camera's ID
  118117. * @return the new active camera or null if none found.
  118118. */
  118119. setActiveCameraByID(id: string): Nullable<Camera>;
  118120. /**
  118121. * sets the active camera of the scene using its name
  118122. * @param name defines the camera's name
  118123. * @returns the new active camera or null if none found.
  118124. */
  118125. setActiveCameraByName(name: string): Nullable<Camera>;
  118126. /**
  118127. * get an animation group using its name
  118128. * @param name defines the material's name
  118129. * @return the animation group or null if none found.
  118130. */
  118131. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  118132. /**
  118133. * Get a material using its unique id
  118134. * @param uniqueId defines the material's unique id
  118135. * @return the material or null if none found.
  118136. */
  118137. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  118138. /**
  118139. * get a material using its id
  118140. * @param id defines the material's ID
  118141. * @return the material or null if none found.
  118142. */
  118143. getMaterialByID(id: string): Nullable<Material>;
  118144. /**
  118145. * Gets a the last added material using a given id
  118146. * @param id defines the material's ID
  118147. * @return the last material with the given id or null if none found.
  118148. */
  118149. getLastMaterialByID(id: string): Nullable<Material>;
  118150. /**
  118151. * Gets a material using its name
  118152. * @param name defines the material's name
  118153. * @return the material or null if none found.
  118154. */
  118155. getMaterialByName(name: string): Nullable<Material>;
  118156. /**
  118157. * Get a texture using its unique id
  118158. * @param uniqueId defines the texture's unique id
  118159. * @return the texture or null if none found.
  118160. */
  118161. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  118162. /**
  118163. * Gets a camera using its id
  118164. * @param id defines the id to look for
  118165. * @returns the camera or null if not found
  118166. */
  118167. getCameraByID(id: string): Nullable<Camera>;
  118168. /**
  118169. * Gets a camera using its unique id
  118170. * @param uniqueId defines the unique id to look for
  118171. * @returns the camera or null if not found
  118172. */
  118173. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  118174. /**
  118175. * Gets a camera using its name
  118176. * @param name defines the camera's name
  118177. * @return the camera or null if none found.
  118178. */
  118179. getCameraByName(name: string): Nullable<Camera>;
  118180. /**
  118181. * Gets a bone using its id
  118182. * @param id defines the bone's id
  118183. * @return the bone or null if not found
  118184. */
  118185. getBoneByID(id: string): Nullable<Bone>;
  118186. /**
  118187. * Gets a bone using its id
  118188. * @param name defines the bone's name
  118189. * @return the bone or null if not found
  118190. */
  118191. getBoneByName(name: string): Nullable<Bone>;
  118192. /**
  118193. * Gets a light node using its name
  118194. * @param name defines the the light's name
  118195. * @return the light or null if none found.
  118196. */
  118197. getLightByName(name: string): Nullable<Light>;
  118198. /**
  118199. * Gets a light node using its id
  118200. * @param id defines the light's id
  118201. * @return the light or null if none found.
  118202. */
  118203. getLightByID(id: string): Nullable<Light>;
  118204. /**
  118205. * Gets a light node using its scene-generated unique ID
  118206. * @param uniqueId defines the light's unique id
  118207. * @return the light or null if none found.
  118208. */
  118209. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  118210. /**
  118211. * Gets a particle system by id
  118212. * @param id defines the particle system id
  118213. * @return the corresponding system or null if none found
  118214. */
  118215. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  118216. /**
  118217. * Gets a geometry using its ID
  118218. * @param id defines the geometry's id
  118219. * @return the geometry or null if none found.
  118220. */
  118221. getGeometryByID(id: string): Nullable<Geometry>;
  118222. private _getGeometryByUniqueID;
  118223. /**
  118224. * Add a new geometry to this scene
  118225. * @param geometry defines the geometry to be added to the scene.
  118226. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  118227. * @return a boolean defining if the geometry was added or not
  118228. */
  118229. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  118230. /**
  118231. * Removes an existing geometry
  118232. * @param geometry defines the geometry to be removed from the scene
  118233. * @return a boolean defining if the geometry was removed or not
  118234. */
  118235. removeGeometry(geometry: Geometry): boolean;
  118236. /**
  118237. * Gets the list of geometries attached to the scene
  118238. * @returns an array of Geometry
  118239. */
  118240. getGeometries(): Geometry[];
  118241. /**
  118242. * Gets the first added mesh found of a given ID
  118243. * @param id defines the id to search for
  118244. * @return the mesh found or null if not found at all
  118245. */
  118246. getMeshByID(id: string): Nullable<AbstractMesh>;
  118247. /**
  118248. * Gets a list of meshes using their id
  118249. * @param id defines the id to search for
  118250. * @returns a list of meshes
  118251. */
  118252. getMeshesByID(id: string): Array<AbstractMesh>;
  118253. /**
  118254. * Gets the first added transform node found of a given ID
  118255. * @param id defines the id to search for
  118256. * @return the found transform node or null if not found at all.
  118257. */
  118258. getTransformNodeByID(id: string): Nullable<TransformNode>;
  118259. /**
  118260. * Gets a transform node with its auto-generated unique id
  118261. * @param uniqueId efines the unique id to search for
  118262. * @return the found transform node or null if not found at all.
  118263. */
  118264. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  118265. /**
  118266. * Gets a list of transform nodes using their id
  118267. * @param id defines the id to search for
  118268. * @returns a list of transform nodes
  118269. */
  118270. getTransformNodesByID(id: string): Array<TransformNode>;
  118271. /**
  118272. * Gets a mesh with its auto-generated unique id
  118273. * @param uniqueId defines the unique id to search for
  118274. * @return the found mesh or null if not found at all.
  118275. */
  118276. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  118277. /**
  118278. * Gets a the last added mesh using a given id
  118279. * @param id defines the id to search for
  118280. * @return the found mesh or null if not found at all.
  118281. */
  118282. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  118283. /**
  118284. * Gets a the last added node (Mesh, Camera, Light) using a given id
  118285. * @param id defines the id to search for
  118286. * @return the found node or null if not found at all
  118287. */
  118288. getLastEntryByID(id: string): Nullable<Node>;
  118289. /**
  118290. * Gets a node (Mesh, Camera, Light) using a given id
  118291. * @param id defines the id to search for
  118292. * @return the found node or null if not found at all
  118293. */
  118294. getNodeByID(id: string): Nullable<Node>;
  118295. /**
  118296. * Gets a node (Mesh, Camera, Light) using a given name
  118297. * @param name defines the name to search for
  118298. * @return the found node or null if not found at all.
  118299. */
  118300. getNodeByName(name: string): Nullable<Node>;
  118301. /**
  118302. * Gets a mesh using a given name
  118303. * @param name defines the name to search for
  118304. * @return the found mesh or null if not found at all.
  118305. */
  118306. getMeshByName(name: string): Nullable<AbstractMesh>;
  118307. /**
  118308. * Gets a transform node using a given name
  118309. * @param name defines the name to search for
  118310. * @return the found transform node or null if not found at all.
  118311. */
  118312. getTransformNodeByName(name: string): Nullable<TransformNode>;
  118313. /**
  118314. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  118315. * @param id defines the id to search for
  118316. * @return the found skeleton or null if not found at all.
  118317. */
  118318. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  118319. /**
  118320. * Gets a skeleton using a given auto generated unique id
  118321. * @param uniqueId defines the unique id to search for
  118322. * @return the found skeleton or null if not found at all.
  118323. */
  118324. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  118325. /**
  118326. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  118327. * @param id defines the id to search for
  118328. * @return the found skeleton or null if not found at all.
  118329. */
  118330. getSkeletonById(id: string): Nullable<Skeleton>;
  118331. /**
  118332. * Gets a skeleton using a given name
  118333. * @param name defines the name to search for
  118334. * @return the found skeleton or null if not found at all.
  118335. */
  118336. getSkeletonByName(name: string): Nullable<Skeleton>;
  118337. /**
  118338. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  118339. * @param id defines the id to search for
  118340. * @return the found morph target manager or null if not found at all.
  118341. */
  118342. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  118343. /**
  118344. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  118345. * @param id defines the id to search for
  118346. * @return the found morph target or null if not found at all.
  118347. */
  118348. getMorphTargetById(id: string): Nullable<MorphTarget>;
  118349. /**
  118350. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  118351. * @param name defines the name to search for
  118352. * @return the found morph target or null if not found at all.
  118353. */
  118354. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  118355. /**
  118356. * Gets a boolean indicating if the given mesh is active
  118357. * @param mesh defines the mesh to look for
  118358. * @returns true if the mesh is in the active list
  118359. */
  118360. isActiveMesh(mesh: AbstractMesh): boolean;
  118361. /**
  118362. * Return a unique id as a string which can serve as an identifier for the scene
  118363. */
  118364. get uid(): string;
  118365. /**
  118366. * Add an externaly attached data from its key.
  118367. * This method call will fail and return false, if such key already exists.
  118368. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  118369. * @param key the unique key that identifies the data
  118370. * @param data the data object to associate to the key for this Engine instance
  118371. * @return true if no such key were already present and the data was added successfully, false otherwise
  118372. */
  118373. addExternalData<T>(key: string, data: T): boolean;
  118374. /**
  118375. * Get an externaly attached data from its key
  118376. * @param key the unique key that identifies the data
  118377. * @return the associated data, if present (can be null), or undefined if not present
  118378. */
  118379. getExternalData<T>(key: string): Nullable<T>;
  118380. /**
  118381. * Get an externaly attached data from its key, create it using a factory if it's not already present
  118382. * @param key the unique key that identifies the data
  118383. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  118384. * @return the associated data, can be null if the factory returned null.
  118385. */
  118386. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  118387. /**
  118388. * Remove an externaly attached data from the Engine instance
  118389. * @param key the unique key that identifies the data
  118390. * @return true if the data was successfully removed, false if it doesn't exist
  118391. */
  118392. removeExternalData(key: string): boolean;
  118393. private _evaluateSubMesh;
  118394. /**
  118395. * Clear the processed materials smart array preventing retention point in material dispose.
  118396. */
  118397. freeProcessedMaterials(): void;
  118398. private _preventFreeActiveMeshesAndRenderingGroups;
  118399. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  118400. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  118401. * when disposing several meshes in a row or a hierarchy of meshes.
  118402. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  118403. */
  118404. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  118405. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  118406. /**
  118407. * Clear the active meshes smart array preventing retention point in mesh dispose.
  118408. */
  118409. freeActiveMeshes(): void;
  118410. /**
  118411. * Clear the info related to rendering groups preventing retention points during dispose.
  118412. */
  118413. freeRenderingGroups(): void;
  118414. /** @hidden */
  118415. _isInIntermediateRendering(): boolean;
  118416. /**
  118417. * Lambda returning the list of potentially active meshes.
  118418. */
  118419. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  118420. /**
  118421. * Lambda returning the list of potentially active sub meshes.
  118422. */
  118423. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  118424. /**
  118425. * Lambda returning the list of potentially intersecting sub meshes.
  118426. */
  118427. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  118428. /**
  118429. * Lambda returning the list of potentially colliding sub meshes.
  118430. */
  118431. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  118432. private _activeMeshesFrozen;
  118433. private _skipEvaluateActiveMeshesCompletely;
  118434. /**
  118435. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  118436. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  118437. * @returns the current scene
  118438. */
  118439. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  118440. /**
  118441. * Use this function to restart evaluating active meshes on every frame
  118442. * @returns the current scene
  118443. */
  118444. unfreezeActiveMeshes(): Scene;
  118445. private _evaluateActiveMeshes;
  118446. private _activeMesh;
  118447. /**
  118448. * Update the transform matrix to update from the current active camera
  118449. * @param force defines a boolean used to force the update even if cache is up to date
  118450. */
  118451. updateTransformMatrix(force?: boolean): void;
  118452. private _bindFrameBuffer;
  118453. /** @hidden */
  118454. _allowPostProcessClearColor: boolean;
  118455. /** @hidden */
  118456. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  118457. private _processSubCameras;
  118458. private _checkIntersections;
  118459. /** @hidden */
  118460. _advancePhysicsEngineStep(step: number): void;
  118461. /**
  118462. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  118463. */
  118464. getDeterministicFrameTime: () => number;
  118465. /** @hidden */
  118466. _animate(): void;
  118467. /** Execute all animations (for a frame) */
  118468. animate(): void;
  118469. /**
  118470. * Render the scene
  118471. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  118472. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  118473. */
  118474. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  118475. /**
  118476. * Freeze all materials
  118477. * A frozen material will not be updatable but should be faster to render
  118478. */
  118479. freezeMaterials(): void;
  118480. /**
  118481. * Unfreeze all materials
  118482. * A frozen material will not be updatable but should be faster to render
  118483. */
  118484. unfreezeMaterials(): void;
  118485. /**
  118486. * Releases all held ressources
  118487. */
  118488. dispose(): void;
  118489. /**
  118490. * Gets if the scene is already disposed
  118491. */
  118492. get isDisposed(): boolean;
  118493. /**
  118494. * Call this function to reduce memory footprint of the scene.
  118495. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  118496. */
  118497. clearCachedVertexData(): void;
  118498. /**
  118499. * This function will remove the local cached buffer data from texture.
  118500. * It will save memory but will prevent the texture from being rebuilt
  118501. */
  118502. cleanCachedTextureBuffer(): void;
  118503. /**
  118504. * Get the world extend vectors with an optional filter
  118505. *
  118506. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  118507. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  118508. */
  118509. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  118510. min: Vector3;
  118511. max: Vector3;
  118512. };
  118513. /**
  118514. * Creates a ray that can be used to pick in the scene
  118515. * @param x defines the x coordinate of the origin (on-screen)
  118516. * @param y defines the y coordinate of the origin (on-screen)
  118517. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118518. * @param camera defines the camera to use for the picking
  118519. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118520. * @returns a Ray
  118521. */
  118522. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  118523. /**
  118524. * Creates a ray that can be used to pick in the scene
  118525. * @param x defines the x coordinate of the origin (on-screen)
  118526. * @param y defines the y coordinate of the origin (on-screen)
  118527. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  118528. * @param result defines the ray where to store the picking ray
  118529. * @param camera defines the camera to use for the picking
  118530. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  118531. * @returns the current scene
  118532. */
  118533. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  118534. /**
  118535. * Creates a ray that can be used to pick in the scene
  118536. * @param x defines the x coordinate of the origin (on-screen)
  118537. * @param y defines the y coordinate of the origin (on-screen)
  118538. * @param camera defines the camera to use for the picking
  118539. * @returns a Ray
  118540. */
  118541. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  118542. /**
  118543. * Creates a ray that can be used to pick in the scene
  118544. * @param x defines the x coordinate of the origin (on-screen)
  118545. * @param y defines the y coordinate of the origin (on-screen)
  118546. * @param result defines the ray where to store the picking ray
  118547. * @param camera defines the camera to use for the picking
  118548. * @returns the current scene
  118549. */
  118550. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  118551. /** Launch a ray to try to pick a mesh in the scene
  118552. * @param x position on screen
  118553. * @param y position on screen
  118554. * @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
  118555. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118556. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118557. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118558. * @returns a PickingInfo
  118559. */
  118560. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118561. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  118562. * @param x position on screen
  118563. * @param y position on screen
  118564. * @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
  118565. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118566. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118567. * @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)
  118568. */
  118569. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  118570. /** Use the given ray to pick a mesh in the scene
  118571. * @param ray The ray to use to pick meshes
  118572. * @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
  118573. * @param fastCheck defines if the first intersection will be used (and not the closest)
  118574. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118575. * @returns a PickingInfo
  118576. */
  118577. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  118578. /**
  118579. * Launch a ray to try to pick a mesh in the scene
  118580. * @param x X position on screen
  118581. * @param y Y position on screen
  118582. * @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
  118583. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  118584. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118585. * @returns an array of PickingInfo
  118586. */
  118587. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118588. /**
  118589. * Launch a ray to try to pick a mesh in the scene
  118590. * @param ray Ray to use
  118591. * @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
  118592. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  118593. * @returns an array of PickingInfo
  118594. */
  118595. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  118596. /**
  118597. * Force the value of meshUnderPointer
  118598. * @param mesh defines the mesh to use
  118599. */
  118600. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  118601. /**
  118602. * Gets the mesh under the pointer
  118603. * @returns a Mesh or null if no mesh is under the pointer
  118604. */
  118605. getPointerOverMesh(): Nullable<AbstractMesh>;
  118606. /** @hidden */
  118607. _rebuildGeometries(): void;
  118608. /** @hidden */
  118609. _rebuildTextures(): void;
  118610. private _getByTags;
  118611. /**
  118612. * Get a list of meshes by tags
  118613. * @param tagsQuery defines the tags query to use
  118614. * @param forEach defines a predicate used to filter results
  118615. * @returns an array of Mesh
  118616. */
  118617. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  118618. /**
  118619. * Get a list of cameras by tags
  118620. * @param tagsQuery defines the tags query to use
  118621. * @param forEach defines a predicate used to filter results
  118622. * @returns an array of Camera
  118623. */
  118624. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  118625. /**
  118626. * Get a list of lights by tags
  118627. * @param tagsQuery defines the tags query to use
  118628. * @param forEach defines a predicate used to filter results
  118629. * @returns an array of Light
  118630. */
  118631. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  118632. /**
  118633. * Get a list of materials by tags
  118634. * @param tagsQuery defines the tags query to use
  118635. * @param forEach defines a predicate used to filter results
  118636. * @returns an array of Material
  118637. */
  118638. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  118639. /**
  118640. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  118641. * This allowed control for front to back rendering or reversly depending of the special needs.
  118642. *
  118643. * @param renderingGroupId The rendering group id corresponding to its index
  118644. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  118645. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  118646. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  118647. */
  118648. 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;
  118649. /**
  118650. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  118651. *
  118652. * @param renderingGroupId The rendering group id corresponding to its index
  118653. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118654. * @param depth Automatically clears depth between groups if true and autoClear is true.
  118655. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  118656. */
  118657. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  118658. /**
  118659. * Gets the current auto clear configuration for one rendering group of the rendering
  118660. * manager.
  118661. * @param index the rendering group index to get the information for
  118662. * @returns The auto clear setup for the requested rendering group
  118663. */
  118664. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  118665. private _blockMaterialDirtyMechanism;
  118666. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  118667. get blockMaterialDirtyMechanism(): boolean;
  118668. set blockMaterialDirtyMechanism(value: boolean);
  118669. /**
  118670. * Will flag all materials as dirty to trigger new shader compilation
  118671. * @param flag defines the flag used to specify which material part must be marked as dirty
  118672. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  118673. */
  118674. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118675. /** @hidden */
  118676. _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;
  118677. /** @hidden */
  118678. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118679. /** @hidden */
  118680. _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;
  118681. /** @hidden */
  118682. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  118683. /** @hidden */
  118684. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118685. /** @hidden */
  118686. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118687. }
  118688. }
  118689. declare module BABYLON {
  118690. /**
  118691. * Set of assets to keep when moving a scene into an asset container.
  118692. */
  118693. export class KeepAssets extends AbstractScene {
  118694. }
  118695. /**
  118696. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  118697. */
  118698. export class InstantiatedEntries {
  118699. /**
  118700. * List of new root nodes (eg. nodes with no parent)
  118701. */
  118702. rootNodes: TransformNode[];
  118703. /**
  118704. * List of new skeletons
  118705. */
  118706. skeletons: Skeleton[];
  118707. /**
  118708. * List of new animation groups
  118709. */
  118710. animationGroups: AnimationGroup[];
  118711. }
  118712. /**
  118713. * Container with a set of assets that can be added or removed from a scene.
  118714. */
  118715. export class AssetContainer extends AbstractScene {
  118716. private _wasAddedToScene;
  118717. /**
  118718. * The scene the AssetContainer belongs to.
  118719. */
  118720. scene: Scene;
  118721. /**
  118722. * Instantiates an AssetContainer.
  118723. * @param scene The scene the AssetContainer belongs to.
  118724. */
  118725. constructor(scene: Scene);
  118726. /**
  118727. * Instantiate or clone all meshes and add the new ones to the scene.
  118728. * Skeletons and animation groups will all be cloned
  118729. * @param nameFunction defines an optional function used to get new names for clones
  118730. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  118731. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  118732. */
  118733. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  118734. /**
  118735. * Adds all the assets from the container to the scene.
  118736. */
  118737. addAllToScene(): void;
  118738. /**
  118739. * Removes all the assets in the container from the scene
  118740. */
  118741. removeAllFromScene(): void;
  118742. /**
  118743. * Disposes all the assets in the container
  118744. */
  118745. dispose(): void;
  118746. private _moveAssets;
  118747. /**
  118748. * Removes all the assets contained in the scene and adds them to the container.
  118749. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  118750. */
  118751. moveAllFromScene(keepAssets?: KeepAssets): void;
  118752. /**
  118753. * 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.
  118754. * @returns the root mesh
  118755. */
  118756. createRootMesh(): Mesh;
  118757. /**
  118758. * Merge animations (direct and animation groups) from this asset container into a scene
  118759. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118760. * @param animatables set of animatables to retarget to a node from the scene
  118761. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  118762. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  118763. */
  118764. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  118765. }
  118766. }
  118767. declare module BABYLON {
  118768. /**
  118769. * Defines how the parser contract is defined.
  118770. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  118771. */
  118772. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  118773. /**
  118774. * Defines how the individual parser contract is defined.
  118775. * These parser can parse an individual asset
  118776. */
  118777. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  118778. /**
  118779. * Base class of the scene acting as a container for the different elements composing a scene.
  118780. * This class is dynamically extended by the different components of the scene increasing
  118781. * flexibility and reducing coupling
  118782. */
  118783. export abstract class AbstractScene {
  118784. /**
  118785. * Stores the list of available parsers in the application.
  118786. */
  118787. private static _BabylonFileParsers;
  118788. /**
  118789. * Stores the list of available individual parsers in the application.
  118790. */
  118791. private static _IndividualBabylonFileParsers;
  118792. /**
  118793. * Adds a parser in the list of available ones
  118794. * @param name Defines the name of the parser
  118795. * @param parser Defines the parser to add
  118796. */
  118797. static AddParser(name: string, parser: BabylonFileParser): void;
  118798. /**
  118799. * Gets a general parser from the list of avaialble ones
  118800. * @param name Defines the name of the parser
  118801. * @returns the requested parser or null
  118802. */
  118803. static GetParser(name: string): Nullable<BabylonFileParser>;
  118804. /**
  118805. * Adds n individual parser in the list of available ones
  118806. * @param name Defines the name of the parser
  118807. * @param parser Defines the parser to add
  118808. */
  118809. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  118810. /**
  118811. * Gets an individual parser from the list of avaialble ones
  118812. * @param name Defines the name of the parser
  118813. * @returns the requested parser or null
  118814. */
  118815. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  118816. /**
  118817. * Parser json data and populate both a scene and its associated container object
  118818. * @param jsonData Defines the data to parse
  118819. * @param scene Defines the scene to parse the data for
  118820. * @param container Defines the container attached to the parsing sequence
  118821. * @param rootUrl Defines the root url of the data
  118822. */
  118823. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  118824. /**
  118825. * Gets the list of root nodes (ie. nodes with no parent)
  118826. */
  118827. rootNodes: Node[];
  118828. /** All of the cameras added to this scene
  118829. * @see https://doc.babylonjs.com/babylon101/cameras
  118830. */
  118831. cameras: Camera[];
  118832. /**
  118833. * All of the lights added to this scene
  118834. * @see https://doc.babylonjs.com/babylon101/lights
  118835. */
  118836. lights: Light[];
  118837. /**
  118838. * All of the (abstract) meshes added to this scene
  118839. */
  118840. meshes: AbstractMesh[];
  118841. /**
  118842. * The list of skeletons added to the scene
  118843. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  118844. */
  118845. skeletons: Skeleton[];
  118846. /**
  118847. * All of the particle systems added to this scene
  118848. * @see https://doc.babylonjs.com/babylon101/particles
  118849. */
  118850. particleSystems: IParticleSystem[];
  118851. /**
  118852. * Gets a list of Animations associated with the scene
  118853. */
  118854. animations: Animation[];
  118855. /**
  118856. * All of the animation groups added to this scene
  118857. * @see https://doc.babylonjs.com/how_to/group
  118858. */
  118859. animationGroups: AnimationGroup[];
  118860. /**
  118861. * All of the multi-materials added to this scene
  118862. * @see https://doc.babylonjs.com/how_to/multi_materials
  118863. */
  118864. multiMaterials: MultiMaterial[];
  118865. /**
  118866. * All of the materials added to this scene
  118867. * In the context of a Scene, it is not supposed to be modified manually.
  118868. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  118869. * Note also that the order of the Material within the array is not significant and might change.
  118870. * @see https://doc.babylonjs.com/babylon101/materials
  118871. */
  118872. materials: Material[];
  118873. /**
  118874. * The list of morph target managers added to the scene
  118875. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  118876. */
  118877. morphTargetManagers: MorphTargetManager[];
  118878. /**
  118879. * The list of geometries used in the scene.
  118880. */
  118881. geometries: Geometry[];
  118882. /**
  118883. * All of the tranform nodes added to this scene
  118884. * In the context of a Scene, it is not supposed to be modified manually.
  118885. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  118886. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  118887. * @see https://doc.babylonjs.com/how_to/transformnode
  118888. */
  118889. transformNodes: TransformNode[];
  118890. /**
  118891. * ActionManagers available on the scene.
  118892. */
  118893. actionManagers: AbstractActionManager[];
  118894. /**
  118895. * Textures to keep.
  118896. */
  118897. textures: BaseTexture[];
  118898. /**
  118899. * Environment texture for the scene
  118900. */
  118901. environmentTexture: Nullable<BaseTexture>;
  118902. /**
  118903. * @returns all meshes, lights, cameras, transformNodes and bones
  118904. */
  118905. getNodes(): Array<Node>;
  118906. }
  118907. }
  118908. declare module BABYLON {
  118909. /**
  118910. * Interface used to define options for Sound class
  118911. */
  118912. export interface ISoundOptions {
  118913. /**
  118914. * Does the sound autoplay once loaded.
  118915. */
  118916. autoplay?: boolean;
  118917. /**
  118918. * Does the sound loop after it finishes playing once.
  118919. */
  118920. loop?: boolean;
  118921. /**
  118922. * Sound's volume
  118923. */
  118924. volume?: number;
  118925. /**
  118926. * Is it a spatial sound?
  118927. */
  118928. spatialSound?: boolean;
  118929. /**
  118930. * Maximum distance to hear that sound
  118931. */
  118932. maxDistance?: number;
  118933. /**
  118934. * Uses user defined attenuation function
  118935. */
  118936. useCustomAttenuation?: boolean;
  118937. /**
  118938. * Define the roll off factor of spatial sounds.
  118939. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118940. */
  118941. rolloffFactor?: number;
  118942. /**
  118943. * Define the reference distance the sound should be heard perfectly.
  118944. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118945. */
  118946. refDistance?: number;
  118947. /**
  118948. * Define the distance attenuation model the sound will follow.
  118949. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  118950. */
  118951. distanceModel?: string;
  118952. /**
  118953. * Defines the playback speed (1 by default)
  118954. */
  118955. playbackRate?: number;
  118956. /**
  118957. * Defines if the sound is from a streaming source
  118958. */
  118959. streaming?: boolean;
  118960. /**
  118961. * Defines an optional length (in seconds) inside the sound file
  118962. */
  118963. length?: number;
  118964. /**
  118965. * Defines an optional offset (in seconds) inside the sound file
  118966. */
  118967. offset?: number;
  118968. /**
  118969. * If true, URLs will not be required to state the audio file codec to use.
  118970. */
  118971. skipCodecCheck?: boolean;
  118972. }
  118973. /**
  118974. * Defines a sound that can be played in the application.
  118975. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  118976. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118977. */
  118978. export class Sound {
  118979. /**
  118980. * The name of the sound in the scene.
  118981. */
  118982. name: string;
  118983. /**
  118984. * Does the sound autoplay once loaded.
  118985. */
  118986. autoplay: boolean;
  118987. /**
  118988. * Does the sound loop after it finishes playing once.
  118989. */
  118990. loop: boolean;
  118991. /**
  118992. * Does the sound use a custom attenuation curve to simulate the falloff
  118993. * happening when the source gets further away from the camera.
  118994. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  118995. */
  118996. useCustomAttenuation: boolean;
  118997. /**
  118998. * The sound track id this sound belongs to.
  118999. */
  119000. soundTrackId: number;
  119001. /**
  119002. * Is this sound currently played.
  119003. */
  119004. isPlaying: boolean;
  119005. /**
  119006. * Is this sound currently paused.
  119007. */
  119008. isPaused: boolean;
  119009. /**
  119010. * Does this sound enables spatial sound.
  119011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119012. */
  119013. spatialSound: boolean;
  119014. /**
  119015. * Define the reference distance the sound should be heard perfectly.
  119016. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119017. */
  119018. refDistance: number;
  119019. /**
  119020. * Define the roll off factor of spatial sounds.
  119021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119022. */
  119023. rolloffFactor: number;
  119024. /**
  119025. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  119026. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119027. */
  119028. maxDistance: number;
  119029. /**
  119030. * Define the distance attenuation model the sound will follow.
  119031. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119032. */
  119033. distanceModel: string;
  119034. /**
  119035. * @hidden
  119036. * Back Compat
  119037. **/
  119038. onended: () => any;
  119039. /**
  119040. * Gets or sets an object used to store user defined information for the sound.
  119041. */
  119042. metadata: any;
  119043. /**
  119044. * Observable event when the current playing sound finishes.
  119045. */
  119046. onEndedObservable: Observable<Sound>;
  119047. private _panningModel;
  119048. private _playbackRate;
  119049. private _streaming;
  119050. private _startTime;
  119051. private _startOffset;
  119052. private _position;
  119053. /** @hidden */
  119054. _positionInEmitterSpace: boolean;
  119055. private _localDirection;
  119056. private _volume;
  119057. private _isReadyToPlay;
  119058. private _isDirectional;
  119059. private _readyToPlayCallback;
  119060. private _audioBuffer;
  119061. private _soundSource;
  119062. private _streamingSource;
  119063. private _soundPanner;
  119064. private _soundGain;
  119065. private _inputAudioNode;
  119066. private _outputAudioNode;
  119067. private _coneInnerAngle;
  119068. private _coneOuterAngle;
  119069. private _coneOuterGain;
  119070. private _scene;
  119071. private _connectedTransformNode;
  119072. private _customAttenuationFunction;
  119073. private _registerFunc;
  119074. private _isOutputConnected;
  119075. private _htmlAudioElement;
  119076. private _urlType;
  119077. private _length?;
  119078. private _offset?;
  119079. /** @hidden */
  119080. static _SceneComponentInitialization: (scene: Scene) => void;
  119081. /**
  119082. * Create a sound and attach it to a scene
  119083. * @param name Name of your sound
  119084. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  119085. * @param scene defines the scene the sound belongs to
  119086. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  119087. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  119088. */
  119089. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  119090. /**
  119091. * Release the sound and its associated resources
  119092. */
  119093. dispose(): void;
  119094. /**
  119095. * Gets if the sounds is ready to be played or not.
  119096. * @returns true if ready, otherwise false
  119097. */
  119098. isReady(): boolean;
  119099. private _soundLoaded;
  119100. /**
  119101. * Sets the data of the sound from an audiobuffer
  119102. * @param audioBuffer The audioBuffer containing the data
  119103. */
  119104. setAudioBuffer(audioBuffer: AudioBuffer): void;
  119105. /**
  119106. * Updates the current sounds options such as maxdistance, loop...
  119107. * @param options A JSON object containing values named as the object properties
  119108. */
  119109. updateOptions(options: ISoundOptions): void;
  119110. private _createSpatialParameters;
  119111. private _updateSpatialParameters;
  119112. /**
  119113. * Switch the panning model to HRTF:
  119114. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119115. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119116. */
  119117. switchPanningModelToHRTF(): void;
  119118. /**
  119119. * Switch the panning model to Equal Power:
  119120. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119121. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119122. */
  119123. switchPanningModelToEqualPower(): void;
  119124. private _switchPanningModel;
  119125. /**
  119126. * Connect this sound to a sound track audio node like gain...
  119127. * @param soundTrackAudioNode the sound track audio node to connect to
  119128. */
  119129. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  119130. /**
  119131. * Transform this sound into a directional source
  119132. * @param coneInnerAngle Size of the inner cone in degree
  119133. * @param coneOuterAngle Size of the outer cone in degree
  119134. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  119135. */
  119136. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  119137. /**
  119138. * Gets or sets the inner angle for the directional cone.
  119139. */
  119140. get directionalConeInnerAngle(): number;
  119141. /**
  119142. * Gets or sets the inner angle for the directional cone.
  119143. */
  119144. set directionalConeInnerAngle(value: number);
  119145. /**
  119146. * Gets or sets the outer angle for the directional cone.
  119147. */
  119148. get directionalConeOuterAngle(): number;
  119149. /**
  119150. * Gets or sets the outer angle for the directional cone.
  119151. */
  119152. set directionalConeOuterAngle(value: number);
  119153. /**
  119154. * Sets the position of the emitter if spatial sound is enabled
  119155. * @param newPosition Defines the new posisiton
  119156. */
  119157. setPosition(newPosition: Vector3): void;
  119158. /**
  119159. * Sets the local direction of the emitter if spatial sound is enabled
  119160. * @param newLocalDirection Defines the new local direction
  119161. */
  119162. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  119163. private _updateDirection;
  119164. /** @hidden */
  119165. updateDistanceFromListener(): void;
  119166. /**
  119167. * Sets a new custom attenuation function for the sound.
  119168. * @param callback Defines the function used for the attenuation
  119169. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  119170. */
  119171. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  119172. /**
  119173. * Play the sound
  119174. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  119175. * @param offset (optional) Start the sound at a specific time in seconds
  119176. * @param length (optional) Sound duration (in seconds)
  119177. */
  119178. play(time?: number, offset?: number, length?: number): void;
  119179. private _onended;
  119180. /**
  119181. * Stop the sound
  119182. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  119183. */
  119184. stop(time?: number): void;
  119185. /**
  119186. * Put the sound in pause
  119187. */
  119188. pause(): void;
  119189. /**
  119190. * Sets a dedicated volume for this sounds
  119191. * @param newVolume Define the new volume of the sound
  119192. * @param time Define time for gradual change to new volume
  119193. */
  119194. setVolume(newVolume: number, time?: number): void;
  119195. /**
  119196. * Set the sound play back rate
  119197. * @param newPlaybackRate Define the playback rate the sound should be played at
  119198. */
  119199. setPlaybackRate(newPlaybackRate: number): void;
  119200. /**
  119201. * Gets the volume of the sound.
  119202. * @returns the volume of the sound
  119203. */
  119204. getVolume(): number;
  119205. /**
  119206. * Attach the sound to a dedicated mesh
  119207. * @param transformNode The transform node to connect the sound with
  119208. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119209. */
  119210. attachToMesh(transformNode: TransformNode): void;
  119211. /**
  119212. * Detach the sound from the previously attached mesh
  119213. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  119214. */
  119215. detachFromMesh(): void;
  119216. private _onRegisterAfterWorldMatrixUpdate;
  119217. /**
  119218. * Clone the current sound in the scene.
  119219. * @returns the new sound clone
  119220. */
  119221. clone(): Nullable<Sound>;
  119222. /**
  119223. * Gets the current underlying audio buffer containing the data
  119224. * @returns the audio buffer
  119225. */
  119226. getAudioBuffer(): Nullable<AudioBuffer>;
  119227. /**
  119228. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  119229. * @returns the source node
  119230. */
  119231. getSoundSource(): Nullable<AudioBufferSourceNode>;
  119232. /**
  119233. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  119234. * @returns the gain node
  119235. */
  119236. getSoundGain(): Nullable<GainNode>;
  119237. /**
  119238. * Serializes the Sound in a JSON representation
  119239. * @returns the JSON representation of the sound
  119240. */
  119241. serialize(): any;
  119242. /**
  119243. * Parse a JSON representation of a sound to innstantiate in a given scene
  119244. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  119245. * @param scene Define the scene the new parsed sound should be created in
  119246. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  119247. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  119248. * @returns the newly parsed sound
  119249. */
  119250. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  119251. }
  119252. }
  119253. declare module BABYLON {
  119254. /**
  119255. * This defines an action helpful to play a defined sound on a triggered action.
  119256. */
  119257. export class PlaySoundAction extends Action {
  119258. private _sound;
  119259. /**
  119260. * Instantiate the action
  119261. * @param triggerOptions defines the trigger options
  119262. * @param sound defines the sound to play
  119263. * @param condition defines the trigger related conditions
  119264. */
  119265. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119266. /** @hidden */
  119267. _prepare(): void;
  119268. /**
  119269. * Execute the action and play the sound.
  119270. */
  119271. execute(): void;
  119272. /**
  119273. * Serializes the actions and its related information.
  119274. * @param parent defines the object to serialize in
  119275. * @returns the serialized object
  119276. */
  119277. serialize(parent: any): any;
  119278. }
  119279. /**
  119280. * This defines an action helpful to stop a defined sound on a triggered action.
  119281. */
  119282. export class StopSoundAction extends Action {
  119283. private _sound;
  119284. /**
  119285. * Instantiate the action
  119286. * @param triggerOptions defines the trigger options
  119287. * @param sound defines the sound to stop
  119288. * @param condition defines the trigger related conditions
  119289. */
  119290. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  119291. /** @hidden */
  119292. _prepare(): void;
  119293. /**
  119294. * Execute the action and stop the sound.
  119295. */
  119296. execute(): void;
  119297. /**
  119298. * Serializes the actions and its related information.
  119299. * @param parent defines the object to serialize in
  119300. * @returns the serialized object
  119301. */
  119302. serialize(parent: any): any;
  119303. }
  119304. }
  119305. declare module BABYLON {
  119306. /**
  119307. * This defines an action responsible to change the value of a property
  119308. * by interpolating between its current value and the newly set one once triggered.
  119309. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  119310. */
  119311. export class InterpolateValueAction extends Action {
  119312. /**
  119313. * Defines the path of the property where the value should be interpolated
  119314. */
  119315. propertyPath: string;
  119316. /**
  119317. * Defines the target value at the end of the interpolation.
  119318. */
  119319. value: any;
  119320. /**
  119321. * Defines the time it will take for the property to interpolate to the value.
  119322. */
  119323. duration: number;
  119324. /**
  119325. * Defines if the other scene animations should be stopped when the action has been triggered
  119326. */
  119327. stopOtherAnimations?: boolean;
  119328. /**
  119329. * Defines a callback raised once the interpolation animation has been done.
  119330. */
  119331. onInterpolationDone?: () => void;
  119332. /**
  119333. * Observable triggered once the interpolation animation has been done.
  119334. */
  119335. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  119336. private _target;
  119337. private _effectiveTarget;
  119338. private _property;
  119339. /**
  119340. * Instantiate the action
  119341. * @param triggerOptions defines the trigger options
  119342. * @param target defines the object containing the value to interpolate
  119343. * @param propertyPath defines the path to the property in the target object
  119344. * @param value defines the target value at the end of the interpolation
  119345. * @param duration deines the time it will take for the property to interpolate to the value.
  119346. * @param condition defines the trigger related conditions
  119347. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  119348. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  119349. */
  119350. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  119351. /** @hidden */
  119352. _prepare(): void;
  119353. /**
  119354. * Execute the action starts the value interpolation.
  119355. */
  119356. execute(): void;
  119357. /**
  119358. * Serializes the actions and its related information.
  119359. * @param parent defines the object to serialize in
  119360. * @returns the serialized object
  119361. */
  119362. serialize(parent: any): any;
  119363. }
  119364. }
  119365. declare module BABYLON {
  119366. /**
  119367. * Options allowed during the creation of a sound track.
  119368. */
  119369. export interface ISoundTrackOptions {
  119370. /**
  119371. * The volume the sound track should take during creation
  119372. */
  119373. volume?: number;
  119374. /**
  119375. * Define if the sound track is the main sound track of the scene
  119376. */
  119377. mainTrack?: boolean;
  119378. }
  119379. /**
  119380. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  119381. * It will be also used in a future release to apply effects on a specific track.
  119382. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119383. */
  119384. export class SoundTrack {
  119385. /**
  119386. * The unique identifier of the sound track in the scene.
  119387. */
  119388. id: number;
  119389. /**
  119390. * The list of sounds included in the sound track.
  119391. */
  119392. soundCollection: Array<Sound>;
  119393. private _outputAudioNode;
  119394. private _scene;
  119395. private _connectedAnalyser;
  119396. private _options;
  119397. private _isInitialized;
  119398. /**
  119399. * Creates a new sound track.
  119400. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  119401. * @param scene Define the scene the sound track belongs to
  119402. * @param options
  119403. */
  119404. constructor(scene: Scene, options?: ISoundTrackOptions);
  119405. private _initializeSoundTrackAudioGraph;
  119406. /**
  119407. * Release the sound track and its associated resources
  119408. */
  119409. dispose(): void;
  119410. /**
  119411. * Adds a sound to this sound track
  119412. * @param sound define the cound to add
  119413. * @ignoreNaming
  119414. */
  119415. AddSound(sound: Sound): void;
  119416. /**
  119417. * Removes a sound to this sound track
  119418. * @param sound define the cound to remove
  119419. * @ignoreNaming
  119420. */
  119421. RemoveSound(sound: Sound): void;
  119422. /**
  119423. * Set a global volume for the full sound track.
  119424. * @param newVolume Define the new volume of the sound track
  119425. */
  119426. setVolume(newVolume: number): void;
  119427. /**
  119428. * Switch the panning model to HRTF:
  119429. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  119430. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119431. */
  119432. switchPanningModelToHRTF(): void;
  119433. /**
  119434. * Switch the panning model to Equal Power:
  119435. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  119436. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  119437. */
  119438. switchPanningModelToEqualPower(): void;
  119439. /**
  119440. * Connect the sound track to an audio analyser allowing some amazing
  119441. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  119442. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  119443. * @param analyser The analyser to connect to the engine
  119444. */
  119445. connectToAnalyser(analyser: Analyser): void;
  119446. }
  119447. }
  119448. declare module BABYLON {
  119449. interface AbstractScene {
  119450. /**
  119451. * The list of sounds used in the scene.
  119452. */
  119453. sounds: Nullable<Array<Sound>>;
  119454. }
  119455. interface Scene {
  119456. /**
  119457. * @hidden
  119458. * Backing field
  119459. */
  119460. _mainSoundTrack: SoundTrack;
  119461. /**
  119462. * The main sound track played by the scene.
  119463. * It cotains your primary collection of sounds.
  119464. */
  119465. mainSoundTrack: SoundTrack;
  119466. /**
  119467. * The list of sound tracks added to the scene
  119468. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119469. */
  119470. soundTracks: Nullable<Array<SoundTrack>>;
  119471. /**
  119472. * Gets a sound using a given name
  119473. * @param name defines the name to search for
  119474. * @return the found sound or null if not found at all.
  119475. */
  119476. getSoundByName(name: string): Nullable<Sound>;
  119477. /**
  119478. * Gets or sets if audio support is enabled
  119479. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119480. */
  119481. audioEnabled: boolean;
  119482. /**
  119483. * Gets or sets if audio will be output to headphones
  119484. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119485. */
  119486. headphone: boolean;
  119487. /**
  119488. * Gets or sets custom audio listener position provider
  119489. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  119490. */
  119491. audioListenerPositionProvider: Nullable<() => Vector3>;
  119492. /**
  119493. * Gets or sets a refresh rate when using 3D audio positioning
  119494. */
  119495. audioPositioningRefreshRate: number;
  119496. }
  119497. /**
  119498. * Defines the sound scene component responsible to manage any sounds
  119499. * in a given scene.
  119500. */
  119501. export class AudioSceneComponent implements ISceneSerializableComponent {
  119502. /**
  119503. * The component name helpfull to identify the component in the list of scene components.
  119504. */
  119505. readonly name: string;
  119506. /**
  119507. * The scene the component belongs to.
  119508. */
  119509. scene: Scene;
  119510. private _audioEnabled;
  119511. /**
  119512. * Gets whether audio is enabled or not.
  119513. * Please use related enable/disable method to switch state.
  119514. */
  119515. get audioEnabled(): boolean;
  119516. private _headphone;
  119517. /**
  119518. * Gets whether audio is outputing to headphone or not.
  119519. * Please use the according Switch methods to change output.
  119520. */
  119521. get headphone(): boolean;
  119522. /**
  119523. * Gets or sets a refresh rate when using 3D audio positioning
  119524. */
  119525. audioPositioningRefreshRate: number;
  119526. private _audioListenerPositionProvider;
  119527. /**
  119528. * Gets the current audio listener position provider
  119529. */
  119530. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  119531. /**
  119532. * Sets a custom listener position for all sounds in the scene
  119533. * By default, this is the position of the first active camera
  119534. */
  119535. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  119536. /**
  119537. * Creates a new instance of the component for the given scene
  119538. * @param scene Defines the scene to register the component in
  119539. */
  119540. constructor(scene: Scene);
  119541. /**
  119542. * Registers the component in a given scene
  119543. */
  119544. register(): void;
  119545. /**
  119546. * Rebuilds the elements related to this component in case of
  119547. * context lost for instance.
  119548. */
  119549. rebuild(): void;
  119550. /**
  119551. * Serializes the component data to the specified json object
  119552. * @param serializationObject The object to serialize to
  119553. */
  119554. serialize(serializationObject: any): void;
  119555. /**
  119556. * Adds all the elements from the container to the scene
  119557. * @param container the container holding the elements
  119558. */
  119559. addFromContainer(container: AbstractScene): void;
  119560. /**
  119561. * Removes all the elements in the container from the scene
  119562. * @param container contains the elements to remove
  119563. * @param dispose if the removed element should be disposed (default: false)
  119564. */
  119565. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  119566. /**
  119567. * Disposes the component and the associated ressources.
  119568. */
  119569. dispose(): void;
  119570. /**
  119571. * Disables audio in the associated scene.
  119572. */
  119573. disableAudio(): void;
  119574. /**
  119575. * Enables audio in the associated scene.
  119576. */
  119577. enableAudio(): void;
  119578. /**
  119579. * Switch audio to headphone output.
  119580. */
  119581. switchAudioModeForHeadphones(): void;
  119582. /**
  119583. * Switch audio to normal speakers.
  119584. */
  119585. switchAudioModeForNormalSpeakers(): void;
  119586. private _cachedCameraDirection;
  119587. private _cachedCameraPosition;
  119588. private _lastCheck;
  119589. private _afterRender;
  119590. }
  119591. }
  119592. declare module BABYLON {
  119593. /**
  119594. * Wraps one or more Sound objects and selects one with random weight for playback.
  119595. */
  119596. export class WeightedSound {
  119597. /** When true a Sound will be selected and played when the current playing Sound completes. */
  119598. loop: boolean;
  119599. private _coneInnerAngle;
  119600. private _coneOuterAngle;
  119601. private _volume;
  119602. /** A Sound is currently playing. */
  119603. isPlaying: boolean;
  119604. /** A Sound is currently paused. */
  119605. isPaused: boolean;
  119606. private _sounds;
  119607. private _weights;
  119608. private _currentIndex?;
  119609. /**
  119610. * Creates a new WeightedSound from the list of sounds given.
  119611. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  119612. * @param sounds Array of Sounds that will be selected from.
  119613. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  119614. */
  119615. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  119616. /**
  119617. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  119618. */
  119619. get directionalConeInnerAngle(): number;
  119620. /**
  119621. * The size of cone in degress for a directional sound in which there will be no attenuation.
  119622. */
  119623. set directionalConeInnerAngle(value: number);
  119624. /**
  119625. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119626. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119627. */
  119628. get directionalConeOuterAngle(): number;
  119629. /**
  119630. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  119631. * Listener angles between innerAngle and outerAngle will falloff linearly.
  119632. */
  119633. set directionalConeOuterAngle(value: number);
  119634. /**
  119635. * Playback volume.
  119636. */
  119637. get volume(): number;
  119638. /**
  119639. * Playback volume.
  119640. */
  119641. set volume(value: number);
  119642. private _onended;
  119643. /**
  119644. * Suspend playback
  119645. */
  119646. pause(): void;
  119647. /**
  119648. * Stop playback
  119649. */
  119650. stop(): void;
  119651. /**
  119652. * Start playback.
  119653. * @param startOffset Position the clip head at a specific time in seconds.
  119654. */
  119655. play(startOffset?: number): void;
  119656. }
  119657. }
  119658. declare module BABYLON {
  119659. /**
  119660. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  119661. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  119662. */
  119663. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  119664. /**
  119665. * Gets the name of the behavior.
  119666. */
  119667. get name(): string;
  119668. /**
  119669. * The easing function used by animations
  119670. */
  119671. static EasingFunction: BackEase;
  119672. /**
  119673. * The easing mode used by animations
  119674. */
  119675. static EasingMode: number;
  119676. /**
  119677. * The duration of the animation, in milliseconds
  119678. */
  119679. transitionDuration: number;
  119680. /**
  119681. * Length of the distance animated by the transition when lower radius is reached
  119682. */
  119683. lowerRadiusTransitionRange: number;
  119684. /**
  119685. * Length of the distance animated by the transition when upper radius is reached
  119686. */
  119687. upperRadiusTransitionRange: number;
  119688. private _autoTransitionRange;
  119689. /**
  119690. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119691. */
  119692. get autoTransitionRange(): boolean;
  119693. /**
  119694. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  119695. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  119696. */
  119697. set autoTransitionRange(value: boolean);
  119698. private _attachedCamera;
  119699. private _onAfterCheckInputsObserver;
  119700. private _onMeshTargetChangedObserver;
  119701. /**
  119702. * Initializes the behavior.
  119703. */
  119704. init(): void;
  119705. /**
  119706. * Attaches the behavior to its arc rotate camera.
  119707. * @param camera Defines the camera to attach the behavior to
  119708. */
  119709. attach(camera: ArcRotateCamera): void;
  119710. /**
  119711. * Detaches the behavior from its current arc rotate camera.
  119712. */
  119713. detach(): void;
  119714. private _radiusIsAnimating;
  119715. private _radiusBounceTransition;
  119716. private _animatables;
  119717. private _cachedWheelPrecision;
  119718. /**
  119719. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  119720. * @param radiusLimit The limit to check against.
  119721. * @return Bool to indicate if at limit.
  119722. */
  119723. private _isRadiusAtLimit;
  119724. /**
  119725. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  119726. * @param radiusDelta The delta by which to animate to. Can be negative.
  119727. */
  119728. private _applyBoundRadiusAnimation;
  119729. /**
  119730. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  119731. */
  119732. protected _clearAnimationLocks(): void;
  119733. /**
  119734. * Stops and removes all animations that have been applied to the camera
  119735. */
  119736. stopAllAnimations(): void;
  119737. }
  119738. }
  119739. declare module BABYLON {
  119740. /**
  119741. * 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.
  119742. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  119743. */
  119744. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  119745. /**
  119746. * Gets the name of the behavior.
  119747. */
  119748. get name(): string;
  119749. private _mode;
  119750. private _radiusScale;
  119751. private _positionScale;
  119752. private _defaultElevation;
  119753. private _elevationReturnTime;
  119754. private _elevationReturnWaitTime;
  119755. private _zoomStopsAnimation;
  119756. private _framingTime;
  119757. /**
  119758. * The easing function used by animations
  119759. */
  119760. static EasingFunction: ExponentialEase;
  119761. /**
  119762. * The easing mode used by animations
  119763. */
  119764. static EasingMode: number;
  119765. /**
  119766. * Sets the current mode used by the behavior
  119767. */
  119768. set mode(mode: number);
  119769. /**
  119770. * Gets current mode used by the behavior.
  119771. */
  119772. get mode(): number;
  119773. /**
  119774. * Sets the scale applied to the radius (1 by default)
  119775. */
  119776. set radiusScale(radius: number);
  119777. /**
  119778. * Gets the scale applied to the radius
  119779. */
  119780. get radiusScale(): number;
  119781. /**
  119782. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119783. */
  119784. set positionScale(scale: number);
  119785. /**
  119786. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  119787. */
  119788. get positionScale(): number;
  119789. /**
  119790. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119791. * behaviour is triggered, in radians.
  119792. */
  119793. set defaultElevation(elevation: number);
  119794. /**
  119795. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  119796. * behaviour is triggered, in radians.
  119797. */
  119798. get defaultElevation(): number;
  119799. /**
  119800. * Sets the time (in milliseconds) taken to return to the default beta position.
  119801. * Negative value indicates camera should not return to default.
  119802. */
  119803. set elevationReturnTime(speed: number);
  119804. /**
  119805. * Gets the time (in milliseconds) taken to return to the default beta position.
  119806. * Negative value indicates camera should not return to default.
  119807. */
  119808. get elevationReturnTime(): number;
  119809. /**
  119810. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119811. */
  119812. set elevationReturnWaitTime(time: number);
  119813. /**
  119814. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  119815. */
  119816. get elevationReturnWaitTime(): number;
  119817. /**
  119818. * Sets the flag that indicates if user zooming should stop animation.
  119819. */
  119820. set zoomStopsAnimation(flag: boolean);
  119821. /**
  119822. * Gets the flag that indicates if user zooming should stop animation.
  119823. */
  119824. get zoomStopsAnimation(): boolean;
  119825. /**
  119826. * Sets the transition time when framing the mesh, in milliseconds
  119827. */
  119828. set framingTime(time: number);
  119829. /**
  119830. * Gets the transition time when framing the mesh, in milliseconds
  119831. */
  119832. get framingTime(): number;
  119833. /**
  119834. * Define if the behavior should automatically change the configured
  119835. * camera limits and sensibilities.
  119836. */
  119837. autoCorrectCameraLimitsAndSensibility: boolean;
  119838. private _onPrePointerObservableObserver;
  119839. private _onAfterCheckInputsObserver;
  119840. private _onMeshTargetChangedObserver;
  119841. private _attachedCamera;
  119842. private _isPointerDown;
  119843. private _lastInteractionTime;
  119844. /**
  119845. * Initializes the behavior.
  119846. */
  119847. init(): void;
  119848. /**
  119849. * Attaches the behavior to its arc rotate camera.
  119850. * @param camera Defines the camera to attach the behavior to
  119851. */
  119852. attach(camera: ArcRotateCamera): void;
  119853. /**
  119854. * Detaches the behavior from its current arc rotate camera.
  119855. */
  119856. detach(): void;
  119857. private _animatables;
  119858. private _betaIsAnimating;
  119859. private _betaTransition;
  119860. private _radiusTransition;
  119861. private _vectorTransition;
  119862. /**
  119863. * Targets the given mesh and updates zoom level accordingly.
  119864. * @param mesh The mesh to target.
  119865. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119866. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119867. */
  119868. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119869. /**
  119870. * Targets the given mesh with its children and updates zoom level accordingly.
  119871. * @param mesh The mesh to target.
  119872. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119873. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119874. */
  119875. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119876. /**
  119877. * Targets the given meshes with their children and updates zoom level accordingly.
  119878. * @param meshes The mesh to target.
  119879. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119880. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119881. */
  119882. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119883. /**
  119884. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  119885. * @param minimumWorld Determines the smaller position of the bounding box extend
  119886. * @param maximumWorld Determines the bigger position of the bounding box extend
  119887. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  119888. * @param onAnimationEnd Callback triggered at the end of the framing animation
  119889. */
  119890. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  119891. /**
  119892. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  119893. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  119894. * frustum width.
  119895. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  119896. * to fully enclose the mesh in the viewing frustum.
  119897. */
  119898. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  119899. /**
  119900. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  119901. * is automatically returned to its default position (expected to be above ground plane).
  119902. */
  119903. private _maintainCameraAboveGround;
  119904. /**
  119905. * Returns the frustum slope based on the canvas ratio and camera FOV
  119906. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  119907. */
  119908. private _getFrustumSlope;
  119909. /**
  119910. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  119911. */
  119912. private _clearAnimationLocks;
  119913. /**
  119914. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  119915. */
  119916. private _applyUserInteraction;
  119917. /**
  119918. * Stops and removes all animations that have been applied to the camera
  119919. */
  119920. stopAllAnimations(): void;
  119921. /**
  119922. * Gets a value indicating if the user is moving the camera
  119923. */
  119924. get isUserIsMoving(): boolean;
  119925. /**
  119926. * The camera can move all the way towards the mesh.
  119927. */
  119928. static IgnoreBoundsSizeMode: number;
  119929. /**
  119930. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  119931. */
  119932. static FitFrustumSidesMode: number;
  119933. }
  119934. }
  119935. declare module BABYLON {
  119936. /**
  119937. * Base class for Camera Pointer Inputs.
  119938. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  119939. * for example usage.
  119940. */
  119941. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  119942. /**
  119943. * Defines the camera the input is attached to.
  119944. */
  119945. abstract camera: Camera;
  119946. /**
  119947. * Whether keyboard modifier keys are pressed at time of last mouse event.
  119948. */
  119949. protected _altKey: boolean;
  119950. protected _ctrlKey: boolean;
  119951. protected _metaKey: boolean;
  119952. protected _shiftKey: boolean;
  119953. /**
  119954. * Which mouse buttons were pressed at time of last mouse event.
  119955. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  119956. */
  119957. protected _buttonsPressed: number;
  119958. /**
  119959. * Defines the buttons associated with the input to handle camera move.
  119960. */
  119961. buttons: number[];
  119962. /**
  119963. * Attach the input controls to a specific dom element to get the input from.
  119964. * @param element Defines the element the controls should be listened from
  119965. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  119966. */
  119967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  119968. /**
  119969. * Detach the current controls from the specified dom element.
  119970. * @param element Defines the element to stop listening the inputs from
  119971. */
  119972. detachControl(element: Nullable<HTMLElement>): void;
  119973. /**
  119974. * Gets the class name of the current input.
  119975. * @returns the class name
  119976. */
  119977. getClassName(): string;
  119978. /**
  119979. * Get the friendly name associated with the input class.
  119980. * @returns the input friendly name
  119981. */
  119982. getSimpleName(): string;
  119983. /**
  119984. * Called on pointer POINTERDOUBLETAP event.
  119985. * Override this method to provide functionality on POINTERDOUBLETAP event.
  119986. */
  119987. protected onDoubleTap(type: string): void;
  119988. /**
  119989. * Called on pointer POINTERMOVE event if only a single touch is active.
  119990. * Override this method to provide functionality.
  119991. */
  119992. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  119993. /**
  119994. * Called on pointer POINTERMOVE event if multiple touches are active.
  119995. * Override this method to provide functionality.
  119996. */
  119997. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  119998. /**
  119999. * Called on JS contextmenu event.
  120000. * Override this method to provide functionality.
  120001. */
  120002. protected onContextMenu(evt: PointerEvent): void;
  120003. /**
  120004. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120005. * press.
  120006. * Override this method to provide functionality.
  120007. */
  120008. protected onButtonDown(evt: PointerEvent): void;
  120009. /**
  120010. * Called each time a new POINTERUP event occurs. Ie, for each button
  120011. * release.
  120012. * Override this method to provide functionality.
  120013. */
  120014. protected onButtonUp(evt: PointerEvent): void;
  120015. /**
  120016. * Called when window becomes inactive.
  120017. * Override this method to provide functionality.
  120018. */
  120019. protected onLostFocus(): void;
  120020. private _pointerInput;
  120021. private _observer;
  120022. private _onLostFocus;
  120023. private pointA;
  120024. private pointB;
  120025. }
  120026. }
  120027. declare module BABYLON {
  120028. /**
  120029. * Manage the pointers inputs to control an arc rotate camera.
  120030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120031. */
  120032. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  120033. /**
  120034. * Defines the camera the input is attached to.
  120035. */
  120036. camera: ArcRotateCamera;
  120037. /**
  120038. * Gets the class name of the current input.
  120039. * @returns the class name
  120040. */
  120041. getClassName(): string;
  120042. /**
  120043. * Defines the buttons associated with the input to handle camera move.
  120044. */
  120045. buttons: number[];
  120046. /**
  120047. * Defines the pointer angular sensibility along the X axis or how fast is
  120048. * the camera rotating.
  120049. */
  120050. angularSensibilityX: number;
  120051. /**
  120052. * Defines the pointer angular sensibility along the Y axis or how fast is
  120053. * the camera rotating.
  120054. */
  120055. angularSensibilityY: number;
  120056. /**
  120057. * Defines the pointer pinch precision or how fast is the camera zooming.
  120058. */
  120059. pinchPrecision: number;
  120060. /**
  120061. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  120062. * from 0.
  120063. * It defines the percentage of current camera.radius to use as delta when
  120064. * pinch zoom is used.
  120065. */
  120066. pinchDeltaPercentage: number;
  120067. /**
  120068. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120069. * that any object in the plane at the camera's target point will scale
  120070. * perfectly with finger motion.
  120071. * Overrides pinchDeltaPercentage and pinchPrecision.
  120072. */
  120073. useNaturalPinchZoom: boolean;
  120074. /**
  120075. * Defines the pointer panning sensibility or how fast is the camera moving.
  120076. */
  120077. panningSensibility: number;
  120078. /**
  120079. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  120080. */
  120081. multiTouchPanning: boolean;
  120082. /**
  120083. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  120084. * zoom (pinch) through multitouch.
  120085. */
  120086. multiTouchPanAndZoom: boolean;
  120087. /**
  120088. * Revers pinch action direction.
  120089. */
  120090. pinchInwards: boolean;
  120091. private _isPanClick;
  120092. private _twoFingerActivityCount;
  120093. private _isPinching;
  120094. /**
  120095. * Called on pointer POINTERMOVE event if only a single touch is active.
  120096. */
  120097. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  120098. /**
  120099. * Called on pointer POINTERDOUBLETAP event.
  120100. */
  120101. protected onDoubleTap(type: string): void;
  120102. /**
  120103. * Called on pointer POINTERMOVE event if multiple touches are active.
  120104. */
  120105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  120106. /**
  120107. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  120108. * press.
  120109. */
  120110. protected onButtonDown(evt: PointerEvent): void;
  120111. /**
  120112. * Called each time a new POINTERUP event occurs. Ie, for each button
  120113. * release.
  120114. */
  120115. protected onButtonUp(evt: PointerEvent): void;
  120116. /**
  120117. * Called when window becomes inactive.
  120118. */
  120119. protected onLostFocus(): void;
  120120. }
  120121. }
  120122. declare module BABYLON {
  120123. /**
  120124. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  120125. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120126. */
  120127. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  120128. /**
  120129. * Defines the camera the input is attached to.
  120130. */
  120131. camera: ArcRotateCamera;
  120132. /**
  120133. * Defines the list of key codes associated with the up action (increase alpha)
  120134. */
  120135. keysUp: number[];
  120136. /**
  120137. * Defines the list of key codes associated with the down action (decrease alpha)
  120138. */
  120139. keysDown: number[];
  120140. /**
  120141. * Defines the list of key codes associated with the left action (increase beta)
  120142. */
  120143. keysLeft: number[];
  120144. /**
  120145. * Defines the list of key codes associated with the right action (decrease beta)
  120146. */
  120147. keysRight: number[];
  120148. /**
  120149. * Defines the list of key codes associated with the reset action.
  120150. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  120151. */
  120152. keysReset: number[];
  120153. /**
  120154. * Defines the panning sensibility of the inputs.
  120155. * (How fast is the camera panning)
  120156. */
  120157. panningSensibility: number;
  120158. /**
  120159. * Defines the zooming sensibility of the inputs.
  120160. * (How fast is the camera zooming)
  120161. */
  120162. zoomingSensibility: number;
  120163. /**
  120164. * Defines whether maintaining the alt key down switch the movement mode from
  120165. * orientation to zoom.
  120166. */
  120167. useAltToZoom: boolean;
  120168. /**
  120169. * Rotation speed of the camera
  120170. */
  120171. angularSpeed: number;
  120172. private _keys;
  120173. private _ctrlPressed;
  120174. private _altPressed;
  120175. private _onCanvasBlurObserver;
  120176. private _onKeyboardObserver;
  120177. private _engine;
  120178. private _scene;
  120179. /**
  120180. * Attach the input controls to a specific dom element to get the input from.
  120181. * @param element Defines the element the controls should be listened from
  120182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120183. */
  120184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120185. /**
  120186. * Detach the current controls from the specified dom element.
  120187. * @param element Defines the element to stop listening the inputs from
  120188. */
  120189. detachControl(element: Nullable<HTMLElement>): void;
  120190. /**
  120191. * Update the current camera state depending on the inputs that have been used this frame.
  120192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  120193. */
  120194. checkInputs(): void;
  120195. /**
  120196. * Gets the class name of the current intput.
  120197. * @returns the class name
  120198. */
  120199. getClassName(): string;
  120200. /**
  120201. * Get the friendly name associated with the input class.
  120202. * @returns the input friendly name
  120203. */
  120204. getSimpleName(): string;
  120205. }
  120206. }
  120207. declare module BABYLON {
  120208. /**
  120209. * Manage the mouse wheel inputs to control an arc rotate camera.
  120210. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120211. */
  120212. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  120213. /**
  120214. * Defines the camera the input is attached to.
  120215. */
  120216. camera: ArcRotateCamera;
  120217. /**
  120218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120219. */
  120220. wheelPrecision: number;
  120221. /**
  120222. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  120223. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  120224. */
  120225. wheelDeltaPercentage: number;
  120226. private _wheel;
  120227. private _observer;
  120228. private computeDeltaFromMouseWheelLegacyEvent;
  120229. /**
  120230. * Attach the input controls to a specific dom element to get the input from.
  120231. * @param element Defines the element the controls should be listened from
  120232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120233. */
  120234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  120235. /**
  120236. * Detach the current controls from the specified dom element.
  120237. * @param element Defines the element to stop listening the inputs from
  120238. */
  120239. detachControl(element: Nullable<HTMLElement>): void;
  120240. /**
  120241. * Gets the class name of the current intput.
  120242. * @returns the class name
  120243. */
  120244. getClassName(): string;
  120245. /**
  120246. * Get the friendly name associated with the input class.
  120247. * @returns the input friendly name
  120248. */
  120249. getSimpleName(): string;
  120250. }
  120251. }
  120252. declare module BABYLON {
  120253. /**
  120254. * Default Inputs manager for the ArcRotateCamera.
  120255. * It groups all the default supported inputs for ease of use.
  120256. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  120257. */
  120258. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  120259. /**
  120260. * Instantiates a new ArcRotateCameraInputsManager.
  120261. * @param camera Defines the camera the inputs belong to
  120262. */
  120263. constructor(camera: ArcRotateCamera);
  120264. /**
  120265. * Add mouse wheel input support to the input manager.
  120266. * @returns the current input manager
  120267. */
  120268. addMouseWheel(): ArcRotateCameraInputsManager;
  120269. /**
  120270. * Add pointers input support to the input manager.
  120271. * @returns the current input manager
  120272. */
  120273. addPointers(): ArcRotateCameraInputsManager;
  120274. /**
  120275. * Add keyboard input support to the input manager.
  120276. * @returns the current input manager
  120277. */
  120278. addKeyboard(): ArcRotateCameraInputsManager;
  120279. }
  120280. }
  120281. declare module BABYLON {
  120282. /**
  120283. * This represents an orbital type of camera.
  120284. *
  120285. * 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.
  120286. * 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.
  120287. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  120288. */
  120289. export class ArcRotateCamera extends TargetCamera {
  120290. /**
  120291. * Defines the rotation angle of the camera along the longitudinal axis.
  120292. */
  120293. alpha: number;
  120294. /**
  120295. * Defines the rotation angle of the camera along the latitudinal axis.
  120296. */
  120297. beta: number;
  120298. /**
  120299. * Defines the radius of the camera from it s target point.
  120300. */
  120301. radius: number;
  120302. protected _target: Vector3;
  120303. protected _targetHost: Nullable<AbstractMesh>;
  120304. /**
  120305. * Defines the target point of the camera.
  120306. * The camera looks towards it form the radius distance.
  120307. */
  120308. get target(): Vector3;
  120309. set target(value: Vector3);
  120310. /**
  120311. * Define the current local position of the camera in the scene
  120312. */
  120313. get position(): Vector3;
  120314. set position(newPosition: Vector3);
  120315. protected _upVector: Vector3;
  120316. protected _upToYMatrix: Matrix;
  120317. protected _YToUpMatrix: Matrix;
  120318. /**
  120319. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  120320. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  120321. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  120322. */
  120323. set upVector(vec: Vector3);
  120324. get upVector(): Vector3;
  120325. /**
  120326. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  120327. */
  120328. setMatUp(): void;
  120329. /**
  120330. * Current inertia value on the longitudinal axis.
  120331. * The bigger this number the longer it will take for the camera to stop.
  120332. */
  120333. inertialAlphaOffset: number;
  120334. /**
  120335. * Current inertia value on the latitudinal axis.
  120336. * The bigger this number the longer it will take for the camera to stop.
  120337. */
  120338. inertialBetaOffset: number;
  120339. /**
  120340. * Current inertia value on the radius axis.
  120341. * The bigger this number the longer it will take for the camera to stop.
  120342. */
  120343. inertialRadiusOffset: number;
  120344. /**
  120345. * Minimum allowed angle on the longitudinal axis.
  120346. * This can help limiting how the Camera is able to move in the scene.
  120347. */
  120348. lowerAlphaLimit: Nullable<number>;
  120349. /**
  120350. * Maximum allowed angle on the longitudinal axis.
  120351. * This can help limiting how the Camera is able to move in the scene.
  120352. */
  120353. upperAlphaLimit: Nullable<number>;
  120354. /**
  120355. * Minimum allowed angle on the latitudinal axis.
  120356. * This can help limiting how the Camera is able to move in the scene.
  120357. */
  120358. lowerBetaLimit: number;
  120359. /**
  120360. * Maximum allowed angle on the latitudinal axis.
  120361. * This can help limiting how the Camera is able to move in the scene.
  120362. */
  120363. upperBetaLimit: number;
  120364. /**
  120365. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  120366. * This can help limiting how the Camera is able to move in the scene.
  120367. */
  120368. lowerRadiusLimit: Nullable<number>;
  120369. /**
  120370. * Maximum allowed distance of the camera to the target (The camera can not get further).
  120371. * This can help limiting how the Camera is able to move in the scene.
  120372. */
  120373. upperRadiusLimit: Nullable<number>;
  120374. /**
  120375. * Defines the current inertia value used during panning of the camera along the X axis.
  120376. */
  120377. inertialPanningX: number;
  120378. /**
  120379. * Defines the current inertia value used during panning of the camera along the Y axis.
  120380. */
  120381. inertialPanningY: number;
  120382. /**
  120383. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  120384. * Basically if your fingers moves away from more than this distance you will be considered
  120385. * in pinch mode.
  120386. */
  120387. pinchToPanMaxDistance: number;
  120388. /**
  120389. * Defines the maximum distance the camera can pan.
  120390. * This could help keeping the cammera always in your scene.
  120391. */
  120392. panningDistanceLimit: Nullable<number>;
  120393. /**
  120394. * Defines the target of the camera before paning.
  120395. */
  120396. panningOriginTarget: Vector3;
  120397. /**
  120398. * Defines the value of the inertia used during panning.
  120399. * 0 would mean stop inertia and one would mean no decelleration at all.
  120400. */
  120401. panningInertia: number;
  120402. /**
  120403. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  120404. */
  120405. get angularSensibilityX(): number;
  120406. set angularSensibilityX(value: number);
  120407. /**
  120408. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  120409. */
  120410. get angularSensibilityY(): number;
  120411. set angularSensibilityY(value: number);
  120412. /**
  120413. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  120414. */
  120415. get pinchPrecision(): number;
  120416. set pinchPrecision(value: number);
  120417. /**
  120418. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  120419. * It will be used instead of pinchDeltaPrecision if different from 0.
  120420. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120421. */
  120422. get pinchDeltaPercentage(): number;
  120423. set pinchDeltaPercentage(value: number);
  120424. /**
  120425. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  120426. * and pinch delta percentage.
  120427. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  120428. * that any object in the plane at the camera's target point will scale
  120429. * perfectly with finger motion.
  120430. */
  120431. get useNaturalPinchZoom(): boolean;
  120432. set useNaturalPinchZoom(value: boolean);
  120433. /**
  120434. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  120435. */
  120436. get panningSensibility(): number;
  120437. set panningSensibility(value: number);
  120438. /**
  120439. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  120440. */
  120441. get keysUp(): number[];
  120442. set keysUp(value: number[]);
  120443. /**
  120444. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  120445. */
  120446. get keysDown(): number[];
  120447. set keysDown(value: number[]);
  120448. /**
  120449. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  120450. */
  120451. get keysLeft(): number[];
  120452. set keysLeft(value: number[]);
  120453. /**
  120454. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  120455. */
  120456. get keysRight(): number[];
  120457. set keysRight(value: number[]);
  120458. /**
  120459. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  120460. */
  120461. get wheelPrecision(): number;
  120462. set wheelPrecision(value: number);
  120463. /**
  120464. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  120465. * It will be used instead of pinchDeltaPrecision if different from 0.
  120466. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  120467. */
  120468. get wheelDeltaPercentage(): number;
  120469. set wheelDeltaPercentage(value: number);
  120470. /**
  120471. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  120472. */
  120473. zoomOnFactor: number;
  120474. /**
  120475. * Defines a screen offset for the camera position.
  120476. */
  120477. targetScreenOffset: Vector2;
  120478. /**
  120479. * Allows the camera to be completely reversed.
  120480. * If false the camera can not arrive upside down.
  120481. */
  120482. allowUpsideDown: boolean;
  120483. /**
  120484. * Define if double tap/click is used to restore the previously saved state of the camera.
  120485. */
  120486. useInputToRestoreState: boolean;
  120487. /** @hidden */
  120488. _viewMatrix: Matrix;
  120489. /** @hidden */
  120490. _useCtrlForPanning: boolean;
  120491. /** @hidden */
  120492. _panningMouseButton: number;
  120493. /**
  120494. * Defines the input associated to the camera.
  120495. */
  120496. inputs: ArcRotateCameraInputsManager;
  120497. /** @hidden */
  120498. _reset: () => void;
  120499. /**
  120500. * Defines the allowed panning axis.
  120501. */
  120502. panningAxis: Vector3;
  120503. protected _localDirection: Vector3;
  120504. protected _transformedDirection: Vector3;
  120505. private _bouncingBehavior;
  120506. /**
  120507. * Gets the bouncing behavior of the camera if it has been enabled.
  120508. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120509. */
  120510. get bouncingBehavior(): Nullable<BouncingBehavior>;
  120511. /**
  120512. * Defines if the bouncing behavior of the camera is enabled on the camera.
  120513. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  120514. */
  120515. get useBouncingBehavior(): boolean;
  120516. set useBouncingBehavior(value: boolean);
  120517. private _framingBehavior;
  120518. /**
  120519. * Gets the framing behavior of the camera if it has been enabled.
  120520. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120521. */
  120522. get framingBehavior(): Nullable<FramingBehavior>;
  120523. /**
  120524. * Defines if the framing behavior of the camera is enabled on the camera.
  120525. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  120526. */
  120527. get useFramingBehavior(): boolean;
  120528. set useFramingBehavior(value: boolean);
  120529. private _autoRotationBehavior;
  120530. /**
  120531. * Gets the auto rotation behavior of the camera if it has been enabled.
  120532. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120533. */
  120534. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  120535. /**
  120536. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  120537. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120538. */
  120539. get useAutoRotationBehavior(): boolean;
  120540. set useAutoRotationBehavior(value: boolean);
  120541. /**
  120542. * Observable triggered when the mesh target has been changed on the camera.
  120543. */
  120544. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  120545. /**
  120546. * Event raised when the camera is colliding with a mesh.
  120547. */
  120548. onCollide: (collidedMesh: AbstractMesh) => void;
  120549. /**
  120550. * Defines whether the camera should check collision with the objects oh the scene.
  120551. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  120552. */
  120553. checkCollisions: boolean;
  120554. /**
  120555. * Defines the collision radius of the camera.
  120556. * This simulates a sphere around the camera.
  120557. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  120558. */
  120559. collisionRadius: Vector3;
  120560. protected _collider: Collider;
  120561. protected _previousPosition: Vector3;
  120562. protected _collisionVelocity: Vector3;
  120563. protected _newPosition: Vector3;
  120564. protected _previousAlpha: number;
  120565. protected _previousBeta: number;
  120566. protected _previousRadius: number;
  120567. protected _collisionTriggered: boolean;
  120568. protected _targetBoundingCenter: Nullable<Vector3>;
  120569. private _computationVector;
  120570. /**
  120571. * Instantiates a new ArcRotateCamera in a given scene
  120572. * @param name Defines the name of the camera
  120573. * @param alpha Defines the camera rotation along the logitudinal axis
  120574. * @param beta Defines the camera rotation along the latitudinal axis
  120575. * @param radius Defines the camera distance from its target
  120576. * @param target Defines the camera target
  120577. * @param scene Defines the scene the camera belongs to
  120578. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  120579. */
  120580. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  120581. /** @hidden */
  120582. _initCache(): void;
  120583. /** @hidden */
  120584. _updateCache(ignoreParentClass?: boolean): void;
  120585. protected _getTargetPosition(): Vector3;
  120586. private _storedAlpha;
  120587. private _storedBeta;
  120588. private _storedRadius;
  120589. private _storedTarget;
  120590. private _storedTargetScreenOffset;
  120591. /**
  120592. * Stores the current state of the camera (alpha, beta, radius and target)
  120593. * @returns the camera itself
  120594. */
  120595. storeState(): Camera;
  120596. /**
  120597. * @hidden
  120598. * Restored camera state. You must call storeState() first
  120599. */
  120600. _restoreStateValues(): boolean;
  120601. /** @hidden */
  120602. _isSynchronizedViewMatrix(): boolean;
  120603. /**
  120604. * Attached controls to the current camera.
  120605. * @param element Defines the element the controls should be listened from
  120606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  120607. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  120608. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  120609. */
  120610. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  120611. /**
  120612. * Detach the current controls from the camera.
  120613. * The camera will stop reacting to inputs.
  120614. * @param element Defines the element to stop listening the inputs from
  120615. */
  120616. detachControl(element: HTMLElement): void;
  120617. /** @hidden */
  120618. _checkInputs(): void;
  120619. protected _checkLimits(): void;
  120620. /**
  120621. * Rebuilds angles (alpha, beta) and radius from the give position and target
  120622. */
  120623. rebuildAnglesAndRadius(): void;
  120624. /**
  120625. * Use a position to define the current camera related information like alpha, beta and radius
  120626. * @param position Defines the position to set the camera at
  120627. */
  120628. setPosition(position: Vector3): void;
  120629. /**
  120630. * Defines the target the camera should look at.
  120631. * This will automatically adapt alpha beta and radius to fit within the new target.
  120632. * @param target Defines the new target as a Vector or a mesh
  120633. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  120634. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  120635. */
  120636. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  120637. /** @hidden */
  120638. _getViewMatrix(): Matrix;
  120639. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  120640. /**
  120641. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  120642. * @param meshes Defines the mesh to zoom on
  120643. * @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)
  120644. */
  120645. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  120646. /**
  120647. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  120648. * The target will be changed but the radius
  120649. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  120650. * @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)
  120651. */
  120652. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  120653. min: Vector3;
  120654. max: Vector3;
  120655. distance: number;
  120656. }, doNotUpdateMaxZ?: boolean): void;
  120657. /**
  120658. * @override
  120659. * Override Camera.createRigCamera
  120660. */
  120661. createRigCamera(name: string, cameraIndex: number): Camera;
  120662. /**
  120663. * @hidden
  120664. * @override
  120665. * Override Camera._updateRigCameras
  120666. */
  120667. _updateRigCameras(): void;
  120668. /**
  120669. * Destroy the camera and release the current resources hold by it.
  120670. */
  120671. dispose(): void;
  120672. /**
  120673. * Gets the current object class name.
  120674. * @return the class name
  120675. */
  120676. getClassName(): string;
  120677. }
  120678. }
  120679. declare module BABYLON {
  120680. /**
  120681. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  120682. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  120683. */
  120684. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  120685. /**
  120686. * Gets the name of the behavior.
  120687. */
  120688. get name(): string;
  120689. private _zoomStopsAnimation;
  120690. private _idleRotationSpeed;
  120691. private _idleRotationWaitTime;
  120692. private _idleRotationSpinupTime;
  120693. /**
  120694. * Sets the flag that indicates if user zooming should stop animation.
  120695. */
  120696. set zoomStopsAnimation(flag: boolean);
  120697. /**
  120698. * Gets the flag that indicates if user zooming should stop animation.
  120699. */
  120700. get zoomStopsAnimation(): boolean;
  120701. /**
  120702. * Sets the default speed at which the camera rotates around the model.
  120703. */
  120704. set idleRotationSpeed(speed: number);
  120705. /**
  120706. * Gets the default speed at which the camera rotates around the model.
  120707. */
  120708. get idleRotationSpeed(): number;
  120709. /**
  120710. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  120711. */
  120712. set idleRotationWaitTime(time: number);
  120713. /**
  120714. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  120715. */
  120716. get idleRotationWaitTime(): number;
  120717. /**
  120718. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120719. */
  120720. set idleRotationSpinupTime(time: number);
  120721. /**
  120722. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  120723. */
  120724. get idleRotationSpinupTime(): number;
  120725. /**
  120726. * Gets a value indicating if the camera is currently rotating because of this behavior
  120727. */
  120728. get rotationInProgress(): boolean;
  120729. private _onPrePointerObservableObserver;
  120730. private _onAfterCheckInputsObserver;
  120731. private _attachedCamera;
  120732. private _isPointerDown;
  120733. private _lastFrameTime;
  120734. private _lastInteractionTime;
  120735. private _cameraRotationSpeed;
  120736. /**
  120737. * Initializes the behavior.
  120738. */
  120739. init(): void;
  120740. /**
  120741. * Attaches the behavior to its arc rotate camera.
  120742. * @param camera Defines the camera to attach the behavior to
  120743. */
  120744. attach(camera: ArcRotateCamera): void;
  120745. /**
  120746. * Detaches the behavior from its current arc rotate camera.
  120747. */
  120748. detach(): void;
  120749. /**
  120750. * Returns true if user is scrolling.
  120751. * @return true if user is scrolling.
  120752. */
  120753. private _userIsZooming;
  120754. private _lastFrameRadius;
  120755. private _shouldAnimationStopForInteraction;
  120756. /**
  120757. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  120758. */
  120759. private _applyUserInteraction;
  120760. private _userIsMoving;
  120761. }
  120762. }
  120763. declare module BABYLON {
  120764. /**
  120765. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  120766. */
  120767. export class AttachToBoxBehavior implements Behavior<Mesh> {
  120768. private ui;
  120769. /**
  120770. * The name of the behavior
  120771. */
  120772. name: string;
  120773. /**
  120774. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  120775. */
  120776. distanceAwayFromFace: number;
  120777. /**
  120778. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  120779. */
  120780. distanceAwayFromBottomOfFace: number;
  120781. private _faceVectors;
  120782. private _target;
  120783. private _scene;
  120784. private _onRenderObserver;
  120785. private _tmpMatrix;
  120786. private _tmpVector;
  120787. /**
  120788. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  120789. * @param ui The transform node that should be attched to the mesh
  120790. */
  120791. constructor(ui: TransformNode);
  120792. /**
  120793. * Initializes the behavior
  120794. */
  120795. init(): void;
  120796. private _closestFace;
  120797. private _zeroVector;
  120798. private _lookAtTmpMatrix;
  120799. private _lookAtToRef;
  120800. /**
  120801. * Attaches the AttachToBoxBehavior to the passed in mesh
  120802. * @param target The mesh that the specified node will be attached to
  120803. */
  120804. attach(target: Mesh): void;
  120805. /**
  120806. * Detaches the behavior from the mesh
  120807. */
  120808. detach(): void;
  120809. }
  120810. }
  120811. declare module BABYLON {
  120812. /**
  120813. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  120814. */
  120815. export class FadeInOutBehavior implements Behavior<Mesh> {
  120816. /**
  120817. * Time in milliseconds to delay before fading in (Default: 0)
  120818. */
  120819. delay: number;
  120820. /**
  120821. * Time in milliseconds for the mesh to fade in (Default: 300)
  120822. */
  120823. fadeInTime: number;
  120824. private _millisecondsPerFrame;
  120825. private _hovered;
  120826. private _hoverValue;
  120827. private _ownerNode;
  120828. /**
  120829. * Instatiates the FadeInOutBehavior
  120830. */
  120831. constructor();
  120832. /**
  120833. * The name of the behavior
  120834. */
  120835. get name(): string;
  120836. /**
  120837. * Initializes the behavior
  120838. */
  120839. init(): void;
  120840. /**
  120841. * Attaches the fade behavior on the passed in mesh
  120842. * @param ownerNode The mesh that will be faded in/out once attached
  120843. */
  120844. attach(ownerNode: Mesh): void;
  120845. /**
  120846. * Detaches the behavior from the mesh
  120847. */
  120848. detach(): void;
  120849. /**
  120850. * Triggers the mesh to begin fading in or out
  120851. * @param value if the object should fade in or out (true to fade in)
  120852. */
  120853. fadeIn(value: boolean): void;
  120854. private _update;
  120855. private _setAllVisibility;
  120856. }
  120857. }
  120858. declare module BABYLON {
  120859. /**
  120860. * Class containing a set of static utilities functions for managing Pivots
  120861. * @hidden
  120862. */
  120863. export class PivotTools {
  120864. private static _PivotCached;
  120865. private static _OldPivotPoint;
  120866. private static _PivotTranslation;
  120867. private static _PivotTmpVector;
  120868. /** @hidden */
  120869. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  120870. /** @hidden */
  120871. static _RestorePivotPoint(mesh: AbstractMesh): void;
  120872. }
  120873. }
  120874. declare module BABYLON {
  120875. /**
  120876. * Class containing static functions to help procedurally build meshes
  120877. */
  120878. export class PlaneBuilder {
  120879. /**
  120880. * Creates a plane mesh
  120881. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  120882. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  120883. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  120884. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120885. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120887. * @param name defines the name of the mesh
  120888. * @param options defines the options used to create the mesh
  120889. * @param scene defines the hosting scene
  120890. * @returns the plane mesh
  120891. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  120892. */
  120893. static CreatePlane(name: string, options: {
  120894. size?: number;
  120895. width?: number;
  120896. height?: number;
  120897. sideOrientation?: number;
  120898. frontUVs?: Vector4;
  120899. backUVs?: Vector4;
  120900. updatable?: boolean;
  120901. sourcePlane?: Plane;
  120902. }, scene?: Nullable<Scene>): Mesh;
  120903. }
  120904. }
  120905. declare module BABYLON {
  120906. /**
  120907. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  120908. */
  120909. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  120910. private static _AnyMouseID;
  120911. /**
  120912. * Abstract mesh the behavior is set on
  120913. */
  120914. attachedNode: AbstractMesh;
  120915. private _dragPlane;
  120916. private _scene;
  120917. private _pointerObserver;
  120918. private _beforeRenderObserver;
  120919. private static _planeScene;
  120920. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  120921. /**
  120922. * 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)
  120923. */
  120924. maxDragAngle: number;
  120925. /**
  120926. * @hidden
  120927. */
  120928. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  120929. /**
  120930. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  120931. */
  120932. currentDraggingPointerID: number;
  120933. /**
  120934. * The last position where the pointer hit the drag plane in world space
  120935. */
  120936. lastDragPosition: Vector3;
  120937. /**
  120938. * If the behavior is currently in a dragging state
  120939. */
  120940. dragging: boolean;
  120941. /**
  120942. * 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)
  120943. */
  120944. dragDeltaRatio: number;
  120945. /**
  120946. * If the drag plane orientation should be updated during the dragging (Default: true)
  120947. */
  120948. updateDragPlane: boolean;
  120949. private _debugMode;
  120950. private _moving;
  120951. /**
  120952. * Fires each time the attached mesh is dragged with the pointer
  120953. * * delta between last drag position and current drag position in world space
  120954. * * dragDistance along the drag axis
  120955. * * dragPlaneNormal normal of the current drag plane used during the drag
  120956. * * dragPlanePoint in world space where the drag intersects the drag plane
  120957. */
  120958. onDragObservable: Observable<{
  120959. delta: Vector3;
  120960. dragPlanePoint: Vector3;
  120961. dragPlaneNormal: Vector3;
  120962. dragDistance: number;
  120963. pointerId: number;
  120964. }>;
  120965. /**
  120966. * Fires each time a drag begins (eg. mouse down on mesh)
  120967. */
  120968. onDragStartObservable: Observable<{
  120969. dragPlanePoint: Vector3;
  120970. pointerId: number;
  120971. }>;
  120972. /**
  120973. * Fires each time a drag ends (eg. mouse release after drag)
  120974. */
  120975. onDragEndObservable: Observable<{
  120976. dragPlanePoint: Vector3;
  120977. pointerId: number;
  120978. }>;
  120979. /**
  120980. * If the attached mesh should be moved when dragged
  120981. */
  120982. moveAttached: boolean;
  120983. /**
  120984. * If the drag behavior will react to drag events (Default: true)
  120985. */
  120986. enabled: boolean;
  120987. /**
  120988. * If pointer events should start and release the drag (Default: true)
  120989. */
  120990. startAndReleaseDragOnPointerEvents: boolean;
  120991. /**
  120992. * If camera controls should be detached during the drag
  120993. */
  120994. detachCameraControls: boolean;
  120995. /**
  120996. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  120997. */
  120998. useObjectOrientationForDragging: boolean;
  120999. private _options;
  121000. /**
  121001. * Gets the options used by the behavior
  121002. */
  121003. get options(): {
  121004. dragAxis?: Vector3;
  121005. dragPlaneNormal?: Vector3;
  121006. };
  121007. /**
  121008. * Sets the options used by the behavior
  121009. */
  121010. set options(options: {
  121011. dragAxis?: Vector3;
  121012. dragPlaneNormal?: Vector3;
  121013. });
  121014. /**
  121015. * Creates a pointer drag behavior that can be attached to a mesh
  121016. * @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)
  121017. */
  121018. constructor(options?: {
  121019. dragAxis?: Vector3;
  121020. dragPlaneNormal?: Vector3;
  121021. });
  121022. /**
  121023. * Predicate to determine if it is valid to move the object to a new position when it is moved
  121024. */
  121025. validateDrag: (targetPosition: Vector3) => boolean;
  121026. /**
  121027. * The name of the behavior
  121028. */
  121029. get name(): string;
  121030. /**
  121031. * Initializes the behavior
  121032. */
  121033. init(): void;
  121034. private _tmpVector;
  121035. private _alternatePickedPoint;
  121036. private _worldDragAxis;
  121037. private _targetPosition;
  121038. private _attachedElement;
  121039. /**
  121040. * Attaches the drag behavior the passed in mesh
  121041. * @param ownerNode The mesh that will be dragged around once attached
  121042. * @param predicate Predicate to use for pick filtering
  121043. */
  121044. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  121045. /**
  121046. * Force relase the drag action by code.
  121047. */
  121048. releaseDrag(): void;
  121049. private _startDragRay;
  121050. private _lastPointerRay;
  121051. /**
  121052. * Simulates the start of a pointer drag event on the behavior
  121053. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  121054. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  121055. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  121056. */
  121057. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  121058. private _startDrag;
  121059. private _dragDelta;
  121060. private _moveDrag;
  121061. private _pickWithRayOnDragPlane;
  121062. private _pointA;
  121063. private _pointB;
  121064. private _pointC;
  121065. private _lineA;
  121066. private _lineB;
  121067. private _localAxis;
  121068. private _lookAt;
  121069. private _updateDragPlanePosition;
  121070. /**
  121071. * Detaches the behavior from the mesh
  121072. */
  121073. detach(): void;
  121074. }
  121075. }
  121076. declare module BABYLON {
  121077. /**
  121078. * A behavior that when attached to a mesh will allow the mesh to be scaled
  121079. */
  121080. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  121081. private _dragBehaviorA;
  121082. private _dragBehaviorB;
  121083. private _startDistance;
  121084. private _initialScale;
  121085. private _targetScale;
  121086. private _ownerNode;
  121087. private _sceneRenderObserver;
  121088. /**
  121089. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  121090. */
  121091. constructor();
  121092. /**
  121093. * The name of the behavior
  121094. */
  121095. get name(): string;
  121096. /**
  121097. * Initializes the behavior
  121098. */
  121099. init(): void;
  121100. private _getCurrentDistance;
  121101. /**
  121102. * Attaches the scale behavior the passed in mesh
  121103. * @param ownerNode The mesh that will be scaled around once attached
  121104. */
  121105. attach(ownerNode: Mesh): void;
  121106. /**
  121107. * Detaches the behavior from the mesh
  121108. */
  121109. detach(): void;
  121110. }
  121111. }
  121112. declare module BABYLON {
  121113. /**
  121114. * 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
  121115. */
  121116. export class SixDofDragBehavior implements Behavior<Mesh> {
  121117. private static _virtualScene;
  121118. private _ownerNode;
  121119. private _sceneRenderObserver;
  121120. private _scene;
  121121. private _targetPosition;
  121122. private _virtualOriginMesh;
  121123. private _virtualDragMesh;
  121124. private _pointerObserver;
  121125. private _moving;
  121126. private _startingOrientation;
  121127. private _attachedElement;
  121128. /**
  121129. * 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)
  121130. */
  121131. private zDragFactor;
  121132. /**
  121133. * If the object should rotate to face the drag origin
  121134. */
  121135. rotateDraggedObject: boolean;
  121136. /**
  121137. * If the behavior is currently in a dragging state
  121138. */
  121139. dragging: boolean;
  121140. /**
  121141. * 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)
  121142. */
  121143. dragDeltaRatio: number;
  121144. /**
  121145. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  121146. */
  121147. currentDraggingPointerID: number;
  121148. /**
  121149. * If camera controls should be detached during the drag
  121150. */
  121151. detachCameraControls: boolean;
  121152. /**
  121153. * Fires each time a drag starts
  121154. */
  121155. onDragStartObservable: Observable<{}>;
  121156. /**
  121157. * Fires each time a drag ends (eg. mouse release after drag)
  121158. */
  121159. onDragEndObservable: Observable<{}>;
  121160. /**
  121161. * 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
  121162. */
  121163. constructor();
  121164. /**
  121165. * The name of the behavior
  121166. */
  121167. get name(): string;
  121168. /**
  121169. * Initializes the behavior
  121170. */
  121171. init(): void;
  121172. /**
  121173. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  121174. */
  121175. private get _pointerCamera();
  121176. /**
  121177. * Attaches the scale behavior the passed in mesh
  121178. * @param ownerNode The mesh that will be scaled around once attached
  121179. */
  121180. attach(ownerNode: Mesh): void;
  121181. /**
  121182. * Detaches the behavior from the mesh
  121183. */
  121184. detach(): void;
  121185. }
  121186. }
  121187. declare module BABYLON {
  121188. /**
  121189. * Class used to apply inverse kinematics to bones
  121190. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  121191. */
  121192. export class BoneIKController {
  121193. private static _tmpVecs;
  121194. private static _tmpQuat;
  121195. private static _tmpMats;
  121196. /**
  121197. * Gets or sets the target mesh
  121198. */
  121199. targetMesh: AbstractMesh;
  121200. /** Gets or sets the mesh used as pole */
  121201. poleTargetMesh: AbstractMesh;
  121202. /**
  121203. * Gets or sets the bone used as pole
  121204. */
  121205. poleTargetBone: Nullable<Bone>;
  121206. /**
  121207. * Gets or sets the target position
  121208. */
  121209. targetPosition: Vector3;
  121210. /**
  121211. * Gets or sets the pole target position
  121212. */
  121213. poleTargetPosition: Vector3;
  121214. /**
  121215. * Gets or sets the pole target local offset
  121216. */
  121217. poleTargetLocalOffset: Vector3;
  121218. /**
  121219. * Gets or sets the pole angle
  121220. */
  121221. poleAngle: number;
  121222. /**
  121223. * Gets or sets the mesh associated with the controller
  121224. */
  121225. mesh: AbstractMesh;
  121226. /**
  121227. * 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)
  121228. */
  121229. slerpAmount: number;
  121230. private _bone1Quat;
  121231. private _bone1Mat;
  121232. private _bone2Ang;
  121233. private _bone1;
  121234. private _bone2;
  121235. private _bone1Length;
  121236. private _bone2Length;
  121237. private _maxAngle;
  121238. private _maxReach;
  121239. private _rightHandedSystem;
  121240. private _bendAxis;
  121241. private _slerping;
  121242. private _adjustRoll;
  121243. /**
  121244. * Gets or sets maximum allowed angle
  121245. */
  121246. get maxAngle(): number;
  121247. set maxAngle(value: number);
  121248. /**
  121249. * Creates a new BoneIKController
  121250. * @param mesh defines the mesh to control
  121251. * @param bone defines the bone to control
  121252. * @param options defines options to set up the controller
  121253. */
  121254. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  121255. targetMesh?: AbstractMesh;
  121256. poleTargetMesh?: AbstractMesh;
  121257. poleTargetBone?: Bone;
  121258. poleTargetLocalOffset?: Vector3;
  121259. poleAngle?: number;
  121260. bendAxis?: Vector3;
  121261. maxAngle?: number;
  121262. slerpAmount?: number;
  121263. });
  121264. private _setMaxAngle;
  121265. /**
  121266. * Force the controller to update the bones
  121267. */
  121268. update(): void;
  121269. }
  121270. }
  121271. declare module BABYLON {
  121272. /**
  121273. * Class used to make a bone look toward a point in space
  121274. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  121275. */
  121276. export class BoneLookController {
  121277. private static _tmpVecs;
  121278. private static _tmpQuat;
  121279. private static _tmpMats;
  121280. /**
  121281. * The target Vector3 that the bone will look at
  121282. */
  121283. target: Vector3;
  121284. /**
  121285. * The mesh that the bone is attached to
  121286. */
  121287. mesh: AbstractMesh;
  121288. /**
  121289. * The bone that will be looking to the target
  121290. */
  121291. bone: Bone;
  121292. /**
  121293. * The up axis of the coordinate system that is used when the bone is rotated
  121294. */
  121295. upAxis: Vector3;
  121296. /**
  121297. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  121298. */
  121299. upAxisSpace: Space;
  121300. /**
  121301. * Used to make an adjustment to the yaw of the bone
  121302. */
  121303. adjustYaw: number;
  121304. /**
  121305. * Used to make an adjustment to the pitch of the bone
  121306. */
  121307. adjustPitch: number;
  121308. /**
  121309. * Used to make an adjustment to the roll of the bone
  121310. */
  121311. adjustRoll: number;
  121312. /**
  121313. * 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)
  121314. */
  121315. slerpAmount: number;
  121316. private _minYaw;
  121317. private _maxYaw;
  121318. private _minPitch;
  121319. private _maxPitch;
  121320. private _minYawSin;
  121321. private _minYawCos;
  121322. private _maxYawSin;
  121323. private _maxYawCos;
  121324. private _midYawConstraint;
  121325. private _minPitchTan;
  121326. private _maxPitchTan;
  121327. private _boneQuat;
  121328. private _slerping;
  121329. private _transformYawPitch;
  121330. private _transformYawPitchInv;
  121331. private _firstFrameSkipped;
  121332. private _yawRange;
  121333. private _fowardAxis;
  121334. /**
  121335. * Gets or sets the minimum yaw angle that the bone can look to
  121336. */
  121337. get minYaw(): number;
  121338. set minYaw(value: number);
  121339. /**
  121340. * Gets or sets the maximum yaw angle that the bone can look to
  121341. */
  121342. get maxYaw(): number;
  121343. set maxYaw(value: number);
  121344. /**
  121345. * Gets or sets the minimum pitch angle that the bone can look to
  121346. */
  121347. get minPitch(): number;
  121348. set minPitch(value: number);
  121349. /**
  121350. * Gets or sets the maximum pitch angle that the bone can look to
  121351. */
  121352. get maxPitch(): number;
  121353. set maxPitch(value: number);
  121354. /**
  121355. * Create a BoneLookController
  121356. * @param mesh the mesh that the bone belongs to
  121357. * @param bone the bone that will be looking to the target
  121358. * @param target the target Vector3 to look at
  121359. * @param options optional settings:
  121360. * * maxYaw: the maximum angle the bone will yaw to
  121361. * * minYaw: the minimum angle the bone will yaw to
  121362. * * maxPitch: the maximum angle the bone will pitch to
  121363. * * minPitch: the minimum angle the bone will yaw to
  121364. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  121365. * * upAxis: the up axis of the coordinate system
  121366. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  121367. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  121368. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  121369. * * adjustYaw: used to make an adjustment to the yaw of the bone
  121370. * * adjustPitch: used to make an adjustment to the pitch of the bone
  121371. * * adjustRoll: used to make an adjustment to the roll of the bone
  121372. **/
  121373. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  121374. maxYaw?: number;
  121375. minYaw?: number;
  121376. maxPitch?: number;
  121377. minPitch?: number;
  121378. slerpAmount?: number;
  121379. upAxis?: Vector3;
  121380. upAxisSpace?: Space;
  121381. yawAxis?: Vector3;
  121382. pitchAxis?: Vector3;
  121383. adjustYaw?: number;
  121384. adjustPitch?: number;
  121385. adjustRoll?: number;
  121386. });
  121387. /**
  121388. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  121389. */
  121390. update(): void;
  121391. private _getAngleDiff;
  121392. private _getAngleBetween;
  121393. private _isAngleBetween;
  121394. }
  121395. }
  121396. declare module BABYLON {
  121397. /**
  121398. * Manage the gamepad inputs to control an arc rotate camera.
  121399. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121400. */
  121401. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  121402. /**
  121403. * Defines the camera the input is attached to.
  121404. */
  121405. camera: ArcRotateCamera;
  121406. /**
  121407. * Defines the gamepad the input is gathering event from.
  121408. */
  121409. gamepad: Nullable<Gamepad>;
  121410. /**
  121411. * Defines the gamepad rotation sensiblity.
  121412. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  121413. */
  121414. gamepadRotationSensibility: number;
  121415. /**
  121416. * Defines the gamepad move sensiblity.
  121417. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  121418. */
  121419. gamepadMoveSensibility: number;
  121420. private _yAxisScale;
  121421. /**
  121422. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  121423. */
  121424. get invertYAxis(): boolean;
  121425. set invertYAxis(value: boolean);
  121426. private _onGamepadConnectedObserver;
  121427. private _onGamepadDisconnectedObserver;
  121428. /**
  121429. * Attach the input controls to a specific dom element to get the input from.
  121430. * @param element Defines the element the controls should be listened from
  121431. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121432. */
  121433. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121434. /**
  121435. * Detach the current controls from the specified dom element.
  121436. * @param element Defines the element to stop listening the inputs from
  121437. */
  121438. detachControl(element: Nullable<HTMLElement>): void;
  121439. /**
  121440. * Update the current camera state depending on the inputs that have been used this frame.
  121441. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121442. */
  121443. checkInputs(): void;
  121444. /**
  121445. * Gets the class name of the current intput.
  121446. * @returns the class name
  121447. */
  121448. getClassName(): string;
  121449. /**
  121450. * Get the friendly name associated with the input class.
  121451. * @returns the input friendly name
  121452. */
  121453. getSimpleName(): string;
  121454. }
  121455. }
  121456. declare module BABYLON {
  121457. interface ArcRotateCameraInputsManager {
  121458. /**
  121459. * Add orientation input support to the input manager.
  121460. * @returns the current input manager
  121461. */
  121462. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  121463. }
  121464. /**
  121465. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  121466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121467. */
  121468. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  121469. /**
  121470. * Defines the camera the input is attached to.
  121471. */
  121472. camera: ArcRotateCamera;
  121473. /**
  121474. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  121475. */
  121476. alphaCorrection: number;
  121477. /**
  121478. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  121479. */
  121480. gammaCorrection: number;
  121481. private _alpha;
  121482. private _gamma;
  121483. private _dirty;
  121484. private _deviceOrientationHandler;
  121485. /**
  121486. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  121487. */
  121488. constructor();
  121489. /**
  121490. * Attach the input controls to a specific dom element to get the input from.
  121491. * @param element Defines the element the controls should be listened from
  121492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121493. */
  121494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121495. /** @hidden */
  121496. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  121497. /**
  121498. * Update the current camera state depending on the inputs that have been used this frame.
  121499. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121500. */
  121501. checkInputs(): void;
  121502. /**
  121503. * Detach the current controls from the specified dom element.
  121504. * @param element Defines the element to stop listening the inputs from
  121505. */
  121506. detachControl(element: Nullable<HTMLElement>): void;
  121507. /**
  121508. * Gets the class name of the current intput.
  121509. * @returns the class name
  121510. */
  121511. getClassName(): string;
  121512. /**
  121513. * Get the friendly name associated with the input class.
  121514. * @returns the input friendly name
  121515. */
  121516. getSimpleName(): string;
  121517. }
  121518. }
  121519. declare module BABYLON {
  121520. /**
  121521. * Listen to mouse events to control the camera.
  121522. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121523. */
  121524. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  121525. /**
  121526. * Defines the camera the input is attached to.
  121527. */
  121528. camera: FlyCamera;
  121529. /**
  121530. * Defines if touch is enabled. (Default is true.)
  121531. */
  121532. touchEnabled: boolean;
  121533. /**
  121534. * Defines the buttons associated with the input to handle camera rotation.
  121535. */
  121536. buttons: number[];
  121537. /**
  121538. * Assign buttons for Yaw control.
  121539. */
  121540. buttonsYaw: number[];
  121541. /**
  121542. * Assign buttons for Pitch control.
  121543. */
  121544. buttonsPitch: number[];
  121545. /**
  121546. * Assign buttons for Roll control.
  121547. */
  121548. buttonsRoll: number[];
  121549. /**
  121550. * Detect if any button is being pressed while mouse is moved.
  121551. * -1 = Mouse locked.
  121552. * 0 = Left button.
  121553. * 1 = Middle Button.
  121554. * 2 = Right Button.
  121555. */
  121556. activeButton: number;
  121557. /**
  121558. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  121559. * Higher values reduce its sensitivity.
  121560. */
  121561. angularSensibility: number;
  121562. private _mousemoveCallback;
  121563. private _observer;
  121564. private _rollObserver;
  121565. private previousPosition;
  121566. private noPreventDefault;
  121567. private element;
  121568. /**
  121569. * Listen to mouse events to control the camera.
  121570. * @param touchEnabled Define if touch is enabled. (Default is true.)
  121571. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121572. */
  121573. constructor(touchEnabled?: boolean);
  121574. /**
  121575. * Attach the mouse control to the HTML DOM element.
  121576. * @param element Defines the element that listens to the input events.
  121577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  121578. */
  121579. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121580. /**
  121581. * Detach the current controls from the specified dom element.
  121582. * @param element Defines the element to stop listening the inputs from
  121583. */
  121584. detachControl(element: Nullable<HTMLElement>): void;
  121585. /**
  121586. * Gets the class name of the current input.
  121587. * @returns the class name.
  121588. */
  121589. getClassName(): string;
  121590. /**
  121591. * Get the friendly name associated with the input class.
  121592. * @returns the input's friendly name.
  121593. */
  121594. getSimpleName(): string;
  121595. private _pointerInput;
  121596. private _onMouseMove;
  121597. /**
  121598. * Rotate camera by mouse offset.
  121599. */
  121600. private rotateCamera;
  121601. }
  121602. }
  121603. declare module BABYLON {
  121604. /**
  121605. * Default Inputs manager for the FlyCamera.
  121606. * It groups all the default supported inputs for ease of use.
  121607. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121608. */
  121609. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  121610. /**
  121611. * Instantiates a new FlyCameraInputsManager.
  121612. * @param camera Defines the camera the inputs belong to.
  121613. */
  121614. constructor(camera: FlyCamera);
  121615. /**
  121616. * Add keyboard input support to the input manager.
  121617. * @returns the new FlyCameraKeyboardMoveInput().
  121618. */
  121619. addKeyboard(): FlyCameraInputsManager;
  121620. /**
  121621. * Add mouse input support to the input manager.
  121622. * @param touchEnabled Enable touch screen support.
  121623. * @returns the new FlyCameraMouseInput().
  121624. */
  121625. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  121626. }
  121627. }
  121628. declare module BABYLON {
  121629. /**
  121630. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121631. * such as in a 3D Space Shooter or a Flight Simulator.
  121632. */
  121633. export class FlyCamera extends TargetCamera {
  121634. /**
  121635. * Define the collision ellipsoid of the camera.
  121636. * This is helpful for simulating a camera body, like a player's body.
  121637. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  121638. */
  121639. ellipsoid: Vector3;
  121640. /**
  121641. * Define an offset for the position of the ellipsoid around the camera.
  121642. * This can be helpful if the camera is attached away from the player's body center,
  121643. * such as at its head.
  121644. */
  121645. ellipsoidOffset: Vector3;
  121646. /**
  121647. * Enable or disable collisions of the camera with the rest of the scene objects.
  121648. */
  121649. checkCollisions: boolean;
  121650. /**
  121651. * Enable or disable gravity on the camera.
  121652. */
  121653. applyGravity: boolean;
  121654. /**
  121655. * Define the current direction the camera is moving to.
  121656. */
  121657. cameraDirection: Vector3;
  121658. /**
  121659. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  121660. * This overrides and empties cameraRotation.
  121661. */
  121662. rotationQuaternion: Quaternion;
  121663. /**
  121664. * Track Roll to maintain the wanted Rolling when looking around.
  121665. */
  121666. _trackRoll: number;
  121667. /**
  121668. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  121669. */
  121670. rollCorrect: number;
  121671. /**
  121672. * Mimic a banked turn, Rolling the camera when Yawing.
  121673. * It's recommended to use rollCorrect = 10 for faster banking correction.
  121674. */
  121675. bankedTurn: boolean;
  121676. /**
  121677. * Limit in radians for how much Roll banking will add. (Default: 90°)
  121678. */
  121679. bankedTurnLimit: number;
  121680. /**
  121681. * Value of 0 disables the banked Roll.
  121682. * Value of 1 is equal to the Yaw angle in radians.
  121683. */
  121684. bankedTurnMultiplier: number;
  121685. /**
  121686. * The inputs manager loads all the input sources, such as keyboard and mouse.
  121687. */
  121688. inputs: FlyCameraInputsManager;
  121689. /**
  121690. * Gets the input sensibility for mouse input.
  121691. * Higher values reduce sensitivity.
  121692. */
  121693. get angularSensibility(): number;
  121694. /**
  121695. * Sets the input sensibility for a mouse input.
  121696. * Higher values reduce sensitivity.
  121697. */
  121698. set angularSensibility(value: number);
  121699. /**
  121700. * Get the keys for camera movement forward.
  121701. */
  121702. get keysForward(): number[];
  121703. /**
  121704. * Set the keys for camera movement forward.
  121705. */
  121706. set keysForward(value: number[]);
  121707. /**
  121708. * Get the keys for camera movement backward.
  121709. */
  121710. get keysBackward(): number[];
  121711. set keysBackward(value: number[]);
  121712. /**
  121713. * Get the keys for camera movement up.
  121714. */
  121715. get keysUp(): number[];
  121716. /**
  121717. * Set the keys for camera movement up.
  121718. */
  121719. set keysUp(value: number[]);
  121720. /**
  121721. * Get the keys for camera movement down.
  121722. */
  121723. get keysDown(): number[];
  121724. /**
  121725. * Set the keys for camera movement down.
  121726. */
  121727. set keysDown(value: number[]);
  121728. /**
  121729. * Get the keys for camera movement left.
  121730. */
  121731. get keysLeft(): number[];
  121732. /**
  121733. * Set the keys for camera movement left.
  121734. */
  121735. set keysLeft(value: number[]);
  121736. /**
  121737. * Set the keys for camera movement right.
  121738. */
  121739. get keysRight(): number[];
  121740. /**
  121741. * Set the keys for camera movement right.
  121742. */
  121743. set keysRight(value: number[]);
  121744. /**
  121745. * Event raised when the camera collides with a mesh in the scene.
  121746. */
  121747. onCollide: (collidedMesh: AbstractMesh) => void;
  121748. private _collider;
  121749. private _needMoveForGravity;
  121750. private _oldPosition;
  121751. private _diffPosition;
  121752. private _newPosition;
  121753. /** @hidden */
  121754. _localDirection: Vector3;
  121755. /** @hidden */
  121756. _transformedDirection: Vector3;
  121757. /**
  121758. * Instantiates a FlyCamera.
  121759. * This is a flying camera, designed for 3D movement and rotation in all directions,
  121760. * such as in a 3D Space Shooter or a Flight Simulator.
  121761. * @param name Define the name of the camera in the scene.
  121762. * @param position Define the starting position of the camera in the scene.
  121763. * @param scene Define the scene the camera belongs to.
  121764. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  121765. */
  121766. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  121767. /**
  121768. * Attach a control to the HTML DOM element.
  121769. * @param element Defines the element that listens to the input events.
  121770. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  121771. */
  121772. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121773. /**
  121774. * Detach a control from the HTML DOM element.
  121775. * The camera will stop reacting to that input.
  121776. * @param element Defines the element that listens to the input events.
  121777. */
  121778. detachControl(element: HTMLElement): void;
  121779. private _collisionMask;
  121780. /**
  121781. * Get the mask that the camera ignores in collision events.
  121782. */
  121783. get collisionMask(): number;
  121784. /**
  121785. * Set the mask that the camera ignores in collision events.
  121786. */
  121787. set collisionMask(mask: number);
  121788. /** @hidden */
  121789. _collideWithWorld(displacement: Vector3): void;
  121790. /** @hidden */
  121791. private _onCollisionPositionChange;
  121792. /** @hidden */
  121793. _checkInputs(): void;
  121794. /** @hidden */
  121795. _decideIfNeedsToMove(): boolean;
  121796. /** @hidden */
  121797. _updatePosition(): void;
  121798. /**
  121799. * Restore the Roll to its target value at the rate specified.
  121800. * @param rate - Higher means slower restoring.
  121801. * @hidden
  121802. */
  121803. restoreRoll(rate: number): void;
  121804. /**
  121805. * Destroy the camera and release the current resources held by it.
  121806. */
  121807. dispose(): void;
  121808. /**
  121809. * Get the current object class name.
  121810. * @returns the class name.
  121811. */
  121812. getClassName(): string;
  121813. }
  121814. }
  121815. declare module BABYLON {
  121816. /**
  121817. * Listen to keyboard events to control the camera.
  121818. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121819. */
  121820. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  121821. /**
  121822. * Defines the camera the input is attached to.
  121823. */
  121824. camera: FlyCamera;
  121825. /**
  121826. * The list of keyboard keys used to control the forward move of the camera.
  121827. */
  121828. keysForward: number[];
  121829. /**
  121830. * The list of keyboard keys used to control the backward move of the camera.
  121831. */
  121832. keysBackward: number[];
  121833. /**
  121834. * The list of keyboard keys used to control the forward move of the camera.
  121835. */
  121836. keysUp: number[];
  121837. /**
  121838. * The list of keyboard keys used to control the backward move of the camera.
  121839. */
  121840. keysDown: number[];
  121841. /**
  121842. * The list of keyboard keys used to control the right strafe move of the camera.
  121843. */
  121844. keysRight: number[];
  121845. /**
  121846. * The list of keyboard keys used to control the left strafe move of the camera.
  121847. */
  121848. keysLeft: number[];
  121849. private _keys;
  121850. private _onCanvasBlurObserver;
  121851. private _onKeyboardObserver;
  121852. private _engine;
  121853. private _scene;
  121854. /**
  121855. * Attach the input controls to a specific dom element to get the input from.
  121856. * @param element Defines the element the controls should be listened from
  121857. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121858. */
  121859. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121860. /**
  121861. * Detach the current controls from the specified dom element.
  121862. * @param element Defines the element to stop listening the inputs from
  121863. */
  121864. detachControl(element: Nullable<HTMLElement>): void;
  121865. /**
  121866. * Gets the class name of the current intput.
  121867. * @returns the class name
  121868. */
  121869. getClassName(): string;
  121870. /** @hidden */
  121871. _onLostFocus(e: FocusEvent): void;
  121872. /**
  121873. * Get the friendly name associated with the input class.
  121874. * @returns the input friendly name
  121875. */
  121876. getSimpleName(): string;
  121877. /**
  121878. * Update the current camera state depending on the inputs that have been used this frame.
  121879. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  121880. */
  121881. checkInputs(): void;
  121882. }
  121883. }
  121884. declare module BABYLON {
  121885. /**
  121886. * Manage the mouse wheel inputs to control a follow camera.
  121887. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121888. */
  121889. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  121890. /**
  121891. * Defines the camera the input is attached to.
  121892. */
  121893. camera: FollowCamera;
  121894. /**
  121895. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  121896. */
  121897. axisControlRadius: boolean;
  121898. /**
  121899. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  121900. */
  121901. axisControlHeight: boolean;
  121902. /**
  121903. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  121904. */
  121905. axisControlRotation: boolean;
  121906. /**
  121907. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  121908. * relation to mouseWheel events.
  121909. */
  121910. wheelPrecision: number;
  121911. /**
  121912. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  121913. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  121914. */
  121915. wheelDeltaPercentage: number;
  121916. private _wheel;
  121917. private _observer;
  121918. /**
  121919. * Attach the input controls to a specific dom element to get the input from.
  121920. * @param element Defines the element the controls should be listened from
  121921. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  121922. */
  121923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  121924. /**
  121925. * Detach the current controls from the specified dom element.
  121926. * @param element Defines the element to stop listening the inputs from
  121927. */
  121928. detachControl(element: Nullable<HTMLElement>): void;
  121929. /**
  121930. * Gets the class name of the current intput.
  121931. * @returns the class name
  121932. */
  121933. getClassName(): string;
  121934. /**
  121935. * Get the friendly name associated with the input class.
  121936. * @returns the input friendly name
  121937. */
  121938. getSimpleName(): string;
  121939. }
  121940. }
  121941. declare module BABYLON {
  121942. /**
  121943. * Manage the pointers inputs to control an follow camera.
  121944. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  121945. */
  121946. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  121947. /**
  121948. * Defines the camera the input is attached to.
  121949. */
  121950. camera: FollowCamera;
  121951. /**
  121952. * Gets the class name of the current input.
  121953. * @returns the class name
  121954. */
  121955. getClassName(): string;
  121956. /**
  121957. * Defines the pointer angular sensibility along the X axis or how fast is
  121958. * the camera rotating.
  121959. * A negative number will reverse the axis direction.
  121960. */
  121961. angularSensibilityX: number;
  121962. /**
  121963. * Defines the pointer angular sensibility along the Y axis or how fast is
  121964. * the camera rotating.
  121965. * A negative number will reverse the axis direction.
  121966. */
  121967. angularSensibilityY: number;
  121968. /**
  121969. * Defines the pointer pinch precision or how fast is the camera zooming.
  121970. * A negative number will reverse the axis direction.
  121971. */
  121972. pinchPrecision: number;
  121973. /**
  121974. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  121975. * from 0.
  121976. * It defines the percentage of current camera.radius to use as delta when
  121977. * pinch zoom is used.
  121978. */
  121979. pinchDeltaPercentage: number;
  121980. /**
  121981. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  121982. */
  121983. axisXControlRadius: boolean;
  121984. /**
  121985. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  121986. */
  121987. axisXControlHeight: boolean;
  121988. /**
  121989. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  121990. */
  121991. axisXControlRotation: boolean;
  121992. /**
  121993. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  121994. */
  121995. axisYControlRadius: boolean;
  121996. /**
  121997. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  121998. */
  121999. axisYControlHeight: boolean;
  122000. /**
  122001. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  122002. */
  122003. axisYControlRotation: boolean;
  122004. /**
  122005. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  122006. */
  122007. axisPinchControlRadius: boolean;
  122008. /**
  122009. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  122010. */
  122011. axisPinchControlHeight: boolean;
  122012. /**
  122013. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  122014. */
  122015. axisPinchControlRotation: boolean;
  122016. /**
  122017. * Log error messages if basic misconfiguration has occurred.
  122018. */
  122019. warningEnable: boolean;
  122020. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122021. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122022. private _warningCounter;
  122023. private _warning;
  122024. }
  122025. }
  122026. declare module BABYLON {
  122027. /**
  122028. * Default Inputs manager for the FollowCamera.
  122029. * It groups all the default supported inputs for ease of use.
  122030. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122031. */
  122032. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  122033. /**
  122034. * Instantiates a new FollowCameraInputsManager.
  122035. * @param camera Defines the camera the inputs belong to
  122036. */
  122037. constructor(camera: FollowCamera);
  122038. /**
  122039. * Add keyboard input support to the input manager.
  122040. * @returns the current input manager
  122041. */
  122042. addKeyboard(): FollowCameraInputsManager;
  122043. /**
  122044. * Add mouse wheel input support to the input manager.
  122045. * @returns the current input manager
  122046. */
  122047. addMouseWheel(): FollowCameraInputsManager;
  122048. /**
  122049. * Add pointers input support to the input manager.
  122050. * @returns the current input manager
  122051. */
  122052. addPointers(): FollowCameraInputsManager;
  122053. /**
  122054. * Add orientation input support to the input manager.
  122055. * @returns the current input manager
  122056. */
  122057. addVRDeviceOrientation(): FollowCameraInputsManager;
  122058. }
  122059. }
  122060. declare module BABYLON {
  122061. /**
  122062. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  122063. * an arc rotate version arcFollowCamera are available.
  122064. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122065. */
  122066. export class FollowCamera extends TargetCamera {
  122067. /**
  122068. * Distance the follow camera should follow an object at
  122069. */
  122070. radius: number;
  122071. /**
  122072. * Minimum allowed distance of the camera to the axis of rotation
  122073. * (The camera can not get closer).
  122074. * This can help limiting how the Camera is able to move in the scene.
  122075. */
  122076. lowerRadiusLimit: Nullable<number>;
  122077. /**
  122078. * Maximum allowed distance of the camera to the axis of rotation
  122079. * (The camera can not get further).
  122080. * This can help limiting how the Camera is able to move in the scene.
  122081. */
  122082. upperRadiusLimit: Nullable<number>;
  122083. /**
  122084. * Define a rotation offset between the camera and the object it follows
  122085. */
  122086. rotationOffset: number;
  122087. /**
  122088. * Minimum allowed angle to camera position relative to target object.
  122089. * This can help limiting how the Camera is able to move in the scene.
  122090. */
  122091. lowerRotationOffsetLimit: Nullable<number>;
  122092. /**
  122093. * Maximum allowed angle to camera position relative to target object.
  122094. * This can help limiting how the Camera is able to move in the scene.
  122095. */
  122096. upperRotationOffsetLimit: Nullable<number>;
  122097. /**
  122098. * Define a height offset between the camera and the object it follows.
  122099. * It can help following an object from the top (like a car chaing a plane)
  122100. */
  122101. heightOffset: number;
  122102. /**
  122103. * Minimum allowed height of camera position relative to target object.
  122104. * This can help limiting how the Camera is able to move in the scene.
  122105. */
  122106. lowerHeightOffsetLimit: Nullable<number>;
  122107. /**
  122108. * Maximum allowed height of camera position relative to target object.
  122109. * This can help limiting how the Camera is able to move in the scene.
  122110. */
  122111. upperHeightOffsetLimit: Nullable<number>;
  122112. /**
  122113. * Define how fast the camera can accelerate to follow it s target.
  122114. */
  122115. cameraAcceleration: number;
  122116. /**
  122117. * Define the speed limit of the camera following an object.
  122118. */
  122119. maxCameraSpeed: number;
  122120. /**
  122121. * Define the target of the camera.
  122122. */
  122123. lockedTarget: Nullable<AbstractMesh>;
  122124. /**
  122125. * Defines the input associated with the camera.
  122126. */
  122127. inputs: FollowCameraInputsManager;
  122128. /**
  122129. * Instantiates the follow camera.
  122130. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122131. * @param name Define the name of the camera in the scene
  122132. * @param position Define the position of the camera
  122133. * @param scene Define the scene the camera belong to
  122134. * @param lockedTarget Define the target of the camera
  122135. */
  122136. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  122137. private _follow;
  122138. /**
  122139. * Attached controls to the current camera.
  122140. * @param element Defines the element the controls should be listened from
  122141. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122142. */
  122143. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122144. /**
  122145. * Detach the current controls from the camera.
  122146. * The camera will stop reacting to inputs.
  122147. * @param element Defines the element to stop listening the inputs from
  122148. */
  122149. detachControl(element: HTMLElement): void;
  122150. /** @hidden */
  122151. _checkInputs(): void;
  122152. private _checkLimits;
  122153. /**
  122154. * Gets the camera class name.
  122155. * @returns the class name
  122156. */
  122157. getClassName(): string;
  122158. }
  122159. /**
  122160. * Arc Rotate version of the follow camera.
  122161. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  122162. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122163. */
  122164. export class ArcFollowCamera extends TargetCamera {
  122165. /** The longitudinal angle of the camera */
  122166. alpha: number;
  122167. /** The latitudinal angle of the camera */
  122168. beta: number;
  122169. /** The radius of the camera from its target */
  122170. radius: number;
  122171. /** Define the camera target (the mesh it should follow) */
  122172. target: Nullable<AbstractMesh>;
  122173. private _cartesianCoordinates;
  122174. /**
  122175. * Instantiates a new ArcFollowCamera
  122176. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  122177. * @param name Define the name of the camera
  122178. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  122179. * @param beta Define the rotation angle of the camera around the elevation axis
  122180. * @param radius Define the radius of the camera from its target point
  122181. * @param target Define the target of the camera
  122182. * @param scene Define the scene the camera belongs to
  122183. */
  122184. constructor(name: string,
  122185. /** The longitudinal angle of the camera */
  122186. alpha: number,
  122187. /** The latitudinal angle of the camera */
  122188. beta: number,
  122189. /** The radius of the camera from its target */
  122190. radius: number,
  122191. /** Define the camera target (the mesh it should follow) */
  122192. target: Nullable<AbstractMesh>, scene: Scene);
  122193. private _follow;
  122194. /** @hidden */
  122195. _checkInputs(): void;
  122196. /**
  122197. * Returns the class name of the object.
  122198. * It is mostly used internally for serialization purposes.
  122199. */
  122200. getClassName(): string;
  122201. }
  122202. }
  122203. declare module BABYLON {
  122204. /**
  122205. * Manage the keyboard inputs to control the movement of a follow camera.
  122206. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122207. */
  122208. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  122209. /**
  122210. * Defines the camera the input is attached to.
  122211. */
  122212. camera: FollowCamera;
  122213. /**
  122214. * Defines the list of key codes associated with the up action (increase heightOffset)
  122215. */
  122216. keysHeightOffsetIncr: number[];
  122217. /**
  122218. * Defines the list of key codes associated with the down action (decrease heightOffset)
  122219. */
  122220. keysHeightOffsetDecr: number[];
  122221. /**
  122222. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  122223. */
  122224. keysHeightOffsetModifierAlt: boolean;
  122225. /**
  122226. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  122227. */
  122228. keysHeightOffsetModifierCtrl: boolean;
  122229. /**
  122230. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  122231. */
  122232. keysHeightOffsetModifierShift: boolean;
  122233. /**
  122234. * Defines the list of key codes associated with the left action (increase rotationOffset)
  122235. */
  122236. keysRotationOffsetIncr: number[];
  122237. /**
  122238. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  122239. */
  122240. keysRotationOffsetDecr: number[];
  122241. /**
  122242. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  122243. */
  122244. keysRotationOffsetModifierAlt: boolean;
  122245. /**
  122246. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  122247. */
  122248. keysRotationOffsetModifierCtrl: boolean;
  122249. /**
  122250. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  122251. */
  122252. keysRotationOffsetModifierShift: boolean;
  122253. /**
  122254. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  122255. */
  122256. keysRadiusIncr: number[];
  122257. /**
  122258. * Defines the list of key codes associated with the zoom-out action (increase radius)
  122259. */
  122260. keysRadiusDecr: number[];
  122261. /**
  122262. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  122263. */
  122264. keysRadiusModifierAlt: boolean;
  122265. /**
  122266. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  122267. */
  122268. keysRadiusModifierCtrl: boolean;
  122269. /**
  122270. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  122271. */
  122272. keysRadiusModifierShift: boolean;
  122273. /**
  122274. * Defines the rate of change of heightOffset.
  122275. */
  122276. heightSensibility: number;
  122277. /**
  122278. * Defines the rate of change of rotationOffset.
  122279. */
  122280. rotationSensibility: number;
  122281. /**
  122282. * Defines the rate of change of radius.
  122283. */
  122284. radiusSensibility: number;
  122285. private _keys;
  122286. private _ctrlPressed;
  122287. private _altPressed;
  122288. private _shiftPressed;
  122289. private _onCanvasBlurObserver;
  122290. private _onKeyboardObserver;
  122291. private _engine;
  122292. private _scene;
  122293. /**
  122294. * Attach the input controls to a specific dom element to get the input from.
  122295. * @param element Defines the element the controls should be listened from
  122296. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122297. */
  122298. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122299. /**
  122300. * Detach the current controls from the specified dom element.
  122301. * @param element Defines the element to stop listening the inputs from
  122302. */
  122303. detachControl(element: Nullable<HTMLElement>): void;
  122304. /**
  122305. * Update the current camera state depending on the inputs that have been used this frame.
  122306. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122307. */
  122308. checkInputs(): void;
  122309. /**
  122310. * Gets the class name of the current input.
  122311. * @returns the class name
  122312. */
  122313. getClassName(): string;
  122314. /**
  122315. * Get the friendly name associated with the input class.
  122316. * @returns the input friendly name
  122317. */
  122318. getSimpleName(): string;
  122319. /**
  122320. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122321. * allow modification of the heightOffset value.
  122322. */
  122323. private _modifierHeightOffset;
  122324. /**
  122325. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122326. * allow modification of the rotationOffset value.
  122327. */
  122328. private _modifierRotationOffset;
  122329. /**
  122330. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  122331. * allow modification of the radius value.
  122332. */
  122333. private _modifierRadius;
  122334. }
  122335. }
  122336. declare module BABYLON {
  122337. interface FreeCameraInputsManager {
  122338. /**
  122339. * @hidden
  122340. */
  122341. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  122342. /**
  122343. * Add orientation input support to the input manager.
  122344. * @returns the current input manager
  122345. */
  122346. addDeviceOrientation(): FreeCameraInputsManager;
  122347. }
  122348. /**
  122349. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  122350. * Screen rotation is taken into account.
  122351. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122352. */
  122353. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  122354. private _camera;
  122355. private _screenOrientationAngle;
  122356. private _constantTranform;
  122357. private _screenQuaternion;
  122358. private _alpha;
  122359. private _beta;
  122360. private _gamma;
  122361. /**
  122362. * Can be used to detect if a device orientation sensor is available on a device
  122363. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  122364. * @returns a promise that will resolve on orientation change
  122365. */
  122366. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  122367. /**
  122368. * @hidden
  122369. */
  122370. _onDeviceOrientationChangedObservable: Observable<void>;
  122371. /**
  122372. * Instantiates a new input
  122373. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122374. */
  122375. constructor();
  122376. /**
  122377. * Define the camera controlled by the input.
  122378. */
  122379. get camera(): FreeCamera;
  122380. set camera(camera: FreeCamera);
  122381. /**
  122382. * Attach the input controls to a specific dom element to get the input from.
  122383. * @param element Defines the element the controls should be listened from
  122384. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122385. */
  122386. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122387. private _orientationChanged;
  122388. private _deviceOrientation;
  122389. /**
  122390. * Detach the current controls from the specified dom element.
  122391. * @param element Defines the element to stop listening the inputs from
  122392. */
  122393. detachControl(element: Nullable<HTMLElement>): void;
  122394. /**
  122395. * Update the current camera state depending on the inputs that have been used this frame.
  122396. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122397. */
  122398. checkInputs(): void;
  122399. /**
  122400. * Gets the class name of the current intput.
  122401. * @returns the class name
  122402. */
  122403. getClassName(): string;
  122404. /**
  122405. * Get the friendly name associated with the input class.
  122406. * @returns the input friendly name
  122407. */
  122408. getSimpleName(): string;
  122409. }
  122410. }
  122411. declare module BABYLON {
  122412. /**
  122413. * Manage the gamepad inputs to control a free camera.
  122414. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122415. */
  122416. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  122417. /**
  122418. * Define the camera the input is attached to.
  122419. */
  122420. camera: FreeCamera;
  122421. /**
  122422. * Define the Gamepad controlling the input
  122423. */
  122424. gamepad: Nullable<Gamepad>;
  122425. /**
  122426. * Defines the gamepad rotation sensiblity.
  122427. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  122428. */
  122429. gamepadAngularSensibility: number;
  122430. /**
  122431. * Defines the gamepad move sensiblity.
  122432. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  122433. */
  122434. gamepadMoveSensibility: number;
  122435. private _yAxisScale;
  122436. /**
  122437. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  122438. */
  122439. get invertYAxis(): boolean;
  122440. set invertYAxis(value: boolean);
  122441. private _onGamepadConnectedObserver;
  122442. private _onGamepadDisconnectedObserver;
  122443. private _cameraTransform;
  122444. private _deltaTransform;
  122445. private _vector3;
  122446. private _vector2;
  122447. /**
  122448. * Attach the input controls to a specific dom element to get the input from.
  122449. * @param element Defines the element the controls should be listened from
  122450. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122451. */
  122452. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122453. /**
  122454. * Detach the current controls from the specified dom element.
  122455. * @param element Defines the element to stop listening the inputs from
  122456. */
  122457. detachControl(element: Nullable<HTMLElement>): void;
  122458. /**
  122459. * Update the current camera state depending on the inputs that have been used this frame.
  122460. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122461. */
  122462. checkInputs(): void;
  122463. /**
  122464. * Gets the class name of the current intput.
  122465. * @returns the class name
  122466. */
  122467. getClassName(): string;
  122468. /**
  122469. * Get the friendly name associated with the input class.
  122470. * @returns the input friendly name
  122471. */
  122472. getSimpleName(): string;
  122473. }
  122474. }
  122475. declare module BABYLON {
  122476. /**
  122477. * Defines the potential axis of a Joystick
  122478. */
  122479. export enum JoystickAxis {
  122480. /** X axis */
  122481. X = 0,
  122482. /** Y axis */
  122483. Y = 1,
  122484. /** Z axis */
  122485. Z = 2
  122486. }
  122487. /**
  122488. * Represents the different customization options available
  122489. * for VirtualJoystick
  122490. */
  122491. interface VirtualJoystickCustomizations {
  122492. /**
  122493. * Size of the joystick's puck
  122494. */
  122495. puckSize: number;
  122496. /**
  122497. * Size of the joystick's container
  122498. */
  122499. containerSize: number;
  122500. /**
  122501. * Color of the joystick && puck
  122502. */
  122503. color: string;
  122504. /**
  122505. * Image URL for the joystick's puck
  122506. */
  122507. puckImage?: string;
  122508. /**
  122509. * Image URL for the joystick's container
  122510. */
  122511. containerImage?: string;
  122512. /**
  122513. * Defines the unmoving position of the joystick container
  122514. */
  122515. position?: {
  122516. x: number;
  122517. y: number;
  122518. };
  122519. /**
  122520. * Defines whether or not the joystick container is always visible
  122521. */
  122522. alwaysVisible: boolean;
  122523. /**
  122524. * Defines whether or not to limit the movement of the puck to the joystick's container
  122525. */
  122526. limitToContainer: boolean;
  122527. }
  122528. /**
  122529. * Class used to define virtual joystick (used in touch mode)
  122530. */
  122531. export class VirtualJoystick {
  122532. /**
  122533. * Gets or sets a boolean indicating that left and right values must be inverted
  122534. */
  122535. reverseLeftRight: boolean;
  122536. /**
  122537. * Gets or sets a boolean indicating that up and down values must be inverted
  122538. */
  122539. reverseUpDown: boolean;
  122540. /**
  122541. * Gets the offset value for the position (ie. the change of the position value)
  122542. */
  122543. deltaPosition: Vector3;
  122544. /**
  122545. * Gets a boolean indicating if the virtual joystick was pressed
  122546. */
  122547. pressed: boolean;
  122548. /**
  122549. * Canvas the virtual joystick will render onto, default z-index of this is 5
  122550. */
  122551. static Canvas: Nullable<HTMLCanvasElement>;
  122552. /**
  122553. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  122554. */
  122555. limitToContainer: boolean;
  122556. private static _globalJoystickIndex;
  122557. private static _alwaysVisibleSticks;
  122558. private static vjCanvasContext;
  122559. private static vjCanvasWidth;
  122560. private static vjCanvasHeight;
  122561. private static halfWidth;
  122562. private static _GetDefaultOptions;
  122563. private _action;
  122564. private _axisTargetedByLeftAndRight;
  122565. private _axisTargetedByUpAndDown;
  122566. private _joystickSensibility;
  122567. private _inversedSensibility;
  122568. private _joystickPointerID;
  122569. private _joystickColor;
  122570. private _joystickPointerPos;
  122571. private _joystickPreviousPointerPos;
  122572. private _joystickPointerStartPos;
  122573. private _deltaJoystickVector;
  122574. private _leftJoystick;
  122575. private _touches;
  122576. private _joystickPosition;
  122577. private _alwaysVisible;
  122578. private _puckImage;
  122579. private _containerImage;
  122580. private _joystickPuckSize;
  122581. private _joystickContainerSize;
  122582. private _clearPuckSize;
  122583. private _clearContainerSize;
  122584. private _clearPuckSizeOffset;
  122585. private _clearContainerSizeOffset;
  122586. private _onPointerDownHandlerRef;
  122587. private _onPointerMoveHandlerRef;
  122588. private _onPointerUpHandlerRef;
  122589. private _onResize;
  122590. /**
  122591. * Creates a new virtual joystick
  122592. * @param leftJoystick defines that the joystick is for left hand (false by default)
  122593. * @param customizations Defines the options we want to customize the VirtualJoystick
  122594. */
  122595. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  122596. /**
  122597. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  122598. * @param newJoystickSensibility defines the new sensibility
  122599. */
  122600. setJoystickSensibility(newJoystickSensibility: number): void;
  122601. private _onPointerDown;
  122602. private _onPointerMove;
  122603. private _onPointerUp;
  122604. /**
  122605. * Change the color of the virtual joystick
  122606. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  122607. */
  122608. setJoystickColor(newColor: string): void;
  122609. /**
  122610. * Size of the joystick's container
  122611. */
  122612. set containerSize(newSize: number);
  122613. get containerSize(): number;
  122614. /**
  122615. * Size of the joystick's puck
  122616. */
  122617. set puckSize(newSize: number);
  122618. get puckSize(): number;
  122619. /**
  122620. * Clears the set position of the joystick
  122621. */
  122622. clearPosition(): void;
  122623. /**
  122624. * Defines whether or not the joystick container is always visible
  122625. */
  122626. set alwaysVisible(value: boolean);
  122627. get alwaysVisible(): boolean;
  122628. /**
  122629. * Sets the constant position of the Joystick container
  122630. * @param x X axis coordinate
  122631. * @param y Y axis coordinate
  122632. */
  122633. setPosition(x: number, y: number): void;
  122634. /**
  122635. * Defines a callback to call when the joystick is touched
  122636. * @param action defines the callback
  122637. */
  122638. setActionOnTouch(action: () => any): void;
  122639. /**
  122640. * Defines which axis you'd like to control for left & right
  122641. * @param axis defines the axis to use
  122642. */
  122643. setAxisForLeftRight(axis: JoystickAxis): void;
  122644. /**
  122645. * Defines which axis you'd like to control for up & down
  122646. * @param axis defines the axis to use
  122647. */
  122648. setAxisForUpDown(axis: JoystickAxis): void;
  122649. /**
  122650. * Clears the canvas from the previous puck / container draw
  122651. */
  122652. private _clearPreviousDraw;
  122653. /**
  122654. * Loads `urlPath` to be used for the container's image
  122655. * @param urlPath defines the urlPath of an image to use
  122656. */
  122657. setContainerImage(urlPath: string): void;
  122658. /**
  122659. * Loads `urlPath` to be used for the puck's image
  122660. * @param urlPath defines the urlPath of an image to use
  122661. */
  122662. setPuckImage(urlPath: string): void;
  122663. /**
  122664. * Draws the Virtual Joystick's container
  122665. */
  122666. private _drawContainer;
  122667. /**
  122668. * Draws the Virtual Joystick's puck
  122669. */
  122670. private _drawPuck;
  122671. private _drawVirtualJoystick;
  122672. /**
  122673. * Release internal HTML canvas
  122674. */
  122675. releaseCanvas(): void;
  122676. }
  122677. }
  122678. declare module BABYLON {
  122679. interface FreeCameraInputsManager {
  122680. /**
  122681. * Add virtual joystick input support to the input manager.
  122682. * @returns the current input manager
  122683. */
  122684. addVirtualJoystick(): FreeCameraInputsManager;
  122685. }
  122686. /**
  122687. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  122688. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122689. */
  122690. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  122691. /**
  122692. * Defines the camera the input is attached to.
  122693. */
  122694. camera: FreeCamera;
  122695. private _leftjoystick;
  122696. private _rightjoystick;
  122697. /**
  122698. * Gets the left stick of the virtual joystick.
  122699. * @returns The virtual Joystick
  122700. */
  122701. getLeftJoystick(): VirtualJoystick;
  122702. /**
  122703. * Gets the right stick of the virtual joystick.
  122704. * @returns The virtual Joystick
  122705. */
  122706. getRightJoystick(): VirtualJoystick;
  122707. /**
  122708. * Update the current camera state depending on the inputs that have been used this frame.
  122709. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  122710. */
  122711. checkInputs(): void;
  122712. /**
  122713. * Attach the input controls to a specific dom element to get the input from.
  122714. * @param element Defines the element the controls should be listened from
  122715. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122716. */
  122717. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122718. /**
  122719. * Detach the current controls from the specified dom element.
  122720. * @param element Defines the element to stop listening the inputs from
  122721. */
  122722. detachControl(element: Nullable<HTMLElement>): void;
  122723. /**
  122724. * Gets the class name of the current intput.
  122725. * @returns the class name
  122726. */
  122727. getClassName(): string;
  122728. /**
  122729. * Get the friendly name associated with the input class.
  122730. * @returns the input friendly name
  122731. */
  122732. getSimpleName(): string;
  122733. }
  122734. }
  122735. declare module BABYLON {
  122736. /**
  122737. * This represents a FPS type of camera controlled by touch.
  122738. * This is like a universal camera minus the Gamepad controls.
  122739. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122740. */
  122741. export class TouchCamera extends FreeCamera {
  122742. /**
  122743. * Defines the touch sensibility for rotation.
  122744. * The higher the faster.
  122745. */
  122746. get touchAngularSensibility(): number;
  122747. set touchAngularSensibility(value: number);
  122748. /**
  122749. * Defines the touch sensibility for move.
  122750. * The higher the faster.
  122751. */
  122752. get touchMoveSensibility(): number;
  122753. set touchMoveSensibility(value: number);
  122754. /**
  122755. * Instantiates a new touch camera.
  122756. * This represents a FPS type of camera controlled by touch.
  122757. * This is like a universal camera minus the Gamepad controls.
  122758. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  122759. * @param name Define the name of the camera in the scene
  122760. * @param position Define the start position of the camera in the scene
  122761. * @param scene Define the scene the camera belongs to
  122762. */
  122763. constructor(name: string, position: Vector3, scene: Scene);
  122764. /**
  122765. * Gets the current object class name.
  122766. * @return the class name
  122767. */
  122768. getClassName(): string;
  122769. /** @hidden */
  122770. _setupInputs(): void;
  122771. }
  122772. }
  122773. declare module BABYLON {
  122774. /**
  122775. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  122776. * being tilted forward or back and left or right.
  122777. */
  122778. export class DeviceOrientationCamera extends FreeCamera {
  122779. private _initialQuaternion;
  122780. private _quaternionCache;
  122781. private _tmpDragQuaternion;
  122782. private _disablePointerInputWhenUsingDeviceOrientation;
  122783. /**
  122784. * Creates a new device orientation camera
  122785. * @param name The name of the camera
  122786. * @param position The start position camera
  122787. * @param scene The scene the camera belongs to
  122788. */
  122789. constructor(name: string, position: Vector3, scene: Scene);
  122790. /**
  122791. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  122792. */
  122793. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  122794. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  122795. private _dragFactor;
  122796. /**
  122797. * Enabled turning on the y axis when the orientation sensor is active
  122798. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  122799. */
  122800. enableHorizontalDragging(dragFactor?: number): void;
  122801. /**
  122802. * Gets the current instance class name ("DeviceOrientationCamera").
  122803. * This helps avoiding instanceof at run time.
  122804. * @returns the class name
  122805. */
  122806. getClassName(): string;
  122807. /**
  122808. * @hidden
  122809. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  122810. */
  122811. _checkInputs(): void;
  122812. /**
  122813. * Reset the camera to its default orientation on the specified axis only.
  122814. * @param axis The axis to reset
  122815. */
  122816. resetToCurrentRotation(axis?: Axis): void;
  122817. }
  122818. }
  122819. declare module BABYLON {
  122820. /**
  122821. * Defines supported buttons for XBox360 compatible gamepads
  122822. */
  122823. export enum Xbox360Button {
  122824. /** A */
  122825. A = 0,
  122826. /** B */
  122827. B = 1,
  122828. /** X */
  122829. X = 2,
  122830. /** Y */
  122831. Y = 3,
  122832. /** Left button */
  122833. LB = 4,
  122834. /** Right button */
  122835. RB = 5,
  122836. /** Back */
  122837. Back = 8,
  122838. /** Start */
  122839. Start = 9,
  122840. /** Left stick */
  122841. LeftStick = 10,
  122842. /** Right stick */
  122843. RightStick = 11
  122844. }
  122845. /** Defines values for XBox360 DPad */
  122846. export enum Xbox360Dpad {
  122847. /** Up */
  122848. Up = 12,
  122849. /** Down */
  122850. Down = 13,
  122851. /** Left */
  122852. Left = 14,
  122853. /** Right */
  122854. Right = 15
  122855. }
  122856. /**
  122857. * Defines a XBox360 gamepad
  122858. */
  122859. export class Xbox360Pad extends Gamepad {
  122860. private _leftTrigger;
  122861. private _rightTrigger;
  122862. private _onlefttriggerchanged;
  122863. private _onrighttriggerchanged;
  122864. private _onbuttondown;
  122865. private _onbuttonup;
  122866. private _ondpaddown;
  122867. private _ondpadup;
  122868. /** Observable raised when a button is pressed */
  122869. onButtonDownObservable: Observable<Xbox360Button>;
  122870. /** Observable raised when a button is released */
  122871. onButtonUpObservable: Observable<Xbox360Button>;
  122872. /** Observable raised when a pad is pressed */
  122873. onPadDownObservable: Observable<Xbox360Dpad>;
  122874. /** Observable raised when a pad is released */
  122875. onPadUpObservable: Observable<Xbox360Dpad>;
  122876. private _buttonA;
  122877. private _buttonB;
  122878. private _buttonX;
  122879. private _buttonY;
  122880. private _buttonBack;
  122881. private _buttonStart;
  122882. private _buttonLB;
  122883. private _buttonRB;
  122884. private _buttonLeftStick;
  122885. private _buttonRightStick;
  122886. private _dPadUp;
  122887. private _dPadDown;
  122888. private _dPadLeft;
  122889. private _dPadRight;
  122890. private _isXboxOnePad;
  122891. /**
  122892. * Creates a new XBox360 gamepad object
  122893. * @param id defines the id of this gamepad
  122894. * @param index defines its index
  122895. * @param gamepad defines the internal HTML gamepad object
  122896. * @param xboxOne defines if it is a XBox One gamepad
  122897. */
  122898. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  122899. /**
  122900. * Defines the callback to call when left trigger is pressed
  122901. * @param callback defines the callback to use
  122902. */
  122903. onlefttriggerchanged(callback: (value: number) => void): void;
  122904. /**
  122905. * Defines the callback to call when right trigger is pressed
  122906. * @param callback defines the callback to use
  122907. */
  122908. onrighttriggerchanged(callback: (value: number) => void): void;
  122909. /**
  122910. * Gets the left trigger value
  122911. */
  122912. get leftTrigger(): number;
  122913. /**
  122914. * Sets the left trigger value
  122915. */
  122916. set leftTrigger(newValue: number);
  122917. /**
  122918. * Gets the right trigger value
  122919. */
  122920. get rightTrigger(): number;
  122921. /**
  122922. * Sets the right trigger value
  122923. */
  122924. set rightTrigger(newValue: number);
  122925. /**
  122926. * Defines the callback to call when a button is pressed
  122927. * @param callback defines the callback to use
  122928. */
  122929. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  122930. /**
  122931. * Defines the callback to call when a button is released
  122932. * @param callback defines the callback to use
  122933. */
  122934. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  122935. /**
  122936. * Defines the callback to call when a pad is pressed
  122937. * @param callback defines the callback to use
  122938. */
  122939. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  122940. /**
  122941. * Defines the callback to call when a pad is released
  122942. * @param callback defines the callback to use
  122943. */
  122944. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  122945. private _setButtonValue;
  122946. private _setDPadValue;
  122947. /**
  122948. * Gets the value of the `A` button
  122949. */
  122950. get buttonA(): number;
  122951. /**
  122952. * Sets the value of the `A` button
  122953. */
  122954. set buttonA(value: number);
  122955. /**
  122956. * Gets the value of the `B` button
  122957. */
  122958. get buttonB(): number;
  122959. /**
  122960. * Sets the value of the `B` button
  122961. */
  122962. set buttonB(value: number);
  122963. /**
  122964. * Gets the value of the `X` button
  122965. */
  122966. get buttonX(): number;
  122967. /**
  122968. * Sets the value of the `X` button
  122969. */
  122970. set buttonX(value: number);
  122971. /**
  122972. * Gets the value of the `Y` button
  122973. */
  122974. get buttonY(): number;
  122975. /**
  122976. * Sets the value of the `Y` button
  122977. */
  122978. set buttonY(value: number);
  122979. /**
  122980. * Gets the value of the `Start` button
  122981. */
  122982. get buttonStart(): number;
  122983. /**
  122984. * Sets the value of the `Start` button
  122985. */
  122986. set buttonStart(value: number);
  122987. /**
  122988. * Gets the value of the `Back` button
  122989. */
  122990. get buttonBack(): number;
  122991. /**
  122992. * Sets the value of the `Back` button
  122993. */
  122994. set buttonBack(value: number);
  122995. /**
  122996. * Gets the value of the `Left` button
  122997. */
  122998. get buttonLB(): number;
  122999. /**
  123000. * Sets the value of the `Left` button
  123001. */
  123002. set buttonLB(value: number);
  123003. /**
  123004. * Gets the value of the `Right` button
  123005. */
  123006. get buttonRB(): number;
  123007. /**
  123008. * Sets the value of the `Right` button
  123009. */
  123010. set buttonRB(value: number);
  123011. /**
  123012. * Gets the value of the Left joystick
  123013. */
  123014. get buttonLeftStick(): number;
  123015. /**
  123016. * Sets the value of the Left joystick
  123017. */
  123018. set buttonLeftStick(value: number);
  123019. /**
  123020. * Gets the value of the Right joystick
  123021. */
  123022. get buttonRightStick(): number;
  123023. /**
  123024. * Sets the value of the Right joystick
  123025. */
  123026. set buttonRightStick(value: number);
  123027. /**
  123028. * Gets the value of D-pad up
  123029. */
  123030. get dPadUp(): number;
  123031. /**
  123032. * Sets the value of D-pad up
  123033. */
  123034. set dPadUp(value: number);
  123035. /**
  123036. * Gets the value of D-pad down
  123037. */
  123038. get dPadDown(): number;
  123039. /**
  123040. * Sets the value of D-pad down
  123041. */
  123042. set dPadDown(value: number);
  123043. /**
  123044. * Gets the value of D-pad left
  123045. */
  123046. get dPadLeft(): number;
  123047. /**
  123048. * Sets the value of D-pad left
  123049. */
  123050. set dPadLeft(value: number);
  123051. /**
  123052. * Gets the value of D-pad right
  123053. */
  123054. get dPadRight(): number;
  123055. /**
  123056. * Sets the value of D-pad right
  123057. */
  123058. set dPadRight(value: number);
  123059. /**
  123060. * Force the gamepad to synchronize with device values
  123061. */
  123062. update(): void;
  123063. /**
  123064. * Disposes the gamepad
  123065. */
  123066. dispose(): void;
  123067. }
  123068. }
  123069. declare module BABYLON {
  123070. /**
  123071. * Defines supported buttons for DualShock compatible gamepads
  123072. */
  123073. export enum DualShockButton {
  123074. /** Cross */
  123075. Cross = 0,
  123076. /** Circle */
  123077. Circle = 1,
  123078. /** Square */
  123079. Square = 2,
  123080. /** Triangle */
  123081. Triangle = 3,
  123082. /** L1 */
  123083. L1 = 4,
  123084. /** R1 */
  123085. R1 = 5,
  123086. /** Share */
  123087. Share = 8,
  123088. /** Options */
  123089. Options = 9,
  123090. /** Left stick */
  123091. LeftStick = 10,
  123092. /** Right stick */
  123093. RightStick = 11
  123094. }
  123095. /** Defines values for DualShock DPad */
  123096. export enum DualShockDpad {
  123097. /** Up */
  123098. Up = 12,
  123099. /** Down */
  123100. Down = 13,
  123101. /** Left */
  123102. Left = 14,
  123103. /** Right */
  123104. Right = 15
  123105. }
  123106. /**
  123107. * Defines a DualShock gamepad
  123108. */
  123109. export class DualShockPad extends Gamepad {
  123110. private _leftTrigger;
  123111. private _rightTrigger;
  123112. private _onlefttriggerchanged;
  123113. private _onrighttriggerchanged;
  123114. private _onbuttondown;
  123115. private _onbuttonup;
  123116. private _ondpaddown;
  123117. private _ondpadup;
  123118. /** Observable raised when a button is pressed */
  123119. onButtonDownObservable: Observable<DualShockButton>;
  123120. /** Observable raised when a button is released */
  123121. onButtonUpObservable: Observable<DualShockButton>;
  123122. /** Observable raised when a pad is pressed */
  123123. onPadDownObservable: Observable<DualShockDpad>;
  123124. /** Observable raised when a pad is released */
  123125. onPadUpObservable: Observable<DualShockDpad>;
  123126. private _buttonCross;
  123127. private _buttonCircle;
  123128. private _buttonSquare;
  123129. private _buttonTriangle;
  123130. private _buttonShare;
  123131. private _buttonOptions;
  123132. private _buttonL1;
  123133. private _buttonR1;
  123134. private _buttonLeftStick;
  123135. private _buttonRightStick;
  123136. private _dPadUp;
  123137. private _dPadDown;
  123138. private _dPadLeft;
  123139. private _dPadRight;
  123140. /**
  123141. * Creates a new DualShock gamepad object
  123142. * @param id defines the id of this gamepad
  123143. * @param index defines its index
  123144. * @param gamepad defines the internal HTML gamepad object
  123145. */
  123146. constructor(id: string, index: number, gamepad: any);
  123147. /**
  123148. * Defines the callback to call when left trigger is pressed
  123149. * @param callback defines the callback to use
  123150. */
  123151. onlefttriggerchanged(callback: (value: number) => void): void;
  123152. /**
  123153. * Defines the callback to call when right trigger is pressed
  123154. * @param callback defines the callback to use
  123155. */
  123156. onrighttriggerchanged(callback: (value: number) => void): void;
  123157. /**
  123158. * Gets the left trigger value
  123159. */
  123160. get leftTrigger(): number;
  123161. /**
  123162. * Sets the left trigger value
  123163. */
  123164. set leftTrigger(newValue: number);
  123165. /**
  123166. * Gets the right trigger value
  123167. */
  123168. get rightTrigger(): number;
  123169. /**
  123170. * Sets the right trigger value
  123171. */
  123172. set rightTrigger(newValue: number);
  123173. /**
  123174. * Defines the callback to call when a button is pressed
  123175. * @param callback defines the callback to use
  123176. */
  123177. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  123178. /**
  123179. * Defines the callback to call when a button is released
  123180. * @param callback defines the callback to use
  123181. */
  123182. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  123183. /**
  123184. * Defines the callback to call when a pad is pressed
  123185. * @param callback defines the callback to use
  123186. */
  123187. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  123188. /**
  123189. * Defines the callback to call when a pad is released
  123190. * @param callback defines the callback to use
  123191. */
  123192. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  123193. private _setButtonValue;
  123194. private _setDPadValue;
  123195. /**
  123196. * Gets the value of the `Cross` button
  123197. */
  123198. get buttonCross(): number;
  123199. /**
  123200. * Sets the value of the `Cross` button
  123201. */
  123202. set buttonCross(value: number);
  123203. /**
  123204. * Gets the value of the `Circle` button
  123205. */
  123206. get buttonCircle(): number;
  123207. /**
  123208. * Sets the value of the `Circle` button
  123209. */
  123210. set buttonCircle(value: number);
  123211. /**
  123212. * Gets the value of the `Square` button
  123213. */
  123214. get buttonSquare(): number;
  123215. /**
  123216. * Sets the value of the `Square` button
  123217. */
  123218. set buttonSquare(value: number);
  123219. /**
  123220. * Gets the value of the `Triangle` button
  123221. */
  123222. get buttonTriangle(): number;
  123223. /**
  123224. * Sets the value of the `Triangle` button
  123225. */
  123226. set buttonTriangle(value: number);
  123227. /**
  123228. * Gets the value of the `Options` button
  123229. */
  123230. get buttonOptions(): number;
  123231. /**
  123232. * Sets the value of the `Options` button
  123233. */
  123234. set buttonOptions(value: number);
  123235. /**
  123236. * Gets the value of the `Share` button
  123237. */
  123238. get buttonShare(): number;
  123239. /**
  123240. * Sets the value of the `Share` button
  123241. */
  123242. set buttonShare(value: number);
  123243. /**
  123244. * Gets the value of the `L1` button
  123245. */
  123246. get buttonL1(): number;
  123247. /**
  123248. * Sets the value of the `L1` button
  123249. */
  123250. set buttonL1(value: number);
  123251. /**
  123252. * Gets the value of the `R1` button
  123253. */
  123254. get buttonR1(): number;
  123255. /**
  123256. * Sets the value of the `R1` button
  123257. */
  123258. set buttonR1(value: number);
  123259. /**
  123260. * Gets the value of the Left joystick
  123261. */
  123262. get buttonLeftStick(): number;
  123263. /**
  123264. * Sets the value of the Left joystick
  123265. */
  123266. set buttonLeftStick(value: number);
  123267. /**
  123268. * Gets the value of the Right joystick
  123269. */
  123270. get buttonRightStick(): number;
  123271. /**
  123272. * Sets the value of the Right joystick
  123273. */
  123274. set buttonRightStick(value: number);
  123275. /**
  123276. * Gets the value of D-pad up
  123277. */
  123278. get dPadUp(): number;
  123279. /**
  123280. * Sets the value of D-pad up
  123281. */
  123282. set dPadUp(value: number);
  123283. /**
  123284. * Gets the value of D-pad down
  123285. */
  123286. get dPadDown(): number;
  123287. /**
  123288. * Sets the value of D-pad down
  123289. */
  123290. set dPadDown(value: number);
  123291. /**
  123292. * Gets the value of D-pad left
  123293. */
  123294. get dPadLeft(): number;
  123295. /**
  123296. * Sets the value of D-pad left
  123297. */
  123298. set dPadLeft(value: number);
  123299. /**
  123300. * Gets the value of D-pad right
  123301. */
  123302. get dPadRight(): number;
  123303. /**
  123304. * Sets the value of D-pad right
  123305. */
  123306. set dPadRight(value: number);
  123307. /**
  123308. * Force the gamepad to synchronize with device values
  123309. */
  123310. update(): void;
  123311. /**
  123312. * Disposes the gamepad
  123313. */
  123314. dispose(): void;
  123315. }
  123316. }
  123317. declare module BABYLON {
  123318. /**
  123319. * Manager for handling gamepads
  123320. */
  123321. export class GamepadManager {
  123322. private _scene?;
  123323. private _babylonGamepads;
  123324. private _oneGamepadConnected;
  123325. /** @hidden */
  123326. _isMonitoring: boolean;
  123327. private _gamepadEventSupported;
  123328. private _gamepadSupport?;
  123329. /**
  123330. * observable to be triggered when the gamepad controller has been connected
  123331. */
  123332. onGamepadConnectedObservable: Observable<Gamepad>;
  123333. /**
  123334. * observable to be triggered when the gamepad controller has been disconnected
  123335. */
  123336. onGamepadDisconnectedObservable: Observable<Gamepad>;
  123337. private _onGamepadConnectedEvent;
  123338. private _onGamepadDisconnectedEvent;
  123339. /**
  123340. * Initializes the gamepad manager
  123341. * @param _scene BabylonJS scene
  123342. */
  123343. constructor(_scene?: Scene | undefined);
  123344. /**
  123345. * The gamepads in the game pad manager
  123346. */
  123347. get gamepads(): Gamepad[];
  123348. /**
  123349. * Get the gamepad controllers based on type
  123350. * @param type The type of gamepad controller
  123351. * @returns Nullable gamepad
  123352. */
  123353. getGamepadByType(type?: number): Nullable<Gamepad>;
  123354. /**
  123355. * Disposes the gamepad manager
  123356. */
  123357. dispose(): void;
  123358. private _addNewGamepad;
  123359. private _startMonitoringGamepads;
  123360. private _stopMonitoringGamepads;
  123361. /** @hidden */
  123362. _checkGamepadsStatus(): void;
  123363. private _updateGamepadObjects;
  123364. }
  123365. }
  123366. declare module BABYLON {
  123367. interface Scene {
  123368. /** @hidden */
  123369. _gamepadManager: Nullable<GamepadManager>;
  123370. /**
  123371. * Gets the gamepad manager associated with the scene
  123372. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  123373. */
  123374. gamepadManager: GamepadManager;
  123375. }
  123376. /**
  123377. * Interface representing a free camera inputs manager
  123378. */
  123379. interface FreeCameraInputsManager {
  123380. /**
  123381. * Adds gamepad input support to the FreeCameraInputsManager.
  123382. * @returns the FreeCameraInputsManager
  123383. */
  123384. addGamepad(): FreeCameraInputsManager;
  123385. }
  123386. /**
  123387. * Interface representing an arc rotate camera inputs manager
  123388. */
  123389. interface ArcRotateCameraInputsManager {
  123390. /**
  123391. * Adds gamepad input support to the ArcRotateCamera InputManager.
  123392. * @returns the camera inputs manager
  123393. */
  123394. addGamepad(): ArcRotateCameraInputsManager;
  123395. }
  123396. /**
  123397. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  123398. */
  123399. export class GamepadSystemSceneComponent implements ISceneComponent {
  123400. /**
  123401. * The component name helpfull to identify the component in the list of scene components.
  123402. */
  123403. readonly name: string;
  123404. /**
  123405. * The scene the component belongs to.
  123406. */
  123407. scene: Scene;
  123408. /**
  123409. * Creates a new instance of the component for the given scene
  123410. * @param scene Defines the scene to register the component in
  123411. */
  123412. constructor(scene: Scene);
  123413. /**
  123414. * Registers the component in a given scene
  123415. */
  123416. register(): void;
  123417. /**
  123418. * Rebuilds the elements related to this component in case of
  123419. * context lost for instance.
  123420. */
  123421. rebuild(): void;
  123422. /**
  123423. * Disposes the component and the associated ressources
  123424. */
  123425. dispose(): void;
  123426. private _beforeCameraUpdate;
  123427. }
  123428. }
  123429. declare module BABYLON {
  123430. /**
  123431. * 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,
  123432. * which still works and will still be found in many Playgrounds.
  123433. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123434. */
  123435. export class UniversalCamera extends TouchCamera {
  123436. /**
  123437. * Defines the gamepad rotation sensiblity.
  123438. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  123439. */
  123440. get gamepadAngularSensibility(): number;
  123441. set gamepadAngularSensibility(value: number);
  123442. /**
  123443. * Defines the gamepad move sensiblity.
  123444. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  123445. */
  123446. get gamepadMoveSensibility(): number;
  123447. set gamepadMoveSensibility(value: number);
  123448. /**
  123449. * 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,
  123450. * which still works and will still be found in many Playgrounds.
  123451. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123452. * @param name Define the name of the camera in the scene
  123453. * @param position Define the start position of the camera in the scene
  123454. * @param scene Define the scene the camera belongs to
  123455. */
  123456. constructor(name: string, position: Vector3, scene: Scene);
  123457. /**
  123458. * Gets the current object class name.
  123459. * @return the class name
  123460. */
  123461. getClassName(): string;
  123462. }
  123463. }
  123464. declare module BABYLON {
  123465. /**
  123466. * This represents a FPS type of camera. This is only here for back compat purpose.
  123467. * Please use the UniversalCamera instead as both are identical.
  123468. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123469. */
  123470. export class GamepadCamera extends UniversalCamera {
  123471. /**
  123472. * Instantiates a new Gamepad Camera
  123473. * This represents a FPS type of camera. This is only here for back compat purpose.
  123474. * Please use the UniversalCamera instead as both are identical.
  123475. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  123476. * @param name Define the name of the camera in the scene
  123477. * @param position Define the start position of the camera in the scene
  123478. * @param scene Define the scene the camera belongs to
  123479. */
  123480. constructor(name: string, position: Vector3, scene: Scene);
  123481. /**
  123482. * Gets the current object class name.
  123483. * @return the class name
  123484. */
  123485. getClassName(): string;
  123486. }
  123487. }
  123488. declare module BABYLON {
  123489. /** @hidden */
  123490. export var passPixelShader: {
  123491. name: string;
  123492. shader: string;
  123493. };
  123494. }
  123495. declare module BABYLON {
  123496. /** @hidden */
  123497. export var passCubePixelShader: {
  123498. name: string;
  123499. shader: string;
  123500. };
  123501. }
  123502. declare module BABYLON {
  123503. /**
  123504. * PassPostProcess which produces an output the same as it's input
  123505. */
  123506. export class PassPostProcess extends PostProcess {
  123507. /**
  123508. * Creates the PassPostProcess
  123509. * @param name The name of the effect.
  123510. * @param options The required width/height ratio to downsize to before computing the render pass.
  123511. * @param camera The camera to apply the render pass to.
  123512. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123513. * @param engine The engine which the post process will be applied. (default: current engine)
  123514. * @param reusable If the post process can be reused on the same frame. (default: false)
  123515. * @param textureType The type of texture to be used when performing the post processing.
  123516. * @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)
  123517. */
  123518. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123519. }
  123520. /**
  123521. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  123522. */
  123523. export class PassCubePostProcess extends PostProcess {
  123524. private _face;
  123525. /**
  123526. * Gets or sets the cube face to display.
  123527. * * 0 is +X
  123528. * * 1 is -X
  123529. * * 2 is +Y
  123530. * * 3 is -Y
  123531. * * 4 is +Z
  123532. * * 5 is -Z
  123533. */
  123534. get face(): number;
  123535. set face(value: number);
  123536. /**
  123537. * Creates the PassCubePostProcess
  123538. * @param name The name of the effect.
  123539. * @param options The required width/height ratio to downsize to before computing the render pass.
  123540. * @param camera The camera to apply the render pass to.
  123541. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  123542. * @param engine The engine which the post process will be applied. (default: current engine)
  123543. * @param reusable If the post process can be reused on the same frame. (default: false)
  123544. * @param textureType The type of texture to be used when performing the post processing.
  123545. * @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)
  123546. */
  123547. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  123548. }
  123549. }
  123550. declare module BABYLON {
  123551. /** @hidden */
  123552. export var anaglyphPixelShader: {
  123553. name: string;
  123554. shader: string;
  123555. };
  123556. }
  123557. declare module BABYLON {
  123558. /**
  123559. * Postprocess used to generate anaglyphic rendering
  123560. */
  123561. export class AnaglyphPostProcess extends PostProcess {
  123562. private _passedProcess;
  123563. /**
  123564. * Creates a new AnaglyphPostProcess
  123565. * @param name defines postprocess name
  123566. * @param options defines creation options or target ratio scale
  123567. * @param rigCameras defines cameras using this postprocess
  123568. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  123569. * @param engine defines hosting engine
  123570. * @param reusable defines if the postprocess will be reused multiple times per frame
  123571. */
  123572. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  123573. }
  123574. }
  123575. declare module BABYLON {
  123576. /**
  123577. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  123578. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123579. */
  123580. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  123581. /**
  123582. * Creates a new AnaglyphArcRotateCamera
  123583. * @param name defines camera name
  123584. * @param alpha defines alpha angle (in radians)
  123585. * @param beta defines beta angle (in radians)
  123586. * @param radius defines radius
  123587. * @param target defines camera target
  123588. * @param interaxialDistance defines distance between each color axis
  123589. * @param scene defines the hosting scene
  123590. */
  123591. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  123592. /**
  123593. * Gets camera class name
  123594. * @returns AnaglyphArcRotateCamera
  123595. */
  123596. getClassName(): string;
  123597. }
  123598. }
  123599. declare module BABYLON {
  123600. /**
  123601. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  123602. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123603. */
  123604. export class AnaglyphFreeCamera extends FreeCamera {
  123605. /**
  123606. * Creates a new AnaglyphFreeCamera
  123607. * @param name defines camera name
  123608. * @param position defines initial position
  123609. * @param interaxialDistance defines distance between each color axis
  123610. * @param scene defines the hosting scene
  123611. */
  123612. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123613. /**
  123614. * Gets camera class name
  123615. * @returns AnaglyphFreeCamera
  123616. */
  123617. getClassName(): string;
  123618. }
  123619. }
  123620. declare module BABYLON {
  123621. /**
  123622. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  123623. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123624. */
  123625. export class AnaglyphGamepadCamera extends GamepadCamera {
  123626. /**
  123627. * Creates a new AnaglyphGamepadCamera
  123628. * @param name defines camera name
  123629. * @param position defines initial position
  123630. * @param interaxialDistance defines distance between each color axis
  123631. * @param scene defines the hosting scene
  123632. */
  123633. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123634. /**
  123635. * Gets camera class name
  123636. * @returns AnaglyphGamepadCamera
  123637. */
  123638. getClassName(): string;
  123639. }
  123640. }
  123641. declare module BABYLON {
  123642. /**
  123643. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  123644. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  123645. */
  123646. export class AnaglyphUniversalCamera extends UniversalCamera {
  123647. /**
  123648. * Creates a new AnaglyphUniversalCamera
  123649. * @param name defines camera name
  123650. * @param position defines initial position
  123651. * @param interaxialDistance defines distance between each color axis
  123652. * @param scene defines the hosting scene
  123653. */
  123654. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  123655. /**
  123656. * Gets camera class name
  123657. * @returns AnaglyphUniversalCamera
  123658. */
  123659. getClassName(): string;
  123660. }
  123661. }
  123662. declare module BABYLON {
  123663. /**
  123664. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  123665. * @see https://doc.babylonjs.com/features/cameras
  123666. */
  123667. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  123668. /**
  123669. * Creates a new StereoscopicArcRotateCamera
  123670. * @param name defines camera name
  123671. * @param alpha defines alpha angle (in radians)
  123672. * @param beta defines beta angle (in radians)
  123673. * @param radius defines radius
  123674. * @param target defines camera target
  123675. * @param interaxialDistance defines distance between each color axis
  123676. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123677. * @param scene defines the hosting scene
  123678. */
  123679. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123680. /**
  123681. * Gets camera class name
  123682. * @returns StereoscopicArcRotateCamera
  123683. */
  123684. getClassName(): string;
  123685. }
  123686. }
  123687. declare module BABYLON {
  123688. /**
  123689. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  123690. * @see https://doc.babylonjs.com/features/cameras
  123691. */
  123692. export class StereoscopicFreeCamera extends FreeCamera {
  123693. /**
  123694. * Creates a new StereoscopicFreeCamera
  123695. * @param name defines camera name
  123696. * @param position defines initial position
  123697. * @param interaxialDistance defines distance between each color axis
  123698. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123699. * @param scene defines the hosting scene
  123700. */
  123701. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123702. /**
  123703. * Gets camera class name
  123704. * @returns StereoscopicFreeCamera
  123705. */
  123706. getClassName(): string;
  123707. }
  123708. }
  123709. declare module BABYLON {
  123710. /**
  123711. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  123712. * @see https://doc.babylonjs.com/features/cameras
  123713. */
  123714. export class StereoscopicGamepadCamera extends GamepadCamera {
  123715. /**
  123716. * Creates a new StereoscopicGamepadCamera
  123717. * @param name defines camera name
  123718. * @param position defines initial position
  123719. * @param interaxialDistance defines distance between each color axis
  123720. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123721. * @param scene defines the hosting scene
  123722. */
  123723. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123724. /**
  123725. * Gets camera class name
  123726. * @returns StereoscopicGamepadCamera
  123727. */
  123728. getClassName(): string;
  123729. }
  123730. }
  123731. declare module BABYLON {
  123732. /**
  123733. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  123734. * @see https://doc.babylonjs.com/features/cameras
  123735. */
  123736. export class StereoscopicUniversalCamera extends UniversalCamera {
  123737. /**
  123738. * Creates a new StereoscopicUniversalCamera
  123739. * @param name defines camera name
  123740. * @param position defines initial position
  123741. * @param interaxialDistance defines distance between each color axis
  123742. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  123743. * @param scene defines the hosting scene
  123744. */
  123745. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  123746. /**
  123747. * Gets camera class name
  123748. * @returns StereoscopicUniversalCamera
  123749. */
  123750. getClassName(): string;
  123751. }
  123752. }
  123753. declare module BABYLON {
  123754. /**
  123755. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  123756. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123757. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123758. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123759. */
  123760. export class VirtualJoysticksCamera extends FreeCamera {
  123761. /**
  123762. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  123763. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  123764. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  123765. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  123766. * @param name Define the name of the camera in the scene
  123767. * @param position Define the start position of the camera in the scene
  123768. * @param scene Define the scene the camera belongs to
  123769. */
  123770. constructor(name: string, position: Vector3, scene: Scene);
  123771. /**
  123772. * Gets the current object class name.
  123773. * @return the class name
  123774. */
  123775. getClassName(): string;
  123776. }
  123777. }
  123778. declare module BABYLON {
  123779. /**
  123780. * This represents all the required metrics to create a VR camera.
  123781. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  123782. */
  123783. export class VRCameraMetrics {
  123784. /**
  123785. * Define the horizontal resolution off the screen.
  123786. */
  123787. hResolution: number;
  123788. /**
  123789. * Define the vertical resolution off the screen.
  123790. */
  123791. vResolution: number;
  123792. /**
  123793. * Define the horizontal screen size.
  123794. */
  123795. hScreenSize: number;
  123796. /**
  123797. * Define the vertical screen size.
  123798. */
  123799. vScreenSize: number;
  123800. /**
  123801. * Define the vertical screen center position.
  123802. */
  123803. vScreenCenter: number;
  123804. /**
  123805. * Define the distance of the eyes to the screen.
  123806. */
  123807. eyeToScreenDistance: number;
  123808. /**
  123809. * Define the distance between both lenses
  123810. */
  123811. lensSeparationDistance: number;
  123812. /**
  123813. * Define the distance between both viewer's eyes.
  123814. */
  123815. interpupillaryDistance: number;
  123816. /**
  123817. * Define the distortion factor of the VR postprocess.
  123818. * Please, touch with care.
  123819. */
  123820. distortionK: number[];
  123821. /**
  123822. * Define the chromatic aberration correction factors for the VR post process.
  123823. */
  123824. chromaAbCorrection: number[];
  123825. /**
  123826. * Define the scale factor of the post process.
  123827. * The smaller the better but the slower.
  123828. */
  123829. postProcessScaleFactor: number;
  123830. /**
  123831. * Define an offset for the lens center.
  123832. */
  123833. lensCenterOffset: number;
  123834. /**
  123835. * Define if the current vr camera should compensate the distortion of the lense or not.
  123836. */
  123837. compensateDistortion: boolean;
  123838. /**
  123839. * Defines if multiview should be enabled when rendering (Default: false)
  123840. */
  123841. multiviewEnabled: boolean;
  123842. /**
  123843. * Gets the rendering aspect ratio based on the provided resolutions.
  123844. */
  123845. get aspectRatio(): number;
  123846. /**
  123847. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  123848. */
  123849. get aspectRatioFov(): number;
  123850. /**
  123851. * @hidden
  123852. */
  123853. get leftHMatrix(): Matrix;
  123854. /**
  123855. * @hidden
  123856. */
  123857. get rightHMatrix(): Matrix;
  123858. /**
  123859. * @hidden
  123860. */
  123861. get leftPreViewMatrix(): Matrix;
  123862. /**
  123863. * @hidden
  123864. */
  123865. get rightPreViewMatrix(): Matrix;
  123866. /**
  123867. * Get the default VRMetrics based on the most generic setup.
  123868. * @returns the default vr metrics
  123869. */
  123870. static GetDefault(): VRCameraMetrics;
  123871. }
  123872. }
  123873. declare module BABYLON {
  123874. /** @hidden */
  123875. export var vrDistortionCorrectionPixelShader: {
  123876. name: string;
  123877. shader: string;
  123878. };
  123879. }
  123880. declare module BABYLON {
  123881. /**
  123882. * VRDistortionCorrectionPostProcess used for mobile VR
  123883. */
  123884. export class VRDistortionCorrectionPostProcess extends PostProcess {
  123885. private _isRightEye;
  123886. private _distortionFactors;
  123887. private _postProcessScaleFactor;
  123888. private _lensCenterOffset;
  123889. private _scaleIn;
  123890. private _scaleFactor;
  123891. private _lensCenter;
  123892. /**
  123893. * Initializes the VRDistortionCorrectionPostProcess
  123894. * @param name The name of the effect.
  123895. * @param camera The camera to apply the render pass to.
  123896. * @param isRightEye If this is for the right eye distortion
  123897. * @param vrMetrics All the required metrics for the VR camera
  123898. */
  123899. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  123900. }
  123901. }
  123902. declare module BABYLON {
  123903. /**
  123904. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  123905. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123906. */
  123907. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  123908. /**
  123909. * Creates a new VRDeviceOrientationArcRotateCamera
  123910. * @param name defines camera name
  123911. * @param alpha defines the camera rotation along the logitudinal axis
  123912. * @param beta defines the camera rotation along the latitudinal axis
  123913. * @param radius defines the camera distance from its target
  123914. * @param target defines the camera target
  123915. * @param scene defines the scene the camera belongs to
  123916. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123917. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123918. */
  123919. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123920. /**
  123921. * Gets camera class name
  123922. * @returns VRDeviceOrientationArcRotateCamera
  123923. */
  123924. getClassName(): string;
  123925. }
  123926. }
  123927. declare module BABYLON {
  123928. /**
  123929. * Camera used to simulate VR rendering (based on FreeCamera)
  123930. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123931. */
  123932. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  123933. /**
  123934. * Creates a new VRDeviceOrientationFreeCamera
  123935. * @param name defines camera name
  123936. * @param position defines the start position of the camera
  123937. * @param scene defines the scene the camera belongs to
  123938. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123939. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123940. */
  123941. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123942. /**
  123943. * Gets camera class name
  123944. * @returns VRDeviceOrientationFreeCamera
  123945. */
  123946. getClassName(): string;
  123947. }
  123948. }
  123949. declare module BABYLON {
  123950. /**
  123951. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  123952. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  123953. */
  123954. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  123955. /**
  123956. * Creates a new VRDeviceOrientationGamepadCamera
  123957. * @param name defines camera name
  123958. * @param position defines the start position of the camera
  123959. * @param scene defines the scene the camera belongs to
  123960. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  123961. * @param vrCameraMetrics defines the vr metrics associated to the camera
  123962. */
  123963. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  123964. /**
  123965. * Gets camera class name
  123966. * @returns VRDeviceOrientationGamepadCamera
  123967. */
  123968. getClassName(): string;
  123969. }
  123970. }
  123971. declare module BABYLON {
  123972. /**
  123973. * A class extending Texture allowing drawing on a texture
  123974. * @see https://doc.babylonjs.com/how_to/dynamictexture
  123975. */
  123976. export class DynamicTexture extends Texture {
  123977. private _generateMipMaps;
  123978. private _canvas;
  123979. private _context;
  123980. /**
  123981. * Creates a DynamicTexture
  123982. * @param name defines the name of the texture
  123983. * @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
  123984. * @param scene defines the scene where you want the texture
  123985. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  123986. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  123987. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  123988. */
  123989. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  123990. /**
  123991. * Get the current class name of the texture useful for serialization or dynamic coding.
  123992. * @returns "DynamicTexture"
  123993. */
  123994. getClassName(): string;
  123995. /**
  123996. * Gets the current state of canRescale
  123997. */
  123998. get canRescale(): boolean;
  123999. private _recreate;
  124000. /**
  124001. * Scales the texture
  124002. * @param ratio the scale factor to apply to both width and height
  124003. */
  124004. scale(ratio: number): void;
  124005. /**
  124006. * Resizes the texture
  124007. * @param width the new width
  124008. * @param height the new height
  124009. */
  124010. scaleTo(width: number, height: number): void;
  124011. /**
  124012. * Gets the context of the canvas used by the texture
  124013. * @returns the canvas context of the dynamic texture
  124014. */
  124015. getContext(): CanvasRenderingContext2D;
  124016. /**
  124017. * Clears the texture
  124018. */
  124019. clear(): void;
  124020. /**
  124021. * Updates the texture
  124022. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124023. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  124024. */
  124025. update(invertY?: boolean, premulAlpha?: boolean): void;
  124026. /**
  124027. * Draws text onto the texture
  124028. * @param text defines the text to be drawn
  124029. * @param x defines the placement of the text from the left
  124030. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  124031. * @param font defines the font to be used with font-style, font-size, font-name
  124032. * @param color defines the color used for the text
  124033. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  124034. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  124035. * @param update defines whether texture is immediately update (default is true)
  124036. */
  124037. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  124038. /**
  124039. * Clones the texture
  124040. * @returns the clone of the texture.
  124041. */
  124042. clone(): DynamicTexture;
  124043. /**
  124044. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  124045. * @returns a serialized dynamic texture object
  124046. */
  124047. serialize(): any;
  124048. private _IsCanvasElement;
  124049. /** @hidden */
  124050. _rebuild(): void;
  124051. }
  124052. }
  124053. declare module BABYLON {
  124054. /** @hidden */
  124055. export var imageProcessingPixelShader: {
  124056. name: string;
  124057. shader: string;
  124058. };
  124059. }
  124060. declare module BABYLON {
  124061. /**
  124062. * ImageProcessingPostProcess
  124063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  124064. */
  124065. export class ImageProcessingPostProcess extends PostProcess {
  124066. /**
  124067. * Default configuration related to image processing available in the PBR Material.
  124068. */
  124069. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124070. /**
  124071. * Gets the image processing configuration used either in this material.
  124072. */
  124073. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124074. /**
  124075. * Sets the Default image processing configuration used either in the this material.
  124076. *
  124077. * If sets to null, the scene one is in use.
  124078. */
  124079. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124080. /**
  124081. * Keep track of the image processing observer to allow dispose and replace.
  124082. */
  124083. private _imageProcessingObserver;
  124084. /**
  124085. * Attaches a new image processing configuration to the PBR Material.
  124086. * @param configuration
  124087. */
  124088. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  124089. /**
  124090. * If the post process is supported.
  124091. */
  124092. get isSupported(): boolean;
  124093. /**
  124094. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124095. */
  124096. get colorCurves(): Nullable<ColorCurves>;
  124097. /**
  124098. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  124099. */
  124100. set colorCurves(value: Nullable<ColorCurves>);
  124101. /**
  124102. * Gets wether the color curves effect is enabled.
  124103. */
  124104. get colorCurvesEnabled(): boolean;
  124105. /**
  124106. * Sets wether the color curves effect is enabled.
  124107. */
  124108. set colorCurvesEnabled(value: boolean);
  124109. /**
  124110. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124111. */
  124112. get colorGradingTexture(): Nullable<BaseTexture>;
  124113. /**
  124114. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  124115. */
  124116. set colorGradingTexture(value: Nullable<BaseTexture>);
  124117. /**
  124118. * Gets wether the color grading effect is enabled.
  124119. */
  124120. get colorGradingEnabled(): boolean;
  124121. /**
  124122. * Gets wether the color grading effect is enabled.
  124123. */
  124124. set colorGradingEnabled(value: boolean);
  124125. /**
  124126. * Gets exposure used in the effect.
  124127. */
  124128. get exposure(): number;
  124129. /**
  124130. * Sets exposure used in the effect.
  124131. */
  124132. set exposure(value: number);
  124133. /**
  124134. * Gets wether tonemapping is enabled or not.
  124135. */
  124136. get toneMappingEnabled(): boolean;
  124137. /**
  124138. * Sets wether tonemapping is enabled or not
  124139. */
  124140. set toneMappingEnabled(value: boolean);
  124141. /**
  124142. * Gets the type of tone mapping effect.
  124143. */
  124144. get toneMappingType(): number;
  124145. /**
  124146. * Sets the type of tone mapping effect.
  124147. */
  124148. set toneMappingType(value: number);
  124149. /**
  124150. * Gets contrast used in the effect.
  124151. */
  124152. get contrast(): number;
  124153. /**
  124154. * Sets contrast used in the effect.
  124155. */
  124156. set contrast(value: number);
  124157. /**
  124158. * Gets Vignette stretch size.
  124159. */
  124160. get vignetteStretch(): number;
  124161. /**
  124162. * Sets Vignette stretch size.
  124163. */
  124164. set vignetteStretch(value: number);
  124165. /**
  124166. * Gets Vignette centre X Offset.
  124167. */
  124168. get vignetteCentreX(): number;
  124169. /**
  124170. * Sets Vignette centre X Offset.
  124171. */
  124172. set vignetteCentreX(value: number);
  124173. /**
  124174. * Gets Vignette centre Y Offset.
  124175. */
  124176. get vignetteCentreY(): number;
  124177. /**
  124178. * Sets Vignette centre Y Offset.
  124179. */
  124180. set vignetteCentreY(value: number);
  124181. /**
  124182. * Gets Vignette weight or intensity of the vignette effect.
  124183. */
  124184. get vignetteWeight(): number;
  124185. /**
  124186. * Sets Vignette weight or intensity of the vignette effect.
  124187. */
  124188. set vignetteWeight(value: number);
  124189. /**
  124190. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124191. * if vignetteEnabled is set to true.
  124192. */
  124193. get vignetteColor(): Color4;
  124194. /**
  124195. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  124196. * if vignetteEnabled is set to true.
  124197. */
  124198. set vignetteColor(value: Color4);
  124199. /**
  124200. * Gets Camera field of view used by the Vignette effect.
  124201. */
  124202. get vignetteCameraFov(): number;
  124203. /**
  124204. * Sets Camera field of view used by the Vignette effect.
  124205. */
  124206. set vignetteCameraFov(value: number);
  124207. /**
  124208. * Gets the vignette blend mode allowing different kind of effect.
  124209. */
  124210. get vignetteBlendMode(): number;
  124211. /**
  124212. * Sets the vignette blend mode allowing different kind of effect.
  124213. */
  124214. set vignetteBlendMode(value: number);
  124215. /**
  124216. * Gets wether the vignette effect is enabled.
  124217. */
  124218. get vignetteEnabled(): boolean;
  124219. /**
  124220. * Sets wether the vignette effect is enabled.
  124221. */
  124222. set vignetteEnabled(value: boolean);
  124223. private _fromLinearSpace;
  124224. /**
  124225. * Gets wether the input of the processing is in Gamma or Linear Space.
  124226. */
  124227. get fromLinearSpace(): boolean;
  124228. /**
  124229. * Sets wether the input of the processing is in Gamma or Linear Space.
  124230. */
  124231. set fromLinearSpace(value: boolean);
  124232. /**
  124233. * Defines cache preventing GC.
  124234. */
  124235. private _defines;
  124236. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  124237. /**
  124238. * "ImageProcessingPostProcess"
  124239. * @returns "ImageProcessingPostProcess"
  124240. */
  124241. getClassName(): string;
  124242. /**
  124243. * @hidden
  124244. */
  124245. _updateParameters(): void;
  124246. dispose(camera?: Camera): void;
  124247. }
  124248. }
  124249. declare module BABYLON {
  124250. /**
  124251. * Class containing static functions to help procedurally build meshes
  124252. */
  124253. export class GroundBuilder {
  124254. /**
  124255. * Creates a ground mesh
  124256. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  124257. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  124258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124259. * @param name defines the name of the mesh
  124260. * @param options defines the options used to create the mesh
  124261. * @param scene defines the hosting scene
  124262. * @returns the ground mesh
  124263. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  124264. */
  124265. static CreateGround(name: string, options: {
  124266. width?: number;
  124267. height?: number;
  124268. subdivisions?: number;
  124269. subdivisionsX?: number;
  124270. subdivisionsY?: number;
  124271. updatable?: boolean;
  124272. }, scene: any): Mesh;
  124273. /**
  124274. * Creates a tiled ground mesh
  124275. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  124276. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  124277. * * 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
  124278. * * 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
  124279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124280. * @param name defines the name of the mesh
  124281. * @param options defines the options used to create the mesh
  124282. * @param scene defines the hosting scene
  124283. * @returns the tiled ground mesh
  124284. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  124285. */
  124286. static CreateTiledGround(name: string, options: {
  124287. xmin: number;
  124288. zmin: number;
  124289. xmax: number;
  124290. zmax: number;
  124291. subdivisions?: {
  124292. w: number;
  124293. h: number;
  124294. };
  124295. precision?: {
  124296. w: number;
  124297. h: number;
  124298. };
  124299. updatable?: boolean;
  124300. }, scene?: Nullable<Scene>): Mesh;
  124301. /**
  124302. * Creates a ground mesh from a height map
  124303. * * The parameter `url` sets the URL of the height map image resource.
  124304. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  124305. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  124306. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  124307. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  124308. * * 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.
  124309. * * 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).
  124310. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  124311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124312. * @param name defines the name of the mesh
  124313. * @param url defines the url to the height map
  124314. * @param options defines the options used to create the mesh
  124315. * @param scene defines the hosting scene
  124316. * @returns the ground mesh
  124317. * @see https://doc.babylonjs.com/babylon101/height_map
  124318. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  124319. */
  124320. static CreateGroundFromHeightMap(name: string, url: string, options: {
  124321. width?: number;
  124322. height?: number;
  124323. subdivisions?: number;
  124324. minHeight?: number;
  124325. maxHeight?: number;
  124326. colorFilter?: Color3;
  124327. alphaFilter?: number;
  124328. updatable?: boolean;
  124329. onReady?: (mesh: GroundMesh) => void;
  124330. }, scene?: Nullable<Scene>): GroundMesh;
  124331. }
  124332. }
  124333. declare module BABYLON {
  124334. /**
  124335. * Class containing static functions to help procedurally build meshes
  124336. */
  124337. export class TorusBuilder {
  124338. /**
  124339. * Creates a torus mesh
  124340. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  124341. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  124342. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  124343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124346. * @param name defines the name of the mesh
  124347. * @param options defines the options used to create the mesh
  124348. * @param scene defines the hosting scene
  124349. * @returns the torus mesh
  124350. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  124351. */
  124352. static CreateTorus(name: string, options: {
  124353. diameter?: number;
  124354. thickness?: number;
  124355. tessellation?: number;
  124356. updatable?: boolean;
  124357. sideOrientation?: number;
  124358. frontUVs?: Vector4;
  124359. backUVs?: Vector4;
  124360. }, scene: any): Mesh;
  124361. }
  124362. }
  124363. declare module BABYLON {
  124364. /**
  124365. * Class containing static functions to help procedurally build meshes
  124366. */
  124367. export class CylinderBuilder {
  124368. /**
  124369. * Creates a cylinder or a cone mesh
  124370. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  124371. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  124372. * * 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.
  124373. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  124374. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  124375. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  124376. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  124377. * * 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).
  124378. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  124379. * * 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).
  124380. * * 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
  124381. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  124382. * * 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
  124383. * * 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.
  124384. * * If `enclose` is false, a ring surface is one element.
  124385. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  124386. * * 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
  124387. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124388. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124389. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  124390. * @param name defines the name of the mesh
  124391. * @param options defines the options used to create the mesh
  124392. * @param scene defines the hosting scene
  124393. * @returns the cylinder mesh
  124394. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  124395. */
  124396. static CreateCylinder(name: string, options: {
  124397. height?: number;
  124398. diameterTop?: number;
  124399. diameterBottom?: number;
  124400. diameter?: number;
  124401. tessellation?: number;
  124402. subdivisions?: number;
  124403. arc?: number;
  124404. faceColors?: Color4[];
  124405. faceUV?: Vector4[];
  124406. updatable?: boolean;
  124407. hasRings?: boolean;
  124408. enclose?: boolean;
  124409. cap?: number;
  124410. sideOrientation?: number;
  124411. frontUVs?: Vector4;
  124412. backUVs?: Vector4;
  124413. }, scene: any): Mesh;
  124414. }
  124415. }
  124416. declare module BABYLON {
  124417. /**
  124418. * States of the webXR experience
  124419. */
  124420. export enum WebXRState {
  124421. /**
  124422. * Transitioning to being in XR mode
  124423. */
  124424. ENTERING_XR = 0,
  124425. /**
  124426. * Transitioning to non XR mode
  124427. */
  124428. EXITING_XR = 1,
  124429. /**
  124430. * In XR mode and presenting
  124431. */
  124432. IN_XR = 2,
  124433. /**
  124434. * Not entered XR mode
  124435. */
  124436. NOT_IN_XR = 3
  124437. }
  124438. /**
  124439. * Abstraction of the XR render target
  124440. */
  124441. export interface WebXRRenderTarget extends IDisposable {
  124442. /**
  124443. * xrpresent context of the canvas which can be used to display/mirror xr content
  124444. */
  124445. canvasContext: WebGLRenderingContext;
  124446. /**
  124447. * xr layer for the canvas
  124448. */
  124449. xrLayer: Nullable<XRWebGLLayer>;
  124450. /**
  124451. * Initializes the xr layer for the session
  124452. * @param xrSession xr session
  124453. * @returns a promise that will resolve once the XR Layer has been created
  124454. */
  124455. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124456. }
  124457. }
  124458. declare module BABYLON {
  124459. /**
  124460. * COnfiguration object for WebXR output canvas
  124461. */
  124462. export class WebXRManagedOutputCanvasOptions {
  124463. /**
  124464. * An optional canvas in case you wish to create it yourself and provide it here.
  124465. * If not provided, a new canvas will be created
  124466. */
  124467. canvasElement?: HTMLCanvasElement;
  124468. /**
  124469. * Options for this XR Layer output
  124470. */
  124471. canvasOptions?: XRWebGLLayerOptions;
  124472. /**
  124473. * CSS styling for a newly created canvas (if not provided)
  124474. */
  124475. newCanvasCssStyle?: string;
  124476. /**
  124477. * Get the default values of the configuration object
  124478. * @returns default values of this configuration object
  124479. */
  124480. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  124481. }
  124482. /**
  124483. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  124484. */
  124485. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  124486. private _options;
  124487. private _canvas;
  124488. private _engine;
  124489. private _originalCanvasSize;
  124490. /**
  124491. * Rendering context of the canvas which can be used to display/mirror xr content
  124492. */
  124493. canvasContext: WebGLRenderingContext;
  124494. /**
  124495. * xr layer for the canvas
  124496. */
  124497. xrLayer: Nullable<XRWebGLLayer>;
  124498. /**
  124499. * Obseervers registered here will be triggered when the xr layer was initialized
  124500. */
  124501. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  124502. /**
  124503. * Initializes the canvas to be added/removed upon entering/exiting xr
  124504. * @param _xrSessionManager The XR Session manager
  124505. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  124506. */
  124507. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  124508. /**
  124509. * Disposes of the object
  124510. */
  124511. dispose(): void;
  124512. /**
  124513. * Initializes the xr layer for the session
  124514. * @param xrSession xr session
  124515. * @returns a promise that will resolve once the XR Layer has been created
  124516. */
  124517. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  124518. private _addCanvas;
  124519. private _removeCanvas;
  124520. private _setCanvasSize;
  124521. private _setManagedOutputCanvas;
  124522. }
  124523. }
  124524. declare module BABYLON {
  124525. /**
  124526. * Manages an XRSession to work with Babylon's engine
  124527. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  124528. */
  124529. export class WebXRSessionManager implements IDisposable {
  124530. /** The scene which the session should be created for */
  124531. scene: Scene;
  124532. private _referenceSpace;
  124533. private _rttProvider;
  124534. private _sessionEnded;
  124535. private _xrNavigator;
  124536. private baseLayer;
  124537. /**
  124538. * The base reference space from which the session started. good if you want to reset your
  124539. * reference space
  124540. */
  124541. baseReferenceSpace: XRReferenceSpace;
  124542. /**
  124543. * Current XR frame
  124544. */
  124545. currentFrame: Nullable<XRFrame>;
  124546. /** WebXR timestamp updated every frame */
  124547. currentTimestamp: number;
  124548. /**
  124549. * Used just in case of a failure to initialize an immersive session.
  124550. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  124551. */
  124552. defaultHeightCompensation: number;
  124553. /**
  124554. * Fires every time a new xrFrame arrives which can be used to update the camera
  124555. */
  124556. onXRFrameObservable: Observable<XRFrame>;
  124557. /**
  124558. * Fires when the reference space changed
  124559. */
  124560. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  124561. /**
  124562. * Fires when the xr session is ended either by the device or manually done
  124563. */
  124564. onXRSessionEnded: Observable<any>;
  124565. /**
  124566. * Fires when the xr session is ended either by the device or manually done
  124567. */
  124568. onXRSessionInit: Observable<XRSession>;
  124569. /**
  124570. * Underlying xr session
  124571. */
  124572. session: XRSession;
  124573. /**
  124574. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  124575. * or get the offset the player is currently at.
  124576. */
  124577. viewerReferenceSpace: XRReferenceSpace;
  124578. /**
  124579. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  124580. * @param scene The scene which the session should be created for
  124581. */
  124582. constructor(
  124583. /** The scene which the session should be created for */
  124584. scene: Scene);
  124585. /**
  124586. * The current reference space used in this session. This reference space can constantly change!
  124587. * It is mainly used to offset the camera's position.
  124588. */
  124589. get referenceSpace(): XRReferenceSpace;
  124590. /**
  124591. * Set a new reference space and triggers the observable
  124592. */
  124593. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  124594. /**
  124595. * Disposes of the session manager
  124596. */
  124597. dispose(): void;
  124598. /**
  124599. * Stops the xrSession and restores the render loop
  124600. * @returns Promise which resolves after it exits XR
  124601. */
  124602. exitXRAsync(): Promise<void>;
  124603. /**
  124604. * Gets the correct render target texture to be rendered this frame for this eye
  124605. * @param eye the eye for which to get the render target
  124606. * @returns the render target for the specified eye
  124607. */
  124608. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  124609. /**
  124610. * Creates a WebXRRenderTarget object for the XR session
  124611. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  124612. * @param options optional options to provide when creating a new render target
  124613. * @returns a WebXR render target to which the session can render
  124614. */
  124615. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  124616. /**
  124617. * Initializes the manager
  124618. * After initialization enterXR can be called to start an XR session
  124619. * @returns Promise which resolves after it is initialized
  124620. */
  124621. initializeAsync(): Promise<void>;
  124622. /**
  124623. * Initializes an xr session
  124624. * @param xrSessionMode mode to initialize
  124625. * @param xrSessionInit defines optional and required values to pass to the session builder
  124626. * @returns a promise which will resolve once the session has been initialized
  124627. */
  124628. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  124629. /**
  124630. * Checks if a session would be supported for the creation options specified
  124631. * @param sessionMode session mode to check if supported eg. immersive-vr
  124632. * @returns A Promise that resolves to true if supported and false if not
  124633. */
  124634. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124635. /**
  124636. * Resets the reference space to the one started the session
  124637. */
  124638. resetReferenceSpace(): void;
  124639. /**
  124640. * Starts rendering to the xr layer
  124641. */
  124642. runXRRenderLoop(): void;
  124643. /**
  124644. * Sets the reference space on the xr session
  124645. * @param referenceSpaceType space to set
  124646. * @returns a promise that will resolve once the reference space has been set
  124647. */
  124648. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  124649. /**
  124650. * Updates the render state of the session
  124651. * @param state state to set
  124652. * @returns a promise that resolves once the render state has been updated
  124653. */
  124654. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  124655. /**
  124656. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  124657. * @param sessionMode defines the session to test
  124658. * @returns a promise with boolean as final value
  124659. */
  124660. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  124661. private _createRenderTargetTexture;
  124662. }
  124663. }
  124664. declare module BABYLON {
  124665. /**
  124666. * WebXR Camera which holds the views for the xrSession
  124667. * @see https://doc.babylonjs.com/how_to/webxr_camera
  124668. */
  124669. export class WebXRCamera extends FreeCamera {
  124670. private _xrSessionManager;
  124671. private _firstFrame;
  124672. private _referenceQuaternion;
  124673. private _referencedPosition;
  124674. private _xrInvPositionCache;
  124675. private _xrInvQuaternionCache;
  124676. /**
  124677. * Should position compensation execute on first frame.
  124678. * This is used when copying the position from a native (non XR) camera
  124679. */
  124680. compensateOnFirstFrame: boolean;
  124681. /**
  124682. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  124683. * @param name the name of the camera
  124684. * @param scene the scene to add the camera to
  124685. * @param _xrSessionManager a constructed xr session manager
  124686. */
  124687. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  124688. /**
  124689. * Return the user's height, unrelated to the current ground.
  124690. * This will be the y position of this camera, when ground level is 0.
  124691. */
  124692. get realWorldHeight(): number;
  124693. /** @hidden */
  124694. _updateForDualEyeDebugging(): void;
  124695. /**
  124696. * Sets this camera's transformation based on a non-vr camera
  124697. * @param otherCamera the non-vr camera to copy the transformation from
  124698. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  124699. */
  124700. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  124701. /**
  124702. * Gets the current instance class name ("WebXRCamera").
  124703. * @returns the class name
  124704. */
  124705. getClassName(): string;
  124706. private _rotate180;
  124707. private _updateFromXRSession;
  124708. private _updateNumberOfRigCameras;
  124709. private _updateReferenceSpace;
  124710. private _updateReferenceSpaceOffset;
  124711. }
  124712. }
  124713. declare module BABYLON {
  124714. /**
  124715. * Defining the interface required for a (webxr) feature
  124716. */
  124717. export interface IWebXRFeature extends IDisposable {
  124718. /**
  124719. * Is this feature attached
  124720. */
  124721. attached: boolean;
  124722. /**
  124723. * Should auto-attach be disabled?
  124724. */
  124725. disableAutoAttach: boolean;
  124726. /**
  124727. * Attach the feature to the session
  124728. * Will usually be called by the features manager
  124729. *
  124730. * @param force should attachment be forced (even when already attached)
  124731. * @returns true if successful.
  124732. */
  124733. attach(force?: boolean): boolean;
  124734. /**
  124735. * Detach the feature from the session
  124736. * Will usually be called by the features manager
  124737. *
  124738. * @returns true if successful.
  124739. */
  124740. detach(): boolean;
  124741. }
  124742. /**
  124743. * A list of the currently available features without referencing them
  124744. */
  124745. export class WebXRFeatureName {
  124746. /**
  124747. * The name of the anchor system feature
  124748. */
  124749. static ANCHOR_SYSTEM: string;
  124750. /**
  124751. * The name of the background remover feature
  124752. */
  124753. static BACKGROUND_REMOVER: string;
  124754. /**
  124755. * The name of the hit test feature
  124756. */
  124757. static HIT_TEST: string;
  124758. /**
  124759. * physics impostors for xr controllers feature
  124760. */
  124761. static PHYSICS_CONTROLLERS: string;
  124762. /**
  124763. * The name of the plane detection feature
  124764. */
  124765. static PLANE_DETECTION: string;
  124766. /**
  124767. * The name of the pointer selection feature
  124768. */
  124769. static POINTER_SELECTION: string;
  124770. /**
  124771. * The name of the teleportation feature
  124772. */
  124773. static TELEPORTATION: string;
  124774. }
  124775. /**
  124776. * Defining the constructor of a feature. Used to register the modules.
  124777. */
  124778. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  124779. /**
  124780. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  124781. * It is mainly used in AR sessions.
  124782. *
  124783. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  124784. */
  124785. export class WebXRFeaturesManager implements IDisposable {
  124786. private _xrSessionManager;
  124787. private static readonly _AvailableFeatures;
  124788. private _features;
  124789. /**
  124790. * constructs a new features manages.
  124791. *
  124792. * @param _xrSessionManager an instance of WebXRSessionManager
  124793. */
  124794. constructor(_xrSessionManager: WebXRSessionManager);
  124795. /**
  124796. * Used to register a module. After calling this function a developer can use this feature in the scene.
  124797. * Mainly used internally.
  124798. *
  124799. * @param featureName the name of the feature to register
  124800. * @param constructorFunction the function used to construct the module
  124801. * @param version the (babylon) version of the module
  124802. * @param stable is that a stable version of this module
  124803. */
  124804. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  124805. /**
  124806. * Returns a constructor of a specific feature.
  124807. *
  124808. * @param featureName the name of the feature to construct
  124809. * @param version the version of the feature to load
  124810. * @param xrSessionManager the xrSessionManager. Used to construct the module
  124811. * @param options optional options provided to the module.
  124812. * @returns a function that, when called, will return a new instance of this feature
  124813. */
  124814. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  124815. /**
  124816. * Can be used to return the list of features currently registered
  124817. *
  124818. * @returns an Array of available features
  124819. */
  124820. static GetAvailableFeatures(): string[];
  124821. /**
  124822. * Gets the versions available for a specific feature
  124823. * @param featureName the name of the feature
  124824. * @returns an array with the available versions
  124825. */
  124826. static GetAvailableVersions(featureName: string): string[];
  124827. /**
  124828. * Return the latest unstable version of this feature
  124829. * @param featureName the name of the feature to search
  124830. * @returns the version number. if not found will return -1
  124831. */
  124832. static GetLatestVersionOfFeature(featureName: string): number;
  124833. /**
  124834. * Return the latest stable version of this feature
  124835. * @param featureName the name of the feature to search
  124836. * @returns the version number. if not found will return -1
  124837. */
  124838. static GetStableVersionOfFeature(featureName: string): number;
  124839. /**
  124840. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  124841. * Can be used during a session to start a feature
  124842. * @param featureName the name of feature to attach
  124843. */
  124844. attachFeature(featureName: string): void;
  124845. /**
  124846. * Can be used inside a session or when the session ends to detach a specific feature
  124847. * @param featureName the name of the feature to detach
  124848. */
  124849. detachFeature(featureName: string): void;
  124850. /**
  124851. * Used to disable an already-enabled feature
  124852. * The feature will be disposed and will be recreated once enabled.
  124853. * @param featureName the feature to disable
  124854. * @returns true if disable was successful
  124855. */
  124856. disableFeature(featureName: string | {
  124857. Name: string;
  124858. }): boolean;
  124859. /**
  124860. * dispose this features manager
  124861. */
  124862. dispose(): void;
  124863. /**
  124864. * 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.
  124865. * 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.
  124866. *
  124867. * @param featureName the name of the feature to load or the class of the feature
  124868. * @param version optional version to load. if not provided the latest version will be enabled
  124869. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  124870. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  124871. * @returns a new constructed feature or throws an error if feature not found.
  124872. */
  124873. enableFeature(featureName: string | {
  124874. Name: string;
  124875. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  124876. /**
  124877. * get the implementation of an enabled feature.
  124878. * @param featureName the name of the feature to load
  124879. * @returns the feature class, if found
  124880. */
  124881. getEnabledFeature(featureName: string): IWebXRFeature;
  124882. /**
  124883. * Get the list of enabled features
  124884. * @returns an array of enabled features
  124885. */
  124886. getEnabledFeatures(): string[];
  124887. }
  124888. }
  124889. declare module BABYLON {
  124890. /**
  124891. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  124892. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  124893. */
  124894. export class WebXRExperienceHelper implements IDisposable {
  124895. private scene;
  124896. private _nonVRCamera;
  124897. private _originalSceneAutoClear;
  124898. private _supported;
  124899. /**
  124900. * Camera used to render xr content
  124901. */
  124902. camera: WebXRCamera;
  124903. /** A features manager for this xr session */
  124904. featuresManager: WebXRFeaturesManager;
  124905. /**
  124906. * Observers registered here will be triggered after the camera's initial transformation is set
  124907. * This can be used to set a different ground level or an extra rotation.
  124908. *
  124909. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  124910. * to the position set after this observable is done executing.
  124911. */
  124912. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  124913. /**
  124914. * Fires when the state of the experience helper has changed
  124915. */
  124916. onStateChangedObservable: Observable<WebXRState>;
  124917. /** Session manager used to keep track of xr session */
  124918. sessionManager: WebXRSessionManager;
  124919. /**
  124920. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  124921. */
  124922. state: WebXRState;
  124923. /**
  124924. * Creates a WebXRExperienceHelper
  124925. * @param scene The scene the helper should be created in
  124926. */
  124927. private constructor();
  124928. /**
  124929. * Creates the experience helper
  124930. * @param scene the scene to attach the experience helper to
  124931. * @returns a promise for the experience helper
  124932. */
  124933. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  124934. /**
  124935. * Disposes of the experience helper
  124936. */
  124937. dispose(): void;
  124938. /**
  124939. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  124940. * @param sessionMode options for the XR session
  124941. * @param referenceSpaceType frame of reference of the XR session
  124942. * @param renderTarget the output canvas that will be used to enter XR mode
  124943. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  124944. * @returns promise that resolves after xr mode has entered
  124945. */
  124946. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  124947. /**
  124948. * Exits XR mode and returns the scene to its original state
  124949. * @returns promise that resolves after xr mode has exited
  124950. */
  124951. exitXRAsync(): Promise<void>;
  124952. private _nonXRToXRCamera;
  124953. private _setState;
  124954. }
  124955. }
  124956. declare module BABYLON {
  124957. /**
  124958. * X-Y values for axes in WebXR
  124959. */
  124960. export interface IWebXRMotionControllerAxesValue {
  124961. /**
  124962. * The value of the x axis
  124963. */
  124964. x: number;
  124965. /**
  124966. * The value of the y-axis
  124967. */
  124968. y: number;
  124969. }
  124970. /**
  124971. * changed / previous values for the values of this component
  124972. */
  124973. export interface IWebXRMotionControllerComponentChangesValues<T> {
  124974. /**
  124975. * current (this frame) value
  124976. */
  124977. current: T;
  124978. /**
  124979. * previous (last change) value
  124980. */
  124981. previous: T;
  124982. }
  124983. /**
  124984. * Represents changes in the component between current frame and last values recorded
  124985. */
  124986. export interface IWebXRMotionControllerComponentChanges {
  124987. /**
  124988. * will be populated with previous and current values if axes changed
  124989. */
  124990. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  124991. /**
  124992. * will be populated with previous and current values if pressed changed
  124993. */
  124994. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124995. /**
  124996. * will be populated with previous and current values if touched changed
  124997. */
  124998. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  124999. /**
  125000. * will be populated with previous and current values if value changed
  125001. */
  125002. value?: IWebXRMotionControllerComponentChangesValues<number>;
  125003. }
  125004. /**
  125005. * This class represents a single component (for example button or thumbstick) of a motion controller
  125006. */
  125007. export class WebXRControllerComponent implements IDisposable {
  125008. /**
  125009. * the id of this component
  125010. */
  125011. id: string;
  125012. /**
  125013. * the type of the component
  125014. */
  125015. type: MotionControllerComponentType;
  125016. private _buttonIndex;
  125017. private _axesIndices;
  125018. private _axes;
  125019. private _changes;
  125020. private _currentValue;
  125021. private _hasChanges;
  125022. private _pressed;
  125023. private _touched;
  125024. /**
  125025. * button component type
  125026. */
  125027. static BUTTON_TYPE: MotionControllerComponentType;
  125028. /**
  125029. * squeeze component type
  125030. */
  125031. static SQUEEZE_TYPE: MotionControllerComponentType;
  125032. /**
  125033. * Thumbstick component type
  125034. */
  125035. static THUMBSTICK_TYPE: MotionControllerComponentType;
  125036. /**
  125037. * Touchpad component type
  125038. */
  125039. static TOUCHPAD_TYPE: MotionControllerComponentType;
  125040. /**
  125041. * trigger component type
  125042. */
  125043. static TRIGGER_TYPE: MotionControllerComponentType;
  125044. /**
  125045. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  125046. * the axes data changes
  125047. */
  125048. onAxisValueChangedObservable: Observable<{
  125049. x: number;
  125050. y: number;
  125051. }>;
  125052. /**
  125053. * Observers registered here will be triggered when the state of a button changes
  125054. * State change is either pressed / touched / value
  125055. */
  125056. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  125057. /**
  125058. * Creates a new component for a motion controller.
  125059. * It is created by the motion controller itself
  125060. *
  125061. * @param id the id of this component
  125062. * @param type the type of the component
  125063. * @param _buttonIndex index in the buttons array of the gamepad
  125064. * @param _axesIndices indices of the values in the axes array of the gamepad
  125065. */
  125066. constructor(
  125067. /**
  125068. * the id of this component
  125069. */
  125070. id: string,
  125071. /**
  125072. * the type of the component
  125073. */
  125074. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  125075. /**
  125076. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  125077. */
  125078. get axes(): IWebXRMotionControllerAxesValue;
  125079. /**
  125080. * Get the changes. Elements will be populated only if they changed with their previous and current value
  125081. */
  125082. get changes(): IWebXRMotionControllerComponentChanges;
  125083. /**
  125084. * Return whether or not the component changed the last frame
  125085. */
  125086. get hasChanges(): boolean;
  125087. /**
  125088. * is the button currently pressed
  125089. */
  125090. get pressed(): boolean;
  125091. /**
  125092. * is the button currently touched
  125093. */
  125094. get touched(): boolean;
  125095. /**
  125096. * Get the current value of this component
  125097. */
  125098. get value(): number;
  125099. /**
  125100. * Dispose this component
  125101. */
  125102. dispose(): void;
  125103. /**
  125104. * Are there axes correlating to this component
  125105. * @return true is axes data is available
  125106. */
  125107. isAxes(): boolean;
  125108. /**
  125109. * Is this component a button (hence - pressable)
  125110. * @returns true if can be pressed
  125111. */
  125112. isButton(): boolean;
  125113. /**
  125114. * update this component using the gamepad object it is in. Called on every frame
  125115. * @param nativeController the native gamepad controller object
  125116. */
  125117. update(nativeController: IMinimalMotionControllerObject): void;
  125118. }
  125119. }
  125120. declare module BABYLON {
  125121. /**
  125122. * Interface used to represent data loading progression
  125123. */
  125124. export interface ISceneLoaderProgressEvent {
  125125. /**
  125126. * Defines if data length to load can be evaluated
  125127. */
  125128. readonly lengthComputable: boolean;
  125129. /**
  125130. * Defines the loaded data length
  125131. */
  125132. readonly loaded: number;
  125133. /**
  125134. * Defines the data length to load
  125135. */
  125136. readonly total: number;
  125137. }
  125138. /**
  125139. * Interface used by SceneLoader plugins to define supported file extensions
  125140. */
  125141. export interface ISceneLoaderPluginExtensions {
  125142. /**
  125143. * Defines the list of supported extensions
  125144. */
  125145. [extension: string]: {
  125146. isBinary: boolean;
  125147. };
  125148. }
  125149. /**
  125150. * Interface used by SceneLoader plugin factory
  125151. */
  125152. export interface ISceneLoaderPluginFactory {
  125153. /**
  125154. * Defines the name of the factory
  125155. */
  125156. name: string;
  125157. /**
  125158. * Function called to create a new plugin
  125159. * @return the new plugin
  125160. */
  125161. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  125162. /**
  125163. * The callback that returns true if the data can be directly loaded.
  125164. * @param data string containing the file data
  125165. * @returns if the data can be loaded directly
  125166. */
  125167. canDirectLoad?(data: string): boolean;
  125168. }
  125169. /**
  125170. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  125171. */
  125172. export interface ISceneLoaderPluginBase {
  125173. /**
  125174. * The friendly name of this plugin.
  125175. */
  125176. name: string;
  125177. /**
  125178. * The file extensions supported by this plugin.
  125179. */
  125180. extensions: string | ISceneLoaderPluginExtensions;
  125181. /**
  125182. * The callback called when loading from a url.
  125183. * @param scene scene loading this url
  125184. * @param url url to load
  125185. * @param onSuccess callback called when the file successfully loads
  125186. * @param onProgress callback called while file is loading (if the server supports this mode)
  125187. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  125188. * @param onError callback called when the file fails to load
  125189. * @returns a file request object
  125190. */
  125191. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125192. /**
  125193. * The callback called when loading from a file object.
  125194. * @param scene scene loading this file
  125195. * @param file defines the file to load
  125196. * @param onSuccess defines the callback to call when data is loaded
  125197. * @param onProgress defines the callback to call during loading process
  125198. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  125199. * @param onError defines the callback to call when an error occurs
  125200. * @returns a file request object
  125201. */
  125202. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  125203. /**
  125204. * The callback that returns true if the data can be directly loaded.
  125205. * @param data string containing the file data
  125206. * @returns if the data can be loaded directly
  125207. */
  125208. canDirectLoad?(data: string): boolean;
  125209. /**
  125210. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  125211. * @param scene scene loading this data
  125212. * @param data string containing the data
  125213. * @returns data to pass to the plugin
  125214. */
  125215. directLoad?(scene: Scene, data: string): any;
  125216. /**
  125217. * The callback that allows custom handling of the root url based on the response url.
  125218. * @param rootUrl the original root url
  125219. * @param responseURL the response url if available
  125220. * @returns the new root url
  125221. */
  125222. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  125223. }
  125224. /**
  125225. * Interface used to define a SceneLoader plugin
  125226. */
  125227. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  125228. /**
  125229. * Import meshes into a scene.
  125230. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125231. * @param scene The scene to import into
  125232. * @param data The data to import
  125233. * @param rootUrl The root url for scene and resources
  125234. * @param meshes The meshes array to import into
  125235. * @param particleSystems The particle systems array to import into
  125236. * @param skeletons The skeletons array to import into
  125237. * @param onError The callback when import fails
  125238. * @returns True if successful or false otherwise
  125239. */
  125240. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  125241. /**
  125242. * Load into a scene.
  125243. * @param scene The scene to load into
  125244. * @param data The data to import
  125245. * @param rootUrl The root url for scene and resources
  125246. * @param onError The callback when import fails
  125247. * @returns True if successful or false otherwise
  125248. */
  125249. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  125250. /**
  125251. * Load into an asset container.
  125252. * @param scene The scene to load into
  125253. * @param data The data to import
  125254. * @param rootUrl The root url for scene and resources
  125255. * @param onError The callback when import fails
  125256. * @returns The loaded asset container
  125257. */
  125258. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  125259. }
  125260. /**
  125261. * Interface used to define an async SceneLoader plugin
  125262. */
  125263. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  125264. /**
  125265. * Import meshes into a scene.
  125266. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125267. * @param scene The scene to import into
  125268. * @param data The data to import
  125269. * @param rootUrl The root url for scene and resources
  125270. * @param onProgress The callback when the load progresses
  125271. * @param fileName Defines the name of the file to load
  125272. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  125273. */
  125274. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  125275. meshes: AbstractMesh[];
  125276. particleSystems: IParticleSystem[];
  125277. skeletons: Skeleton[];
  125278. animationGroups: AnimationGroup[];
  125279. }>;
  125280. /**
  125281. * Load into a scene.
  125282. * @param scene The scene to load into
  125283. * @param data The data to import
  125284. * @param rootUrl The root url for scene and resources
  125285. * @param onProgress The callback when the load progresses
  125286. * @param fileName Defines the name of the file to load
  125287. * @returns Nothing
  125288. */
  125289. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  125290. /**
  125291. * Load into an asset container.
  125292. * @param scene The scene to load into
  125293. * @param data The data to import
  125294. * @param rootUrl The root url for scene and resources
  125295. * @param onProgress The callback when the load progresses
  125296. * @param fileName Defines the name of the file to load
  125297. * @returns The loaded asset container
  125298. */
  125299. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  125300. }
  125301. /**
  125302. * Mode that determines how to handle old animation groups before loading new ones.
  125303. */
  125304. export enum SceneLoaderAnimationGroupLoadingMode {
  125305. /**
  125306. * Reset all old animations to initial state then dispose them.
  125307. */
  125308. Clean = 0,
  125309. /**
  125310. * Stop all old animations.
  125311. */
  125312. Stop = 1,
  125313. /**
  125314. * Restart old animations from first frame.
  125315. */
  125316. Sync = 2,
  125317. /**
  125318. * Old animations remains untouched.
  125319. */
  125320. NoSync = 3
  125321. }
  125322. /**
  125323. * Class used to load scene from various file formats using registered plugins
  125324. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  125325. */
  125326. export class SceneLoader {
  125327. /**
  125328. * No logging while loading
  125329. */
  125330. static readonly NO_LOGGING: number;
  125331. /**
  125332. * Minimal logging while loading
  125333. */
  125334. static readonly MINIMAL_LOGGING: number;
  125335. /**
  125336. * Summary logging while loading
  125337. */
  125338. static readonly SUMMARY_LOGGING: number;
  125339. /**
  125340. * Detailled logging while loading
  125341. */
  125342. static readonly DETAILED_LOGGING: number;
  125343. /**
  125344. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  125345. */
  125346. static get ForceFullSceneLoadingForIncremental(): boolean;
  125347. static set ForceFullSceneLoadingForIncremental(value: boolean);
  125348. /**
  125349. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  125350. */
  125351. static get ShowLoadingScreen(): boolean;
  125352. static set ShowLoadingScreen(value: boolean);
  125353. /**
  125354. * Defines the current logging level (while loading the scene)
  125355. * @ignorenaming
  125356. */
  125357. static get loggingLevel(): number;
  125358. static set loggingLevel(value: number);
  125359. /**
  125360. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  125361. */
  125362. static get CleanBoneMatrixWeights(): boolean;
  125363. static set CleanBoneMatrixWeights(value: boolean);
  125364. /**
  125365. * Event raised when a plugin is used to load a scene
  125366. */
  125367. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  125368. private static _registeredPlugins;
  125369. private static _getDefaultPlugin;
  125370. private static _getPluginForExtension;
  125371. private static _getPluginForDirectLoad;
  125372. private static _getPluginForFilename;
  125373. private static _getDirectLoad;
  125374. private static _loadData;
  125375. private static _getFileInfo;
  125376. /**
  125377. * Gets a plugin that can load the given extension
  125378. * @param extension defines the extension to load
  125379. * @returns a plugin or null if none works
  125380. */
  125381. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  125382. /**
  125383. * Gets a boolean indicating that the given extension can be loaded
  125384. * @param extension defines the extension to load
  125385. * @returns true if the extension is supported
  125386. */
  125387. static IsPluginForExtensionAvailable(extension: string): boolean;
  125388. /**
  125389. * Adds a new plugin to the list of registered plugins
  125390. * @param plugin defines the plugin to add
  125391. */
  125392. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  125393. /**
  125394. * Import meshes into a scene
  125395. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125396. * @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)
  125397. * @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)
  125398. * @param scene the instance of BABYLON.Scene to append to
  125399. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  125400. * @param onProgress a callback with a progress event for each file being loaded
  125401. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125402. * @param pluginExtension the extension used to determine the plugin
  125403. * @returns The loaded plugin
  125404. */
  125405. 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>;
  125406. /**
  125407. * Import meshes into a scene
  125408. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  125409. * @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)
  125410. * @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)
  125411. * @param scene the instance of BABYLON.Scene to append to
  125412. * @param onProgress a callback with a progress event for each file being loaded
  125413. * @param pluginExtension the extension used to determine the plugin
  125414. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  125415. */
  125416. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  125417. meshes: AbstractMesh[];
  125418. particleSystems: IParticleSystem[];
  125419. skeletons: Skeleton[];
  125420. animationGroups: AnimationGroup[];
  125421. }>;
  125422. /**
  125423. * Load a scene
  125424. * @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)
  125425. * @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)
  125426. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125427. * @param onSuccess a callback with the scene when import succeeds
  125428. * @param onProgress a callback with a progress event for each file being loaded
  125429. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125430. * @param pluginExtension the extension used to determine the plugin
  125431. * @returns The loaded plugin
  125432. */
  125433. 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>;
  125434. /**
  125435. * Load a scene
  125436. * @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)
  125437. * @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)
  125438. * @param engine is the instance of BABYLON.Engine to use to create the scene
  125439. * @param onProgress a callback with a progress event for each file being loaded
  125440. * @param pluginExtension the extension used to determine the plugin
  125441. * @returns The loaded scene
  125442. */
  125443. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125444. /**
  125445. * Append a scene
  125446. * @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)
  125447. * @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)
  125448. * @param scene is the instance of BABYLON.Scene to append to
  125449. * @param onSuccess a callback with the scene when import succeeds
  125450. * @param onProgress a callback with a progress event for each file being loaded
  125451. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125452. * @param pluginExtension the extension used to determine the plugin
  125453. * @returns The loaded plugin
  125454. */
  125455. 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>;
  125456. /**
  125457. * Append a scene
  125458. * @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)
  125459. * @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)
  125460. * @param scene is the instance of BABYLON.Scene to append to
  125461. * @param onProgress a callback with a progress event for each file being loaded
  125462. * @param pluginExtension the extension used to determine the plugin
  125463. * @returns The given scene
  125464. */
  125465. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  125466. /**
  125467. * Load a scene into an asset container
  125468. * @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)
  125469. * @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)
  125470. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125471. * @param onSuccess a callback with the scene when import succeeds
  125472. * @param onProgress a callback with a progress event for each file being loaded
  125473. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125474. * @param pluginExtension the extension used to determine the plugin
  125475. * @returns The loaded plugin
  125476. */
  125477. 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>;
  125478. /**
  125479. * Load a scene into an asset container
  125480. * @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)
  125481. * @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)
  125482. * @param scene is the instance of Scene to append to
  125483. * @param onProgress a callback with a progress event for each file being loaded
  125484. * @param pluginExtension the extension used to determine the plugin
  125485. * @returns The loaded asset container
  125486. */
  125487. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  125488. /**
  125489. * Import animations from a file into a scene
  125490. * @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)
  125491. * @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)
  125492. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125493. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125494. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125495. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125496. * @param onSuccess a callback with the scene when import succeeds
  125497. * @param onProgress a callback with a progress event for each file being loaded
  125498. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125499. * @param pluginExtension the extension used to determine the plugin
  125500. */
  125501. 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;
  125502. /**
  125503. * Import animations from a file into a scene
  125504. * @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)
  125505. * @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)
  125506. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  125507. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  125508. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  125509. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  125510. * @param onSuccess a callback with the scene when import succeeds
  125511. * @param onProgress a callback with a progress event for each file being loaded
  125512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  125513. * @param pluginExtension the extension used to determine the plugin
  125514. * @returns the updated scene with imported animations
  125515. */
  125516. 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>;
  125517. }
  125518. }
  125519. declare module BABYLON {
  125520. /**
  125521. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  125522. */
  125523. export type MotionControllerHandedness = "none" | "left" | "right";
  125524. /**
  125525. * The type of components available in motion controllers.
  125526. * This is not the name of the component.
  125527. */
  125528. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  125529. /**
  125530. * The state of a controller component
  125531. */
  125532. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  125533. /**
  125534. * The schema of motion controller layout.
  125535. * No object will be initialized using this interface
  125536. * This is used just to define the profile.
  125537. */
  125538. export interface IMotionControllerLayout {
  125539. /**
  125540. * Path to load the assets. Usually relative to the base path
  125541. */
  125542. assetPath: string;
  125543. /**
  125544. * Available components (unsorted)
  125545. */
  125546. components: {
  125547. /**
  125548. * A map of component Ids
  125549. */
  125550. [componentId: string]: {
  125551. /**
  125552. * The type of input the component outputs
  125553. */
  125554. type: MotionControllerComponentType;
  125555. /**
  125556. * The indices of this component in the gamepad object
  125557. */
  125558. gamepadIndices: {
  125559. /**
  125560. * Index of button
  125561. */
  125562. button?: number;
  125563. /**
  125564. * If available, index of x-axis
  125565. */
  125566. xAxis?: number;
  125567. /**
  125568. * If available, index of y-axis
  125569. */
  125570. yAxis?: number;
  125571. };
  125572. /**
  125573. * The mesh's root node name
  125574. */
  125575. rootNodeName: string;
  125576. /**
  125577. * Animation definitions for this model
  125578. */
  125579. visualResponses: {
  125580. [stateKey: string]: {
  125581. /**
  125582. * What property will be animated
  125583. */
  125584. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  125585. /**
  125586. * What states influence this visual response
  125587. */
  125588. states: MotionControllerComponentStateType[];
  125589. /**
  125590. * Type of animation - movement or visibility
  125591. */
  125592. valueNodeProperty: "transform" | "visibility";
  125593. /**
  125594. * Base node name to move. Its position will be calculated according to the min and max nodes
  125595. */
  125596. valueNodeName?: string;
  125597. /**
  125598. * Minimum movement node
  125599. */
  125600. minNodeName?: string;
  125601. /**
  125602. * Max movement node
  125603. */
  125604. maxNodeName?: string;
  125605. };
  125606. };
  125607. /**
  125608. * If touch enabled, what is the name of node to display user feedback
  125609. */
  125610. touchPointNodeName?: string;
  125611. };
  125612. };
  125613. /**
  125614. * Is it xr standard mapping or not
  125615. */
  125616. gamepadMapping: "" | "xr-standard";
  125617. /**
  125618. * Base root node of this entire model
  125619. */
  125620. rootNodeName: string;
  125621. /**
  125622. * Defines the main button component id
  125623. */
  125624. selectComponentId: string;
  125625. }
  125626. /**
  125627. * A definition for the layout map in the input profile
  125628. */
  125629. export interface IMotionControllerLayoutMap {
  125630. /**
  125631. * Layouts with handedness type as a key
  125632. */
  125633. [handedness: string]: IMotionControllerLayout;
  125634. }
  125635. /**
  125636. * The XR Input profile schema
  125637. * Profiles can be found here:
  125638. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  125639. */
  125640. export interface IMotionControllerProfile {
  125641. /**
  125642. * fallback profiles for this profileId
  125643. */
  125644. fallbackProfileIds: string[];
  125645. /**
  125646. * The layout map, with handedness as key
  125647. */
  125648. layouts: IMotionControllerLayoutMap;
  125649. /**
  125650. * The id of this profile
  125651. * correlates to the profile(s) in the xrInput.profiles array
  125652. */
  125653. profileId: string;
  125654. }
  125655. /**
  125656. * A helper-interface for the 3 meshes needed for controller button animation
  125657. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  125658. */
  125659. export interface IMotionControllerButtonMeshMap {
  125660. /**
  125661. * the mesh that defines the pressed value mesh position.
  125662. * This is used to find the max-position of this button
  125663. */
  125664. pressedMesh: AbstractMesh;
  125665. /**
  125666. * the mesh that defines the unpressed value mesh position.
  125667. * This is used to find the min (or initial) position of this button
  125668. */
  125669. unpressedMesh: AbstractMesh;
  125670. /**
  125671. * The mesh that will be changed when value changes
  125672. */
  125673. valueMesh: AbstractMesh;
  125674. }
  125675. /**
  125676. * A helper-interface for the 3 meshes needed for controller axis animation.
  125677. * This will be expanded when touchpad animations are fully supported
  125678. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  125679. */
  125680. export interface IMotionControllerMeshMap {
  125681. /**
  125682. * the mesh that defines the maximum value mesh position.
  125683. */
  125684. maxMesh?: AbstractMesh;
  125685. /**
  125686. * the mesh that defines the minimum value mesh position.
  125687. */
  125688. minMesh?: AbstractMesh;
  125689. /**
  125690. * The mesh that will be changed when axis value changes
  125691. */
  125692. valueMesh: AbstractMesh;
  125693. }
  125694. /**
  125695. * The elements needed for change-detection of the gamepad objects in motion controllers
  125696. */
  125697. export interface IMinimalMotionControllerObject {
  125698. /**
  125699. * Available axes of this controller
  125700. */
  125701. axes: number[];
  125702. /**
  125703. * An array of available buttons
  125704. */
  125705. buttons: Array<{
  125706. /**
  125707. * Value of the button/trigger
  125708. */
  125709. value: number;
  125710. /**
  125711. * If the button/trigger is currently touched
  125712. */
  125713. touched: boolean;
  125714. /**
  125715. * If the button/trigger is currently pressed
  125716. */
  125717. pressed: boolean;
  125718. }>;
  125719. /**
  125720. * EXPERIMENTAL haptic support.
  125721. */
  125722. hapticActuators?: Array<{
  125723. pulse: (value: number, duration: number) => Promise<boolean>;
  125724. }>;
  125725. }
  125726. /**
  125727. * An Abstract Motion controller
  125728. * This class receives an xrInput and a profile layout and uses those to initialize the components
  125729. * Each component has an observable to check for changes in value and state
  125730. */
  125731. export abstract class WebXRAbstractMotionController implements IDisposable {
  125732. protected scene: Scene;
  125733. protected layout: IMotionControllerLayout;
  125734. /**
  125735. * The gamepad object correlating to this controller
  125736. */
  125737. gamepadObject: IMinimalMotionControllerObject;
  125738. /**
  125739. * handedness (left/right/none) of this controller
  125740. */
  125741. handedness: MotionControllerHandedness;
  125742. private _initComponent;
  125743. private _modelReady;
  125744. /**
  125745. * A map of components (WebXRControllerComponent) in this motion controller
  125746. * Components have a ComponentType and can also have both button and axis definitions
  125747. */
  125748. readonly components: {
  125749. [id: string]: WebXRControllerComponent;
  125750. };
  125751. /**
  125752. * Disable the model's animation. Can be set at any time.
  125753. */
  125754. disableAnimation: boolean;
  125755. /**
  125756. * Observers registered here will be triggered when the model of this controller is done loading
  125757. */
  125758. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  125759. /**
  125760. * The profile id of this motion controller
  125761. */
  125762. abstract profileId: string;
  125763. /**
  125764. * The root mesh of the model. It is null if the model was not yet initialized
  125765. */
  125766. rootMesh: Nullable<AbstractMesh>;
  125767. /**
  125768. * constructs a new abstract motion controller
  125769. * @param scene the scene to which the model of the controller will be added
  125770. * @param layout The profile layout to load
  125771. * @param gamepadObject The gamepad object correlating to this controller
  125772. * @param handedness handedness (left/right/none) of this controller
  125773. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  125774. */
  125775. constructor(scene: Scene, layout: IMotionControllerLayout,
  125776. /**
  125777. * The gamepad object correlating to this controller
  125778. */
  125779. gamepadObject: IMinimalMotionControllerObject,
  125780. /**
  125781. * handedness (left/right/none) of this controller
  125782. */
  125783. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  125784. /**
  125785. * Dispose this controller, the model mesh and all its components
  125786. */
  125787. dispose(): void;
  125788. /**
  125789. * Returns all components of specific type
  125790. * @param type the type to search for
  125791. * @return an array of components with this type
  125792. */
  125793. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  125794. /**
  125795. * get a component based an its component id as defined in layout.components
  125796. * @param id the id of the component
  125797. * @returns the component correlates to the id or undefined if not found
  125798. */
  125799. getComponent(id: string): WebXRControllerComponent;
  125800. /**
  125801. * Get the list of components available in this motion controller
  125802. * @returns an array of strings correlating to available components
  125803. */
  125804. getComponentIds(): string[];
  125805. /**
  125806. * Get the first component of specific type
  125807. * @param type type of component to find
  125808. * @return a controller component or null if not found
  125809. */
  125810. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  125811. /**
  125812. * Get the main (Select) component of this controller as defined in the layout
  125813. * @returns the main component of this controller
  125814. */
  125815. getMainComponent(): WebXRControllerComponent;
  125816. /**
  125817. * Loads the model correlating to this controller
  125818. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  125819. * @returns A promise fulfilled with the result of the model loading
  125820. */
  125821. loadModel(): Promise<boolean>;
  125822. /**
  125823. * Update this model using the current XRFrame
  125824. * @param xrFrame the current xr frame to use and update the model
  125825. */
  125826. updateFromXRFrame(xrFrame: XRFrame): void;
  125827. /**
  125828. * Backwards compatibility due to a deeply-integrated typo
  125829. */
  125830. get handness(): XREye;
  125831. /**
  125832. * Pulse (vibrate) this controller
  125833. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  125834. * Consecutive calls to this function will cancel the last pulse call
  125835. *
  125836. * @param value the strength of the pulse in 0.0...1.0 range
  125837. * @param duration Duration of the pulse in milliseconds
  125838. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  125839. * @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
  125840. */
  125841. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  125842. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125843. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  125844. /**
  125845. * Moves the axis on the controller mesh based on its current state
  125846. * @param axis the index of the axis
  125847. * @param axisValue the value of the axis which determines the meshes new position
  125848. * @hidden
  125849. */
  125850. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  125851. /**
  125852. * Update the model itself with the current frame data
  125853. * @param xrFrame the frame to use for updating the model mesh
  125854. */
  125855. protected updateModel(xrFrame: XRFrame): void;
  125856. /**
  125857. * Get the filename and path for this controller's model
  125858. * @returns a map of filename and path
  125859. */
  125860. protected abstract _getFilenameAndPath(): {
  125861. filename: string;
  125862. path: string;
  125863. };
  125864. /**
  125865. * This function is called before the mesh is loaded. It checks for loading constraints.
  125866. * For example, this function can check if the GLB loader is available
  125867. * If this function returns false, the generic controller will be loaded instead
  125868. * @returns Is the client ready to load the mesh
  125869. */
  125870. protected abstract _getModelLoadingConstraints(): boolean;
  125871. /**
  125872. * This function will be called after the model was successfully loaded and can be used
  125873. * for mesh transformations before it is available for the user
  125874. * @param meshes the loaded meshes
  125875. */
  125876. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  125877. /**
  125878. * Set the root mesh for this controller. Important for the WebXR controller class
  125879. * @param meshes the loaded meshes
  125880. */
  125881. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  125882. /**
  125883. * A function executed each frame that updates the mesh (if needed)
  125884. * @param xrFrame the current xrFrame
  125885. */
  125886. protected abstract _updateModel(xrFrame: XRFrame): void;
  125887. private _getGenericFilenameAndPath;
  125888. private _getGenericParentMesh;
  125889. }
  125890. }
  125891. declare module BABYLON {
  125892. /**
  125893. * A generic trigger-only motion controller for WebXR
  125894. */
  125895. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  125896. /**
  125897. * Static version of the profile id of this controller
  125898. */
  125899. static ProfileId: string;
  125900. profileId: string;
  125901. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  125902. protected _getFilenameAndPath(): {
  125903. filename: string;
  125904. path: string;
  125905. };
  125906. protected _getModelLoadingConstraints(): boolean;
  125907. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  125908. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125909. protected _updateModel(): void;
  125910. }
  125911. }
  125912. declare module BABYLON {
  125913. /**
  125914. * Class containing static functions to help procedurally build meshes
  125915. */
  125916. export class SphereBuilder {
  125917. /**
  125918. * Creates a sphere mesh
  125919. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  125920. * * 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`)
  125921. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  125922. * * 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
  125923. * * 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)
  125924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  125925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  125926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  125927. * @param name defines the name of the mesh
  125928. * @param options defines the options used to create the mesh
  125929. * @param scene defines the hosting scene
  125930. * @returns the sphere mesh
  125931. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  125932. */
  125933. static CreateSphere(name: string, options: {
  125934. segments?: number;
  125935. diameter?: number;
  125936. diameterX?: number;
  125937. diameterY?: number;
  125938. diameterZ?: number;
  125939. arc?: number;
  125940. slice?: number;
  125941. sideOrientation?: number;
  125942. frontUVs?: Vector4;
  125943. backUVs?: Vector4;
  125944. updatable?: boolean;
  125945. }, scene?: Nullable<Scene>): Mesh;
  125946. }
  125947. }
  125948. declare module BABYLON {
  125949. /**
  125950. * A profiled motion controller has its profile loaded from an online repository.
  125951. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  125952. */
  125953. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  125954. private _repositoryUrl;
  125955. private _buttonMeshMapping;
  125956. private _touchDots;
  125957. /**
  125958. * The profile ID of this controller. Will be populated when the controller initializes.
  125959. */
  125960. profileId: string;
  125961. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  125962. dispose(): void;
  125963. protected _getFilenameAndPath(): {
  125964. filename: string;
  125965. path: string;
  125966. };
  125967. protected _getModelLoadingConstraints(): boolean;
  125968. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  125969. protected _setRootMesh(meshes: AbstractMesh[]): void;
  125970. protected _updateModel(_xrFrame: XRFrame): void;
  125971. }
  125972. }
  125973. declare module BABYLON {
  125974. /**
  125975. * A construction function type to create a new controller based on an xrInput object
  125976. */
  125977. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  125978. /**
  125979. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  125980. *
  125981. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  125982. * it should be replaced with auto-loaded controllers.
  125983. *
  125984. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  125985. */
  125986. export class WebXRMotionControllerManager {
  125987. private static _AvailableControllers;
  125988. private static _Fallbacks;
  125989. private static _ProfileLoadingPromises;
  125990. private static _ProfilesList;
  125991. /**
  125992. * The base URL of the online controller repository. Can be changed at any time.
  125993. */
  125994. static BaseRepositoryUrl: string;
  125995. /**
  125996. * Which repository gets priority - local or online
  125997. */
  125998. static PrioritizeOnlineRepository: boolean;
  125999. /**
  126000. * Use the online repository, or use only locally-defined controllers
  126001. */
  126002. static UseOnlineRepository: boolean;
  126003. /**
  126004. * Clear the cache used for profile loading and reload when requested again
  126005. */
  126006. static ClearProfilesCache(): void;
  126007. /**
  126008. * Register the default fallbacks.
  126009. * This function is called automatically when this file is imported.
  126010. */
  126011. static DefaultFallbacks(): void;
  126012. /**
  126013. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  126014. * @param profileId the profile to which a fallback needs to be found
  126015. * @return an array with corresponding fallback profiles
  126016. */
  126017. static FindFallbackWithProfileId(profileId: string): string[];
  126018. /**
  126019. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  126020. * The order of search:
  126021. *
  126022. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  126023. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  126024. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  126025. * 4) return the generic trigger controller if none were found
  126026. *
  126027. * @param xrInput the xrInput to which a new controller is initialized
  126028. * @param scene the scene to which the model will be added
  126029. * @param forceProfile force a certain profile for this controller
  126030. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  126031. */
  126032. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  126033. /**
  126034. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  126035. *
  126036. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  126037. *
  126038. * @param type the profile type to register
  126039. * @param constructFunction the function to be called when loading this profile
  126040. */
  126041. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  126042. /**
  126043. * Register a fallback to a specific profile.
  126044. * @param profileId the profileId that will receive the fallbacks
  126045. * @param fallbacks A list of fallback profiles
  126046. */
  126047. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  126048. /**
  126049. * Will update the list of profiles available in the repository
  126050. * @return a promise that resolves to a map of profiles available online
  126051. */
  126052. static UpdateProfilesList(): Promise<{
  126053. [profile: string]: string;
  126054. }>;
  126055. private static _LoadProfileFromRepository;
  126056. private static _LoadProfilesFromAvailableControllers;
  126057. }
  126058. }
  126059. declare module BABYLON {
  126060. /**
  126061. * Configuration options for the WebXR controller creation
  126062. */
  126063. export interface IWebXRControllerOptions {
  126064. /**
  126065. * Should the controller mesh be animated when a user interacts with it
  126066. * The pressed buttons / thumbstick and touchpad animations will be disabled
  126067. */
  126068. disableMotionControllerAnimation?: boolean;
  126069. /**
  126070. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  126071. */
  126072. doNotLoadControllerMesh?: boolean;
  126073. /**
  126074. * Force a specific controller type for this controller.
  126075. * This can be used when creating your own profile or when testing different controllers
  126076. */
  126077. forceControllerProfile?: string;
  126078. /**
  126079. * Defines a rendering group ID for meshes that will be loaded.
  126080. * This is for the default controllers only.
  126081. */
  126082. renderingGroupId?: number;
  126083. }
  126084. /**
  126085. * Represents an XR controller
  126086. */
  126087. export class WebXRInputSource {
  126088. private _scene;
  126089. /** The underlying input source for the controller */
  126090. inputSource: XRInputSource;
  126091. private _options;
  126092. private _tmpVector;
  126093. private _uniqueId;
  126094. /**
  126095. * 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
  126096. */
  126097. grip?: AbstractMesh;
  126098. /**
  126099. * If available, this is the gamepad object related to this controller.
  126100. * Using this object it is possible to get click events and trackpad changes of the
  126101. * webxr controller that is currently being used.
  126102. */
  126103. motionController?: WebXRAbstractMotionController;
  126104. /**
  126105. * Event that fires when the controller is removed/disposed.
  126106. * The object provided as event data is this controller, after associated assets were disposed.
  126107. * uniqueId is still available.
  126108. */
  126109. onDisposeObservable: Observable<WebXRInputSource>;
  126110. /**
  126111. * Will be triggered when the mesh associated with the motion controller is done loading.
  126112. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  126113. * A shortened version of controller -> motion controller -> on mesh loaded.
  126114. */
  126115. onMeshLoadedObservable: Observable<AbstractMesh>;
  126116. /**
  126117. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  126118. */
  126119. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  126120. /**
  126121. * Pointer which can be used to select objects or attach a visible laser to
  126122. */
  126123. pointer: AbstractMesh;
  126124. /**
  126125. * Creates the input source object
  126126. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  126127. * @param _scene the scene which the controller should be associated to
  126128. * @param inputSource the underlying input source for the controller
  126129. * @param _options options for this controller creation
  126130. */
  126131. constructor(_scene: Scene,
  126132. /** The underlying input source for the controller */
  126133. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  126134. /**
  126135. * Get this controllers unique id
  126136. */
  126137. get uniqueId(): string;
  126138. /**
  126139. * Disposes of the object
  126140. */
  126141. dispose(): void;
  126142. /**
  126143. * Gets a world space ray coming from the pointer or grip
  126144. * @param result the resulting ray
  126145. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  126146. */
  126147. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  126148. /**
  126149. * Updates the controller pose based on the given XRFrame
  126150. * @param xrFrame xr frame to update the pose with
  126151. * @param referenceSpace reference space to use
  126152. */
  126153. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  126154. }
  126155. }
  126156. declare module BABYLON {
  126157. /**
  126158. * The schema for initialization options of the XR Input class
  126159. */
  126160. export interface IWebXRInputOptions {
  126161. /**
  126162. * If set to true no model will be automatically loaded
  126163. */
  126164. doNotLoadControllerMeshes?: boolean;
  126165. /**
  126166. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  126167. * If not found, the xr input profile data will be used.
  126168. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  126169. */
  126170. forceInputProfile?: string;
  126171. /**
  126172. * Do not send a request to the controller repository to load the profile.
  126173. *
  126174. * Instead, use the controllers available in babylon itself.
  126175. */
  126176. disableOnlineControllerRepository?: boolean;
  126177. /**
  126178. * A custom URL for the controllers repository
  126179. */
  126180. customControllersRepositoryURL?: string;
  126181. /**
  126182. * Should the controller model's components not move according to the user input
  126183. */
  126184. disableControllerAnimation?: boolean;
  126185. /**
  126186. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  126187. */
  126188. controllerOptions?: IWebXRControllerOptions;
  126189. }
  126190. /**
  126191. * XR input used to track XR inputs such as controllers/rays
  126192. */
  126193. export class WebXRInput implements IDisposable {
  126194. /**
  126195. * the xr session manager for this session
  126196. */
  126197. xrSessionManager: WebXRSessionManager;
  126198. /**
  126199. * the WebXR camera for this session. Mainly used for teleportation
  126200. */
  126201. xrCamera: WebXRCamera;
  126202. private readonly options;
  126203. /**
  126204. * XR controllers being tracked
  126205. */
  126206. controllers: Array<WebXRInputSource>;
  126207. private _frameObserver;
  126208. private _sessionEndedObserver;
  126209. private _sessionInitObserver;
  126210. /**
  126211. * Event when a controller has been connected/added
  126212. */
  126213. onControllerAddedObservable: Observable<WebXRInputSource>;
  126214. /**
  126215. * Event when a controller has been removed/disconnected
  126216. */
  126217. onControllerRemovedObservable: Observable<WebXRInputSource>;
  126218. /**
  126219. * Initializes the WebXRInput
  126220. * @param xrSessionManager the xr session manager for this session
  126221. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  126222. * @param options = initialization options for this xr input
  126223. */
  126224. constructor(
  126225. /**
  126226. * the xr session manager for this session
  126227. */
  126228. xrSessionManager: WebXRSessionManager,
  126229. /**
  126230. * the WebXR camera for this session. Mainly used for teleportation
  126231. */
  126232. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  126233. private _onInputSourcesChange;
  126234. private _addAndRemoveControllers;
  126235. /**
  126236. * Disposes of the object
  126237. */
  126238. dispose(): void;
  126239. }
  126240. }
  126241. declare module BABYLON {
  126242. /**
  126243. * This is the base class for all WebXR features.
  126244. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  126245. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  126246. */
  126247. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  126248. protected _xrSessionManager: WebXRSessionManager;
  126249. private _attached;
  126250. private _removeOnDetach;
  126251. /**
  126252. * Should auto-attach be disabled?
  126253. */
  126254. disableAutoAttach: boolean;
  126255. /**
  126256. * Construct a new (abstract) WebXR feature
  126257. * @param _xrSessionManager the xr session manager for this feature
  126258. */
  126259. constructor(_xrSessionManager: WebXRSessionManager);
  126260. /**
  126261. * Is this feature attached
  126262. */
  126263. get attached(): boolean;
  126264. /**
  126265. * attach this feature
  126266. *
  126267. * @param force should attachment be forced (even when already attached)
  126268. * @returns true if successful, false is failed or already attached
  126269. */
  126270. attach(force?: boolean): boolean;
  126271. /**
  126272. * detach this feature.
  126273. *
  126274. * @returns true if successful, false if failed or already detached
  126275. */
  126276. detach(): boolean;
  126277. /**
  126278. * Dispose this feature and all of the resources attached
  126279. */
  126280. dispose(): void;
  126281. /**
  126282. * This is used to register callbacks that will automatically be removed when detach is called.
  126283. * @param observable the observable to which the observer will be attached
  126284. * @param callback the callback to register
  126285. */
  126286. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  126287. /**
  126288. * Code in this function will be executed on each xrFrame received from the browser.
  126289. * This function will not execute after the feature is detached.
  126290. * @param _xrFrame the current frame
  126291. */
  126292. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  126293. }
  126294. }
  126295. declare module BABYLON {
  126296. /**
  126297. * Renders a layer on top of an existing scene
  126298. */
  126299. export class UtilityLayerRenderer implements IDisposable {
  126300. /** the original scene that will be rendered on top of */
  126301. originalScene: Scene;
  126302. private _pointerCaptures;
  126303. private _lastPointerEvents;
  126304. private static _DefaultUtilityLayer;
  126305. private static _DefaultKeepDepthUtilityLayer;
  126306. private _sharedGizmoLight;
  126307. private _renderCamera;
  126308. /**
  126309. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  126310. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  126311. * @returns the camera that is used when rendering the utility layer
  126312. */
  126313. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  126314. /**
  126315. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  126316. * @param cam the camera that should be used when rendering the utility layer
  126317. */
  126318. setRenderCamera(cam: Nullable<Camera>): void;
  126319. /**
  126320. * @hidden
  126321. * Light which used by gizmos to get light shading
  126322. */
  126323. _getSharedGizmoLight(): HemisphericLight;
  126324. /**
  126325. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  126326. */
  126327. pickUtilitySceneFirst: boolean;
  126328. /**
  126329. * 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)
  126330. */
  126331. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  126332. /**
  126333. * 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)
  126334. */
  126335. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  126336. /**
  126337. * The scene that is rendered on top of the original scene
  126338. */
  126339. utilityLayerScene: Scene;
  126340. /**
  126341. * If the utility layer should automatically be rendered on top of existing scene
  126342. */
  126343. shouldRender: boolean;
  126344. /**
  126345. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  126346. */
  126347. onlyCheckPointerDownEvents: boolean;
  126348. /**
  126349. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  126350. */
  126351. processAllEvents: boolean;
  126352. /**
  126353. * Observable raised when the pointer move from the utility layer scene to the main scene
  126354. */
  126355. onPointerOutObservable: Observable<number>;
  126356. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  126357. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  126358. private _afterRenderObserver;
  126359. private _sceneDisposeObserver;
  126360. private _originalPointerObserver;
  126361. /**
  126362. * Instantiates a UtilityLayerRenderer
  126363. * @param originalScene the original scene that will be rendered on top of
  126364. * @param handleEvents boolean indicating if the utility layer should handle events
  126365. */
  126366. constructor(
  126367. /** the original scene that will be rendered on top of */
  126368. originalScene: Scene, handleEvents?: boolean);
  126369. private _notifyObservers;
  126370. /**
  126371. * Renders the utility layers scene on top of the original scene
  126372. */
  126373. render(): void;
  126374. /**
  126375. * Disposes of the renderer
  126376. */
  126377. dispose(): void;
  126378. private _updateCamera;
  126379. }
  126380. }
  126381. declare module BABYLON {
  126382. /**
  126383. * Options interface for the pointer selection module
  126384. */
  126385. export interface IWebXRControllerPointerSelectionOptions {
  126386. /**
  126387. * if provided, this scene will be used to render meshes.
  126388. */
  126389. customUtilityLayerScene?: Scene;
  126390. /**
  126391. * 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)
  126392. * If not disabled, the last picked point will be used to execute a pointer up event
  126393. * If disabled, pointer up event will be triggered right after the pointer down event.
  126394. * Used in screen and gaze target ray mode only
  126395. */
  126396. disablePointerUpOnTouchOut: boolean;
  126397. /**
  126398. * For gaze mode (time to select instead of press)
  126399. */
  126400. forceGazeMode: boolean;
  126401. /**
  126402. * 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
  126403. * to start a new countdown to the pointer down event.
  126404. * Defaults to 1.
  126405. */
  126406. gazeModePointerMovedFactor?: number;
  126407. /**
  126408. * Different button type to use instead of the main component
  126409. */
  126410. overrideButtonId?: string;
  126411. /**
  126412. * use this rendering group id for the meshes (optional)
  126413. */
  126414. renderingGroupId?: number;
  126415. /**
  126416. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  126417. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  126418. * 3000 means 3 seconds between pointing at something and selecting it
  126419. */
  126420. timeToSelect?: number;
  126421. /**
  126422. * Should meshes created here be added to a utility layer or the main scene
  126423. */
  126424. useUtilityLayer?: boolean;
  126425. /**
  126426. * the xr input to use with this pointer selection
  126427. */
  126428. xrInput: WebXRInput;
  126429. }
  126430. /**
  126431. * A module that will enable pointer selection for motion controllers of XR Input Sources
  126432. */
  126433. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  126434. private readonly _options;
  126435. private static _idCounter;
  126436. private _attachController;
  126437. private _controllers;
  126438. private _scene;
  126439. private _tmpVectorForPickCompare;
  126440. /**
  126441. * The module's name
  126442. */
  126443. static readonly Name: string;
  126444. /**
  126445. * The (Babylon) version of this module.
  126446. * This is an integer representing the implementation version.
  126447. * This number does not correspond to the WebXR specs version
  126448. */
  126449. static readonly Version: number;
  126450. /**
  126451. * Disable lighting on the laser pointer (so it will always be visible)
  126452. */
  126453. disablePointerLighting: boolean;
  126454. /**
  126455. * Disable lighting on the selection mesh (so it will always be visible)
  126456. */
  126457. disableSelectionMeshLighting: boolean;
  126458. /**
  126459. * Should the laser pointer be displayed
  126460. */
  126461. displayLaserPointer: boolean;
  126462. /**
  126463. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  126464. */
  126465. displaySelectionMesh: boolean;
  126466. /**
  126467. * This color will be set to the laser pointer when selection is triggered
  126468. */
  126469. laserPointerPickedColor: Color3;
  126470. /**
  126471. * Default color of the laser pointer
  126472. */
  126473. laserPointerDefaultColor: Color3;
  126474. /**
  126475. * default color of the selection ring
  126476. */
  126477. selectionMeshDefaultColor: Color3;
  126478. /**
  126479. * This color will be applied to the selection ring when selection is triggered
  126480. */
  126481. selectionMeshPickedColor: Color3;
  126482. /**
  126483. * Optional filter to be used for ray selection. This predicate shares behavior with
  126484. * scene.pointerMovePredicate which takes priority if it is also assigned.
  126485. */
  126486. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  126487. /**
  126488. * constructs a new background remover module
  126489. * @param _xrSessionManager the session manager for this module
  126490. * @param _options read-only options to be used in this module
  126491. */
  126492. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  126493. /**
  126494. * attach this feature
  126495. * Will usually be called by the features manager
  126496. *
  126497. * @returns true if successful.
  126498. */
  126499. attach(): boolean;
  126500. /**
  126501. * detach this feature.
  126502. * Will usually be called by the features manager
  126503. *
  126504. * @returns true if successful.
  126505. */
  126506. detach(): boolean;
  126507. /**
  126508. * Will get the mesh under a specific pointer.
  126509. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  126510. * @param controllerId the controllerId to check
  126511. * @returns The mesh under pointer or null if no mesh is under the pointer
  126512. */
  126513. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  126514. /**
  126515. * Get the xr controller that correlates to the pointer id in the pointer event
  126516. *
  126517. * @param id the pointer id to search for
  126518. * @returns the controller that correlates to this id or null if not found
  126519. */
  126520. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  126521. protected _onXRFrame(_xrFrame: XRFrame): void;
  126522. private _attachGazeMode;
  126523. private _attachScreenRayMode;
  126524. private _attachTrackedPointerRayMode;
  126525. private _convertNormalToDirectionOfRay;
  126526. private _detachController;
  126527. private _generateNewMeshPair;
  126528. private _pickingMoved;
  126529. private _updatePointerDistance;
  126530. /** @hidden */
  126531. get lasterPointerDefaultColor(): Color3;
  126532. }
  126533. }
  126534. declare module BABYLON {
  126535. /**
  126536. * Button which can be used to enter a different mode of XR
  126537. */
  126538. export class WebXREnterExitUIButton {
  126539. /** button element */
  126540. element: HTMLElement;
  126541. /** XR initialization options for the button */
  126542. sessionMode: XRSessionMode;
  126543. /** Reference space type */
  126544. referenceSpaceType: XRReferenceSpaceType;
  126545. /**
  126546. * Creates a WebXREnterExitUIButton
  126547. * @param element button element
  126548. * @param sessionMode XR initialization session mode
  126549. * @param referenceSpaceType the type of reference space to be used
  126550. */
  126551. constructor(
  126552. /** button element */
  126553. element: HTMLElement,
  126554. /** XR initialization options for the button */
  126555. sessionMode: XRSessionMode,
  126556. /** Reference space type */
  126557. referenceSpaceType: XRReferenceSpaceType);
  126558. /**
  126559. * Extendable function which can be used to update the button's visuals when the state changes
  126560. * @param activeButton the current active button in the UI
  126561. */
  126562. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  126563. }
  126564. /**
  126565. * Options to create the webXR UI
  126566. */
  126567. export class WebXREnterExitUIOptions {
  126568. /**
  126569. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  126570. */
  126571. customButtons?: Array<WebXREnterExitUIButton>;
  126572. /**
  126573. * A reference space type to use when creating the default button.
  126574. * Default is local-floor
  126575. */
  126576. referenceSpaceType?: XRReferenceSpaceType;
  126577. /**
  126578. * Context to enter xr with
  126579. */
  126580. renderTarget?: Nullable<WebXRRenderTarget>;
  126581. /**
  126582. * A session mode to use when creating the default button.
  126583. * Default is immersive-vr
  126584. */
  126585. sessionMode?: XRSessionMode;
  126586. /**
  126587. * A list of optional features to init the session with
  126588. */
  126589. optionalFeatures?: string[];
  126590. /**
  126591. * A list of optional features to init the session with
  126592. */
  126593. requiredFeatures?: string[];
  126594. }
  126595. /**
  126596. * UI to allow the user to enter/exit XR mode
  126597. */
  126598. export class WebXREnterExitUI implements IDisposable {
  126599. private scene;
  126600. /** version of the options passed to this UI */
  126601. options: WebXREnterExitUIOptions;
  126602. private _activeButton;
  126603. private _buttons;
  126604. private _overlay;
  126605. /**
  126606. * Fired every time the active button is changed.
  126607. *
  126608. * When xr is entered via a button that launches xr that button will be the callback parameter
  126609. *
  126610. * When exiting xr the callback parameter will be null)
  126611. */
  126612. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  126613. /**
  126614. *
  126615. * @param scene babylon scene object to use
  126616. * @param options (read-only) version of the options passed to this UI
  126617. */
  126618. private constructor();
  126619. /**
  126620. * Creates UI to allow the user to enter/exit XR mode
  126621. * @param scene the scene to add the ui to
  126622. * @param helper the xr experience helper to enter/exit xr with
  126623. * @param options options to configure the UI
  126624. * @returns the created ui
  126625. */
  126626. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  126627. /**
  126628. * Disposes of the XR UI component
  126629. */
  126630. dispose(): void;
  126631. private _updateButtons;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * Class containing static functions to help procedurally build meshes
  126637. */
  126638. export class LinesBuilder {
  126639. /**
  126640. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  126641. * * 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
  126642. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  126643. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  126644. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  126645. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  126646. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126647. * * 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
  126648. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  126649. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126650. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  126651. * @param name defines the name of the new line system
  126652. * @param options defines the options used to create the line system
  126653. * @param scene defines the hosting scene
  126654. * @returns a new line system mesh
  126655. */
  126656. static CreateLineSystem(name: string, options: {
  126657. lines: Vector3[][];
  126658. updatable?: boolean;
  126659. instance?: Nullable<LinesMesh>;
  126660. colors?: Nullable<Color4[][]>;
  126661. useVertexAlpha?: boolean;
  126662. }, scene: Nullable<Scene>): LinesMesh;
  126663. /**
  126664. * Creates a line mesh
  126665. * 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
  126666. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126667. * * The parameter `points` is an array successive Vector3
  126668. * * 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
  126669. * * The optional parameter `colors` is an array of successive Color4, one per line point
  126670. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  126671. * * When updating an instance, remember that only point positions can change, not the number of points
  126672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126673. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  126674. * @param name defines the name of the new line system
  126675. * @param options defines the options used to create the line system
  126676. * @param scene defines the hosting scene
  126677. * @returns a new line mesh
  126678. */
  126679. static CreateLines(name: string, options: {
  126680. points: Vector3[];
  126681. updatable?: boolean;
  126682. instance?: Nullable<LinesMesh>;
  126683. colors?: Color4[];
  126684. useVertexAlpha?: boolean;
  126685. }, scene?: Nullable<Scene>): LinesMesh;
  126686. /**
  126687. * Creates a dashed line mesh
  126688. * * 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
  126689. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  126690. * * The parameter `points` is an array successive Vector3
  126691. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  126692. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  126693. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  126694. * * 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
  126695. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  126696. * * When updating an instance, remember that only point positions can change, not the number of points
  126697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126698. * @param name defines the name of the mesh
  126699. * @param options defines the options used to create the mesh
  126700. * @param scene defines the hosting scene
  126701. * @returns the dashed line mesh
  126702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  126703. */
  126704. static CreateDashedLines(name: string, options: {
  126705. points: Vector3[];
  126706. dashSize?: number;
  126707. gapSize?: number;
  126708. dashNb?: number;
  126709. updatable?: boolean;
  126710. instance?: LinesMesh;
  126711. useVertexAlpha?: boolean;
  126712. }, scene?: Nullable<Scene>): LinesMesh;
  126713. }
  126714. }
  126715. declare module BABYLON {
  126716. /**
  126717. * Construction options for a timer
  126718. */
  126719. export interface ITimerOptions<T> {
  126720. /**
  126721. * Time-to-end
  126722. */
  126723. timeout: number;
  126724. /**
  126725. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  126726. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  126727. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  126728. */
  126729. contextObservable: Observable<T>;
  126730. /**
  126731. * Optional parameters when adding an observer to the observable
  126732. */
  126733. observableParameters?: {
  126734. mask?: number;
  126735. insertFirst?: boolean;
  126736. scope?: any;
  126737. };
  126738. /**
  126739. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  126740. */
  126741. breakCondition?: (data?: ITimerData<T>) => boolean;
  126742. /**
  126743. * Will be triggered when the time condition has met
  126744. */
  126745. onEnded?: (data: ITimerData<any>) => void;
  126746. /**
  126747. * Will be triggered when the break condition has met (prematurely ended)
  126748. */
  126749. onAborted?: (data: ITimerData<any>) => void;
  126750. /**
  126751. * Optional function to execute on each tick (or count)
  126752. */
  126753. onTick?: (data: ITimerData<any>) => void;
  126754. }
  126755. /**
  126756. * An interface defining the data sent by the timer
  126757. */
  126758. export interface ITimerData<T> {
  126759. /**
  126760. * When did it start
  126761. */
  126762. startTime: number;
  126763. /**
  126764. * Time now
  126765. */
  126766. currentTime: number;
  126767. /**
  126768. * Time passed since started
  126769. */
  126770. deltaTime: number;
  126771. /**
  126772. * How much is completed, in [0.0...1.0].
  126773. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  126774. */
  126775. completeRate: number;
  126776. /**
  126777. * What the registered observable sent in the last count
  126778. */
  126779. payload: T;
  126780. }
  126781. /**
  126782. * The current state of the timer
  126783. */
  126784. export enum TimerState {
  126785. /**
  126786. * Timer initialized, not yet started
  126787. */
  126788. INIT = 0,
  126789. /**
  126790. * Timer started and counting
  126791. */
  126792. STARTED = 1,
  126793. /**
  126794. * Timer ended (whether aborted or time reached)
  126795. */
  126796. ENDED = 2
  126797. }
  126798. /**
  126799. * A simple version of the timer. Will take options and start the timer immediately after calling it
  126800. *
  126801. * @param options options with which to initialize this timer
  126802. */
  126803. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  126804. /**
  126805. * An advanced implementation of a timer class
  126806. */
  126807. export class AdvancedTimer<T = any> implements IDisposable {
  126808. /**
  126809. * Will notify each time the timer calculates the remaining time
  126810. */
  126811. onEachCountObservable: Observable<ITimerData<T>>;
  126812. /**
  126813. * Will trigger when the timer was aborted due to the break condition
  126814. */
  126815. onTimerAbortedObservable: Observable<ITimerData<T>>;
  126816. /**
  126817. * Will trigger when the timer ended successfully
  126818. */
  126819. onTimerEndedObservable: Observable<ITimerData<T>>;
  126820. /**
  126821. * Will trigger when the timer state has changed
  126822. */
  126823. onStateChangedObservable: Observable<TimerState>;
  126824. private _observer;
  126825. private _contextObservable;
  126826. private _observableParameters;
  126827. private _startTime;
  126828. private _timer;
  126829. private _state;
  126830. private _breakCondition;
  126831. private _timeToEnd;
  126832. private _breakOnNextTick;
  126833. /**
  126834. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  126835. * @param options construction options for this advanced timer
  126836. */
  126837. constructor(options: ITimerOptions<T>);
  126838. /**
  126839. * set a breaking condition for this timer. Default is to never break during count
  126840. * @param predicate the new break condition. Returns true to break, false otherwise
  126841. */
  126842. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  126843. /**
  126844. * Reset ALL associated observables in this advanced timer
  126845. */
  126846. clearObservables(): void;
  126847. /**
  126848. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  126849. *
  126850. * @param timeToEnd how much time to measure until timer ended
  126851. */
  126852. start(timeToEnd?: number): void;
  126853. /**
  126854. * Will force a stop on the next tick.
  126855. */
  126856. stop(): void;
  126857. /**
  126858. * Dispose this timer, clearing all resources
  126859. */
  126860. dispose(): void;
  126861. private _setState;
  126862. private _tick;
  126863. private _stop;
  126864. }
  126865. }
  126866. declare module BABYLON {
  126867. /**
  126868. * The options container for the teleportation module
  126869. */
  126870. export interface IWebXRTeleportationOptions {
  126871. /**
  126872. * if provided, this scene will be used to render meshes.
  126873. */
  126874. customUtilityLayerScene?: Scene;
  126875. /**
  126876. * Values to configure the default target mesh
  126877. */
  126878. defaultTargetMeshOptions?: {
  126879. /**
  126880. * Fill color of the teleportation area
  126881. */
  126882. teleportationFillColor?: string;
  126883. /**
  126884. * Border color for the teleportation area
  126885. */
  126886. teleportationBorderColor?: string;
  126887. /**
  126888. * Disable the mesh's animation sequence
  126889. */
  126890. disableAnimation?: boolean;
  126891. /**
  126892. * Disable lighting on the material or the ring and arrow
  126893. */
  126894. disableLighting?: boolean;
  126895. /**
  126896. * Override the default material of the torus and arrow
  126897. */
  126898. torusArrowMaterial?: Material;
  126899. };
  126900. /**
  126901. * A list of meshes to use as floor meshes.
  126902. * Meshes can be added and removed after initializing the feature using the
  126903. * addFloorMesh and removeFloorMesh functions
  126904. * If empty, rotation will still work
  126905. */
  126906. floorMeshes?: AbstractMesh[];
  126907. /**
  126908. * use this rendering group id for the meshes (optional)
  126909. */
  126910. renderingGroupId?: number;
  126911. /**
  126912. * Should teleportation move only to snap points
  126913. */
  126914. snapPointsOnly?: boolean;
  126915. /**
  126916. * An array of points to which the teleportation will snap to.
  126917. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  126918. */
  126919. snapPositions?: Vector3[];
  126920. /**
  126921. * How close should the teleportation ray be in order to snap to position.
  126922. * Default to 0.8 units (meters)
  126923. */
  126924. snapToPositionRadius?: number;
  126925. /**
  126926. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  126927. * If you want to support rotation, make sure your mesh has a direction indicator.
  126928. *
  126929. * When left untouched, the default mesh will be initialized.
  126930. */
  126931. teleportationTargetMesh?: AbstractMesh;
  126932. /**
  126933. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  126934. */
  126935. timeToTeleport?: number;
  126936. /**
  126937. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  126938. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  126939. */
  126940. useMainComponentOnly?: boolean;
  126941. /**
  126942. * Should meshes created here be added to a utility layer or the main scene
  126943. */
  126944. useUtilityLayer?: boolean;
  126945. /**
  126946. * Babylon XR Input class for controller
  126947. */
  126948. xrInput: WebXRInput;
  126949. }
  126950. /**
  126951. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  126952. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  126953. * the input of the attached controllers.
  126954. */
  126955. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  126956. private _options;
  126957. private _controllers;
  126958. private _currentTeleportationControllerId;
  126959. private _floorMeshes;
  126960. private _quadraticBezierCurve;
  126961. private _selectionFeature;
  126962. private _snapToPositions;
  126963. private _snappedToPoint;
  126964. private _teleportationRingMaterial?;
  126965. private _tmpRay;
  126966. private _tmpVector;
  126967. /**
  126968. * The module's name
  126969. */
  126970. static readonly Name: string;
  126971. /**
  126972. * The (Babylon) version of this module.
  126973. * This is an integer representing the implementation version.
  126974. * This number does not correspond to the webxr specs version
  126975. */
  126976. static readonly Version: number;
  126977. /**
  126978. * Is movement backwards enabled
  126979. */
  126980. backwardsMovementEnabled: boolean;
  126981. /**
  126982. * Distance to travel when moving backwards
  126983. */
  126984. backwardsTeleportationDistance: number;
  126985. /**
  126986. * The distance from the user to the inspection point in the direction of the controller
  126987. * A higher number will allow the user to move further
  126988. * defaults to 5 (meters, in xr units)
  126989. */
  126990. parabolicCheckRadius: number;
  126991. /**
  126992. * Should the module support parabolic ray on top of direct ray
  126993. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  126994. * Very helpful when moving between floors / different heights
  126995. */
  126996. parabolicRayEnabled: boolean;
  126997. /**
  126998. * How much rotation should be applied when rotating right and left
  126999. */
  127000. rotationAngle: number;
  127001. /**
  127002. * Is rotation enabled when moving forward?
  127003. * Disabling this feature will prevent the user from deciding the direction when teleporting
  127004. */
  127005. rotationEnabled: boolean;
  127006. /**
  127007. * constructs a new anchor system
  127008. * @param _xrSessionManager an instance of WebXRSessionManager
  127009. * @param _options configuration object for this feature
  127010. */
  127011. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  127012. /**
  127013. * Get the snapPointsOnly flag
  127014. */
  127015. get snapPointsOnly(): boolean;
  127016. /**
  127017. * Sets the snapPointsOnly flag
  127018. * @param snapToPoints should teleportation be exclusively to snap points
  127019. */
  127020. set snapPointsOnly(snapToPoints: boolean);
  127021. /**
  127022. * Add a new mesh to the floor meshes array
  127023. * @param mesh the mesh to use as floor mesh
  127024. */
  127025. addFloorMesh(mesh: AbstractMesh): void;
  127026. /**
  127027. * Add a new snap-to point to fix teleportation to this position
  127028. * @param newSnapPoint The new Snap-To point
  127029. */
  127030. addSnapPoint(newSnapPoint: Vector3): void;
  127031. attach(): boolean;
  127032. detach(): boolean;
  127033. dispose(): void;
  127034. /**
  127035. * Remove a mesh from the floor meshes array
  127036. * @param mesh the mesh to remove
  127037. */
  127038. removeFloorMesh(mesh: AbstractMesh): void;
  127039. /**
  127040. * Remove a mesh from the floor meshes array using its name
  127041. * @param name the mesh name to remove
  127042. */
  127043. removeFloorMeshByName(name: string): void;
  127044. /**
  127045. * 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
  127046. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  127047. * @returns was the point found and removed or not
  127048. */
  127049. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  127050. /**
  127051. * This function sets a selection feature that will be disabled when
  127052. * the forward ray is shown and will be reattached when hidden.
  127053. * This is used to remove the selection rays when moving.
  127054. * @param selectionFeature the feature to disable when forward movement is enabled
  127055. */
  127056. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  127057. protected _onXRFrame(_xrFrame: XRFrame): void;
  127058. private _attachController;
  127059. private _createDefaultTargetMesh;
  127060. private _detachController;
  127061. private _findClosestSnapPointWithRadius;
  127062. private _setTargetMeshPosition;
  127063. private _setTargetMeshVisibility;
  127064. private _showParabolicPath;
  127065. private _teleportForward;
  127066. }
  127067. }
  127068. declare module BABYLON {
  127069. /**
  127070. * Options for the default xr helper
  127071. */
  127072. export class WebXRDefaultExperienceOptions {
  127073. /**
  127074. * Enable or disable default UI to enter XR
  127075. */
  127076. disableDefaultUI?: boolean;
  127077. /**
  127078. * Should teleportation not initialize. defaults to false.
  127079. */
  127080. disableTeleportation?: boolean;
  127081. /**
  127082. * Floor meshes that will be used for teleport
  127083. */
  127084. floorMeshes?: Array<AbstractMesh>;
  127085. /**
  127086. * If set to true, the first frame will not be used to reset position
  127087. * The first frame is mainly used when copying transformation from the old camera
  127088. * Mainly used in AR
  127089. */
  127090. ignoreNativeCameraTransformation?: boolean;
  127091. /**
  127092. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  127093. */
  127094. inputOptions?: IWebXRInputOptions;
  127095. /**
  127096. * optional configuration for the output canvas
  127097. */
  127098. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  127099. /**
  127100. * optional UI options. This can be used among other to change session mode and reference space type
  127101. */
  127102. uiOptions?: WebXREnterExitUIOptions;
  127103. /**
  127104. * When loading teleportation and pointer select, use stable versions instead of latest.
  127105. */
  127106. useStablePlugins?: boolean;
  127107. /**
  127108. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  127109. */
  127110. renderingGroupId?: number;
  127111. /**
  127112. * A list of optional features to init the session with
  127113. * If set to true, all features we support will be added
  127114. */
  127115. optionalFeatures?: boolean | string[];
  127116. }
  127117. /**
  127118. * Default experience which provides a similar setup to the previous webVRExperience
  127119. */
  127120. export class WebXRDefaultExperience {
  127121. /**
  127122. * Base experience
  127123. */
  127124. baseExperience: WebXRExperienceHelper;
  127125. /**
  127126. * Enables ui for entering/exiting xr
  127127. */
  127128. enterExitUI: WebXREnterExitUI;
  127129. /**
  127130. * Input experience extension
  127131. */
  127132. input: WebXRInput;
  127133. /**
  127134. * Enables laser pointer and selection
  127135. */
  127136. pointerSelection: WebXRControllerPointerSelection;
  127137. /**
  127138. * Default target xr should render to
  127139. */
  127140. renderTarget: WebXRRenderTarget;
  127141. /**
  127142. * Enables teleportation
  127143. */
  127144. teleportation: WebXRMotionControllerTeleportation;
  127145. private constructor();
  127146. /**
  127147. * Creates the default xr experience
  127148. * @param scene scene
  127149. * @param options options for basic configuration
  127150. * @returns resulting WebXRDefaultExperience
  127151. */
  127152. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127153. /**
  127154. * DIsposes of the experience helper
  127155. */
  127156. dispose(): void;
  127157. }
  127158. }
  127159. declare module BABYLON {
  127160. /**
  127161. * Options to modify the vr teleportation behavior.
  127162. */
  127163. export interface VRTeleportationOptions {
  127164. /**
  127165. * The name of the mesh which should be used as the teleportation floor. (default: null)
  127166. */
  127167. floorMeshName?: string;
  127168. /**
  127169. * A list of meshes to be used as the teleportation floor. (default: empty)
  127170. */
  127171. floorMeshes?: Mesh[];
  127172. /**
  127173. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  127174. */
  127175. teleportationMode?: number;
  127176. /**
  127177. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  127178. */
  127179. teleportationTime?: number;
  127180. /**
  127181. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  127182. */
  127183. teleportationSpeed?: number;
  127184. /**
  127185. * The easing function used in the animation or null for Linear. (default CircleEase)
  127186. */
  127187. easingFunction?: EasingFunction;
  127188. }
  127189. /**
  127190. * Options to modify the vr experience helper's behavior.
  127191. */
  127192. export interface VRExperienceHelperOptions extends WebVROptions {
  127193. /**
  127194. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  127195. */
  127196. createDeviceOrientationCamera?: boolean;
  127197. /**
  127198. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  127199. */
  127200. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  127201. /**
  127202. * Uses the main button on the controller to toggle the laser casted. (default: true)
  127203. */
  127204. laserToggle?: boolean;
  127205. /**
  127206. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  127207. */
  127208. floorMeshes?: Mesh[];
  127209. /**
  127210. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  127211. */
  127212. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  127213. /**
  127214. * Defines if WebXR should be used instead of WebVR (if available)
  127215. */
  127216. useXR?: boolean;
  127217. }
  127218. /**
  127219. * Event containing information after VR has been entered
  127220. */
  127221. export class OnAfterEnteringVRObservableEvent {
  127222. /**
  127223. * If entering vr was successful
  127224. */
  127225. success: boolean;
  127226. }
  127227. /**
  127228. * Helps to quickly add VR support to an existing scene.
  127229. * See https://doc.babylonjs.com/how_to/webvr_helper
  127230. */
  127231. export class VRExperienceHelper {
  127232. /** Options to modify the vr experience helper's behavior. */
  127233. webVROptions: VRExperienceHelperOptions;
  127234. private _scene;
  127235. private _position;
  127236. private _btnVR;
  127237. private _btnVRDisplayed;
  127238. private _webVRsupported;
  127239. private _webVRready;
  127240. private _webVRrequesting;
  127241. private _webVRpresenting;
  127242. private _hasEnteredVR;
  127243. private _fullscreenVRpresenting;
  127244. private _inputElement;
  127245. private _webVRCamera;
  127246. private _vrDeviceOrientationCamera;
  127247. private _deviceOrientationCamera;
  127248. private _existingCamera;
  127249. private _onKeyDown;
  127250. private _onVrDisplayPresentChange;
  127251. private _onVRDisplayChanged;
  127252. private _onVRRequestPresentStart;
  127253. private _onVRRequestPresentComplete;
  127254. /**
  127255. * 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)
  127256. */
  127257. enableGazeEvenWhenNoPointerLock: boolean;
  127258. /**
  127259. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  127260. */
  127261. exitVROnDoubleTap: boolean;
  127262. /**
  127263. * Observable raised right before entering VR.
  127264. */
  127265. onEnteringVRObservable: Observable<VRExperienceHelper>;
  127266. /**
  127267. * Observable raised when entering VR has completed.
  127268. */
  127269. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  127270. /**
  127271. * Observable raised when exiting VR.
  127272. */
  127273. onExitingVRObservable: Observable<VRExperienceHelper>;
  127274. /**
  127275. * Observable raised when controller mesh is loaded.
  127276. */
  127277. onControllerMeshLoadedObservable: Observable<WebVRController>;
  127278. /** Return this.onEnteringVRObservable
  127279. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  127280. */
  127281. get onEnteringVR(): Observable<VRExperienceHelper>;
  127282. /** Return this.onExitingVRObservable
  127283. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  127284. */
  127285. get onExitingVR(): Observable<VRExperienceHelper>;
  127286. /** Return this.onControllerMeshLoadedObservable
  127287. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  127288. */
  127289. get onControllerMeshLoaded(): Observable<WebVRController>;
  127290. private _rayLength;
  127291. private _useCustomVRButton;
  127292. private _teleportationRequested;
  127293. private _teleportActive;
  127294. private _floorMeshName;
  127295. private _floorMeshesCollection;
  127296. private _teleportationMode;
  127297. private _teleportationTime;
  127298. private _teleportationSpeed;
  127299. private _teleportationEasing;
  127300. private _rotationAllowed;
  127301. private _teleportBackwardsVector;
  127302. private _teleportationTarget;
  127303. private _isDefaultTeleportationTarget;
  127304. private _postProcessMove;
  127305. private _teleportationFillColor;
  127306. private _teleportationBorderColor;
  127307. private _rotationAngle;
  127308. private _haloCenter;
  127309. private _cameraGazer;
  127310. private _padSensibilityUp;
  127311. private _padSensibilityDown;
  127312. private _leftController;
  127313. private _rightController;
  127314. private _gazeColor;
  127315. private _laserColor;
  127316. private _pickedLaserColor;
  127317. private _pickedGazeColor;
  127318. /**
  127319. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  127320. */
  127321. onNewMeshSelected: Observable<AbstractMesh>;
  127322. /**
  127323. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  127324. * This observable will provide the mesh and the controller used to select the mesh
  127325. */
  127326. onMeshSelectedWithController: Observable<{
  127327. mesh: AbstractMesh;
  127328. controller: WebVRController;
  127329. }>;
  127330. /**
  127331. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  127332. */
  127333. onNewMeshPicked: Observable<PickingInfo>;
  127334. private _circleEase;
  127335. /**
  127336. * Observable raised before camera teleportation
  127337. */
  127338. onBeforeCameraTeleport: Observable<Vector3>;
  127339. /**
  127340. * Observable raised after camera teleportation
  127341. */
  127342. onAfterCameraTeleport: Observable<Vector3>;
  127343. /**
  127344. * Observable raised when current selected mesh gets unselected
  127345. */
  127346. onSelectedMeshUnselected: Observable<AbstractMesh>;
  127347. private _raySelectionPredicate;
  127348. /**
  127349. * To be optionaly changed by user to define custom ray selection
  127350. */
  127351. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  127352. /**
  127353. * To be optionaly changed by user to define custom selection logic (after ray selection)
  127354. */
  127355. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127356. /**
  127357. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  127358. */
  127359. teleportationEnabled: boolean;
  127360. private _defaultHeight;
  127361. private _teleportationInitialized;
  127362. private _interactionsEnabled;
  127363. private _interactionsRequested;
  127364. private _displayGaze;
  127365. private _displayLaserPointer;
  127366. /**
  127367. * The mesh used to display where the user is going to teleport.
  127368. */
  127369. get teleportationTarget(): Mesh;
  127370. /**
  127371. * Sets the mesh to be used to display where the user is going to teleport.
  127372. */
  127373. set teleportationTarget(value: Mesh);
  127374. /**
  127375. * 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
  127376. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  127377. * See https://doc.babylonjs.com/resources/baking_transformations
  127378. */
  127379. get gazeTrackerMesh(): Mesh;
  127380. set gazeTrackerMesh(value: Mesh);
  127381. /**
  127382. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  127383. */
  127384. updateGazeTrackerScale: boolean;
  127385. /**
  127386. * If the gaze trackers color should be updated when selecting meshes
  127387. */
  127388. updateGazeTrackerColor: boolean;
  127389. /**
  127390. * If the controller laser color should be updated when selecting meshes
  127391. */
  127392. updateControllerLaserColor: boolean;
  127393. /**
  127394. * The gaze tracking mesh corresponding to the left controller
  127395. */
  127396. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  127397. /**
  127398. * The gaze tracking mesh corresponding to the right controller
  127399. */
  127400. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  127401. /**
  127402. * If the ray of the gaze should be displayed.
  127403. */
  127404. get displayGaze(): boolean;
  127405. /**
  127406. * Sets if the ray of the gaze should be displayed.
  127407. */
  127408. set displayGaze(value: boolean);
  127409. /**
  127410. * If the ray of the LaserPointer should be displayed.
  127411. */
  127412. get displayLaserPointer(): boolean;
  127413. /**
  127414. * Sets if the ray of the LaserPointer should be displayed.
  127415. */
  127416. set displayLaserPointer(value: boolean);
  127417. /**
  127418. * The deviceOrientationCamera used as the camera when not in VR.
  127419. */
  127420. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  127421. /**
  127422. * Based on the current WebVR support, returns the current VR camera used.
  127423. */
  127424. get currentVRCamera(): Nullable<Camera>;
  127425. /**
  127426. * The webVRCamera which is used when in VR.
  127427. */
  127428. get webVRCamera(): WebVRFreeCamera;
  127429. /**
  127430. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  127431. */
  127432. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  127433. /**
  127434. * The html button that is used to trigger entering into VR.
  127435. */
  127436. get vrButton(): Nullable<HTMLButtonElement>;
  127437. private get _teleportationRequestInitiated();
  127438. /**
  127439. * Defines whether or not Pointer lock should be requested when switching to
  127440. * full screen.
  127441. */
  127442. requestPointerLockOnFullScreen: boolean;
  127443. /**
  127444. * If asking to force XR, this will be populated with the default xr experience
  127445. */
  127446. xr: WebXRDefaultExperience;
  127447. /**
  127448. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  127449. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  127450. */
  127451. xrTestDone: boolean;
  127452. /**
  127453. * Instantiates a VRExperienceHelper.
  127454. * Helps to quickly add VR support to an existing scene.
  127455. * @param scene The scene the VRExperienceHelper belongs to.
  127456. * @param webVROptions Options to modify the vr experience helper's behavior.
  127457. */
  127458. constructor(scene: Scene,
  127459. /** Options to modify the vr experience helper's behavior. */
  127460. webVROptions?: VRExperienceHelperOptions);
  127461. private completeVRInit;
  127462. private _onDefaultMeshLoaded;
  127463. private _onResize;
  127464. private _onFullscreenChange;
  127465. /**
  127466. * Gets a value indicating if we are currently in VR mode.
  127467. */
  127468. get isInVRMode(): boolean;
  127469. private onVrDisplayPresentChange;
  127470. private onVRDisplayChanged;
  127471. private moveButtonToBottomRight;
  127472. private displayVRButton;
  127473. private updateButtonVisibility;
  127474. private _cachedAngularSensibility;
  127475. /**
  127476. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  127477. * Otherwise, will use the fullscreen API.
  127478. */
  127479. enterVR(): void;
  127480. /**
  127481. * Attempt to exit VR, or fullscreen.
  127482. */
  127483. exitVR(): void;
  127484. /**
  127485. * The position of the vr experience helper.
  127486. */
  127487. get position(): Vector3;
  127488. /**
  127489. * Sets the position of the vr experience helper.
  127490. */
  127491. set position(value: Vector3);
  127492. /**
  127493. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  127494. */
  127495. enableInteractions(): void;
  127496. private get _noControllerIsActive();
  127497. private beforeRender;
  127498. private _isTeleportationFloor;
  127499. /**
  127500. * Adds a floor mesh to be used for teleportation.
  127501. * @param floorMesh the mesh to be used for teleportation.
  127502. */
  127503. addFloorMesh(floorMesh: Mesh): void;
  127504. /**
  127505. * Removes a floor mesh from being used for teleportation.
  127506. * @param floorMesh the mesh to be removed.
  127507. */
  127508. removeFloorMesh(floorMesh: Mesh): void;
  127509. /**
  127510. * Enables interactions and teleportation using the VR controllers and gaze.
  127511. * @param vrTeleportationOptions options to modify teleportation behavior.
  127512. */
  127513. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  127514. private _onNewGamepadConnected;
  127515. private _tryEnableInteractionOnController;
  127516. private _onNewGamepadDisconnected;
  127517. private _enableInteractionOnController;
  127518. private _checkTeleportWithRay;
  127519. private _checkRotate;
  127520. private _checkTeleportBackwards;
  127521. private _enableTeleportationOnController;
  127522. private _createTeleportationCircles;
  127523. private _displayTeleportationTarget;
  127524. private _hideTeleportationTarget;
  127525. private _rotateCamera;
  127526. private _moveTeleportationSelectorTo;
  127527. private _workingVector;
  127528. private _workingQuaternion;
  127529. private _workingMatrix;
  127530. /**
  127531. * Time Constant Teleportation Mode
  127532. */
  127533. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  127534. /**
  127535. * Speed Constant Teleportation Mode
  127536. */
  127537. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  127538. /**
  127539. * Teleports the users feet to the desired location
  127540. * @param location The location where the user's feet should be placed
  127541. */
  127542. teleportCamera(location: Vector3): void;
  127543. private _convertNormalToDirectionOfRay;
  127544. private _castRayAndSelectObject;
  127545. private _notifySelectedMeshUnselected;
  127546. /**
  127547. * Permanently set new colors for the laser pointer
  127548. * @param color the new laser color
  127549. * @param pickedColor the new laser color when picked mesh detected
  127550. */
  127551. setLaserColor(color: Color3, pickedColor?: Color3): void;
  127552. /**
  127553. * Set lighting enabled / disabled on the laser pointer of both controllers
  127554. * @param enabled should the lighting be enabled on the laser pointer
  127555. */
  127556. setLaserLightingState(enabled?: boolean): void;
  127557. /**
  127558. * Permanently set new colors for the gaze pointer
  127559. * @param color the new gaze color
  127560. * @param pickedColor the new gaze color when picked mesh detected
  127561. */
  127562. setGazeColor(color: Color3, pickedColor?: Color3): void;
  127563. /**
  127564. * Sets the color of the laser ray from the vr controllers.
  127565. * @param color new color for the ray.
  127566. */
  127567. changeLaserColor(color: Color3): void;
  127568. /**
  127569. * Sets the color of the ray from the vr headsets gaze.
  127570. * @param color new color for the ray.
  127571. */
  127572. changeGazeColor(color: Color3): void;
  127573. /**
  127574. * Exits VR and disposes of the vr experience helper
  127575. */
  127576. dispose(): void;
  127577. /**
  127578. * Gets the name of the VRExperienceHelper class
  127579. * @returns "VRExperienceHelper"
  127580. */
  127581. getClassName(): string;
  127582. }
  127583. }
  127584. declare module BABYLON {
  127585. /**
  127586. * Contains an array of blocks representing the octree
  127587. */
  127588. export interface IOctreeContainer<T> {
  127589. /**
  127590. * Blocks within the octree
  127591. */
  127592. blocks: Array<OctreeBlock<T>>;
  127593. }
  127594. /**
  127595. * Class used to store a cell in an octree
  127596. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127597. */
  127598. export class OctreeBlock<T> {
  127599. /**
  127600. * Gets the content of the current block
  127601. */
  127602. entries: T[];
  127603. /**
  127604. * Gets the list of block children
  127605. */
  127606. blocks: Array<OctreeBlock<T>>;
  127607. private _depth;
  127608. private _maxDepth;
  127609. private _capacity;
  127610. private _minPoint;
  127611. private _maxPoint;
  127612. private _boundingVectors;
  127613. private _creationFunc;
  127614. /**
  127615. * Creates a new block
  127616. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  127617. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  127618. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127619. * @param depth defines the current depth of this block in the octree
  127620. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  127621. * @param creationFunc defines a callback to call when an element is added to the block
  127622. */
  127623. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  127624. /**
  127625. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  127626. */
  127627. get capacity(): number;
  127628. /**
  127629. * Gets the minimum vector (in world space) of the block's bounding box
  127630. */
  127631. get minPoint(): Vector3;
  127632. /**
  127633. * Gets the maximum vector (in world space) of the block's bounding box
  127634. */
  127635. get maxPoint(): Vector3;
  127636. /**
  127637. * Add a new element to this block
  127638. * @param entry defines the element to add
  127639. */
  127640. addEntry(entry: T): void;
  127641. /**
  127642. * Remove an element from this block
  127643. * @param entry defines the element to remove
  127644. */
  127645. removeEntry(entry: T): void;
  127646. /**
  127647. * Add an array of elements to this block
  127648. * @param entries defines the array of elements to add
  127649. */
  127650. addEntries(entries: T[]): void;
  127651. /**
  127652. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  127653. * @param frustumPlanes defines the frustum planes to test
  127654. * @param selection defines the array to store current content if selection is positive
  127655. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127656. */
  127657. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127658. /**
  127659. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  127660. * @param sphereCenter defines the bounding sphere center
  127661. * @param sphereRadius defines the bounding sphere radius
  127662. * @param selection defines the array to store current content if selection is positive
  127663. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127664. */
  127665. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  127666. /**
  127667. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  127668. * @param ray defines the ray to test with
  127669. * @param selection defines the array to store current content if selection is positive
  127670. */
  127671. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  127672. /**
  127673. * Subdivide the content into child blocks (this block will then be empty)
  127674. */
  127675. createInnerBlocks(): void;
  127676. /**
  127677. * @hidden
  127678. */
  127679. 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;
  127680. }
  127681. }
  127682. declare module BABYLON {
  127683. /**
  127684. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  127685. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127686. */
  127687. export class Octree<T> {
  127688. /** 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.) */
  127689. maxDepth: number;
  127690. /**
  127691. * Blocks within the octree containing objects
  127692. */
  127693. blocks: Array<OctreeBlock<T>>;
  127694. /**
  127695. * Content stored in the octree
  127696. */
  127697. dynamicContent: T[];
  127698. private _maxBlockCapacity;
  127699. private _selectionContent;
  127700. private _creationFunc;
  127701. /**
  127702. * Creates a octree
  127703. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127704. * @param creationFunc function to be used to instatiate the octree
  127705. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  127706. * @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.)
  127707. */
  127708. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  127709. /** 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.) */
  127710. maxDepth?: number);
  127711. /**
  127712. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  127713. * @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);
  127714. * @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);
  127715. * @param entries meshes to be added to the octree blocks
  127716. */
  127717. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  127718. /**
  127719. * Adds a mesh to the octree
  127720. * @param entry Mesh to add to the octree
  127721. */
  127722. addMesh(entry: T): void;
  127723. /**
  127724. * Remove an element from the octree
  127725. * @param entry defines the element to remove
  127726. */
  127727. removeMesh(entry: T): void;
  127728. /**
  127729. * Selects an array of meshes within the frustum
  127730. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  127731. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  127732. * @returns array of meshes within the frustum
  127733. */
  127734. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  127735. /**
  127736. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  127737. * @param sphereCenter defines the bounding sphere center
  127738. * @param sphereRadius defines the bounding sphere radius
  127739. * @param allowDuplicate defines if the selection array can contains duplicated entries
  127740. * @returns an array of objects that intersect the sphere
  127741. */
  127742. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  127743. /**
  127744. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  127745. * @param ray defines the ray to test with
  127746. * @returns array of intersected objects
  127747. */
  127748. intersectsRay(ray: Ray): SmartArray<T>;
  127749. /**
  127750. * Adds a mesh into the octree block if it intersects the block
  127751. */
  127752. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  127753. /**
  127754. * Adds a submesh into the octree block if it intersects the block
  127755. */
  127756. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  127757. }
  127758. }
  127759. declare module BABYLON {
  127760. interface Scene {
  127761. /**
  127762. * @hidden
  127763. * Backing Filed
  127764. */
  127765. _selectionOctree: Octree<AbstractMesh>;
  127766. /**
  127767. * Gets the octree used to boost mesh selection (picking)
  127768. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127769. */
  127770. selectionOctree: Octree<AbstractMesh>;
  127771. /**
  127772. * Creates or updates the octree used to boost selection (picking)
  127773. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127774. * @param maxCapacity defines the maximum capacity per leaf
  127775. * @param maxDepth defines the maximum depth of the octree
  127776. * @returns an octree of AbstractMesh
  127777. */
  127778. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  127779. }
  127780. interface AbstractMesh {
  127781. /**
  127782. * @hidden
  127783. * Backing Field
  127784. */
  127785. _submeshesOctree: Octree<SubMesh>;
  127786. /**
  127787. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  127788. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  127789. * @param maxCapacity defines the maximum size of each block (64 by default)
  127790. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  127791. * @returns the new octree
  127792. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  127793. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  127794. */
  127795. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  127796. }
  127797. /**
  127798. * Defines the octree scene component responsible to manage any octrees
  127799. * in a given scene.
  127800. */
  127801. export class OctreeSceneComponent {
  127802. /**
  127803. * The component name help to identify the component in the list of scene components.
  127804. */
  127805. readonly name: string;
  127806. /**
  127807. * The scene the component belongs to.
  127808. */
  127809. scene: Scene;
  127810. /**
  127811. * Indicates if the meshes have been checked to make sure they are isEnabled()
  127812. */
  127813. readonly checksIsEnabled: boolean;
  127814. /**
  127815. * Creates a new instance of the component for the given scene
  127816. * @param scene Defines the scene to register the component in
  127817. */
  127818. constructor(scene: Scene);
  127819. /**
  127820. * Registers the component in a given scene
  127821. */
  127822. register(): void;
  127823. /**
  127824. * Return the list of active meshes
  127825. * @returns the list of active meshes
  127826. */
  127827. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  127828. /**
  127829. * Return the list of active sub meshes
  127830. * @param mesh The mesh to get the candidates sub meshes from
  127831. * @returns the list of active sub meshes
  127832. */
  127833. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  127834. private _tempRay;
  127835. /**
  127836. * Return the list of sub meshes intersecting with a given local ray
  127837. * @param mesh defines the mesh to find the submesh for
  127838. * @param localRay defines the ray in local space
  127839. * @returns the list of intersecting sub meshes
  127840. */
  127841. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  127842. /**
  127843. * Return the list of sub meshes colliding with a collider
  127844. * @param mesh defines the mesh to find the submesh for
  127845. * @param collider defines the collider to evaluate the collision against
  127846. * @returns the list of colliding sub meshes
  127847. */
  127848. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  127849. /**
  127850. * Rebuilds the elements related to this component in case of
  127851. * context lost for instance.
  127852. */
  127853. rebuild(): void;
  127854. /**
  127855. * Disposes the component and the associated ressources.
  127856. */
  127857. dispose(): void;
  127858. }
  127859. }
  127860. declare module BABYLON {
  127861. /**
  127862. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  127863. */
  127864. export class Gizmo implements IDisposable {
  127865. /** The utility layer the gizmo will be added to */
  127866. gizmoLayer: UtilityLayerRenderer;
  127867. /**
  127868. * The root mesh of the gizmo
  127869. */
  127870. _rootMesh: Mesh;
  127871. private _attachedMesh;
  127872. /**
  127873. * Ratio for the scale of the gizmo (Default: 1)
  127874. */
  127875. scaleRatio: number;
  127876. /**
  127877. * If a custom mesh has been set (Default: false)
  127878. */
  127879. protected _customMeshSet: boolean;
  127880. /**
  127881. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  127882. * * When set, interactions will be enabled
  127883. */
  127884. get attachedMesh(): Nullable<AbstractMesh>;
  127885. set attachedMesh(value: Nullable<AbstractMesh>);
  127886. /**
  127887. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  127888. * @param mesh The mesh to replace the default mesh of the gizmo
  127889. */
  127890. setCustomMesh(mesh: Mesh): void;
  127891. /**
  127892. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  127893. */
  127894. updateGizmoRotationToMatchAttachedMesh: boolean;
  127895. /**
  127896. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  127897. */
  127898. updateGizmoPositionToMatchAttachedMesh: boolean;
  127899. /**
  127900. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  127901. */
  127902. updateScale: boolean;
  127903. protected _interactionsEnabled: boolean;
  127904. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127905. private _beforeRenderObserver;
  127906. private _tempVector;
  127907. /**
  127908. * Creates a gizmo
  127909. * @param gizmoLayer The utility layer the gizmo will be added to
  127910. */
  127911. constructor(
  127912. /** The utility layer the gizmo will be added to */
  127913. gizmoLayer?: UtilityLayerRenderer);
  127914. /**
  127915. * Updates the gizmo to match the attached mesh's position/rotation
  127916. */
  127917. protected _update(): void;
  127918. /**
  127919. * Disposes of the gizmo
  127920. */
  127921. dispose(): void;
  127922. }
  127923. }
  127924. declare module BABYLON {
  127925. /**
  127926. * Single plane drag gizmo
  127927. */
  127928. export class PlaneDragGizmo extends Gizmo {
  127929. /**
  127930. * Drag behavior responsible for the gizmos dragging interactions
  127931. */
  127932. dragBehavior: PointerDragBehavior;
  127933. private _pointerObserver;
  127934. /**
  127935. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  127936. */
  127937. snapDistance: number;
  127938. /**
  127939. * Event that fires each time the gizmo snaps to a new location.
  127940. * * snapDistance is the the change in distance
  127941. */
  127942. onSnapObservable: Observable<{
  127943. snapDistance: number;
  127944. }>;
  127945. private _plane;
  127946. private _coloredMaterial;
  127947. private _hoverMaterial;
  127948. private _isEnabled;
  127949. private _parent;
  127950. /** @hidden */
  127951. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  127952. /** @hidden */
  127953. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  127954. /**
  127955. * Creates a PlaneDragGizmo
  127956. * @param gizmoLayer The utility layer the gizmo will be added to
  127957. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  127958. * @param color The color of the gizmo
  127959. */
  127960. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  127961. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  127962. /**
  127963. * If the gizmo is enabled
  127964. */
  127965. set isEnabled(value: boolean);
  127966. get isEnabled(): boolean;
  127967. /**
  127968. * Disposes of the gizmo
  127969. */
  127970. dispose(): void;
  127971. }
  127972. }
  127973. declare module BABYLON {
  127974. /**
  127975. * Gizmo that enables dragging a mesh along 3 axis
  127976. */
  127977. export class PositionGizmo extends Gizmo {
  127978. /**
  127979. * Internal gizmo used for interactions on the x axis
  127980. */
  127981. xGizmo: AxisDragGizmo;
  127982. /**
  127983. * Internal gizmo used for interactions on the y axis
  127984. */
  127985. yGizmo: AxisDragGizmo;
  127986. /**
  127987. * Internal gizmo used for interactions on the z axis
  127988. */
  127989. zGizmo: AxisDragGizmo;
  127990. /**
  127991. * Internal gizmo used for interactions on the yz plane
  127992. */
  127993. xPlaneGizmo: PlaneDragGizmo;
  127994. /**
  127995. * Internal gizmo used for interactions on the xz plane
  127996. */
  127997. yPlaneGizmo: PlaneDragGizmo;
  127998. /**
  127999. * Internal gizmo used for interactions on the xy plane
  128000. */
  128001. zPlaneGizmo: PlaneDragGizmo;
  128002. /**
  128003. * private variables
  128004. */
  128005. private _meshAttached;
  128006. private _updateGizmoRotationToMatchAttachedMesh;
  128007. private _snapDistance;
  128008. private _scaleRatio;
  128009. /** Fires an event when any of it's sub gizmos are dragged */
  128010. onDragStartObservable: Observable<unknown>;
  128011. /** Fires an event when any of it's sub gizmos are released from dragging */
  128012. onDragEndObservable: Observable<unknown>;
  128013. /**
  128014. * If set to true, planar drag is enabled
  128015. */
  128016. private _planarGizmoEnabled;
  128017. get attachedMesh(): Nullable<AbstractMesh>;
  128018. set attachedMesh(mesh: Nullable<AbstractMesh>);
  128019. /**
  128020. * Creates a PositionGizmo
  128021. * @param gizmoLayer The utility layer the gizmo will be added to
  128022. */
  128023. constructor(gizmoLayer?: UtilityLayerRenderer);
  128024. /**
  128025. * If the planar drag gizmo is enabled
  128026. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  128027. */
  128028. set planarGizmoEnabled(value: boolean);
  128029. get planarGizmoEnabled(): boolean;
  128030. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  128031. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  128032. /**
  128033. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128034. */
  128035. set snapDistance(value: number);
  128036. get snapDistance(): number;
  128037. /**
  128038. * Ratio for the scale of the gizmo (Default: 1)
  128039. */
  128040. set scaleRatio(value: number);
  128041. get scaleRatio(): number;
  128042. /**
  128043. * Disposes of the gizmo
  128044. */
  128045. dispose(): void;
  128046. /**
  128047. * CustomMeshes are not supported by this gizmo
  128048. * @param mesh The mesh to replace the default mesh of the gizmo
  128049. */
  128050. setCustomMesh(mesh: Mesh): void;
  128051. }
  128052. }
  128053. declare module BABYLON {
  128054. /**
  128055. * Single axis drag gizmo
  128056. */
  128057. export class AxisDragGizmo extends Gizmo {
  128058. /**
  128059. * Drag behavior responsible for the gizmos dragging interactions
  128060. */
  128061. dragBehavior: PointerDragBehavior;
  128062. private _pointerObserver;
  128063. /**
  128064. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  128065. */
  128066. snapDistance: number;
  128067. /**
  128068. * Event that fires each time the gizmo snaps to a new location.
  128069. * * snapDistance is the the change in distance
  128070. */
  128071. onSnapObservable: Observable<{
  128072. snapDistance: number;
  128073. }>;
  128074. private _isEnabled;
  128075. private _parent;
  128076. private _arrow;
  128077. private _coloredMaterial;
  128078. private _hoverMaterial;
  128079. /** @hidden */
  128080. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  128081. /** @hidden */
  128082. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  128083. /**
  128084. * Creates an AxisDragGizmo
  128085. * @param gizmoLayer The utility layer the gizmo will be added to
  128086. * @param dragAxis The axis which the gizmo will be able to drag on
  128087. * @param color The color of the gizmo
  128088. */
  128089. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  128090. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  128091. /**
  128092. * If the gizmo is enabled
  128093. */
  128094. set isEnabled(value: boolean);
  128095. get isEnabled(): boolean;
  128096. /**
  128097. * Disposes of the gizmo
  128098. */
  128099. dispose(): void;
  128100. }
  128101. }
  128102. declare module BABYLON.Debug {
  128103. /**
  128104. * The Axes viewer will show 3 axes in a specific point in space
  128105. */
  128106. export class AxesViewer {
  128107. private _xAxis;
  128108. private _yAxis;
  128109. private _zAxis;
  128110. private _scaleLinesFactor;
  128111. private _instanced;
  128112. /**
  128113. * Gets the hosting scene
  128114. */
  128115. scene: Scene;
  128116. /**
  128117. * Gets or sets a number used to scale line length
  128118. */
  128119. scaleLines: number;
  128120. /** Gets the node hierarchy used to render x-axis */
  128121. get xAxis(): TransformNode;
  128122. /** Gets the node hierarchy used to render y-axis */
  128123. get yAxis(): TransformNode;
  128124. /** Gets the node hierarchy used to render z-axis */
  128125. get zAxis(): TransformNode;
  128126. /**
  128127. * Creates a new AxesViewer
  128128. * @param scene defines the hosting scene
  128129. * @param scaleLines defines a number used to scale line length (1 by default)
  128130. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  128131. * @param xAxis defines the node hierarchy used to render the x-axis
  128132. * @param yAxis defines the node hierarchy used to render the y-axis
  128133. * @param zAxis defines the node hierarchy used to render the z-axis
  128134. */
  128135. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  128136. /**
  128137. * Force the viewer to update
  128138. * @param position defines the position of the viewer
  128139. * @param xaxis defines the x axis of the viewer
  128140. * @param yaxis defines the y axis of the viewer
  128141. * @param zaxis defines the z axis of the viewer
  128142. */
  128143. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  128144. /**
  128145. * Creates an instance of this axes viewer.
  128146. * @returns a new axes viewer with instanced meshes
  128147. */
  128148. createInstance(): AxesViewer;
  128149. /** Releases resources */
  128150. dispose(): void;
  128151. private static _SetRenderingGroupId;
  128152. }
  128153. }
  128154. declare module BABYLON.Debug {
  128155. /**
  128156. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  128157. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  128158. */
  128159. export class BoneAxesViewer extends AxesViewer {
  128160. /**
  128161. * Gets or sets the target mesh where to display the axes viewer
  128162. */
  128163. mesh: Nullable<Mesh>;
  128164. /**
  128165. * Gets or sets the target bone where to display the axes viewer
  128166. */
  128167. bone: Nullable<Bone>;
  128168. /** Gets current position */
  128169. pos: Vector3;
  128170. /** Gets direction of X axis */
  128171. xaxis: Vector3;
  128172. /** Gets direction of Y axis */
  128173. yaxis: Vector3;
  128174. /** Gets direction of Z axis */
  128175. zaxis: Vector3;
  128176. /**
  128177. * Creates a new BoneAxesViewer
  128178. * @param scene defines the hosting scene
  128179. * @param bone defines the target bone
  128180. * @param mesh defines the target mesh
  128181. * @param scaleLines defines a scaling factor for line length (1 by default)
  128182. */
  128183. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  128184. /**
  128185. * Force the viewer to update
  128186. */
  128187. update(): void;
  128188. /** Releases resources */
  128189. dispose(): void;
  128190. }
  128191. }
  128192. declare module BABYLON {
  128193. /**
  128194. * Interface used to define scene explorer extensibility option
  128195. */
  128196. export interface IExplorerExtensibilityOption {
  128197. /**
  128198. * Define the option label
  128199. */
  128200. label: string;
  128201. /**
  128202. * Defines the action to execute on click
  128203. */
  128204. action: (entity: any) => void;
  128205. }
  128206. /**
  128207. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  128208. */
  128209. export interface IExplorerExtensibilityGroup {
  128210. /**
  128211. * Defines a predicate to test if a given type mut be extended
  128212. */
  128213. predicate: (entity: any) => boolean;
  128214. /**
  128215. * Gets the list of options added to a type
  128216. */
  128217. entries: IExplorerExtensibilityOption[];
  128218. }
  128219. /**
  128220. * Interface used to define the options to use to create the Inspector
  128221. */
  128222. export interface IInspectorOptions {
  128223. /**
  128224. * Display in overlay mode (default: false)
  128225. */
  128226. overlay?: boolean;
  128227. /**
  128228. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  128229. */
  128230. globalRoot?: HTMLElement;
  128231. /**
  128232. * Display the Scene explorer
  128233. */
  128234. showExplorer?: boolean;
  128235. /**
  128236. * Display the property inspector
  128237. */
  128238. showInspector?: boolean;
  128239. /**
  128240. * Display in embed mode (both panes on the right)
  128241. */
  128242. embedMode?: boolean;
  128243. /**
  128244. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  128245. */
  128246. handleResize?: boolean;
  128247. /**
  128248. * Allow the panes to popup (default: true)
  128249. */
  128250. enablePopup?: boolean;
  128251. /**
  128252. * Allow the panes to be closed by users (default: true)
  128253. */
  128254. enableClose?: boolean;
  128255. /**
  128256. * Optional list of extensibility entries
  128257. */
  128258. explorerExtensibility?: IExplorerExtensibilityGroup[];
  128259. /**
  128260. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  128261. */
  128262. inspectorURL?: string;
  128263. /**
  128264. * Optional initial tab (default to DebugLayerTab.Properties)
  128265. */
  128266. initialTab?: DebugLayerTab;
  128267. }
  128268. interface Scene {
  128269. /**
  128270. * @hidden
  128271. * Backing field
  128272. */
  128273. _debugLayer: DebugLayer;
  128274. /**
  128275. * Gets the debug layer (aka Inspector) associated with the scene
  128276. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128277. */
  128278. debugLayer: DebugLayer;
  128279. }
  128280. /**
  128281. * Enum of inspector action tab
  128282. */
  128283. export enum DebugLayerTab {
  128284. /**
  128285. * Properties tag (default)
  128286. */
  128287. Properties = 0,
  128288. /**
  128289. * Debug tab
  128290. */
  128291. Debug = 1,
  128292. /**
  128293. * Statistics tab
  128294. */
  128295. Statistics = 2,
  128296. /**
  128297. * Tools tab
  128298. */
  128299. Tools = 3,
  128300. /**
  128301. * Settings tab
  128302. */
  128303. Settings = 4
  128304. }
  128305. /**
  128306. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128307. * what is happening in your scene
  128308. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128309. */
  128310. export class DebugLayer {
  128311. /**
  128312. * Define the url to get the inspector script from.
  128313. * By default it uses the babylonjs CDN.
  128314. * @ignoreNaming
  128315. */
  128316. static InspectorURL: string;
  128317. private _scene;
  128318. private BJSINSPECTOR;
  128319. private _onPropertyChangedObservable?;
  128320. /**
  128321. * Observable triggered when a property is changed through the inspector.
  128322. */
  128323. get onPropertyChangedObservable(): any;
  128324. /**
  128325. * Instantiates a new debug layer.
  128326. * The debug layer (aka Inspector) is the go to tool in order to better understand
  128327. * what is happening in your scene
  128328. * @see https://doc.babylonjs.com/features/playground_debuglayer
  128329. * @param scene Defines the scene to inspect
  128330. */
  128331. constructor(scene: Scene);
  128332. /** Creates the inspector window. */
  128333. private _createInspector;
  128334. /**
  128335. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  128336. * @param entity defines the entity to select
  128337. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  128338. */
  128339. select(entity: any, lineContainerTitles?: string | string[]): void;
  128340. /** Get the inspector from bundle or global */
  128341. private _getGlobalInspector;
  128342. /**
  128343. * Get if the inspector is visible or not.
  128344. * @returns true if visible otherwise, false
  128345. */
  128346. isVisible(): boolean;
  128347. /**
  128348. * Hide the inspector and close its window.
  128349. */
  128350. hide(): void;
  128351. /**
  128352. * Update the scene in the inspector
  128353. */
  128354. setAsActiveScene(): void;
  128355. /**
  128356. * Launch the debugLayer.
  128357. * @param config Define the configuration of the inspector
  128358. * @return a promise fulfilled when the debug layer is visible
  128359. */
  128360. show(config?: IInspectorOptions): Promise<DebugLayer>;
  128361. }
  128362. }
  128363. declare module BABYLON {
  128364. /**
  128365. * Class containing static functions to help procedurally build meshes
  128366. */
  128367. export class BoxBuilder {
  128368. /**
  128369. * Creates a box mesh
  128370. * * The parameter `size` sets the size (float) of each box side (default 1)
  128371. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  128372. * * 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)
  128373. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  128374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128377. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  128378. * @param name defines the name of the mesh
  128379. * @param options defines the options used to create the mesh
  128380. * @param scene defines the hosting scene
  128381. * @returns the box mesh
  128382. */
  128383. static CreateBox(name: string, options: {
  128384. size?: number;
  128385. width?: number;
  128386. height?: number;
  128387. depth?: number;
  128388. faceUV?: Vector4[];
  128389. faceColors?: Color4[];
  128390. sideOrientation?: number;
  128391. frontUVs?: Vector4;
  128392. backUVs?: Vector4;
  128393. wrap?: boolean;
  128394. topBaseAt?: number;
  128395. bottomBaseAt?: number;
  128396. updatable?: boolean;
  128397. }, scene?: Nullable<Scene>): Mesh;
  128398. }
  128399. }
  128400. declare module BABYLON.Debug {
  128401. /**
  128402. * Used to show the physics impostor around the specific mesh
  128403. */
  128404. export class PhysicsViewer {
  128405. /** @hidden */
  128406. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  128407. /** @hidden */
  128408. protected _meshes: Array<Nullable<AbstractMesh>>;
  128409. /** @hidden */
  128410. protected _scene: Nullable<Scene>;
  128411. /** @hidden */
  128412. protected _numMeshes: number;
  128413. /** @hidden */
  128414. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  128415. private _renderFunction;
  128416. private _utilityLayer;
  128417. private _debugBoxMesh;
  128418. private _debugSphereMesh;
  128419. private _debugCylinderMesh;
  128420. private _debugMaterial;
  128421. private _debugMeshMeshes;
  128422. /**
  128423. * Creates a new PhysicsViewer
  128424. * @param scene defines the hosting scene
  128425. */
  128426. constructor(scene: Scene);
  128427. /** @hidden */
  128428. protected _updateDebugMeshes(): void;
  128429. /**
  128430. * Renders a specified physic impostor
  128431. * @param impostor defines the impostor to render
  128432. * @param targetMesh defines the mesh represented by the impostor
  128433. * @returns the new debug mesh used to render the impostor
  128434. */
  128435. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  128436. /**
  128437. * Hides a specified physic impostor
  128438. * @param impostor defines the impostor to hide
  128439. */
  128440. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  128441. private _getDebugMaterial;
  128442. private _getDebugBoxMesh;
  128443. private _getDebugSphereMesh;
  128444. private _getDebugCylinderMesh;
  128445. private _getDebugMeshMesh;
  128446. private _getDebugMesh;
  128447. /** Releases all resources */
  128448. dispose(): void;
  128449. }
  128450. }
  128451. declare module BABYLON {
  128452. /**
  128453. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128454. * in order to better appreciate the issue one might have.
  128455. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128456. */
  128457. export class RayHelper {
  128458. /**
  128459. * Defines the ray we are currently tryin to visualize.
  128460. */
  128461. ray: Nullable<Ray>;
  128462. private _renderPoints;
  128463. private _renderLine;
  128464. private _renderFunction;
  128465. private _scene;
  128466. private _updateToMeshFunction;
  128467. private _attachedToMesh;
  128468. private _meshSpaceDirection;
  128469. private _meshSpaceOrigin;
  128470. /**
  128471. * Helper function to create a colored helper in a scene in one line.
  128472. * @param ray Defines the ray we are currently tryin to visualize
  128473. * @param scene Defines the scene the ray is used in
  128474. * @param color Defines the color we want to see the ray in
  128475. * @returns The newly created ray helper.
  128476. */
  128477. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  128478. /**
  128479. * Instantiate a new ray helper.
  128480. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  128481. * in order to better appreciate the issue one might have.
  128482. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  128483. * @param ray Defines the ray we are currently tryin to visualize
  128484. */
  128485. constructor(ray: Ray);
  128486. /**
  128487. * Shows the ray we are willing to debug.
  128488. * @param scene Defines the scene the ray needs to be rendered in
  128489. * @param color Defines the color the ray needs to be rendered in
  128490. */
  128491. show(scene: Scene, color?: Color3): void;
  128492. /**
  128493. * Hides the ray we are debugging.
  128494. */
  128495. hide(): void;
  128496. private _render;
  128497. /**
  128498. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  128499. * @param mesh Defines the mesh we want the helper attached to
  128500. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  128501. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  128502. * @param length Defines the length of the ray
  128503. */
  128504. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  128505. /**
  128506. * Detach the ray helper from the mesh it has previously been attached to.
  128507. */
  128508. detachFromMesh(): void;
  128509. private _updateToMesh;
  128510. /**
  128511. * Dispose the helper and release its associated resources.
  128512. */
  128513. dispose(): void;
  128514. }
  128515. }
  128516. declare module BABYLON.Debug {
  128517. /**
  128518. * Class used to render a debug view of a given skeleton
  128519. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  128520. */
  128521. export class SkeletonViewer {
  128522. /** defines the skeleton to render */
  128523. skeleton: Skeleton;
  128524. /** defines the mesh attached to the skeleton */
  128525. mesh: AbstractMesh;
  128526. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128527. autoUpdateBonesMatrices: boolean;
  128528. /** defines the rendering group id to use with the viewer */
  128529. renderingGroupId: number;
  128530. /** Gets or sets the color used to render the skeleton */
  128531. color: Color3;
  128532. private _scene;
  128533. private _debugLines;
  128534. private _debugMesh;
  128535. private _isEnabled;
  128536. private _renderFunction;
  128537. private _utilityLayer;
  128538. /**
  128539. * Returns the mesh used to render the bones
  128540. */
  128541. get debugMesh(): Nullable<LinesMesh>;
  128542. /**
  128543. * Creates a new SkeletonViewer
  128544. * @param skeleton defines the skeleton to render
  128545. * @param mesh defines the mesh attached to the skeleton
  128546. * @param scene defines the hosting scene
  128547. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  128548. * @param renderingGroupId defines the rendering group id to use with the viewer
  128549. */
  128550. constructor(
  128551. /** defines the skeleton to render */
  128552. skeleton: Skeleton,
  128553. /** defines the mesh attached to the skeleton */
  128554. mesh: AbstractMesh, scene: Scene,
  128555. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  128556. autoUpdateBonesMatrices?: boolean,
  128557. /** defines the rendering group id to use with the viewer */
  128558. renderingGroupId?: number);
  128559. /** Gets or sets a boolean indicating if the viewer is enabled */
  128560. set isEnabled(value: boolean);
  128561. get isEnabled(): boolean;
  128562. private _getBonePosition;
  128563. private _getLinesForBonesWithLength;
  128564. private _getLinesForBonesNoLength;
  128565. /** Update the viewer to sync with current skeleton state */
  128566. update(): void;
  128567. /** Release associated resources */
  128568. dispose(): void;
  128569. }
  128570. }
  128571. declare module BABYLON {
  128572. /**
  128573. * Enum for Device Types
  128574. */
  128575. export enum DeviceType {
  128576. /** Generic */
  128577. Generic = 0,
  128578. /** Keyboard */
  128579. Keyboard = 1,
  128580. /** Mouse */
  128581. Mouse = 2,
  128582. /** Touch Pointers */
  128583. Touch = 3,
  128584. /** PS4 Dual Shock */
  128585. DualShock = 4,
  128586. /** Xbox */
  128587. Xbox = 5,
  128588. /** Switch Controller */
  128589. Switch = 6
  128590. }
  128591. /**
  128592. * Enum for All Pointers (Touch/Mouse)
  128593. */
  128594. export enum PointerInput {
  128595. /** Horizontal Axis */
  128596. Horizontal = 0,
  128597. /** Vertical Axis */
  128598. Vertical = 1,
  128599. /** Left Click or Touch */
  128600. LeftClick = 2,
  128601. /** Middle Click */
  128602. MiddleClick = 3,
  128603. /** Right Click */
  128604. RightClick = 4,
  128605. /** Browser Back */
  128606. BrowserBack = 5,
  128607. /** Browser Forward */
  128608. BrowserForward = 6
  128609. }
  128610. /**
  128611. * Enum for Dual Shock Gamepad
  128612. */
  128613. export enum DualShockInput {
  128614. /** Cross */
  128615. Cross = 0,
  128616. /** Circle */
  128617. Circle = 1,
  128618. /** Square */
  128619. Square = 2,
  128620. /** Triangle */
  128621. Triangle = 3,
  128622. /** L1 */
  128623. L1 = 4,
  128624. /** R1 */
  128625. R1 = 5,
  128626. /** L2 */
  128627. L2 = 6,
  128628. /** R2 */
  128629. R2 = 7,
  128630. /** Share */
  128631. Share = 8,
  128632. /** Options */
  128633. Options = 9,
  128634. /** L3 */
  128635. L3 = 10,
  128636. /** R3 */
  128637. R3 = 11,
  128638. /** DPadUp */
  128639. DPadUp = 12,
  128640. /** DPadDown */
  128641. DPadDown = 13,
  128642. /** DPadLeft */
  128643. DPadLeft = 14,
  128644. /** DRight */
  128645. DPadRight = 15,
  128646. /** Home */
  128647. Home = 16,
  128648. /** TouchPad */
  128649. TouchPad = 17,
  128650. /** LStickXAxis */
  128651. LStickXAxis = 18,
  128652. /** LStickYAxis */
  128653. LStickYAxis = 19,
  128654. /** RStickXAxis */
  128655. RStickXAxis = 20,
  128656. /** RStickYAxis */
  128657. RStickYAxis = 21
  128658. }
  128659. /**
  128660. * Enum for Xbox Gamepad
  128661. */
  128662. export enum XboxInput {
  128663. /** A */
  128664. A = 0,
  128665. /** B */
  128666. B = 1,
  128667. /** X */
  128668. X = 2,
  128669. /** Y */
  128670. Y = 3,
  128671. /** LB */
  128672. LB = 4,
  128673. /** RB */
  128674. RB = 5,
  128675. /** LT */
  128676. LT = 6,
  128677. /** RT */
  128678. RT = 7,
  128679. /** Back */
  128680. Back = 8,
  128681. /** Start */
  128682. Start = 9,
  128683. /** LS */
  128684. LS = 10,
  128685. /** RS */
  128686. RS = 11,
  128687. /** DPadUp */
  128688. DPadUp = 12,
  128689. /** DPadDown */
  128690. DPadDown = 13,
  128691. /** DPadLeft */
  128692. DPadLeft = 14,
  128693. /** DRight */
  128694. DPadRight = 15,
  128695. /** Home */
  128696. Home = 16,
  128697. /** LStickXAxis */
  128698. LStickXAxis = 17,
  128699. /** LStickYAxis */
  128700. LStickYAxis = 18,
  128701. /** RStickXAxis */
  128702. RStickXAxis = 19,
  128703. /** RStickYAxis */
  128704. RStickYAxis = 20
  128705. }
  128706. /**
  128707. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  128708. */
  128709. export enum SwitchInput {
  128710. /** B */
  128711. B = 0,
  128712. /** A */
  128713. A = 1,
  128714. /** Y */
  128715. Y = 2,
  128716. /** X */
  128717. X = 3,
  128718. /** L */
  128719. L = 4,
  128720. /** R */
  128721. R = 5,
  128722. /** ZL */
  128723. ZL = 6,
  128724. /** ZR */
  128725. ZR = 7,
  128726. /** Minus */
  128727. Minus = 8,
  128728. /** Plus */
  128729. Plus = 9,
  128730. /** LS */
  128731. LS = 10,
  128732. /** RS */
  128733. RS = 11,
  128734. /** DPadUp */
  128735. DPadUp = 12,
  128736. /** DPadDown */
  128737. DPadDown = 13,
  128738. /** DPadLeft */
  128739. DPadLeft = 14,
  128740. /** DRight */
  128741. DPadRight = 15,
  128742. /** Home */
  128743. Home = 16,
  128744. /** Capture */
  128745. Capture = 17,
  128746. /** LStickXAxis */
  128747. LStickXAxis = 18,
  128748. /** LStickYAxis */
  128749. LStickYAxis = 19,
  128750. /** RStickXAxis */
  128751. RStickXAxis = 20,
  128752. /** RStickYAxis */
  128753. RStickYAxis = 21
  128754. }
  128755. }
  128756. declare module BABYLON {
  128757. /**
  128758. * This class will take all inputs from Keyboard, Pointer, and
  128759. * any Gamepads and provide a polling system that all devices
  128760. * will use. This class assumes that there will only be one
  128761. * pointer device and one keyboard.
  128762. */
  128763. export class DeviceInputSystem implements IDisposable {
  128764. /**
  128765. * Callback to be triggered when a device is connected
  128766. */
  128767. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128768. /**
  128769. * Callback to be triggered when a device is disconnected
  128770. */
  128771. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  128772. /**
  128773. * Callback to be triggered when event driven input is updated
  128774. */
  128775. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  128776. private _inputs;
  128777. private _gamepads;
  128778. private _keyboardActive;
  128779. private _pointerActive;
  128780. private _elementToAttachTo;
  128781. private _keyboardDownEvent;
  128782. private _keyboardUpEvent;
  128783. private _pointerMoveEvent;
  128784. private _pointerDownEvent;
  128785. private _pointerUpEvent;
  128786. private _gamepadConnectedEvent;
  128787. private _gamepadDisconnectedEvent;
  128788. private static _MAX_KEYCODES;
  128789. private static _MAX_POINTER_INPUTS;
  128790. private constructor();
  128791. /**
  128792. * Creates a new DeviceInputSystem instance
  128793. * @param engine Engine to pull input element from
  128794. * @returns The new instance
  128795. */
  128796. static Create(engine: Engine): DeviceInputSystem;
  128797. /**
  128798. * Checks for current device input value, given an id and input index
  128799. * @param deviceName Id of connected device
  128800. * @param inputIndex Index of device input
  128801. * @returns Current value of input
  128802. */
  128803. /**
  128804. * Checks for current device input value, given an id and input index
  128805. * @param deviceType Enum specifiying device type
  128806. * @param deviceSlot "Slot" or index that device is referenced in
  128807. * @param inputIndex Id of input to be checked
  128808. * @returns Current value of input
  128809. */
  128810. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): Nullable<number>;
  128811. /**
  128812. * Dispose of all the eventlisteners
  128813. */
  128814. dispose(): void;
  128815. /**
  128816. * Add device and inputs to device array
  128817. * @param deviceType Enum specifiying device type
  128818. * @param deviceSlot "Slot" or index that device is referenced in
  128819. * @param numberOfInputs Number of input entries to create for given device
  128820. */
  128821. private _registerDevice;
  128822. /**
  128823. * Given a specific device name, remove that device from the device map
  128824. * @param deviceType Enum specifiying device type
  128825. * @param deviceSlot "Slot" or index that device is referenced in
  128826. */
  128827. private _unregisterDevice;
  128828. /**
  128829. * Handle all actions that come from keyboard interaction
  128830. */
  128831. private _handleKeyActions;
  128832. /**
  128833. * Handle all actions that come from pointer interaction
  128834. */
  128835. private _handlePointerActions;
  128836. /**
  128837. * Handle all actions that come from gamepad interaction
  128838. */
  128839. private _handleGamepadActions;
  128840. /**
  128841. * Update all non-event based devices with each frame
  128842. * @param deviceType Enum specifiying device type
  128843. * @param deviceSlot "Slot" or index that device is referenced in
  128844. * @param inputIndex Id of input to be checked
  128845. */
  128846. private _updateDevice;
  128847. /**
  128848. * Gets DeviceType from the device name
  128849. * @param deviceName Name of Device from DeviceInputSystem
  128850. * @returns DeviceType enum value
  128851. */
  128852. private _getGamepadDeviceType;
  128853. }
  128854. }
  128855. declare module BABYLON {
  128856. /**
  128857. * Type to handle enforcement of inputs
  128858. */
  128859. 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;
  128860. }
  128861. declare module BABYLON {
  128862. /**
  128863. * Class that handles all input for a specific device
  128864. */
  128865. export class DeviceSource<T extends DeviceType> {
  128866. /** Type of device */
  128867. readonly deviceType: DeviceType;
  128868. /** "Slot" or index that device is referenced in */
  128869. readonly deviceSlot: number;
  128870. /**
  128871. * Observable to handle device input changes per device
  128872. */
  128873. readonly onInputChangedObservable: Observable<{
  128874. inputIndex: DeviceInput<T>;
  128875. previousState: Nullable<number>;
  128876. currentState: Nullable<number>;
  128877. }>;
  128878. private readonly _deviceInputSystem;
  128879. /**
  128880. * Default Constructor
  128881. * @param deviceInputSystem Reference to DeviceInputSystem
  128882. * @param deviceType Type of device
  128883. * @param deviceSlot "Slot" or index that device is referenced in
  128884. */
  128885. constructor(deviceInputSystem: DeviceInputSystem,
  128886. /** Type of device */
  128887. deviceType: DeviceType,
  128888. /** "Slot" or index that device is referenced in */
  128889. deviceSlot?: number);
  128890. /**
  128891. * Get input for specific input
  128892. * @param inputIndex index of specific input on device
  128893. * @returns Input value from DeviceInputSystem
  128894. */
  128895. getInput(inputIndex: DeviceInput<T>): Nullable<number>;
  128896. }
  128897. /**
  128898. * Class to keep track of devices
  128899. */
  128900. export class DeviceSourceManager implements IDisposable {
  128901. /**
  128902. * Observable to be triggered when before a device is connected
  128903. */
  128904. readonly onBeforeDeviceConnectedObservable: Observable<{
  128905. deviceType: DeviceType;
  128906. deviceSlot: number;
  128907. }>;
  128908. /**
  128909. * Observable to be triggered when before a device is disconnected
  128910. */
  128911. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  128912. deviceType: DeviceType;
  128913. deviceSlot: number;
  128914. }>;
  128915. /**
  128916. * Observable to be triggered when after a device is connected
  128917. */
  128918. readonly onAfterDeviceConnectedObservable: Observable<{
  128919. deviceType: DeviceType;
  128920. deviceSlot: number;
  128921. }>;
  128922. /**
  128923. * Observable to be triggered when after a device is disconnected
  128924. */
  128925. readonly onAfterDeviceDisconnectedObservable: Observable<{
  128926. deviceType: DeviceType;
  128927. deviceSlot: number;
  128928. }>;
  128929. private readonly _devices;
  128930. private readonly _firstDevice;
  128931. private readonly _deviceInputSystem;
  128932. /**
  128933. * Default Constructor
  128934. * @param engine engine to pull input element from
  128935. */
  128936. constructor(engine: Engine);
  128937. /**
  128938. * Gets a DeviceSource, given a type and slot
  128939. * @param deviceType Enum specifying device type
  128940. * @param deviceSlot "Slot" or index that device is referenced in
  128941. * @returns DeviceSource object
  128942. */
  128943. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  128944. /**
  128945. * Gets an array of DeviceSource objects for a given device type
  128946. * @param deviceType Enum specifying device type
  128947. * @returns Array of DeviceSource objects
  128948. */
  128949. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  128950. /**
  128951. * Dispose of DeviceInputSystem and other parts
  128952. */
  128953. dispose(): void;
  128954. /**
  128955. * Function to add device name to device list
  128956. * @param deviceType Enum specifying device type
  128957. * @param deviceSlot "Slot" or index that device is referenced in
  128958. */
  128959. private _addDevice;
  128960. /**
  128961. * Function to remove device name to device list
  128962. * @param deviceType Enum specifying device type
  128963. * @param deviceSlot "Slot" or index that device is referenced in
  128964. */
  128965. private _removeDevice;
  128966. /**
  128967. * Updates array storing first connected device of each type
  128968. * @param type Type of Device
  128969. */
  128970. private _updateFirstDevices;
  128971. }
  128972. }
  128973. declare module BABYLON {
  128974. /**
  128975. * Options to create the null engine
  128976. */
  128977. export class NullEngineOptions {
  128978. /**
  128979. * Render width (Default: 512)
  128980. */
  128981. renderWidth: number;
  128982. /**
  128983. * Render height (Default: 256)
  128984. */
  128985. renderHeight: number;
  128986. /**
  128987. * Texture size (Default: 512)
  128988. */
  128989. textureSize: number;
  128990. /**
  128991. * If delta time between frames should be constant
  128992. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128993. */
  128994. deterministicLockstep: boolean;
  128995. /**
  128996. * Maximum about of steps between frames (Default: 4)
  128997. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  128998. */
  128999. lockstepMaxSteps: number;
  129000. }
  129001. /**
  129002. * The null engine class provides support for headless version of babylon.js.
  129003. * This can be used in server side scenario or for testing purposes
  129004. */
  129005. export class NullEngine extends Engine {
  129006. private _options;
  129007. /**
  129008. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  129009. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129010. * @returns true if engine is in deterministic lock step mode
  129011. */
  129012. isDeterministicLockStep(): boolean;
  129013. /**
  129014. * Gets the max steps when engine is running in deterministic lock step
  129015. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129016. * @returns the max steps
  129017. */
  129018. getLockstepMaxSteps(): number;
  129019. /**
  129020. * Gets the current hardware scaling level.
  129021. * By default the hardware scaling level is computed from the window device ratio.
  129022. * 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.
  129023. * @returns a number indicating the current hardware scaling level
  129024. */
  129025. getHardwareScalingLevel(): number;
  129026. constructor(options?: NullEngineOptions);
  129027. /**
  129028. * Creates a vertex buffer
  129029. * @param vertices the data for the vertex buffer
  129030. * @returns the new WebGL static buffer
  129031. */
  129032. createVertexBuffer(vertices: FloatArray): DataBuffer;
  129033. /**
  129034. * Creates a new index buffer
  129035. * @param indices defines the content of the index buffer
  129036. * @param updatable defines if the index buffer must be updatable
  129037. * @returns a new webGL buffer
  129038. */
  129039. createIndexBuffer(indices: IndicesArray): DataBuffer;
  129040. /**
  129041. * Clear the current render buffer or the current render target (if any is set up)
  129042. * @param color defines the color to use
  129043. * @param backBuffer defines if the back buffer must be cleared
  129044. * @param depth defines if the depth buffer must be cleared
  129045. * @param stencil defines if the stencil buffer must be cleared
  129046. */
  129047. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  129048. /**
  129049. * Gets the current render width
  129050. * @param useScreen defines if screen size must be used (or the current render target if any)
  129051. * @returns a number defining the current render width
  129052. */
  129053. getRenderWidth(useScreen?: boolean): number;
  129054. /**
  129055. * Gets the current render height
  129056. * @param useScreen defines if screen size must be used (or the current render target if any)
  129057. * @returns a number defining the current render height
  129058. */
  129059. getRenderHeight(useScreen?: boolean): number;
  129060. /**
  129061. * Set the WebGL's viewport
  129062. * @param viewport defines the viewport element to be used
  129063. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  129064. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  129065. */
  129066. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  129067. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  129068. /**
  129069. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  129070. * @param pipelineContext defines the pipeline context to use
  129071. * @param uniformsNames defines the list of uniform names
  129072. * @returns an array of webGL uniform locations
  129073. */
  129074. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  129075. /**
  129076. * Gets the lsit of active attributes for a given webGL program
  129077. * @param pipelineContext defines the pipeline context to use
  129078. * @param attributesNames defines the list of attribute names to get
  129079. * @returns an array of indices indicating the offset of each attribute
  129080. */
  129081. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  129082. /**
  129083. * Binds an effect to the webGL context
  129084. * @param effect defines the effect to bind
  129085. */
  129086. bindSamplers(effect: Effect): void;
  129087. /**
  129088. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  129089. * @param effect defines the effect to activate
  129090. */
  129091. enableEffect(effect: Effect): void;
  129092. /**
  129093. * Set various states to the webGL context
  129094. * @param culling defines backface culling state
  129095. * @param zOffset defines the value to apply to zOffset (0 by default)
  129096. * @param force defines if states must be applied even if cache is up to date
  129097. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  129098. */
  129099. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  129100. /**
  129101. * Set the value of an uniform to an array of int32
  129102. * @param uniform defines the webGL uniform location where to store the value
  129103. * @param array defines the array of int32 to store
  129104. */
  129105. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  129106. /**
  129107. * Set the value of an uniform to an array of int32 (stored as vec2)
  129108. * @param uniform defines the webGL uniform location where to store the value
  129109. * @param array defines the array of int32 to store
  129110. */
  129111. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  129112. /**
  129113. * Set the value of an uniform to an array of int32 (stored as vec3)
  129114. * @param uniform defines the webGL uniform location where to store the value
  129115. * @param array defines the array of int32 to store
  129116. */
  129117. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  129118. /**
  129119. * Set the value of an uniform to an array of int32 (stored as vec4)
  129120. * @param uniform defines the webGL uniform location where to store the value
  129121. * @param array defines the array of int32 to store
  129122. */
  129123. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  129124. /**
  129125. * Set the value of an uniform to an array of float32
  129126. * @param uniform defines the webGL uniform location where to store the value
  129127. * @param array defines the array of float32 to store
  129128. */
  129129. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  129130. /**
  129131. * Set the value of an uniform to an array of float32 (stored as vec2)
  129132. * @param uniform defines the webGL uniform location where to store the value
  129133. * @param array defines the array of float32 to store
  129134. */
  129135. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  129136. /**
  129137. * Set the value of an uniform to an array of float32 (stored as vec3)
  129138. * @param uniform defines the webGL uniform location where to store the value
  129139. * @param array defines the array of float32 to store
  129140. */
  129141. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  129142. /**
  129143. * Set the value of an uniform to an array of float32 (stored as vec4)
  129144. * @param uniform defines the webGL uniform location where to store the value
  129145. * @param array defines the array of float32 to store
  129146. */
  129147. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  129148. /**
  129149. * Set the value of an uniform to an array of number
  129150. * @param uniform defines the webGL uniform location where to store the value
  129151. * @param array defines the array of number to store
  129152. */
  129153. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  129154. /**
  129155. * Set the value of an uniform to an array of number (stored as vec2)
  129156. * @param uniform defines the webGL uniform location where to store the value
  129157. * @param array defines the array of number to store
  129158. */
  129159. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  129160. /**
  129161. * Set the value of an uniform to an array of number (stored as vec3)
  129162. * @param uniform defines the webGL uniform location where to store the value
  129163. * @param array defines the array of number to store
  129164. */
  129165. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  129166. /**
  129167. * Set the value of an uniform to an array of number (stored as vec4)
  129168. * @param uniform defines the webGL uniform location where to store the value
  129169. * @param array defines the array of number to store
  129170. */
  129171. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  129172. /**
  129173. * Set the value of an uniform to an array of float32 (stored as matrices)
  129174. * @param uniform defines the webGL uniform location where to store the value
  129175. * @param matrices defines the array of float32 to store
  129176. */
  129177. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  129178. /**
  129179. * Set the value of an uniform to a matrix (3x3)
  129180. * @param uniform defines the webGL uniform location where to store the value
  129181. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  129182. */
  129183. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129184. /**
  129185. * Set the value of an uniform to a matrix (2x2)
  129186. * @param uniform defines the webGL uniform location where to store the value
  129187. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  129188. */
  129189. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  129190. /**
  129191. * Set the value of an uniform to a number (float)
  129192. * @param uniform defines the webGL uniform location where to store the value
  129193. * @param value defines the float number to store
  129194. */
  129195. setFloat(uniform: WebGLUniformLocation, value: number): void;
  129196. /**
  129197. * Set the value of an uniform to a vec2
  129198. * @param uniform defines the webGL uniform location where to store the value
  129199. * @param x defines the 1st component of the value
  129200. * @param y defines the 2nd component of the value
  129201. */
  129202. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  129203. /**
  129204. * Set the value of an uniform to a vec3
  129205. * @param uniform defines the webGL uniform location where to store the value
  129206. * @param x defines the 1st component of the value
  129207. * @param y defines the 2nd component of the value
  129208. * @param z defines the 3rd component of the value
  129209. */
  129210. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  129211. /**
  129212. * Set the value of an uniform to a boolean
  129213. * @param uniform defines the webGL uniform location where to store the value
  129214. * @param bool defines the boolean to store
  129215. */
  129216. setBool(uniform: WebGLUniformLocation, bool: number): void;
  129217. /**
  129218. * Set the value of an uniform to a vec4
  129219. * @param uniform defines the webGL uniform location where to store the value
  129220. * @param x defines the 1st component of the value
  129221. * @param y defines the 2nd component of the value
  129222. * @param z defines the 3rd component of the value
  129223. * @param w defines the 4th component of the value
  129224. */
  129225. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  129226. /**
  129227. * Sets the current alpha mode
  129228. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  129229. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  129230. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  129231. */
  129232. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  129233. /**
  129234. * Bind webGl buffers directly to the webGL context
  129235. * @param vertexBuffers defines the vertex buffer to bind
  129236. * @param indexBuffer defines the index buffer to bind
  129237. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  129238. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  129239. * @param effect defines the effect associated with the vertex buffer
  129240. */
  129241. bindBuffers(vertexBuffers: {
  129242. [key: string]: VertexBuffer;
  129243. }, indexBuffer: DataBuffer, effect: Effect): void;
  129244. /**
  129245. * Force the entire cache to be cleared
  129246. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  129247. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  129248. */
  129249. wipeCaches(bruteForce?: boolean): void;
  129250. /**
  129251. * Send a draw order
  129252. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  129253. * @param indexStart defines the starting index
  129254. * @param indexCount defines the number of index to draw
  129255. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129256. */
  129257. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  129258. /**
  129259. * Draw a list of indexed primitives
  129260. * @param fillMode defines the primitive to use
  129261. * @param indexStart defines the starting index
  129262. * @param indexCount defines the number of index to draw
  129263. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129264. */
  129265. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  129266. /**
  129267. * Draw a list of unindexed primitives
  129268. * @param fillMode defines the primitive to use
  129269. * @param verticesStart defines the index of first vertex to draw
  129270. * @param verticesCount defines the count of vertices to draw
  129271. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  129272. */
  129273. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  129274. /** @hidden */
  129275. _createTexture(): WebGLTexture;
  129276. /** @hidden */
  129277. _releaseTexture(texture: InternalTexture): void;
  129278. /**
  129279. * Usually called from Texture.ts.
  129280. * Passed information to create a WebGLTexture
  129281. * @param urlArg defines a value which contains one of the following:
  129282. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  129283. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  129284. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  129285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  129286. * @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)
  129287. * @param scene needed for loading to the correct scene
  129288. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  129289. * @param onLoad optional callback to be called upon successful completion
  129290. * @param onError optional callback to be called upon failure
  129291. * @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
  129292. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  129293. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  129294. * @param forcedExtension defines the extension to use to pick the right loader
  129295. * @param mimeType defines an optional mime type
  129296. * @returns a InternalTexture for assignment back into BABYLON.Texture
  129297. */
  129298. 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;
  129299. /**
  129300. * Creates a new render target texture
  129301. * @param size defines the size of the texture
  129302. * @param options defines the options used to create the texture
  129303. * @returns a new render target texture stored in an InternalTexture
  129304. */
  129305. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  129306. /**
  129307. * Update the sampling mode of a given texture
  129308. * @param samplingMode defines the required sampling mode
  129309. * @param texture defines the texture to update
  129310. */
  129311. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  129312. /**
  129313. * Binds the frame buffer to the specified texture.
  129314. * @param texture The texture to render to or null for the default canvas
  129315. * @param faceIndex The face of the texture to render to in case of cube texture
  129316. * @param requiredWidth The width of the target to render to
  129317. * @param requiredHeight The height of the target to render to
  129318. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  129319. * @param lodLevel defines le lod level to bind to the frame buffer
  129320. */
  129321. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  129322. /**
  129323. * Unbind the current render target texture from the webGL context
  129324. * @param texture defines the render target texture to unbind
  129325. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129326. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129327. */
  129328. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  129329. /**
  129330. * Creates a dynamic vertex buffer
  129331. * @param vertices the data for the dynamic vertex buffer
  129332. * @returns the new WebGL dynamic buffer
  129333. */
  129334. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  129335. /**
  129336. * Update the content of a dynamic texture
  129337. * @param texture defines the texture to update
  129338. * @param canvas defines the canvas containing the source
  129339. * @param invertY defines if data must be stored with Y axis inverted
  129340. * @param premulAlpha defines if alpha is stored as premultiplied
  129341. * @param format defines the format of the data
  129342. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  129343. */
  129344. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  129345. /**
  129346. * Gets a boolean indicating if all created effects are ready
  129347. * @returns true if all effects are ready
  129348. */
  129349. areAllEffectsReady(): boolean;
  129350. /**
  129351. * @hidden
  129352. * Get the current error code of the webGL context
  129353. * @returns the error code
  129354. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  129355. */
  129356. getError(): number;
  129357. /** @hidden */
  129358. _getUnpackAlignement(): number;
  129359. /** @hidden */
  129360. _unpackFlipY(value: boolean): void;
  129361. /**
  129362. * Update a dynamic index buffer
  129363. * @param indexBuffer defines the target index buffer
  129364. * @param indices defines the data to update
  129365. * @param offset defines the offset in the target index buffer where update should start
  129366. */
  129367. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  129368. /**
  129369. * Updates a dynamic vertex buffer.
  129370. * @param vertexBuffer the vertex buffer to update
  129371. * @param vertices the data used to update the vertex buffer
  129372. * @param byteOffset the byte offset of the data (optional)
  129373. * @param byteLength the byte length of the data (optional)
  129374. */
  129375. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  129376. /** @hidden */
  129377. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  129378. /** @hidden */
  129379. _bindTexture(channel: number, texture: InternalTexture): void;
  129380. protected _deleteBuffer(buffer: WebGLBuffer): void;
  129381. /**
  129382. * 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
  129383. */
  129384. releaseEffects(): void;
  129385. displayLoadingUI(): void;
  129386. hideLoadingUI(): void;
  129387. /** @hidden */
  129388. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129389. /** @hidden */
  129390. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129391. /** @hidden */
  129392. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  129393. /** @hidden */
  129394. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  129395. }
  129396. }
  129397. declare module BABYLON {
  129398. /**
  129399. * @hidden
  129400. **/
  129401. export class _TimeToken {
  129402. _startTimeQuery: Nullable<WebGLQuery>;
  129403. _endTimeQuery: Nullable<WebGLQuery>;
  129404. _timeElapsedQuery: Nullable<WebGLQuery>;
  129405. _timeElapsedQueryEnded: boolean;
  129406. }
  129407. }
  129408. declare module BABYLON {
  129409. /** @hidden */
  129410. export class _OcclusionDataStorage {
  129411. /** @hidden */
  129412. occlusionInternalRetryCounter: number;
  129413. /** @hidden */
  129414. isOcclusionQueryInProgress: boolean;
  129415. /** @hidden */
  129416. isOccluded: boolean;
  129417. /** @hidden */
  129418. occlusionRetryCount: number;
  129419. /** @hidden */
  129420. occlusionType: number;
  129421. /** @hidden */
  129422. occlusionQueryAlgorithmType: number;
  129423. }
  129424. interface Engine {
  129425. /**
  129426. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  129427. * @return the new query
  129428. */
  129429. createQuery(): WebGLQuery;
  129430. /**
  129431. * Delete and release a webGL query
  129432. * @param query defines the query to delete
  129433. * @return the current engine
  129434. */
  129435. deleteQuery(query: WebGLQuery): Engine;
  129436. /**
  129437. * Check if a given query has resolved and got its value
  129438. * @param query defines the query to check
  129439. * @returns true if the query got its value
  129440. */
  129441. isQueryResultAvailable(query: WebGLQuery): boolean;
  129442. /**
  129443. * Gets the value of a given query
  129444. * @param query defines the query to check
  129445. * @returns the value of the query
  129446. */
  129447. getQueryResult(query: WebGLQuery): number;
  129448. /**
  129449. * Initiates an occlusion query
  129450. * @param algorithmType defines the algorithm to use
  129451. * @param query defines the query to use
  129452. * @returns the current engine
  129453. * @see https://doc.babylonjs.com/features/occlusionquery
  129454. */
  129455. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  129456. /**
  129457. * Ends an occlusion query
  129458. * @see https://doc.babylonjs.com/features/occlusionquery
  129459. * @param algorithmType defines the algorithm to use
  129460. * @returns the current engine
  129461. */
  129462. endOcclusionQuery(algorithmType: number): Engine;
  129463. /**
  129464. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  129465. * Please note that only one query can be issued at a time
  129466. * @returns a time token used to track the time span
  129467. */
  129468. startTimeQuery(): Nullable<_TimeToken>;
  129469. /**
  129470. * Ends a time query
  129471. * @param token defines the token used to measure the time span
  129472. * @returns the time spent (in ns)
  129473. */
  129474. endTimeQuery(token: _TimeToken): int;
  129475. /** @hidden */
  129476. _currentNonTimestampToken: Nullable<_TimeToken>;
  129477. /** @hidden */
  129478. _createTimeQuery(): WebGLQuery;
  129479. /** @hidden */
  129480. _deleteTimeQuery(query: WebGLQuery): void;
  129481. /** @hidden */
  129482. _getGlAlgorithmType(algorithmType: number): number;
  129483. /** @hidden */
  129484. _getTimeQueryResult(query: WebGLQuery): any;
  129485. /** @hidden */
  129486. _getTimeQueryAvailability(query: WebGLQuery): any;
  129487. }
  129488. interface AbstractMesh {
  129489. /**
  129490. * Backing filed
  129491. * @hidden
  129492. */
  129493. __occlusionDataStorage: _OcclusionDataStorage;
  129494. /**
  129495. * Access property
  129496. * @hidden
  129497. */
  129498. _occlusionDataStorage: _OcclusionDataStorage;
  129499. /**
  129500. * 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.
  129501. * The default value is -1 which means don't break the query and wait till the result
  129502. * @see https://doc.babylonjs.com/features/occlusionquery
  129503. */
  129504. occlusionRetryCount: number;
  129505. /**
  129506. * 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:
  129507. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  129508. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  129509. * * 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.
  129510. * @see https://doc.babylonjs.com/features/occlusionquery
  129511. */
  129512. occlusionType: number;
  129513. /**
  129514. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  129515. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  129516. * * 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.
  129517. * @see https://doc.babylonjs.com/features/occlusionquery
  129518. */
  129519. occlusionQueryAlgorithmType: number;
  129520. /**
  129521. * 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
  129522. * @see https://doc.babylonjs.com/features/occlusionquery
  129523. */
  129524. isOccluded: boolean;
  129525. /**
  129526. * Flag to check the progress status of the query
  129527. * @see https://doc.babylonjs.com/features/occlusionquery
  129528. */
  129529. isOcclusionQueryInProgress: boolean;
  129530. }
  129531. }
  129532. declare module BABYLON {
  129533. /** @hidden */
  129534. export var _forceTransformFeedbackToBundle: boolean;
  129535. interface Engine {
  129536. /**
  129537. * Creates a webGL transform feedback object
  129538. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  129539. * @returns the webGL transform feedback object
  129540. */
  129541. createTransformFeedback(): WebGLTransformFeedback;
  129542. /**
  129543. * Delete a webGL transform feedback object
  129544. * @param value defines the webGL transform feedback object to delete
  129545. */
  129546. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  129547. /**
  129548. * Bind a webGL transform feedback object to the webgl context
  129549. * @param value defines the webGL transform feedback object to bind
  129550. */
  129551. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  129552. /**
  129553. * Begins a transform feedback operation
  129554. * @param usePoints defines if points or triangles must be used
  129555. */
  129556. beginTransformFeedback(usePoints: boolean): void;
  129557. /**
  129558. * Ends a transform feedback operation
  129559. */
  129560. endTransformFeedback(): void;
  129561. /**
  129562. * Specify the varyings to use with transform feedback
  129563. * @param program defines the associated webGL program
  129564. * @param value defines the list of strings representing the varying names
  129565. */
  129566. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  129567. /**
  129568. * Bind a webGL buffer for a transform feedback operation
  129569. * @param value defines the webGL buffer to bind
  129570. */
  129571. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  129572. }
  129573. }
  129574. declare module BABYLON {
  129575. /**
  129576. * Creation options of the multi render target texture.
  129577. */
  129578. export interface IMultiRenderTargetOptions {
  129579. /**
  129580. * Define if the texture needs to create mip maps after render.
  129581. */
  129582. generateMipMaps?: boolean;
  129583. /**
  129584. * Define the types of all the draw buffers we want to create
  129585. */
  129586. types?: number[];
  129587. /**
  129588. * Define the sampling modes of all the draw buffers we want to create
  129589. */
  129590. samplingModes?: number[];
  129591. /**
  129592. * Define if a depth buffer is required
  129593. */
  129594. generateDepthBuffer?: boolean;
  129595. /**
  129596. * Define if a stencil buffer is required
  129597. */
  129598. generateStencilBuffer?: boolean;
  129599. /**
  129600. * Define if a depth texture is required instead of a depth buffer
  129601. */
  129602. generateDepthTexture?: boolean;
  129603. /**
  129604. * Define the number of desired draw buffers
  129605. */
  129606. textureCount?: number;
  129607. /**
  129608. * Define if aspect ratio should be adapted to the texture or stay the scene one
  129609. */
  129610. doNotChangeAspectRatio?: boolean;
  129611. /**
  129612. * Define the default type of the buffers we are creating
  129613. */
  129614. defaultType?: number;
  129615. }
  129616. /**
  129617. * A multi render target, like a render target provides the ability to render to a texture.
  129618. * Unlike the render target, it can render to several draw buffers in one draw.
  129619. * This is specially interesting in deferred rendering or for any effects requiring more than
  129620. * just one color from a single pass.
  129621. */
  129622. export class MultiRenderTarget extends RenderTargetTexture {
  129623. private _internalTextures;
  129624. private _textures;
  129625. private _multiRenderTargetOptions;
  129626. private _count;
  129627. /**
  129628. * Get if draw buffers are currently supported by the used hardware and browser.
  129629. */
  129630. get isSupported(): boolean;
  129631. /**
  129632. * Get the list of textures generated by the multi render target.
  129633. */
  129634. get textures(): Texture[];
  129635. /**
  129636. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  129637. */
  129638. get count(): number;
  129639. /**
  129640. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  129641. */
  129642. get depthTexture(): Texture;
  129643. /**
  129644. * Set the wrapping mode on U of all the textures we are rendering to.
  129645. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129646. */
  129647. set wrapU(wrap: number);
  129648. /**
  129649. * Set the wrapping mode on V of all the textures we are rendering to.
  129650. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  129651. */
  129652. set wrapV(wrap: number);
  129653. /**
  129654. * Instantiate a new multi render target texture.
  129655. * A multi render target, like a render target provides the ability to render to a texture.
  129656. * Unlike the render target, it can render to several draw buffers in one draw.
  129657. * This is specially interesting in deferred rendering or for any effects requiring more than
  129658. * just one color from a single pass.
  129659. * @param name Define the name of the texture
  129660. * @param size Define the size of the buffers to render to
  129661. * @param count Define the number of target we are rendering into
  129662. * @param scene Define the scene the texture belongs to
  129663. * @param options Define the options used to create the multi render target
  129664. */
  129665. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  129666. /** @hidden */
  129667. _rebuild(): void;
  129668. private _createInternalTextures;
  129669. private _createTextures;
  129670. /**
  129671. * Define the number of samples used if MSAA is enabled.
  129672. */
  129673. get samples(): number;
  129674. set samples(value: number);
  129675. /**
  129676. * Resize all the textures in the multi render target.
  129677. * Be carrefull as it will recreate all the data in the new texture.
  129678. * @param size Define the new size
  129679. */
  129680. resize(size: any): void;
  129681. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  129682. /**
  129683. * Dispose the render targets and their associated resources
  129684. */
  129685. dispose(): void;
  129686. /**
  129687. * Release all the underlying texture used as draw buffers.
  129688. */
  129689. releaseInternalTextures(): void;
  129690. }
  129691. }
  129692. declare module BABYLON {
  129693. interface ThinEngine {
  129694. /**
  129695. * Unbind a list of render target textures from the webGL context
  129696. * This is used only when drawBuffer extension or webGL2 are active
  129697. * @param textures defines the render target textures to unbind
  129698. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  129699. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  129700. */
  129701. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  129702. /**
  129703. * Create a multi render target texture
  129704. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  129705. * @param size defines the size of the texture
  129706. * @param options defines the creation options
  129707. * @returns the cube texture as an InternalTexture
  129708. */
  129709. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  129710. /**
  129711. * Update the sample count for a given multiple render target texture
  129712. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  129713. * @param textures defines the textures to update
  129714. * @param samples defines the sample count to set
  129715. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  129716. */
  129717. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  129718. /**
  129719. * Select a subsets of attachments to draw to.
  129720. * @param attachments gl attachments
  129721. */
  129722. bindAttachments(attachments: number[]): void;
  129723. }
  129724. }
  129725. declare module BABYLON {
  129726. /**
  129727. * Class used to define an additional view for the engine
  129728. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129729. */
  129730. export class EngineView {
  129731. /** Defines the canvas where to render the view */
  129732. target: HTMLCanvasElement;
  129733. /** Defines an optional camera used to render the view (will use active camera else) */
  129734. camera?: Camera;
  129735. }
  129736. interface Engine {
  129737. /**
  129738. * Gets or sets the HTML element to use for attaching events
  129739. */
  129740. inputElement: Nullable<HTMLElement>;
  129741. /**
  129742. * Gets the current engine view
  129743. * @see https://doc.babylonjs.com/how_to/multi_canvases
  129744. */
  129745. activeView: Nullable<EngineView>;
  129746. /** Gets or sets the list of views */
  129747. views: EngineView[];
  129748. /**
  129749. * Register a new child canvas
  129750. * @param canvas defines the canvas to register
  129751. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  129752. * @returns the associated view
  129753. */
  129754. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  129755. /**
  129756. * Remove a registered child canvas
  129757. * @param canvas defines the canvas to remove
  129758. * @returns the current engine
  129759. */
  129760. unRegisterView(canvas: HTMLCanvasElement): Engine;
  129761. }
  129762. }
  129763. declare module BABYLON {
  129764. interface Engine {
  129765. /** @hidden */
  129766. _excludedCompressedTextures: string[];
  129767. /** @hidden */
  129768. _textureFormatInUse: string;
  129769. /**
  129770. * Gets the list of texture formats supported
  129771. */
  129772. readonly texturesSupported: Array<string>;
  129773. /**
  129774. * Gets the texture format in use
  129775. */
  129776. readonly textureFormatInUse: Nullable<string>;
  129777. /**
  129778. * Set the compressed texture extensions or file names to skip.
  129779. *
  129780. * @param skippedFiles defines the list of those texture files you want to skip
  129781. * Example: [".dds", ".env", "myfile.png"]
  129782. */
  129783. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  129784. /**
  129785. * Set the compressed texture format to use, based on the formats you have, and the formats
  129786. * supported by the hardware / browser.
  129787. *
  129788. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  129789. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  129790. * to API arguments needed to compressed textures. This puts the burden on the container
  129791. * generator to house the arcane code for determining these for current & future formats.
  129792. *
  129793. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  129794. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  129795. *
  129796. * Note: The result of this call is not taken into account when a texture is base64.
  129797. *
  129798. * @param formatsAvailable defines the list of those format families you have created
  129799. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  129800. *
  129801. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  129802. * @returns The extension selected.
  129803. */
  129804. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  129805. }
  129806. }
  129807. declare module BABYLON {
  129808. /**
  129809. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  129810. */
  129811. export interface CubeMapInfo {
  129812. /**
  129813. * The pixel array for the front face.
  129814. * This is stored in format, left to right, up to down format.
  129815. */
  129816. front: Nullable<ArrayBufferView>;
  129817. /**
  129818. * The pixel array for the back face.
  129819. * This is stored in format, left to right, up to down format.
  129820. */
  129821. back: Nullable<ArrayBufferView>;
  129822. /**
  129823. * The pixel array for the left face.
  129824. * This is stored in format, left to right, up to down format.
  129825. */
  129826. left: Nullable<ArrayBufferView>;
  129827. /**
  129828. * The pixel array for the right face.
  129829. * This is stored in format, left to right, up to down format.
  129830. */
  129831. right: Nullable<ArrayBufferView>;
  129832. /**
  129833. * The pixel array for the up face.
  129834. * This is stored in format, left to right, up to down format.
  129835. */
  129836. up: Nullable<ArrayBufferView>;
  129837. /**
  129838. * The pixel array for the down face.
  129839. * This is stored in format, left to right, up to down format.
  129840. */
  129841. down: Nullable<ArrayBufferView>;
  129842. /**
  129843. * The size of the cubemap stored.
  129844. *
  129845. * Each faces will be size * size pixels.
  129846. */
  129847. size: number;
  129848. /**
  129849. * The format of the texture.
  129850. *
  129851. * RGBA, RGB.
  129852. */
  129853. format: number;
  129854. /**
  129855. * The type of the texture data.
  129856. *
  129857. * UNSIGNED_INT, FLOAT.
  129858. */
  129859. type: number;
  129860. /**
  129861. * Specifies whether the texture is in gamma space.
  129862. */
  129863. gammaSpace: boolean;
  129864. }
  129865. /**
  129866. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  129867. */
  129868. export class PanoramaToCubeMapTools {
  129869. private static FACE_LEFT;
  129870. private static FACE_RIGHT;
  129871. private static FACE_FRONT;
  129872. private static FACE_BACK;
  129873. private static FACE_DOWN;
  129874. private static FACE_UP;
  129875. /**
  129876. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  129877. *
  129878. * @param float32Array The source data.
  129879. * @param inputWidth The width of the input panorama.
  129880. * @param inputHeight The height of the input panorama.
  129881. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  129882. * @return The cubemap data
  129883. */
  129884. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  129885. private static CreateCubemapTexture;
  129886. private static CalcProjectionSpherical;
  129887. }
  129888. }
  129889. declare module BABYLON {
  129890. /**
  129891. * Helper class dealing with the extraction of spherical polynomial dataArray
  129892. * from a cube map.
  129893. */
  129894. export class CubeMapToSphericalPolynomialTools {
  129895. private static FileFaces;
  129896. /**
  129897. * Converts a texture to the according Spherical Polynomial data.
  129898. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129899. *
  129900. * @param texture The texture to extract the information from.
  129901. * @return The Spherical Polynomial data.
  129902. */
  129903. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  129904. /**
  129905. * Converts a cubemap to the according Spherical Polynomial data.
  129906. * This extracts the first 3 orders only as they are the only one used in the lighting.
  129907. *
  129908. * @param cubeInfo The Cube map to extract the information from.
  129909. * @return The Spherical Polynomial data.
  129910. */
  129911. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  129912. }
  129913. }
  129914. declare module BABYLON {
  129915. interface BaseTexture {
  129916. /**
  129917. * Get the polynomial representation of the texture data.
  129918. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  129919. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  129920. */
  129921. sphericalPolynomial: Nullable<SphericalPolynomial>;
  129922. }
  129923. }
  129924. declare module BABYLON {
  129925. /** @hidden */
  129926. export var rgbdEncodePixelShader: {
  129927. name: string;
  129928. shader: string;
  129929. };
  129930. }
  129931. declare module BABYLON {
  129932. /** @hidden */
  129933. export var rgbdDecodePixelShader: {
  129934. name: string;
  129935. shader: string;
  129936. };
  129937. }
  129938. declare module BABYLON {
  129939. /**
  129940. * Raw texture data and descriptor sufficient for WebGL texture upload
  129941. */
  129942. export interface EnvironmentTextureInfo {
  129943. /**
  129944. * Version of the environment map
  129945. */
  129946. version: number;
  129947. /**
  129948. * Width of image
  129949. */
  129950. width: number;
  129951. /**
  129952. * Irradiance information stored in the file.
  129953. */
  129954. irradiance: any;
  129955. /**
  129956. * Specular information stored in the file.
  129957. */
  129958. specular: any;
  129959. }
  129960. /**
  129961. * Defines One Image in the file. It requires only the position in the file
  129962. * as well as the length.
  129963. */
  129964. interface BufferImageData {
  129965. /**
  129966. * Length of the image data.
  129967. */
  129968. length: number;
  129969. /**
  129970. * Position of the data from the null terminator delimiting the end of the JSON.
  129971. */
  129972. position: number;
  129973. }
  129974. /**
  129975. * Defines the specular data enclosed in the file.
  129976. * This corresponds to the version 1 of the data.
  129977. */
  129978. export interface EnvironmentTextureSpecularInfoV1 {
  129979. /**
  129980. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  129981. */
  129982. specularDataPosition?: number;
  129983. /**
  129984. * This contains all the images data needed to reconstruct the cubemap.
  129985. */
  129986. mipmaps: Array<BufferImageData>;
  129987. /**
  129988. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  129989. */
  129990. lodGenerationScale: number;
  129991. }
  129992. /**
  129993. * Sets of helpers addressing the serialization and deserialization of environment texture
  129994. * stored in a BabylonJS env file.
  129995. * Those files are usually stored as .env files.
  129996. */
  129997. export class EnvironmentTextureTools {
  129998. /**
  129999. * Magic number identifying the env file.
  130000. */
  130001. private static _MagicBytes;
  130002. /**
  130003. * Gets the environment info from an env file.
  130004. * @param data The array buffer containing the .env bytes.
  130005. * @returns the environment file info (the json header) if successfully parsed.
  130006. */
  130007. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  130008. /**
  130009. * Creates an environment texture from a loaded cube texture.
  130010. * @param texture defines the cube texture to convert in env file
  130011. * @return a promise containing the environment data if succesfull.
  130012. */
  130013. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  130014. /**
  130015. * Creates a JSON representation of the spherical data.
  130016. * @param texture defines the texture containing the polynomials
  130017. * @return the JSON representation of the spherical info
  130018. */
  130019. private static _CreateEnvTextureIrradiance;
  130020. /**
  130021. * Creates the ArrayBufferViews used for initializing environment texture image data.
  130022. * @param data the image data
  130023. * @param info parameters that determine what views will be created for accessing the underlying buffer
  130024. * @return the views described by info providing access to the underlying buffer
  130025. */
  130026. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  130027. /**
  130028. * Uploads the texture info contained in the env file to the GPU.
  130029. * @param texture defines the internal texture to upload to
  130030. * @param data defines the data to load
  130031. * @param info defines the texture info retrieved through the GetEnvInfo method
  130032. * @returns a promise
  130033. */
  130034. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  130035. private static _OnImageReadyAsync;
  130036. /**
  130037. * Uploads the levels of image data to the GPU.
  130038. * @param texture defines the internal texture to upload to
  130039. * @param imageData defines the array buffer views of image data [mipmap][face]
  130040. * @returns a promise
  130041. */
  130042. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  130043. /**
  130044. * Uploads spherical polynomials information to the texture.
  130045. * @param texture defines the texture we are trying to upload the information to
  130046. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  130047. */
  130048. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  130049. /** @hidden */
  130050. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  130051. }
  130052. }
  130053. declare module BABYLON {
  130054. /**
  130055. * Class used to inline functions in shader code
  130056. */
  130057. export class ShaderCodeInliner {
  130058. private static readonly _RegexpFindFunctionNameAndType;
  130059. private _sourceCode;
  130060. private _functionDescr;
  130061. private _numMaxIterations;
  130062. /** Gets or sets the token used to mark the functions to inline */
  130063. inlineToken: string;
  130064. /** Gets or sets the debug mode */
  130065. debug: boolean;
  130066. /** Gets the code after the inlining process */
  130067. get code(): string;
  130068. /**
  130069. * Initializes the inliner
  130070. * @param sourceCode shader code source to inline
  130071. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  130072. */
  130073. constructor(sourceCode: string, numMaxIterations?: number);
  130074. /**
  130075. * Start the processing of the shader code
  130076. */
  130077. processCode(): void;
  130078. private _collectFunctions;
  130079. private _processInlining;
  130080. private _extractBetweenMarkers;
  130081. private _skipWhitespaces;
  130082. private _removeComments;
  130083. private _replaceFunctionCallsByCode;
  130084. private _findBackward;
  130085. private _escapeRegExp;
  130086. private _replaceNames;
  130087. }
  130088. }
  130089. declare module BABYLON {
  130090. /**
  130091. * Container for accessors for natively-stored mesh data buffers.
  130092. */
  130093. class NativeDataBuffer extends DataBuffer {
  130094. /**
  130095. * Accessor value used to identify/retrieve a natively-stored index buffer.
  130096. */
  130097. nativeIndexBuffer?: any;
  130098. /**
  130099. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  130100. */
  130101. nativeVertexBuffer?: any;
  130102. }
  130103. /** @hidden */
  130104. class NativeTexture extends InternalTexture {
  130105. getInternalTexture(): InternalTexture;
  130106. getViewCount(): number;
  130107. }
  130108. /** @hidden */
  130109. export class NativeEngine extends Engine {
  130110. private readonly _native;
  130111. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  130112. private readonly INVALID_HANDLE;
  130113. getHardwareScalingLevel(): number;
  130114. constructor();
  130115. dispose(): void;
  130116. /**
  130117. * Can be used to override the current requestAnimationFrame requester.
  130118. * @hidden
  130119. */
  130120. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  130121. /**
  130122. * Override default engine behavior.
  130123. * @param color
  130124. * @param backBuffer
  130125. * @param depth
  130126. * @param stencil
  130127. */
  130128. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  130129. /**
  130130. * Gets host document
  130131. * @returns the host document object
  130132. */
  130133. getHostDocument(): Nullable<Document>;
  130134. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  130135. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  130136. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  130137. recordVertexArrayObject(vertexBuffers: {
  130138. [key: string]: VertexBuffer;
  130139. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  130140. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130141. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  130142. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  130143. /**
  130144. * Draw a list of indexed primitives
  130145. * @param fillMode defines the primitive to use
  130146. * @param indexStart defines the starting index
  130147. * @param indexCount defines the number of index to draw
  130148. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130149. */
  130150. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  130151. /**
  130152. * Draw a list of unindexed primitives
  130153. * @param fillMode defines the primitive to use
  130154. * @param verticesStart defines the index of first vertex to draw
  130155. * @param verticesCount defines the count of vertices to draw
  130156. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  130157. */
  130158. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  130159. createPipelineContext(): IPipelineContext;
  130160. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  130161. /** @hidden */
  130162. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  130163. /** @hidden */
  130164. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  130165. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130166. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  130167. protected _setProgram(program: WebGLProgram): void;
  130168. _releaseEffect(effect: Effect): void;
  130169. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  130170. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  130171. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  130172. bindSamplers(effect: Effect): void;
  130173. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  130174. getRenderWidth(useScreen?: boolean): number;
  130175. getRenderHeight(useScreen?: boolean): number;
  130176. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  130177. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  130178. /**
  130179. * Set the z offset to apply to current rendering
  130180. * @param value defines the offset to apply
  130181. */
  130182. setZOffset(value: number): void;
  130183. /**
  130184. * Gets the current value of the zOffset
  130185. * @returns the current zOffset state
  130186. */
  130187. getZOffset(): number;
  130188. /**
  130189. * Enable or disable depth buffering
  130190. * @param enable defines the state to set
  130191. */
  130192. setDepthBuffer(enable: boolean): void;
  130193. /**
  130194. * Gets a boolean indicating if depth writing is enabled
  130195. * @returns the current depth writing state
  130196. */
  130197. getDepthWrite(): boolean;
  130198. /**
  130199. * Enable or disable depth writing
  130200. * @param enable defines the state to set
  130201. */
  130202. setDepthWrite(enable: boolean): void;
  130203. /**
  130204. * Enable or disable color writing
  130205. * @param enable defines the state to set
  130206. */
  130207. setColorWrite(enable: boolean): void;
  130208. /**
  130209. * Gets a boolean indicating if color writing is enabled
  130210. * @returns the current color writing state
  130211. */
  130212. getColorWrite(): boolean;
  130213. /**
  130214. * Sets alpha constants used by some alpha blending modes
  130215. * @param r defines the red component
  130216. * @param g defines the green component
  130217. * @param b defines the blue component
  130218. * @param a defines the alpha component
  130219. */
  130220. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  130221. /**
  130222. * Sets the current alpha mode
  130223. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  130224. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  130225. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130226. */
  130227. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  130228. /**
  130229. * Gets the current alpha mode
  130230. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  130231. * @returns the current alpha mode
  130232. */
  130233. getAlphaMode(): number;
  130234. setInt(uniform: WebGLUniformLocation, int: number): void;
  130235. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  130236. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  130237. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  130238. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  130239. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  130240. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  130241. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  130242. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  130243. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  130244. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  130245. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  130246. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  130247. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  130248. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130249. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  130250. setFloat(uniform: WebGLUniformLocation, value: number): void;
  130251. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  130252. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  130253. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  130254. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  130255. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  130256. wipeCaches(bruteForce?: boolean): void;
  130257. _createTexture(): WebGLTexture;
  130258. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  130259. /**
  130260. * Usually called from Texture.ts.
  130261. * Passed information to create a WebGLTexture
  130262. * @param url defines a value which contains one of the following:
  130263. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  130264. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  130265. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  130266. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  130267. * @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)
  130268. * @param scene needed for loading to the correct scene
  130269. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  130270. * @param onLoad optional callback to be called upon successful completion
  130271. * @param onError optional callback to be called upon failure
  130272. * @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
  130273. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  130274. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  130275. * @param forcedExtension defines the extension to use to pick the right loader
  130276. * @param mimeType defines an optional mime type
  130277. * @returns a InternalTexture for assignment back into BABYLON.Texture
  130278. */
  130279. 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;
  130280. /**
  130281. * Creates a cube texture
  130282. * @param rootUrl defines the url where the files to load is located
  130283. * @param scene defines the current scene
  130284. * @param files defines the list of files to load (1 per face)
  130285. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  130286. * @param onLoad defines an optional callback raised when the texture is loaded
  130287. * @param onError defines an optional callback raised if there is an issue to load the texture
  130288. * @param format defines the format of the data
  130289. * @param forcedExtension defines the extension to use to pick the right loader
  130290. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  130291. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  130292. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  130293. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  130294. * @returns the cube texture as an InternalTexture
  130295. */
  130296. 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;
  130297. private _getSamplingFilter;
  130298. private static _GetNativeTextureFormat;
  130299. createRenderTargetTexture(size: number | {
  130300. width: number;
  130301. height: number;
  130302. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  130303. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  130304. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  130305. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  130306. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  130307. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  130308. /**
  130309. * Updates a dynamic vertex buffer.
  130310. * @param vertexBuffer the vertex buffer to update
  130311. * @param data the data used to update the vertex buffer
  130312. * @param byteOffset the byte offset of the data (optional)
  130313. * @param byteLength the byte length of the data (optional)
  130314. */
  130315. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  130316. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  130317. private _updateAnisotropicLevel;
  130318. private _getAddressMode;
  130319. /** @hidden */
  130320. _bindTexture(channel: number, texture: InternalTexture): void;
  130321. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  130322. releaseEffects(): void;
  130323. /** @hidden */
  130324. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130325. /** @hidden */
  130326. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130327. /** @hidden */
  130328. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  130329. /** @hidden */
  130330. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  130331. }
  130332. }
  130333. declare module BABYLON {
  130334. /**
  130335. * Gather the list of clipboard event types as constants.
  130336. */
  130337. export class ClipboardEventTypes {
  130338. /**
  130339. * The clipboard event is fired when a copy command is active (pressed).
  130340. */
  130341. static readonly COPY: number;
  130342. /**
  130343. * The clipboard event is fired when a cut command is active (pressed).
  130344. */
  130345. static readonly CUT: number;
  130346. /**
  130347. * The clipboard event is fired when a paste command is active (pressed).
  130348. */
  130349. static readonly PASTE: number;
  130350. }
  130351. /**
  130352. * This class is used to store clipboard related info for the onClipboardObservable event.
  130353. */
  130354. export class ClipboardInfo {
  130355. /**
  130356. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130357. */
  130358. type: number;
  130359. /**
  130360. * Defines the related dom event
  130361. */
  130362. event: ClipboardEvent;
  130363. /**
  130364. *Creates an instance of ClipboardInfo.
  130365. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  130366. * @param event Defines the related dom event
  130367. */
  130368. constructor(
  130369. /**
  130370. * Defines the type of event (BABYLON.ClipboardEventTypes)
  130371. */
  130372. type: number,
  130373. /**
  130374. * Defines the related dom event
  130375. */
  130376. event: ClipboardEvent);
  130377. /**
  130378. * Get the clipboard event's type from the keycode.
  130379. * @param keyCode Defines the keyCode for the current keyboard event.
  130380. * @return {number}
  130381. */
  130382. static GetTypeFromCharacter(keyCode: number): number;
  130383. }
  130384. }
  130385. declare module BABYLON {
  130386. /**
  130387. * Google Daydream controller
  130388. */
  130389. export class DaydreamController extends WebVRController {
  130390. /**
  130391. * Base Url for the controller model.
  130392. */
  130393. static MODEL_BASE_URL: string;
  130394. /**
  130395. * File name for the controller model.
  130396. */
  130397. static MODEL_FILENAME: string;
  130398. /**
  130399. * Gamepad Id prefix used to identify Daydream Controller.
  130400. */
  130401. static readonly GAMEPAD_ID_PREFIX: string;
  130402. /**
  130403. * Creates a new DaydreamController from a gamepad
  130404. * @param vrGamepad the gamepad that the controller should be created from
  130405. */
  130406. constructor(vrGamepad: any);
  130407. /**
  130408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130409. * @param scene scene in which to add meshes
  130410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130411. */
  130412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130413. /**
  130414. * Called once for each button that changed state since the last frame
  130415. * @param buttonIdx Which button index changed
  130416. * @param state New state of the button
  130417. * @param changes Which properties on the state changed since last frame
  130418. */
  130419. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130420. }
  130421. }
  130422. declare module BABYLON {
  130423. /**
  130424. * Gear VR Controller
  130425. */
  130426. export class GearVRController extends WebVRController {
  130427. /**
  130428. * Base Url for the controller model.
  130429. */
  130430. static MODEL_BASE_URL: string;
  130431. /**
  130432. * File name for the controller model.
  130433. */
  130434. static MODEL_FILENAME: string;
  130435. /**
  130436. * Gamepad Id prefix used to identify this controller.
  130437. */
  130438. static readonly GAMEPAD_ID_PREFIX: string;
  130439. private readonly _buttonIndexToObservableNameMap;
  130440. /**
  130441. * Creates a new GearVRController from a gamepad
  130442. * @param vrGamepad the gamepad that the controller should be created from
  130443. */
  130444. constructor(vrGamepad: any);
  130445. /**
  130446. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130447. * @param scene scene in which to add meshes
  130448. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130449. */
  130450. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130451. /**
  130452. * Called once for each button that changed state since the last frame
  130453. * @param buttonIdx Which button index changed
  130454. * @param state New state of the button
  130455. * @param changes Which properties on the state changed since last frame
  130456. */
  130457. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130458. }
  130459. }
  130460. declare module BABYLON {
  130461. /**
  130462. * Generic Controller
  130463. */
  130464. export class GenericController extends WebVRController {
  130465. /**
  130466. * Base Url for the controller model.
  130467. */
  130468. static readonly MODEL_BASE_URL: string;
  130469. /**
  130470. * File name for the controller model.
  130471. */
  130472. static readonly MODEL_FILENAME: string;
  130473. /**
  130474. * Creates a new GenericController from a gamepad
  130475. * @param vrGamepad the gamepad that the controller should be created from
  130476. */
  130477. constructor(vrGamepad: any);
  130478. /**
  130479. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130480. * @param scene scene in which to add meshes
  130481. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130482. */
  130483. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130484. /**
  130485. * Called once for each button that changed state since the last frame
  130486. * @param buttonIdx Which button index changed
  130487. * @param state New state of the button
  130488. * @param changes Which properties on the state changed since last frame
  130489. */
  130490. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130491. }
  130492. }
  130493. declare module BABYLON {
  130494. /**
  130495. * Oculus Touch Controller
  130496. */
  130497. export class OculusTouchController extends WebVRController {
  130498. /**
  130499. * Base Url for the controller model.
  130500. */
  130501. static MODEL_BASE_URL: string;
  130502. /**
  130503. * File name for the left controller model.
  130504. */
  130505. static MODEL_LEFT_FILENAME: string;
  130506. /**
  130507. * File name for the right controller model.
  130508. */
  130509. static MODEL_RIGHT_FILENAME: string;
  130510. /**
  130511. * Base Url for the Quest controller model.
  130512. */
  130513. static QUEST_MODEL_BASE_URL: string;
  130514. /**
  130515. * @hidden
  130516. * If the controllers are running on a device that needs the updated Quest controller models
  130517. */
  130518. static _IsQuest: boolean;
  130519. /**
  130520. * Fired when the secondary trigger on this controller is modified
  130521. */
  130522. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  130523. /**
  130524. * Fired when the thumb rest on this controller is modified
  130525. */
  130526. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  130527. /**
  130528. * Creates a new OculusTouchController from a gamepad
  130529. * @param vrGamepad the gamepad that the controller should be created from
  130530. */
  130531. constructor(vrGamepad: any);
  130532. /**
  130533. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130534. * @param scene scene in which to add meshes
  130535. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130536. */
  130537. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130538. /**
  130539. * Fired when the A button on this controller is modified
  130540. */
  130541. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130542. /**
  130543. * Fired when the B button on this controller is modified
  130544. */
  130545. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130546. /**
  130547. * Fired when the X button on this controller is modified
  130548. */
  130549. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130550. /**
  130551. * Fired when the Y button on this controller is modified
  130552. */
  130553. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130554. /**
  130555. * Called once for each button that changed state since the last frame
  130556. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  130557. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  130558. * 2) secondary trigger (same)
  130559. * 3) A (right) X (left), touch, pressed = value
  130560. * 4) B / Y
  130561. * 5) thumb rest
  130562. * @param buttonIdx Which button index changed
  130563. * @param state New state of the button
  130564. * @param changes Which properties on the state changed since last frame
  130565. */
  130566. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130567. }
  130568. }
  130569. declare module BABYLON {
  130570. /**
  130571. * Vive Controller
  130572. */
  130573. export class ViveController extends WebVRController {
  130574. /**
  130575. * Base Url for the controller model.
  130576. */
  130577. static MODEL_BASE_URL: string;
  130578. /**
  130579. * File name for the controller model.
  130580. */
  130581. static MODEL_FILENAME: string;
  130582. /**
  130583. * Creates a new ViveController from a gamepad
  130584. * @param vrGamepad the gamepad that the controller should be created from
  130585. */
  130586. constructor(vrGamepad: any);
  130587. /**
  130588. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130589. * @param scene scene in which to add meshes
  130590. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130591. */
  130592. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  130593. /**
  130594. * Fired when the left button on this controller is modified
  130595. */
  130596. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130597. /**
  130598. * Fired when the right button on this controller is modified
  130599. */
  130600. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130601. /**
  130602. * Fired when the menu button on this controller is modified
  130603. */
  130604. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130605. /**
  130606. * Called once for each button that changed state since the last frame
  130607. * Vive mapping:
  130608. * 0: touchpad
  130609. * 1: trigger
  130610. * 2: left AND right buttons
  130611. * 3: menu button
  130612. * @param buttonIdx Which button index changed
  130613. * @param state New state of the button
  130614. * @param changes Which properties on the state changed since last frame
  130615. */
  130616. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130617. }
  130618. }
  130619. declare module BABYLON {
  130620. /**
  130621. * Defines the WindowsMotionController object that the state of the windows motion controller
  130622. */
  130623. export class WindowsMotionController extends WebVRController {
  130624. /**
  130625. * The base url used to load the left and right controller models
  130626. */
  130627. static MODEL_BASE_URL: string;
  130628. /**
  130629. * The name of the left controller model file
  130630. */
  130631. static MODEL_LEFT_FILENAME: string;
  130632. /**
  130633. * The name of the right controller model file
  130634. */
  130635. static MODEL_RIGHT_FILENAME: string;
  130636. /**
  130637. * The controller name prefix for this controller type
  130638. */
  130639. static readonly GAMEPAD_ID_PREFIX: string;
  130640. /**
  130641. * The controller id pattern for this controller type
  130642. */
  130643. private static readonly GAMEPAD_ID_PATTERN;
  130644. private _loadedMeshInfo;
  130645. protected readonly _mapping: {
  130646. buttons: string[];
  130647. buttonMeshNames: {
  130648. trigger: string;
  130649. menu: string;
  130650. grip: string;
  130651. thumbstick: string;
  130652. trackpad: string;
  130653. };
  130654. buttonObservableNames: {
  130655. trigger: string;
  130656. menu: string;
  130657. grip: string;
  130658. thumbstick: string;
  130659. trackpad: string;
  130660. };
  130661. axisMeshNames: string[];
  130662. pointingPoseMeshName: string;
  130663. };
  130664. /**
  130665. * Fired when the trackpad on this controller is clicked
  130666. */
  130667. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130668. /**
  130669. * Fired when the trackpad on this controller is modified
  130670. */
  130671. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130672. /**
  130673. * The current x and y values of this controller's trackpad
  130674. */
  130675. trackpad: StickValues;
  130676. /**
  130677. * Creates a new WindowsMotionController from a gamepad
  130678. * @param vrGamepad the gamepad that the controller should be created from
  130679. */
  130680. constructor(vrGamepad: any);
  130681. /**
  130682. * Fired when the trigger on this controller is modified
  130683. */
  130684. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130685. /**
  130686. * Fired when the menu button on this controller is modified
  130687. */
  130688. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130689. /**
  130690. * Fired when the grip button on this controller is modified
  130691. */
  130692. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130693. /**
  130694. * Fired when the thumbstick button on this controller is modified
  130695. */
  130696. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130697. /**
  130698. * Fired when the touchpad button on this controller is modified
  130699. */
  130700. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130701. /**
  130702. * Fired when the touchpad values on this controller are modified
  130703. */
  130704. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  130705. protected _updateTrackpad(): void;
  130706. /**
  130707. * Called once per frame by the engine.
  130708. */
  130709. update(): void;
  130710. /**
  130711. * Called once for each button that changed state since the last frame
  130712. * @param buttonIdx Which button index changed
  130713. * @param state New state of the button
  130714. * @param changes Which properties on the state changed since last frame
  130715. */
  130716. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  130717. /**
  130718. * Moves the buttons on the controller mesh based on their current state
  130719. * @param buttonName the name of the button to move
  130720. * @param buttonValue the value of the button which determines the buttons new position
  130721. */
  130722. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  130723. /**
  130724. * Moves the axis on the controller mesh based on its current state
  130725. * @param axis the index of the axis
  130726. * @param axisValue the value of the axis which determines the meshes new position
  130727. * @hidden
  130728. */
  130729. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  130730. /**
  130731. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  130732. * @param scene scene in which to add meshes
  130733. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  130734. */
  130735. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  130736. /**
  130737. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  130738. * can be transformed by button presses and axes values, based on this._mapping.
  130739. *
  130740. * @param scene scene in which the meshes exist
  130741. * @param meshes list of meshes that make up the controller model to process
  130742. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  130743. */
  130744. private processModel;
  130745. private createMeshInfo;
  130746. /**
  130747. * Gets the ray of the controller in the direction the controller is pointing
  130748. * @param length the length the resulting ray should be
  130749. * @returns a ray in the direction the controller is pointing
  130750. */
  130751. getForwardRay(length?: number): Ray;
  130752. /**
  130753. * Disposes of the controller
  130754. */
  130755. dispose(): void;
  130756. }
  130757. /**
  130758. * This class represents a new windows motion controller in XR.
  130759. */
  130760. export class XRWindowsMotionController extends WindowsMotionController {
  130761. /**
  130762. * Changing the original WIndowsMotionController mapping to fir the new mapping
  130763. */
  130764. protected readonly _mapping: {
  130765. buttons: string[];
  130766. buttonMeshNames: {
  130767. trigger: string;
  130768. menu: string;
  130769. grip: string;
  130770. thumbstick: string;
  130771. trackpad: string;
  130772. };
  130773. buttonObservableNames: {
  130774. trigger: string;
  130775. menu: string;
  130776. grip: string;
  130777. thumbstick: string;
  130778. trackpad: string;
  130779. };
  130780. axisMeshNames: string[];
  130781. pointingPoseMeshName: string;
  130782. };
  130783. /**
  130784. * Construct a new XR-Based windows motion controller
  130785. *
  130786. * @param gamepadInfo the gamepad object from the browser
  130787. */
  130788. constructor(gamepadInfo: any);
  130789. /**
  130790. * holds the thumbstick values (X,Y)
  130791. */
  130792. thumbstickValues: StickValues;
  130793. /**
  130794. * Fired when the thumbstick on this controller is clicked
  130795. */
  130796. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  130797. /**
  130798. * Fired when the thumbstick on this controller is modified
  130799. */
  130800. onThumbstickValuesChangedObservable: Observable<StickValues>;
  130801. /**
  130802. * Fired when the touchpad button on this controller is modified
  130803. */
  130804. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  130805. /**
  130806. * Fired when the touchpad values on this controller are modified
  130807. */
  130808. onTrackpadValuesChangedObservable: Observable<StickValues>;
  130809. /**
  130810. * Fired when the thumbstick button on this controller is modified
  130811. * here to prevent breaking changes
  130812. */
  130813. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  130814. /**
  130815. * updating the thumbstick(!) and not the trackpad.
  130816. * This is named this way due to the difference between WebVR and XR and to avoid
  130817. * changing the parent class.
  130818. */
  130819. protected _updateTrackpad(): void;
  130820. /**
  130821. * Disposes the class with joy
  130822. */
  130823. dispose(): void;
  130824. }
  130825. }
  130826. declare module BABYLON {
  130827. /**
  130828. * Class containing static functions to help procedurally build meshes
  130829. */
  130830. export class PolyhedronBuilder {
  130831. /**
  130832. * Creates a polyhedron mesh
  130833. * * 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
  130834. * * The parameter `size` (positive float, default 1) sets the polygon size
  130835. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  130836. * * 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`
  130837. * * 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
  130838. * * 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)`)
  130839. * * 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
  130840. * * 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
  130841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  130842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  130843. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  130844. * @param name defines the name of the mesh
  130845. * @param options defines the options used to create the mesh
  130846. * @param scene defines the hosting scene
  130847. * @returns the polyhedron mesh
  130848. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  130849. */
  130850. static CreatePolyhedron(name: string, options: {
  130851. type?: number;
  130852. size?: number;
  130853. sizeX?: number;
  130854. sizeY?: number;
  130855. sizeZ?: number;
  130856. custom?: any;
  130857. faceUV?: Vector4[];
  130858. faceColors?: Color4[];
  130859. flat?: boolean;
  130860. updatable?: boolean;
  130861. sideOrientation?: number;
  130862. frontUVs?: Vector4;
  130863. backUVs?: Vector4;
  130864. }, scene?: Nullable<Scene>): Mesh;
  130865. }
  130866. }
  130867. declare module BABYLON {
  130868. /**
  130869. * Gizmo that enables scaling a mesh along 3 axis
  130870. */
  130871. export class ScaleGizmo extends Gizmo {
  130872. /**
  130873. * Internal gizmo used for interactions on the x axis
  130874. */
  130875. xGizmo: AxisScaleGizmo;
  130876. /**
  130877. * Internal gizmo used for interactions on the y axis
  130878. */
  130879. yGizmo: AxisScaleGizmo;
  130880. /**
  130881. * Internal gizmo used for interactions on the z axis
  130882. */
  130883. zGizmo: AxisScaleGizmo;
  130884. /**
  130885. * Internal gizmo used to scale all axis equally
  130886. */
  130887. uniformScaleGizmo: AxisScaleGizmo;
  130888. private _meshAttached;
  130889. private _updateGizmoRotationToMatchAttachedMesh;
  130890. private _snapDistance;
  130891. private _scaleRatio;
  130892. private _uniformScalingMesh;
  130893. private _octahedron;
  130894. private _sensitivity;
  130895. /** Fires an event when any of it's sub gizmos are dragged */
  130896. onDragStartObservable: Observable<unknown>;
  130897. /** Fires an event when any of it's sub gizmos are released from dragging */
  130898. onDragEndObservable: Observable<unknown>;
  130899. get attachedMesh(): Nullable<AbstractMesh>;
  130900. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130901. /**
  130902. * Creates a ScaleGizmo
  130903. * @param gizmoLayer The utility layer the gizmo will be added to
  130904. */
  130905. constructor(gizmoLayer?: UtilityLayerRenderer);
  130906. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130907. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130908. /**
  130909. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130910. */
  130911. set snapDistance(value: number);
  130912. get snapDistance(): number;
  130913. /**
  130914. * Ratio for the scale of the gizmo (Default: 1)
  130915. */
  130916. set scaleRatio(value: number);
  130917. get scaleRatio(): number;
  130918. /**
  130919. * Sensitivity factor for dragging (Default: 1)
  130920. */
  130921. set sensitivity(value: number);
  130922. get sensitivity(): number;
  130923. /**
  130924. * Disposes of the gizmo
  130925. */
  130926. dispose(): void;
  130927. }
  130928. }
  130929. declare module BABYLON {
  130930. /**
  130931. * Single axis scale gizmo
  130932. */
  130933. export class AxisScaleGizmo extends Gizmo {
  130934. /**
  130935. * Drag behavior responsible for the gizmos dragging interactions
  130936. */
  130937. dragBehavior: PointerDragBehavior;
  130938. private _pointerObserver;
  130939. /**
  130940. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130941. */
  130942. snapDistance: number;
  130943. /**
  130944. * Event that fires each time the gizmo snaps to a new location.
  130945. * * snapDistance is the the change in distance
  130946. */
  130947. onSnapObservable: Observable<{
  130948. snapDistance: number;
  130949. }>;
  130950. /**
  130951. * If the scaling operation should be done on all axis (default: false)
  130952. */
  130953. uniformScaling: boolean;
  130954. /**
  130955. * Custom sensitivity value for the drag strength
  130956. */
  130957. sensitivity: number;
  130958. private _isEnabled;
  130959. private _parent;
  130960. private _arrow;
  130961. private _coloredMaterial;
  130962. private _hoverMaterial;
  130963. /**
  130964. * Creates an AxisScaleGizmo
  130965. * @param gizmoLayer The utility layer the gizmo will be added to
  130966. * @param dragAxis The axis which the gizmo will be able to scale on
  130967. * @param color The color of the gizmo
  130968. */
  130969. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  130970. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  130971. /**
  130972. * If the gizmo is enabled
  130973. */
  130974. set isEnabled(value: boolean);
  130975. get isEnabled(): boolean;
  130976. /**
  130977. * Disposes of the gizmo
  130978. */
  130979. dispose(): void;
  130980. /**
  130981. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130982. * @param mesh The mesh to replace the default mesh of the gizmo
  130983. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  130984. */
  130985. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  130986. }
  130987. }
  130988. declare module BABYLON {
  130989. /**
  130990. * Bounding box gizmo
  130991. */
  130992. export class BoundingBoxGizmo extends Gizmo {
  130993. private _lineBoundingBox;
  130994. private _rotateSpheresParent;
  130995. private _scaleBoxesParent;
  130996. private _boundingDimensions;
  130997. private _renderObserver;
  130998. private _pointerObserver;
  130999. private _scaleDragSpeed;
  131000. private _tmpQuaternion;
  131001. private _tmpVector;
  131002. private _tmpRotationMatrix;
  131003. /**
  131004. * 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)
  131005. */
  131006. ignoreChildren: boolean;
  131007. /**
  131008. * 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)
  131009. */
  131010. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  131011. /**
  131012. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  131013. */
  131014. rotationSphereSize: number;
  131015. /**
  131016. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  131017. */
  131018. scaleBoxSize: number;
  131019. /**
  131020. * 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)
  131021. */
  131022. fixedDragMeshScreenSize: boolean;
  131023. /**
  131024. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  131025. */
  131026. fixedDragMeshScreenSizeDistanceFactor: number;
  131027. /**
  131028. * Fired when a rotation sphere or scale box is dragged
  131029. */
  131030. onDragStartObservable: Observable<{}>;
  131031. /**
  131032. * Fired when a scale box is dragged
  131033. */
  131034. onScaleBoxDragObservable: Observable<{}>;
  131035. /**
  131036. * Fired when a scale box drag is ended
  131037. */
  131038. onScaleBoxDragEndObservable: Observable<{}>;
  131039. /**
  131040. * Fired when a rotation sphere is dragged
  131041. */
  131042. onRotationSphereDragObservable: Observable<{}>;
  131043. /**
  131044. * Fired when a rotation sphere drag is ended
  131045. */
  131046. onRotationSphereDragEndObservable: Observable<{}>;
  131047. /**
  131048. * Relative bounding box pivot used when scaling the attached mesh. When null object with scale from the opposite corner. 0.5,0.5,0.5 for center and 0.5,0,0.5 for bottom (Default: null)
  131049. */
  131050. scalePivot: Nullable<Vector3>;
  131051. /**
  131052. * Mesh used as a pivot to rotate the attached mesh
  131053. */
  131054. private _anchorMesh;
  131055. private _existingMeshScale;
  131056. private _dragMesh;
  131057. private pointerDragBehavior;
  131058. private coloredMaterial;
  131059. private hoverColoredMaterial;
  131060. /**
  131061. * Sets the color of the bounding box gizmo
  131062. * @param color the color to set
  131063. */
  131064. setColor(color: Color3): void;
  131065. /**
  131066. * Creates an BoundingBoxGizmo
  131067. * @param gizmoLayer The utility layer the gizmo will be added to
  131068. * @param color The color of the gizmo
  131069. */
  131070. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  131071. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  131072. private _selectNode;
  131073. /**
  131074. * Updates the bounding box information for the Gizmo
  131075. */
  131076. updateBoundingBox(): void;
  131077. private _updateRotationSpheres;
  131078. private _updateScaleBoxes;
  131079. /**
  131080. * Enables rotation on the specified axis and disables rotation on the others
  131081. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  131082. */
  131083. setEnabledRotationAxis(axis: string): void;
  131084. /**
  131085. * Enables/disables scaling
  131086. * @param enable if scaling should be enabled
  131087. * @param homogeneousScaling defines if scaling should only be homogeneous
  131088. */
  131089. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  131090. private _updateDummy;
  131091. /**
  131092. * Enables a pointer drag behavior on the bounding box of the gizmo
  131093. */
  131094. enableDragBehavior(): void;
  131095. /**
  131096. * Disposes of the gizmo
  131097. */
  131098. dispose(): void;
  131099. /**
  131100. * 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)
  131101. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  131102. * @returns the bounding box mesh with the passed in mesh as a child
  131103. */
  131104. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  131105. /**
  131106. * CustomMeshes are not supported by this gizmo
  131107. * @param mesh The mesh to replace the default mesh of the gizmo
  131108. */
  131109. setCustomMesh(mesh: Mesh): void;
  131110. }
  131111. }
  131112. declare module BABYLON {
  131113. /**
  131114. * Single plane rotation gizmo
  131115. */
  131116. export class PlaneRotationGizmo extends Gizmo {
  131117. /**
  131118. * Drag behavior responsible for the gizmos dragging interactions
  131119. */
  131120. dragBehavior: PointerDragBehavior;
  131121. private _pointerObserver;
  131122. /**
  131123. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  131124. */
  131125. snapDistance: number;
  131126. /**
  131127. * Event that fires each time the gizmo snaps to a new location.
  131128. * * snapDistance is the the change in distance
  131129. */
  131130. onSnapObservable: Observable<{
  131131. snapDistance: number;
  131132. }>;
  131133. private _isEnabled;
  131134. private _parent;
  131135. /**
  131136. * Creates a PlaneRotationGizmo
  131137. * @param gizmoLayer The utility layer the gizmo will be added to
  131138. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  131139. * @param color The color of the gizmo
  131140. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131141. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131142. */
  131143. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  131144. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  131145. /**
  131146. * If the gizmo is enabled
  131147. */
  131148. set isEnabled(value: boolean);
  131149. get isEnabled(): boolean;
  131150. /**
  131151. * Disposes of the gizmo
  131152. */
  131153. dispose(): void;
  131154. }
  131155. }
  131156. declare module BABYLON {
  131157. /**
  131158. * Gizmo that enables rotating a mesh along 3 axis
  131159. */
  131160. export class RotationGizmo extends Gizmo {
  131161. /**
  131162. * Internal gizmo used for interactions on the x axis
  131163. */
  131164. xGizmo: PlaneRotationGizmo;
  131165. /**
  131166. * Internal gizmo used for interactions on the y axis
  131167. */
  131168. yGizmo: PlaneRotationGizmo;
  131169. /**
  131170. * Internal gizmo used for interactions on the z axis
  131171. */
  131172. zGizmo: PlaneRotationGizmo;
  131173. /** Fires an event when any of it's sub gizmos are dragged */
  131174. onDragStartObservable: Observable<unknown>;
  131175. /** Fires an event when any of it's sub gizmos are released from dragging */
  131176. onDragEndObservable: Observable<unknown>;
  131177. private _meshAttached;
  131178. get attachedMesh(): Nullable<AbstractMesh>;
  131179. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131180. /**
  131181. * Creates a RotationGizmo
  131182. * @param gizmoLayer The utility layer the gizmo will be added to
  131183. * @param tessellation Amount of tessellation to be used when creating rotation circles
  131184. * @param useEulerRotation Use and update Euler angle instead of quaternion
  131185. */
  131186. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  131187. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131188. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131189. /**
  131190. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131191. */
  131192. set snapDistance(value: number);
  131193. get snapDistance(): number;
  131194. /**
  131195. * Ratio for the scale of the gizmo (Default: 1)
  131196. */
  131197. set scaleRatio(value: number);
  131198. get scaleRatio(): number;
  131199. /**
  131200. * Disposes of the gizmo
  131201. */
  131202. dispose(): void;
  131203. /**
  131204. * CustomMeshes are not supported by this gizmo
  131205. * @param mesh The mesh to replace the default mesh of the gizmo
  131206. */
  131207. setCustomMesh(mesh: Mesh): void;
  131208. }
  131209. }
  131210. declare module BABYLON {
  131211. /**
  131212. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  131213. */
  131214. export class GizmoManager implements IDisposable {
  131215. private scene;
  131216. /**
  131217. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  131218. */
  131219. gizmos: {
  131220. positionGizmo: Nullable<PositionGizmo>;
  131221. rotationGizmo: Nullable<RotationGizmo>;
  131222. scaleGizmo: Nullable<ScaleGizmo>;
  131223. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  131224. };
  131225. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  131226. clearGizmoOnEmptyPointerEvent: boolean;
  131227. /** Fires an event when the manager is attached to a mesh */
  131228. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  131229. private _gizmosEnabled;
  131230. private _pointerObserver;
  131231. private _attachedMesh;
  131232. private _boundingBoxColor;
  131233. private _defaultUtilityLayer;
  131234. private _defaultKeepDepthUtilityLayer;
  131235. /**
  131236. * When bounding box gizmo is enabled, this can be used to track drag/end events
  131237. */
  131238. boundingBoxDragBehavior: SixDofDragBehavior;
  131239. /**
  131240. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  131241. */
  131242. attachableMeshes: Nullable<Array<AbstractMesh>>;
  131243. /**
  131244. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  131245. */
  131246. usePointerToAttachGizmos: boolean;
  131247. /**
  131248. * Utility layer that the bounding box gizmo belongs to
  131249. */
  131250. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  131251. /**
  131252. * Utility layer that all gizmos besides bounding box belong to
  131253. */
  131254. get utilityLayer(): UtilityLayerRenderer;
  131255. /**
  131256. * Instatiates a gizmo manager
  131257. * @param scene the scene to overlay the gizmos on top of
  131258. */
  131259. constructor(scene: Scene);
  131260. /**
  131261. * Attaches a set of gizmos to the specified mesh
  131262. * @param mesh The mesh the gizmo's should be attached to
  131263. */
  131264. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  131265. /**
  131266. * If the position gizmo is enabled
  131267. */
  131268. set positionGizmoEnabled(value: boolean);
  131269. get positionGizmoEnabled(): boolean;
  131270. /**
  131271. * If the rotation gizmo is enabled
  131272. */
  131273. set rotationGizmoEnabled(value: boolean);
  131274. get rotationGizmoEnabled(): boolean;
  131275. /**
  131276. * If the scale gizmo is enabled
  131277. */
  131278. set scaleGizmoEnabled(value: boolean);
  131279. get scaleGizmoEnabled(): boolean;
  131280. /**
  131281. * If the boundingBox gizmo is enabled
  131282. */
  131283. set boundingBoxGizmoEnabled(value: boolean);
  131284. get boundingBoxGizmoEnabled(): boolean;
  131285. /**
  131286. * Disposes of the gizmo manager
  131287. */
  131288. dispose(): void;
  131289. }
  131290. }
  131291. declare module BABYLON {
  131292. /**
  131293. * A directional light is defined by a direction (what a surprise!).
  131294. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  131295. * 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.
  131296. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131297. */
  131298. export class DirectionalLight extends ShadowLight {
  131299. private _shadowFrustumSize;
  131300. /**
  131301. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  131302. */
  131303. get shadowFrustumSize(): number;
  131304. /**
  131305. * Specifies a fix frustum size for the shadow generation.
  131306. */
  131307. set shadowFrustumSize(value: number);
  131308. private _shadowOrthoScale;
  131309. /**
  131310. * Gets the shadow projection scale against the optimal computed one.
  131311. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131312. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131313. */
  131314. get shadowOrthoScale(): number;
  131315. /**
  131316. * Sets the shadow projection scale against the optimal computed one.
  131317. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  131318. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  131319. */
  131320. set shadowOrthoScale(value: number);
  131321. /**
  131322. * Automatically compute the projection matrix to best fit (including all the casters)
  131323. * on each frame.
  131324. */
  131325. autoUpdateExtends: boolean;
  131326. /**
  131327. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  131328. * on each frame. autoUpdateExtends must be set to true for this to work
  131329. */
  131330. autoCalcShadowZBounds: boolean;
  131331. private _orthoLeft;
  131332. private _orthoRight;
  131333. private _orthoTop;
  131334. private _orthoBottom;
  131335. /**
  131336. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  131337. * The directional light is emitted from everywhere in the given direction.
  131338. * It can cast shadows.
  131339. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131340. * @param name The friendly name of the light
  131341. * @param direction The direction of the light
  131342. * @param scene The scene the light belongs to
  131343. */
  131344. constructor(name: string, direction: Vector3, scene: Scene);
  131345. /**
  131346. * Returns the string "DirectionalLight".
  131347. * @return The class name
  131348. */
  131349. getClassName(): string;
  131350. /**
  131351. * Returns the integer 1.
  131352. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131353. */
  131354. getTypeID(): number;
  131355. /**
  131356. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  131357. * Returns the DirectionalLight Shadow projection matrix.
  131358. */
  131359. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131360. /**
  131361. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  131362. * Returns the DirectionalLight Shadow projection matrix.
  131363. */
  131364. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  131365. /**
  131366. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  131367. * Returns the DirectionalLight Shadow projection matrix.
  131368. */
  131369. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131370. protected _buildUniformLayout(): void;
  131371. /**
  131372. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  131373. * @param effect The effect to update
  131374. * @param lightIndex The index of the light in the effect to update
  131375. * @returns The directional light
  131376. */
  131377. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  131378. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  131379. /**
  131380. * Gets the minZ used for shadow according to both the scene and the light.
  131381. *
  131382. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131383. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131384. * @param activeCamera The camera we are returning the min for
  131385. * @returns the depth min z
  131386. */
  131387. getDepthMinZ(activeCamera: Camera): number;
  131388. /**
  131389. * Gets the maxZ used for shadow according to both the scene and the light.
  131390. *
  131391. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  131392. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  131393. * @param activeCamera The camera we are returning the max for
  131394. * @returns the depth max z
  131395. */
  131396. getDepthMaxZ(activeCamera: Camera): number;
  131397. /**
  131398. * Prepares the list of defines specific to the light type.
  131399. * @param defines the list of defines
  131400. * @param lightIndex defines the index of the light for the effect
  131401. */
  131402. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131403. }
  131404. }
  131405. declare module BABYLON {
  131406. /**
  131407. * Class containing static functions to help procedurally build meshes
  131408. */
  131409. export class HemisphereBuilder {
  131410. /**
  131411. * Creates a hemisphere mesh
  131412. * @param name defines the name of the mesh
  131413. * @param options defines the options used to create the mesh
  131414. * @param scene defines the hosting scene
  131415. * @returns the hemisphere mesh
  131416. */
  131417. static CreateHemisphere(name: string, options: {
  131418. segments?: number;
  131419. diameter?: number;
  131420. sideOrientation?: number;
  131421. }, scene: any): Mesh;
  131422. }
  131423. }
  131424. declare module BABYLON {
  131425. /**
  131426. * A spot light is defined by a position, a direction, an angle, and an exponent.
  131427. * These values define a cone of light starting from the position, emitting toward the direction.
  131428. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  131429. * and the exponent defines the speed of the decay of the light with distance (reach).
  131430. * Documentation: https://doc.babylonjs.com/babylon101/lights
  131431. */
  131432. export class SpotLight extends ShadowLight {
  131433. private _angle;
  131434. private _innerAngle;
  131435. private _cosHalfAngle;
  131436. private _lightAngleScale;
  131437. private _lightAngleOffset;
  131438. /**
  131439. * Gets the cone angle of the spot light in Radians.
  131440. */
  131441. get angle(): number;
  131442. /**
  131443. * Sets the cone angle of the spot light in Radians.
  131444. */
  131445. set angle(value: number);
  131446. /**
  131447. * Only used in gltf falloff mode, this defines the angle where
  131448. * the directional falloff will start before cutting at angle which could be seen
  131449. * as outer angle.
  131450. */
  131451. get innerAngle(): number;
  131452. /**
  131453. * Only used in gltf falloff mode, this defines the angle where
  131454. * the directional falloff will start before cutting at angle which could be seen
  131455. * as outer angle.
  131456. */
  131457. set innerAngle(value: number);
  131458. private _shadowAngleScale;
  131459. /**
  131460. * Allows scaling the angle of the light for shadow generation only.
  131461. */
  131462. get shadowAngleScale(): number;
  131463. /**
  131464. * Allows scaling the angle of the light for shadow generation only.
  131465. */
  131466. set shadowAngleScale(value: number);
  131467. /**
  131468. * The light decay speed with the distance from the emission spot.
  131469. */
  131470. exponent: number;
  131471. private _projectionTextureMatrix;
  131472. /**
  131473. * Allows reading the projecton texture
  131474. */
  131475. get projectionTextureMatrix(): Matrix;
  131476. protected _projectionTextureLightNear: number;
  131477. /**
  131478. * Gets the near clip of the Spotlight for texture projection.
  131479. */
  131480. get projectionTextureLightNear(): number;
  131481. /**
  131482. * Sets the near clip of the Spotlight for texture projection.
  131483. */
  131484. set projectionTextureLightNear(value: number);
  131485. protected _projectionTextureLightFar: number;
  131486. /**
  131487. * Gets the far clip of the Spotlight for texture projection.
  131488. */
  131489. get projectionTextureLightFar(): number;
  131490. /**
  131491. * Sets the far clip of the Spotlight for texture projection.
  131492. */
  131493. set projectionTextureLightFar(value: number);
  131494. protected _projectionTextureUpDirection: Vector3;
  131495. /**
  131496. * Gets the Up vector of the Spotlight for texture projection.
  131497. */
  131498. get projectionTextureUpDirection(): Vector3;
  131499. /**
  131500. * Sets the Up vector of the Spotlight for texture projection.
  131501. */
  131502. set projectionTextureUpDirection(value: Vector3);
  131503. private _projectionTexture;
  131504. /**
  131505. * Gets the projection texture of the light.
  131506. */
  131507. get projectionTexture(): Nullable<BaseTexture>;
  131508. /**
  131509. * Sets the projection texture of the light.
  131510. */
  131511. set projectionTexture(value: Nullable<BaseTexture>);
  131512. private _projectionTextureViewLightDirty;
  131513. private _projectionTextureProjectionLightDirty;
  131514. private _projectionTextureDirty;
  131515. private _projectionTextureViewTargetVector;
  131516. private _projectionTextureViewLightMatrix;
  131517. private _projectionTextureProjectionLightMatrix;
  131518. private _projectionTextureScalingMatrix;
  131519. /**
  131520. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  131521. * It can cast shadows.
  131522. * Documentation : https://doc.babylonjs.com/babylon101/lights
  131523. * @param name The light friendly name
  131524. * @param position The position of the spot light in the scene
  131525. * @param direction The direction of the light in the scene
  131526. * @param angle The cone angle of the light in Radians
  131527. * @param exponent The light decay speed with the distance from the emission spot
  131528. * @param scene The scene the lights belongs to
  131529. */
  131530. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  131531. /**
  131532. * Returns the string "SpotLight".
  131533. * @returns the class name
  131534. */
  131535. getClassName(): string;
  131536. /**
  131537. * Returns the integer 2.
  131538. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  131539. */
  131540. getTypeID(): number;
  131541. /**
  131542. * Overrides the direction setter to recompute the projection texture view light Matrix.
  131543. */
  131544. protected _setDirection(value: Vector3): void;
  131545. /**
  131546. * Overrides the position setter to recompute the projection texture view light Matrix.
  131547. */
  131548. protected _setPosition(value: Vector3): void;
  131549. /**
  131550. * 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.
  131551. * Returns the SpotLight.
  131552. */
  131553. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  131554. protected _computeProjectionTextureViewLightMatrix(): void;
  131555. protected _computeProjectionTextureProjectionLightMatrix(): void;
  131556. /**
  131557. * Main function for light texture projection matrix computing.
  131558. */
  131559. protected _computeProjectionTextureMatrix(): void;
  131560. protected _buildUniformLayout(): void;
  131561. private _computeAngleValues;
  131562. /**
  131563. * Sets the passed Effect "effect" with the Light textures.
  131564. * @param effect The effect to update
  131565. * @param lightIndex The index of the light in the effect to update
  131566. * @returns The light
  131567. */
  131568. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  131569. /**
  131570. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  131571. * @param effect The effect to update
  131572. * @param lightIndex The index of the light in the effect to update
  131573. * @returns The spot light
  131574. */
  131575. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  131576. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  131577. /**
  131578. * Disposes the light and the associated resources.
  131579. */
  131580. dispose(): void;
  131581. /**
  131582. * Prepares the list of defines specific to the light type.
  131583. * @param defines the list of defines
  131584. * @param lightIndex defines the index of the light for the effect
  131585. */
  131586. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  131587. }
  131588. }
  131589. declare module BABYLON {
  131590. /**
  131591. * Gizmo that enables viewing a light
  131592. */
  131593. export class LightGizmo extends Gizmo {
  131594. private _lightMesh;
  131595. private _material;
  131596. private _cachedPosition;
  131597. private _cachedForward;
  131598. private _attachedMeshParent;
  131599. /**
  131600. * Creates a LightGizmo
  131601. * @param gizmoLayer The utility layer the gizmo will be added to
  131602. */
  131603. constructor(gizmoLayer?: UtilityLayerRenderer);
  131604. private _light;
  131605. /**
  131606. * The light that the gizmo is attached to
  131607. */
  131608. set light(light: Nullable<Light>);
  131609. get light(): Nullable<Light>;
  131610. /**
  131611. * Gets the material used to render the light gizmo
  131612. */
  131613. get material(): StandardMaterial;
  131614. /**
  131615. * @hidden
  131616. * Updates the gizmo to match the attached mesh's position/rotation
  131617. */
  131618. protected _update(): void;
  131619. private static _Scale;
  131620. /**
  131621. * Creates the lines for a light mesh
  131622. */
  131623. private static _CreateLightLines;
  131624. /**
  131625. * Disposes of the light gizmo
  131626. */
  131627. dispose(): void;
  131628. private static _CreateHemisphericLightMesh;
  131629. private static _CreatePointLightMesh;
  131630. private static _CreateSpotLightMesh;
  131631. private static _CreateDirectionalLightMesh;
  131632. }
  131633. }
  131634. declare module BABYLON {
  131635. /** @hidden */
  131636. export var backgroundFragmentDeclaration: {
  131637. name: string;
  131638. shader: string;
  131639. };
  131640. }
  131641. declare module BABYLON {
  131642. /** @hidden */
  131643. export var backgroundUboDeclaration: {
  131644. name: string;
  131645. shader: string;
  131646. };
  131647. }
  131648. declare module BABYLON {
  131649. /** @hidden */
  131650. export var backgroundPixelShader: {
  131651. name: string;
  131652. shader: string;
  131653. };
  131654. }
  131655. declare module BABYLON {
  131656. /** @hidden */
  131657. export var backgroundVertexDeclaration: {
  131658. name: string;
  131659. shader: string;
  131660. };
  131661. }
  131662. declare module BABYLON {
  131663. /** @hidden */
  131664. export var backgroundVertexShader: {
  131665. name: string;
  131666. shader: string;
  131667. };
  131668. }
  131669. declare module BABYLON {
  131670. /**
  131671. * Background material used to create an efficient environement around your scene.
  131672. */
  131673. export class BackgroundMaterial extends PushMaterial {
  131674. /**
  131675. * Standard reflectance value at parallel view angle.
  131676. */
  131677. static StandardReflectance0: number;
  131678. /**
  131679. * Standard reflectance value at grazing angle.
  131680. */
  131681. static StandardReflectance90: number;
  131682. protected _primaryColor: Color3;
  131683. /**
  131684. * Key light Color (multiply against the environement texture)
  131685. */
  131686. primaryColor: Color3;
  131687. protected __perceptualColor: Nullable<Color3>;
  131688. /**
  131689. * Experimental Internal Use Only.
  131690. *
  131691. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  131692. * This acts as a helper to set the primary color to a more "human friendly" value.
  131693. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  131694. * output color as close as possible from the chosen value.
  131695. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  131696. * part of lighting setup.)
  131697. */
  131698. get _perceptualColor(): Nullable<Color3>;
  131699. set _perceptualColor(value: Nullable<Color3>);
  131700. protected _primaryColorShadowLevel: float;
  131701. /**
  131702. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  131703. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  131704. */
  131705. get primaryColorShadowLevel(): float;
  131706. set primaryColorShadowLevel(value: float);
  131707. protected _primaryColorHighlightLevel: float;
  131708. /**
  131709. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  131710. * The primary color is used at the level chosen to define what the white area would look.
  131711. */
  131712. get primaryColorHighlightLevel(): float;
  131713. set primaryColorHighlightLevel(value: float);
  131714. protected _reflectionTexture: Nullable<BaseTexture>;
  131715. /**
  131716. * Reflection Texture used in the material.
  131717. * Should be author in a specific way for the best result (refer to the documentation).
  131718. */
  131719. reflectionTexture: Nullable<BaseTexture>;
  131720. protected _reflectionBlur: float;
  131721. /**
  131722. * Reflection Texture level of blur.
  131723. *
  131724. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  131725. * texture twice.
  131726. */
  131727. reflectionBlur: float;
  131728. protected _diffuseTexture: Nullable<BaseTexture>;
  131729. /**
  131730. * Diffuse Texture used in the material.
  131731. * Should be author in a specific way for the best result (refer to the documentation).
  131732. */
  131733. diffuseTexture: Nullable<BaseTexture>;
  131734. protected _shadowLights: Nullable<IShadowLight[]>;
  131735. /**
  131736. * Specify the list of lights casting shadow on the material.
  131737. * All scene shadow lights will be included if null.
  131738. */
  131739. shadowLights: Nullable<IShadowLight[]>;
  131740. protected _shadowLevel: float;
  131741. /**
  131742. * Helps adjusting the shadow to a softer level if required.
  131743. * 0 means black shadows and 1 means no shadows.
  131744. */
  131745. shadowLevel: float;
  131746. protected _sceneCenter: Vector3;
  131747. /**
  131748. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  131749. * It is usually zero but might be interesting to modify according to your setup.
  131750. */
  131751. sceneCenter: Vector3;
  131752. protected _opacityFresnel: boolean;
  131753. /**
  131754. * This helps specifying that the material is falling off to the sky box at grazing angle.
  131755. * This helps ensuring a nice transition when the camera goes under the ground.
  131756. */
  131757. opacityFresnel: boolean;
  131758. protected _reflectionFresnel: boolean;
  131759. /**
  131760. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  131761. * This helps adding a mirror texture on the ground.
  131762. */
  131763. reflectionFresnel: boolean;
  131764. protected _reflectionFalloffDistance: number;
  131765. /**
  131766. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  131767. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  131768. */
  131769. reflectionFalloffDistance: number;
  131770. protected _reflectionAmount: number;
  131771. /**
  131772. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  131773. */
  131774. reflectionAmount: number;
  131775. protected _reflectionReflectance0: number;
  131776. /**
  131777. * This specifies the weight of the reflection at grazing angle.
  131778. */
  131779. reflectionReflectance0: number;
  131780. protected _reflectionReflectance90: number;
  131781. /**
  131782. * This specifies the weight of the reflection at a perpendicular point of view.
  131783. */
  131784. reflectionReflectance90: number;
  131785. /**
  131786. * Sets the reflection reflectance fresnel values according to the default standard
  131787. * empirically know to work well :-)
  131788. */
  131789. set reflectionStandardFresnelWeight(value: number);
  131790. protected _useRGBColor: boolean;
  131791. /**
  131792. * Helps to directly use the maps channels instead of their level.
  131793. */
  131794. useRGBColor: boolean;
  131795. protected _enableNoise: boolean;
  131796. /**
  131797. * This helps reducing the banding effect that could occur on the background.
  131798. */
  131799. enableNoise: boolean;
  131800. /**
  131801. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  131802. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  131803. * Recommended to be keep at 1.0 except for special cases.
  131804. */
  131805. get fovMultiplier(): number;
  131806. set fovMultiplier(value: number);
  131807. private _fovMultiplier;
  131808. /**
  131809. * Enable the FOV adjustment feature controlled by fovMultiplier.
  131810. */
  131811. useEquirectangularFOV: boolean;
  131812. private _maxSimultaneousLights;
  131813. /**
  131814. * Number of Simultaneous lights allowed on the material.
  131815. */
  131816. maxSimultaneousLights: int;
  131817. private _shadowOnly;
  131818. /**
  131819. * Make the material only render shadows
  131820. */
  131821. shadowOnly: boolean;
  131822. /**
  131823. * Default configuration related to image processing available in the Background Material.
  131824. */
  131825. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131826. /**
  131827. * Keep track of the image processing observer to allow dispose and replace.
  131828. */
  131829. private _imageProcessingObserver;
  131830. /**
  131831. * Attaches a new image processing configuration to the PBR Material.
  131832. * @param configuration (if null the scene configuration will be use)
  131833. */
  131834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131835. /**
  131836. * Gets the image processing configuration used either in this material.
  131837. */
  131838. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  131839. /**
  131840. * Sets the Default image processing configuration used either in the this material.
  131841. *
  131842. * If sets to null, the scene one is in use.
  131843. */
  131844. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  131845. /**
  131846. * Gets wether the color curves effect is enabled.
  131847. */
  131848. get cameraColorCurvesEnabled(): boolean;
  131849. /**
  131850. * Sets wether the color curves effect is enabled.
  131851. */
  131852. set cameraColorCurvesEnabled(value: boolean);
  131853. /**
  131854. * Gets wether the color grading effect is enabled.
  131855. */
  131856. get cameraColorGradingEnabled(): boolean;
  131857. /**
  131858. * Gets wether the color grading effect is enabled.
  131859. */
  131860. set cameraColorGradingEnabled(value: boolean);
  131861. /**
  131862. * Gets wether tonemapping is enabled or not.
  131863. */
  131864. get cameraToneMappingEnabled(): boolean;
  131865. /**
  131866. * Sets wether tonemapping is enabled or not
  131867. */
  131868. set cameraToneMappingEnabled(value: boolean);
  131869. /**
  131870. * The camera exposure used on this material.
  131871. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131872. * This corresponds to a photographic exposure.
  131873. */
  131874. get cameraExposure(): float;
  131875. /**
  131876. * The camera exposure used on this material.
  131877. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  131878. * This corresponds to a photographic exposure.
  131879. */
  131880. set cameraExposure(value: float);
  131881. /**
  131882. * Gets The camera contrast used on this material.
  131883. */
  131884. get cameraContrast(): float;
  131885. /**
  131886. * Sets The camera contrast used on this material.
  131887. */
  131888. set cameraContrast(value: float);
  131889. /**
  131890. * Gets the Color Grading 2D Lookup Texture.
  131891. */
  131892. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  131893. /**
  131894. * Sets the Color Grading 2D Lookup Texture.
  131895. */
  131896. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  131897. /**
  131898. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131899. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131900. * 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;
  131901. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131902. */
  131903. get cameraColorCurves(): Nullable<ColorCurves>;
  131904. /**
  131905. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  131906. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  131907. * 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;
  131908. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  131909. */
  131910. set cameraColorCurves(value: Nullable<ColorCurves>);
  131911. /**
  131912. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  131913. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  131914. */
  131915. switchToBGR: boolean;
  131916. private _renderTargets;
  131917. private _reflectionControls;
  131918. private _white;
  131919. private _primaryShadowColor;
  131920. private _primaryHighlightColor;
  131921. /**
  131922. * Instantiates a Background Material in the given scene
  131923. * @param name The friendly name of the material
  131924. * @param scene The scene to add the material to
  131925. */
  131926. constructor(name: string, scene: Scene);
  131927. /**
  131928. * Gets a boolean indicating that current material needs to register RTT
  131929. */
  131930. get hasRenderTargetTextures(): boolean;
  131931. /**
  131932. * The entire material has been created in order to prevent overdraw.
  131933. * @returns false
  131934. */
  131935. needAlphaTesting(): boolean;
  131936. /**
  131937. * The entire material has been created in order to prevent overdraw.
  131938. * @returns true if blending is enable
  131939. */
  131940. needAlphaBlending(): boolean;
  131941. /**
  131942. * Checks wether the material is ready to be rendered for a given mesh.
  131943. * @param mesh The mesh to render
  131944. * @param subMesh The submesh to check against
  131945. * @param useInstances Specify wether or not the material is used with instances
  131946. * @returns true if all the dependencies are ready (Textures, Effects...)
  131947. */
  131948. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  131949. /**
  131950. * Compute the primary color according to the chosen perceptual color.
  131951. */
  131952. private _computePrimaryColorFromPerceptualColor;
  131953. /**
  131954. * Compute the highlights and shadow colors according to their chosen levels.
  131955. */
  131956. private _computePrimaryColors;
  131957. /**
  131958. * Build the uniform buffer used in the material.
  131959. */
  131960. buildUniformLayout(): void;
  131961. /**
  131962. * Unbind the material.
  131963. */
  131964. unbind(): void;
  131965. /**
  131966. * Bind only the world matrix to the material.
  131967. * @param world The world matrix to bind.
  131968. */
  131969. bindOnlyWorldMatrix(world: Matrix): void;
  131970. /**
  131971. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  131972. * @param world The world matrix to bind.
  131973. * @param subMesh The submesh to bind for.
  131974. */
  131975. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  131976. /**
  131977. * Checks to see if a texture is used in the material.
  131978. * @param texture - Base texture to use.
  131979. * @returns - Boolean specifying if a texture is used in the material.
  131980. */
  131981. hasTexture(texture: BaseTexture): boolean;
  131982. /**
  131983. * Dispose the material.
  131984. * @param forceDisposeEffect Force disposal of the associated effect.
  131985. * @param forceDisposeTextures Force disposal of the associated textures.
  131986. */
  131987. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  131988. /**
  131989. * Clones the material.
  131990. * @param name The cloned name.
  131991. * @returns The cloned material.
  131992. */
  131993. clone(name: string): BackgroundMaterial;
  131994. /**
  131995. * Serializes the current material to its JSON representation.
  131996. * @returns The JSON representation.
  131997. */
  131998. serialize(): any;
  131999. /**
  132000. * Gets the class name of the material
  132001. * @returns "BackgroundMaterial"
  132002. */
  132003. getClassName(): string;
  132004. /**
  132005. * Parse a JSON input to create back a background material.
  132006. * @param source The JSON data to parse
  132007. * @param scene The scene to create the parsed material in
  132008. * @param rootUrl The root url of the assets the material depends upon
  132009. * @returns the instantiated BackgroundMaterial.
  132010. */
  132011. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  132012. }
  132013. }
  132014. declare module BABYLON {
  132015. /**
  132016. * Represents the different options available during the creation of
  132017. * a Environment helper.
  132018. *
  132019. * This can control the default ground, skybox and image processing setup of your scene.
  132020. */
  132021. export interface IEnvironmentHelperOptions {
  132022. /**
  132023. * Specifies whether or not to create a ground.
  132024. * True by default.
  132025. */
  132026. createGround: boolean;
  132027. /**
  132028. * Specifies the ground size.
  132029. * 15 by default.
  132030. */
  132031. groundSize: number;
  132032. /**
  132033. * The texture used on the ground for the main color.
  132034. * Comes from the BabylonJS CDN by default.
  132035. *
  132036. * Remarks: Can be either a texture or a url.
  132037. */
  132038. groundTexture: string | BaseTexture;
  132039. /**
  132040. * The color mixed in the ground texture by default.
  132041. * BabylonJS clearColor by default.
  132042. */
  132043. groundColor: Color3;
  132044. /**
  132045. * Specifies the ground opacity.
  132046. * 1 by default.
  132047. */
  132048. groundOpacity: number;
  132049. /**
  132050. * Enables the ground to receive shadows.
  132051. * True by default.
  132052. */
  132053. enableGroundShadow: boolean;
  132054. /**
  132055. * Helps preventing the shadow to be fully black on the ground.
  132056. * 0.5 by default.
  132057. */
  132058. groundShadowLevel: number;
  132059. /**
  132060. * Creates a mirror texture attach to the ground.
  132061. * false by default.
  132062. */
  132063. enableGroundMirror: boolean;
  132064. /**
  132065. * Specifies the ground mirror size ratio.
  132066. * 0.3 by default as the default kernel is 64.
  132067. */
  132068. groundMirrorSizeRatio: number;
  132069. /**
  132070. * Specifies the ground mirror blur kernel size.
  132071. * 64 by default.
  132072. */
  132073. groundMirrorBlurKernel: number;
  132074. /**
  132075. * Specifies the ground mirror visibility amount.
  132076. * 1 by default
  132077. */
  132078. groundMirrorAmount: number;
  132079. /**
  132080. * Specifies the ground mirror reflectance weight.
  132081. * This uses the standard weight of the background material to setup the fresnel effect
  132082. * of the mirror.
  132083. * 1 by default.
  132084. */
  132085. groundMirrorFresnelWeight: number;
  132086. /**
  132087. * Specifies the ground mirror Falloff distance.
  132088. * This can helps reducing the size of the reflection.
  132089. * 0 by Default.
  132090. */
  132091. groundMirrorFallOffDistance: number;
  132092. /**
  132093. * Specifies the ground mirror texture type.
  132094. * Unsigned Int by Default.
  132095. */
  132096. groundMirrorTextureType: number;
  132097. /**
  132098. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  132099. * the shown objects.
  132100. */
  132101. groundYBias: number;
  132102. /**
  132103. * Specifies whether or not to create a skybox.
  132104. * True by default.
  132105. */
  132106. createSkybox: boolean;
  132107. /**
  132108. * Specifies the skybox size.
  132109. * 20 by default.
  132110. */
  132111. skyboxSize: number;
  132112. /**
  132113. * The texture used on the skybox for the main color.
  132114. * Comes from the BabylonJS CDN by default.
  132115. *
  132116. * Remarks: Can be either a texture or a url.
  132117. */
  132118. skyboxTexture: string | BaseTexture;
  132119. /**
  132120. * The color mixed in the skybox texture by default.
  132121. * BabylonJS clearColor by default.
  132122. */
  132123. skyboxColor: Color3;
  132124. /**
  132125. * The background rotation around the Y axis of the scene.
  132126. * This helps aligning the key lights of your scene with the background.
  132127. * 0 by default.
  132128. */
  132129. backgroundYRotation: number;
  132130. /**
  132131. * Compute automatically the size of the elements to best fit with the scene.
  132132. */
  132133. sizeAuto: boolean;
  132134. /**
  132135. * Default position of the rootMesh if autoSize is not true.
  132136. */
  132137. rootPosition: Vector3;
  132138. /**
  132139. * Sets up the image processing in the scene.
  132140. * true by default.
  132141. */
  132142. setupImageProcessing: boolean;
  132143. /**
  132144. * The texture used as your environment texture in the scene.
  132145. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  132146. *
  132147. * Remarks: Can be either a texture or a url.
  132148. */
  132149. environmentTexture: string | BaseTexture;
  132150. /**
  132151. * The value of the exposure to apply to the scene.
  132152. * 0.6 by default if setupImageProcessing is true.
  132153. */
  132154. cameraExposure: number;
  132155. /**
  132156. * The value of the contrast to apply to the scene.
  132157. * 1.6 by default if setupImageProcessing is true.
  132158. */
  132159. cameraContrast: number;
  132160. /**
  132161. * Specifies whether or not tonemapping should be enabled in the scene.
  132162. * true by default if setupImageProcessing is true.
  132163. */
  132164. toneMappingEnabled: boolean;
  132165. }
  132166. /**
  132167. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  132168. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  132169. * It also helps with the default setup of your imageProcessing configuration.
  132170. */
  132171. export class EnvironmentHelper {
  132172. /**
  132173. * Default ground texture URL.
  132174. */
  132175. private static _groundTextureCDNUrl;
  132176. /**
  132177. * Default skybox texture URL.
  132178. */
  132179. private static _skyboxTextureCDNUrl;
  132180. /**
  132181. * Default environment texture URL.
  132182. */
  132183. private static _environmentTextureCDNUrl;
  132184. /**
  132185. * Creates the default options for the helper.
  132186. */
  132187. private static _getDefaultOptions;
  132188. private _rootMesh;
  132189. /**
  132190. * Gets the root mesh created by the helper.
  132191. */
  132192. get rootMesh(): Mesh;
  132193. private _skybox;
  132194. /**
  132195. * Gets the skybox created by the helper.
  132196. */
  132197. get skybox(): Nullable<Mesh>;
  132198. private _skyboxTexture;
  132199. /**
  132200. * Gets the skybox texture created by the helper.
  132201. */
  132202. get skyboxTexture(): Nullable<BaseTexture>;
  132203. private _skyboxMaterial;
  132204. /**
  132205. * Gets the skybox material created by the helper.
  132206. */
  132207. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  132208. private _ground;
  132209. /**
  132210. * Gets the ground mesh created by the helper.
  132211. */
  132212. get ground(): Nullable<Mesh>;
  132213. private _groundTexture;
  132214. /**
  132215. * Gets the ground texture created by the helper.
  132216. */
  132217. get groundTexture(): Nullable<BaseTexture>;
  132218. private _groundMirror;
  132219. /**
  132220. * Gets the ground mirror created by the helper.
  132221. */
  132222. get groundMirror(): Nullable<MirrorTexture>;
  132223. /**
  132224. * Gets the ground mirror render list to helps pushing the meshes
  132225. * you wish in the ground reflection.
  132226. */
  132227. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  132228. private _groundMaterial;
  132229. /**
  132230. * Gets the ground material created by the helper.
  132231. */
  132232. get groundMaterial(): Nullable<BackgroundMaterial>;
  132233. /**
  132234. * Stores the creation options.
  132235. */
  132236. private readonly _scene;
  132237. private _options;
  132238. /**
  132239. * This observable will be notified with any error during the creation of the environment,
  132240. * mainly texture creation errors.
  132241. */
  132242. onErrorObservable: Observable<{
  132243. message?: string;
  132244. exception?: any;
  132245. }>;
  132246. /**
  132247. * constructor
  132248. * @param options Defines the options we want to customize the helper
  132249. * @param scene The scene to add the material to
  132250. */
  132251. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  132252. /**
  132253. * Updates the background according to the new options
  132254. * @param options
  132255. */
  132256. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  132257. /**
  132258. * Sets the primary color of all the available elements.
  132259. * @param color the main color to affect to the ground and the background
  132260. */
  132261. setMainColor(color: Color3): void;
  132262. /**
  132263. * Setup the image processing according to the specified options.
  132264. */
  132265. private _setupImageProcessing;
  132266. /**
  132267. * Setup the environment texture according to the specified options.
  132268. */
  132269. private _setupEnvironmentTexture;
  132270. /**
  132271. * Setup the background according to the specified options.
  132272. */
  132273. private _setupBackground;
  132274. /**
  132275. * Get the scene sizes according to the setup.
  132276. */
  132277. private _getSceneSize;
  132278. /**
  132279. * Setup the ground according to the specified options.
  132280. */
  132281. private _setupGround;
  132282. /**
  132283. * Setup the ground material according to the specified options.
  132284. */
  132285. private _setupGroundMaterial;
  132286. /**
  132287. * Setup the ground diffuse texture according to the specified options.
  132288. */
  132289. private _setupGroundDiffuseTexture;
  132290. /**
  132291. * Setup the ground mirror texture according to the specified options.
  132292. */
  132293. private _setupGroundMirrorTexture;
  132294. /**
  132295. * Setup the ground to receive the mirror texture.
  132296. */
  132297. private _setupMirrorInGroundMaterial;
  132298. /**
  132299. * Setup the skybox according to the specified options.
  132300. */
  132301. private _setupSkybox;
  132302. /**
  132303. * Setup the skybox material according to the specified options.
  132304. */
  132305. private _setupSkyboxMaterial;
  132306. /**
  132307. * Setup the skybox reflection texture according to the specified options.
  132308. */
  132309. private _setupSkyboxReflectionTexture;
  132310. private _errorHandler;
  132311. /**
  132312. * Dispose all the elements created by the Helper.
  132313. */
  132314. dispose(): void;
  132315. }
  132316. }
  132317. declare module BABYLON {
  132318. /**
  132319. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  132320. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  132321. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  132322. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  132323. */
  132324. export class PhotoDome extends TransformNode {
  132325. /**
  132326. * Define the image as a Monoscopic panoramic 360 image.
  132327. */
  132328. static readonly MODE_MONOSCOPIC: number;
  132329. /**
  132330. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132331. */
  132332. static readonly MODE_TOPBOTTOM: number;
  132333. /**
  132334. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132335. */
  132336. static readonly MODE_SIDEBYSIDE: number;
  132337. private _useDirectMapping;
  132338. /**
  132339. * The texture being displayed on the sphere
  132340. */
  132341. protected _photoTexture: Texture;
  132342. /**
  132343. * Gets or sets the texture being displayed on the sphere
  132344. */
  132345. get photoTexture(): Texture;
  132346. set photoTexture(value: Texture);
  132347. /**
  132348. * Observable raised when an error occured while loading the 360 image
  132349. */
  132350. onLoadErrorObservable: Observable<string>;
  132351. /**
  132352. * The skybox material
  132353. */
  132354. protected _material: BackgroundMaterial;
  132355. /**
  132356. * The surface used for the skybox
  132357. */
  132358. protected _mesh: Mesh;
  132359. /**
  132360. * Gets the mesh used for the skybox.
  132361. */
  132362. get mesh(): Mesh;
  132363. /**
  132364. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  132365. * Also see the options.resolution property.
  132366. */
  132367. get fovMultiplier(): number;
  132368. set fovMultiplier(value: number);
  132369. private _imageMode;
  132370. /**
  132371. * Gets or set the current video mode for the video. It can be:
  132372. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  132373. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  132374. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  132375. */
  132376. get imageMode(): number;
  132377. set imageMode(value: number);
  132378. /**
  132379. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  132380. * @param name Element's name, child elements will append suffixes for their own names.
  132381. * @param urlsOfPhoto defines the url of the photo to display
  132382. * @param options defines an object containing optional or exposed sub element properties
  132383. * @param onError defines a callback called when an error occured while loading the texture
  132384. */
  132385. constructor(name: string, urlOfPhoto: string, options: {
  132386. resolution?: number;
  132387. size?: number;
  132388. useDirectMapping?: boolean;
  132389. faceForward?: boolean;
  132390. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  132391. private _onBeforeCameraRenderObserver;
  132392. private _changeImageMode;
  132393. /**
  132394. * Releases resources associated with this node.
  132395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  132396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  132397. */
  132398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  132399. }
  132400. }
  132401. declare module BABYLON {
  132402. /**
  132403. * Class used to host RGBD texture specific utilities
  132404. */
  132405. export class RGBDTextureTools {
  132406. /**
  132407. * Expand the RGBD Texture from RGBD to Half Float if possible.
  132408. * @param texture the texture to expand.
  132409. */
  132410. static ExpandRGBDTexture(texture: Texture): void;
  132411. }
  132412. }
  132413. declare module BABYLON {
  132414. /**
  132415. * Class used to host texture specific utilities
  132416. */
  132417. export class BRDFTextureTools {
  132418. /**
  132419. * Prevents texture cache collision
  132420. */
  132421. private static _instanceNumber;
  132422. /**
  132423. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  132424. * @param scene defines the hosting scene
  132425. * @returns the environment BRDF texture
  132426. */
  132427. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  132428. private static _environmentBRDFBase64Texture;
  132429. }
  132430. }
  132431. declare module BABYLON {
  132432. /**
  132433. * @hidden
  132434. */
  132435. export interface IMaterialClearCoatDefines {
  132436. CLEARCOAT: boolean;
  132437. CLEARCOAT_DEFAULTIOR: boolean;
  132438. CLEARCOAT_TEXTURE: boolean;
  132439. CLEARCOAT_TEXTUREDIRECTUV: number;
  132440. CLEARCOAT_BUMP: boolean;
  132441. CLEARCOAT_BUMPDIRECTUV: number;
  132442. CLEARCOAT_TINT: boolean;
  132443. CLEARCOAT_TINT_TEXTURE: boolean;
  132444. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  132445. /** @hidden */
  132446. _areTexturesDirty: boolean;
  132447. }
  132448. /**
  132449. * Define the code related to the clear coat parameters of the pbr material.
  132450. */
  132451. export class PBRClearCoatConfiguration {
  132452. /**
  132453. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132454. * The default fits with a polyurethane material.
  132455. */
  132456. private static readonly _DefaultIndexOfRefraction;
  132457. private _isEnabled;
  132458. /**
  132459. * Defines if the clear coat is enabled in the material.
  132460. */
  132461. isEnabled: boolean;
  132462. /**
  132463. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  132464. */
  132465. intensity: number;
  132466. /**
  132467. * Defines the clear coat layer roughness.
  132468. */
  132469. roughness: number;
  132470. private _indexOfRefraction;
  132471. /**
  132472. * Defines the index of refraction of the clear coat.
  132473. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  132474. * The default fits with a polyurethane material.
  132475. * Changing the default value is more performance intensive.
  132476. */
  132477. indexOfRefraction: number;
  132478. private _texture;
  132479. /**
  132480. * Stores the clear coat values in a texture.
  132481. */
  132482. texture: Nullable<BaseTexture>;
  132483. private _bumpTexture;
  132484. /**
  132485. * Define the clear coat specific bump texture.
  132486. */
  132487. bumpTexture: Nullable<BaseTexture>;
  132488. private _isTintEnabled;
  132489. /**
  132490. * Defines if the clear coat tint is enabled in the material.
  132491. */
  132492. isTintEnabled: boolean;
  132493. /**
  132494. * Defines the clear coat tint of the material.
  132495. * This is only use if tint is enabled
  132496. */
  132497. tintColor: Color3;
  132498. /**
  132499. * Defines the distance at which the tint color should be found in the
  132500. * clear coat media.
  132501. * This is only use if tint is enabled
  132502. */
  132503. tintColorAtDistance: number;
  132504. /**
  132505. * Defines the clear coat layer thickness.
  132506. * This is only use if tint is enabled
  132507. */
  132508. tintThickness: number;
  132509. private _tintTexture;
  132510. /**
  132511. * Stores the clear tint values in a texture.
  132512. * rgb is tint
  132513. * a is a thickness factor
  132514. */
  132515. tintTexture: Nullable<BaseTexture>;
  132516. /** @hidden */
  132517. private _internalMarkAllSubMeshesAsTexturesDirty;
  132518. /** @hidden */
  132519. _markAllSubMeshesAsTexturesDirty(): void;
  132520. /**
  132521. * Instantiate a new istance of clear coat configuration.
  132522. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132523. */
  132524. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132525. /**
  132526. * Gets wehter the submesh is ready to be used or not.
  132527. * @param defines the list of "defines" to update.
  132528. * @param scene defines the scene the material belongs to.
  132529. * @param engine defines the engine the material belongs to.
  132530. * @param disableBumpMap defines wether the material disables bump or not.
  132531. * @returns - boolean indicating that the submesh is ready or not.
  132532. */
  132533. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  132534. /**
  132535. * Checks to see if a texture is used in the material.
  132536. * @param defines the list of "defines" to update.
  132537. * @param scene defines the scene to the material belongs to.
  132538. */
  132539. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  132540. /**
  132541. * Binds the material data.
  132542. * @param uniformBuffer defines the Uniform buffer to fill in.
  132543. * @param scene defines the scene the material belongs to.
  132544. * @param engine defines the engine the material belongs to.
  132545. * @param disableBumpMap defines wether the material disables bump or not.
  132546. * @param isFrozen defines wether the material is frozen or not.
  132547. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  132548. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  132549. */
  132550. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  132551. /**
  132552. * Checks to see if a texture is used in the material.
  132553. * @param texture - Base texture to use.
  132554. * @returns - Boolean specifying if a texture is used in the material.
  132555. */
  132556. hasTexture(texture: BaseTexture): boolean;
  132557. /**
  132558. * Returns an array of the actively used textures.
  132559. * @param activeTextures Array of BaseTextures
  132560. */
  132561. getActiveTextures(activeTextures: BaseTexture[]): void;
  132562. /**
  132563. * Returns the animatable textures.
  132564. * @param animatables Array of animatable textures.
  132565. */
  132566. getAnimatables(animatables: IAnimatable[]): void;
  132567. /**
  132568. * Disposes the resources of the material.
  132569. * @param forceDisposeTextures - Forces the disposal of all textures.
  132570. */
  132571. dispose(forceDisposeTextures?: boolean): void;
  132572. /**
  132573. * Get the current class name of the texture useful for serialization or dynamic coding.
  132574. * @returns "PBRClearCoatConfiguration"
  132575. */
  132576. getClassName(): string;
  132577. /**
  132578. * Add fallbacks to the effect fallbacks list.
  132579. * @param defines defines the Base texture to use.
  132580. * @param fallbacks defines the current fallback list.
  132581. * @param currentRank defines the current fallback rank.
  132582. * @returns the new fallback rank.
  132583. */
  132584. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132585. /**
  132586. * Add the required uniforms to the current list.
  132587. * @param uniforms defines the current uniform list.
  132588. */
  132589. static AddUniforms(uniforms: string[]): void;
  132590. /**
  132591. * Add the required samplers to the current list.
  132592. * @param samplers defines the current sampler list.
  132593. */
  132594. static AddSamplers(samplers: string[]): void;
  132595. /**
  132596. * Add the required uniforms to the current buffer.
  132597. * @param uniformBuffer defines the current uniform buffer.
  132598. */
  132599. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132600. /**
  132601. * Makes a duplicate of the current configuration into another one.
  132602. * @param clearCoatConfiguration define the config where to copy the info
  132603. */
  132604. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  132605. /**
  132606. * Serializes this clear coat configuration.
  132607. * @returns - An object with the serialized config.
  132608. */
  132609. serialize(): any;
  132610. /**
  132611. * Parses a anisotropy Configuration from a serialized object.
  132612. * @param source - Serialized object.
  132613. * @param scene Defines the scene we are parsing for
  132614. * @param rootUrl Defines the rootUrl to load from
  132615. */
  132616. parse(source: any, scene: Scene, rootUrl: string): void;
  132617. }
  132618. }
  132619. declare module BABYLON {
  132620. /**
  132621. * @hidden
  132622. */
  132623. export interface IMaterialAnisotropicDefines {
  132624. ANISOTROPIC: boolean;
  132625. ANISOTROPIC_TEXTURE: boolean;
  132626. ANISOTROPIC_TEXTUREDIRECTUV: number;
  132627. MAINUV1: boolean;
  132628. _areTexturesDirty: boolean;
  132629. _needUVs: boolean;
  132630. }
  132631. /**
  132632. * Define the code related to the anisotropic parameters of the pbr material.
  132633. */
  132634. export class PBRAnisotropicConfiguration {
  132635. private _isEnabled;
  132636. /**
  132637. * Defines if the anisotropy is enabled in the material.
  132638. */
  132639. isEnabled: boolean;
  132640. /**
  132641. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  132642. */
  132643. intensity: number;
  132644. /**
  132645. * Defines if the effect is along the tangents, bitangents or in between.
  132646. * By default, the effect is "strectching" the highlights along the tangents.
  132647. */
  132648. direction: Vector2;
  132649. private _texture;
  132650. /**
  132651. * Stores the anisotropy values in a texture.
  132652. * rg is direction (like normal from -1 to 1)
  132653. * b is a intensity
  132654. */
  132655. texture: Nullable<BaseTexture>;
  132656. /** @hidden */
  132657. private _internalMarkAllSubMeshesAsTexturesDirty;
  132658. /** @hidden */
  132659. _markAllSubMeshesAsTexturesDirty(): void;
  132660. /**
  132661. * Instantiate a new istance of anisotropy configuration.
  132662. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132663. */
  132664. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132665. /**
  132666. * Specifies that the submesh is ready to be used.
  132667. * @param defines the list of "defines" to update.
  132668. * @param scene defines the scene the material belongs to.
  132669. * @returns - boolean indicating that the submesh is ready or not.
  132670. */
  132671. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  132672. /**
  132673. * Checks to see if a texture is used in the material.
  132674. * @param defines the list of "defines" to update.
  132675. * @param mesh the mesh we are preparing the defines for.
  132676. * @param scene defines the scene the material belongs to.
  132677. */
  132678. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  132679. /**
  132680. * Binds the material data.
  132681. * @param uniformBuffer defines the Uniform buffer to fill in.
  132682. * @param scene defines the scene the material belongs to.
  132683. * @param isFrozen defines wether the material is frozen or not.
  132684. */
  132685. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132686. /**
  132687. * Checks to see if a texture is used in the material.
  132688. * @param texture - Base texture to use.
  132689. * @returns - Boolean specifying if a texture is used in the material.
  132690. */
  132691. hasTexture(texture: BaseTexture): boolean;
  132692. /**
  132693. * Returns an array of the actively used textures.
  132694. * @param activeTextures Array of BaseTextures
  132695. */
  132696. getActiveTextures(activeTextures: BaseTexture[]): void;
  132697. /**
  132698. * Returns the animatable textures.
  132699. * @param animatables Array of animatable textures.
  132700. */
  132701. getAnimatables(animatables: IAnimatable[]): void;
  132702. /**
  132703. * Disposes the resources of the material.
  132704. * @param forceDisposeTextures - Forces the disposal of all textures.
  132705. */
  132706. dispose(forceDisposeTextures?: boolean): void;
  132707. /**
  132708. * Get the current class name of the texture useful for serialization or dynamic coding.
  132709. * @returns "PBRAnisotropicConfiguration"
  132710. */
  132711. getClassName(): string;
  132712. /**
  132713. * Add fallbacks to the effect fallbacks list.
  132714. * @param defines defines the Base texture to use.
  132715. * @param fallbacks defines the current fallback list.
  132716. * @param currentRank defines the current fallback rank.
  132717. * @returns the new fallback rank.
  132718. */
  132719. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132720. /**
  132721. * Add the required uniforms to the current list.
  132722. * @param uniforms defines the current uniform list.
  132723. */
  132724. static AddUniforms(uniforms: string[]): void;
  132725. /**
  132726. * Add the required uniforms to the current buffer.
  132727. * @param uniformBuffer defines the current uniform buffer.
  132728. */
  132729. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132730. /**
  132731. * Add the required samplers to the current list.
  132732. * @param samplers defines the current sampler list.
  132733. */
  132734. static AddSamplers(samplers: string[]): void;
  132735. /**
  132736. * Makes a duplicate of the current configuration into another one.
  132737. * @param anisotropicConfiguration define the config where to copy the info
  132738. */
  132739. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  132740. /**
  132741. * Serializes this anisotropy configuration.
  132742. * @returns - An object with the serialized config.
  132743. */
  132744. serialize(): any;
  132745. /**
  132746. * Parses a anisotropy Configuration from a serialized object.
  132747. * @param source - Serialized object.
  132748. * @param scene Defines the scene we are parsing for
  132749. * @param rootUrl Defines the rootUrl to load from
  132750. */
  132751. parse(source: any, scene: Scene, rootUrl: string): void;
  132752. }
  132753. }
  132754. declare module BABYLON {
  132755. /**
  132756. * @hidden
  132757. */
  132758. export interface IMaterialBRDFDefines {
  132759. BRDF_V_HEIGHT_CORRELATED: boolean;
  132760. MS_BRDF_ENERGY_CONSERVATION: boolean;
  132761. SPHERICAL_HARMONICS: boolean;
  132762. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  132763. /** @hidden */
  132764. _areMiscDirty: boolean;
  132765. }
  132766. /**
  132767. * Define the code related to the BRDF parameters of the pbr material.
  132768. */
  132769. export class PBRBRDFConfiguration {
  132770. /**
  132771. * Default value used for the energy conservation.
  132772. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132773. */
  132774. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  132775. /**
  132776. * Default value used for the Smith Visibility Height Correlated mode.
  132777. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  132778. */
  132779. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  132780. /**
  132781. * Default value used for the IBL diffuse part.
  132782. * This can help switching back to the polynomials mode globally which is a tiny bit
  132783. * less GPU intensive at the drawback of a lower quality.
  132784. */
  132785. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  132786. /**
  132787. * Default value used for activating energy conservation for the specular workflow.
  132788. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132789. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132790. */
  132791. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  132792. private _useEnergyConservation;
  132793. /**
  132794. * Defines if the material uses energy conservation.
  132795. */
  132796. useEnergyConservation: boolean;
  132797. private _useSmithVisibilityHeightCorrelated;
  132798. /**
  132799. * LEGACY Mode set to false
  132800. * Defines if the material uses height smith correlated visibility term.
  132801. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  132802. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  132803. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  132804. * Not relying on height correlated will also disable energy conservation.
  132805. */
  132806. useSmithVisibilityHeightCorrelated: boolean;
  132807. private _useSphericalHarmonics;
  132808. /**
  132809. * LEGACY Mode set to false
  132810. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  132811. * diffuse part of the IBL.
  132812. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  132813. * to the ground truth.
  132814. */
  132815. useSphericalHarmonics: boolean;
  132816. private _useSpecularGlossinessInputEnergyConservation;
  132817. /**
  132818. * Defines if the material uses energy conservation, when the specular workflow is active.
  132819. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  132820. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  132821. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  132822. */
  132823. useSpecularGlossinessInputEnergyConservation: boolean;
  132824. /** @hidden */
  132825. private _internalMarkAllSubMeshesAsMiscDirty;
  132826. /** @hidden */
  132827. _markAllSubMeshesAsMiscDirty(): void;
  132828. /**
  132829. * Instantiate a new istance of clear coat configuration.
  132830. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  132831. */
  132832. constructor(markAllSubMeshesAsMiscDirty: () => void);
  132833. /**
  132834. * Checks to see if a texture is used in the material.
  132835. * @param defines the list of "defines" to update.
  132836. */
  132837. prepareDefines(defines: IMaterialBRDFDefines): void;
  132838. /**
  132839. * Get the current class name of the texture useful for serialization or dynamic coding.
  132840. * @returns "PBRClearCoatConfiguration"
  132841. */
  132842. getClassName(): string;
  132843. /**
  132844. * Makes a duplicate of the current configuration into another one.
  132845. * @param brdfConfiguration define the config where to copy the info
  132846. */
  132847. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  132848. /**
  132849. * Serializes this BRDF configuration.
  132850. * @returns - An object with the serialized config.
  132851. */
  132852. serialize(): any;
  132853. /**
  132854. * Parses a anisotropy Configuration from a serialized object.
  132855. * @param source - Serialized object.
  132856. * @param scene Defines the scene we are parsing for
  132857. * @param rootUrl Defines the rootUrl to load from
  132858. */
  132859. parse(source: any, scene: Scene, rootUrl: string): void;
  132860. }
  132861. }
  132862. declare module BABYLON {
  132863. /**
  132864. * @hidden
  132865. */
  132866. export interface IMaterialSheenDefines {
  132867. SHEEN: boolean;
  132868. SHEEN_TEXTURE: boolean;
  132869. SHEEN_TEXTUREDIRECTUV: number;
  132870. SHEEN_LINKWITHALBEDO: boolean;
  132871. SHEEN_ROUGHNESS: boolean;
  132872. SHEEN_ALBEDOSCALING: boolean;
  132873. /** @hidden */
  132874. _areTexturesDirty: boolean;
  132875. }
  132876. /**
  132877. * Define the code related to the Sheen parameters of the pbr material.
  132878. */
  132879. export class PBRSheenConfiguration {
  132880. private _isEnabled;
  132881. /**
  132882. * Defines if the material uses sheen.
  132883. */
  132884. isEnabled: boolean;
  132885. private _linkSheenWithAlbedo;
  132886. /**
  132887. * Defines if the sheen is linked to the sheen color.
  132888. */
  132889. linkSheenWithAlbedo: boolean;
  132890. /**
  132891. * Defines the sheen intensity.
  132892. */
  132893. intensity: number;
  132894. /**
  132895. * Defines the sheen color.
  132896. */
  132897. color: Color3;
  132898. private _texture;
  132899. /**
  132900. * Stores the sheen tint values in a texture.
  132901. * rgb is tint
  132902. * a is a intensity or roughness if roughness has been defined
  132903. */
  132904. texture: Nullable<BaseTexture>;
  132905. private _roughness;
  132906. /**
  132907. * Defines the sheen roughness.
  132908. * It is not taken into account if linkSheenWithAlbedo is true.
  132909. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  132910. */
  132911. roughness: Nullable<number>;
  132912. private _albedoScaling;
  132913. /**
  132914. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  132915. * It allows the strength of the sheen effect to not depend on the base color of the material,
  132916. * making it easier to setup and tweak the effect
  132917. */
  132918. albedoScaling: boolean;
  132919. /** @hidden */
  132920. private _internalMarkAllSubMeshesAsTexturesDirty;
  132921. /** @hidden */
  132922. _markAllSubMeshesAsTexturesDirty(): void;
  132923. /**
  132924. * Instantiate a new istance of clear coat configuration.
  132925. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  132926. */
  132927. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  132928. /**
  132929. * Specifies that the submesh is ready to be used.
  132930. * @param defines the list of "defines" to update.
  132931. * @param scene defines the scene the material belongs to.
  132932. * @returns - boolean indicating that the submesh is ready or not.
  132933. */
  132934. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  132935. /**
  132936. * Checks to see if a texture is used in the material.
  132937. * @param defines the list of "defines" to update.
  132938. * @param scene defines the scene the material belongs to.
  132939. */
  132940. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  132941. /**
  132942. * Binds the material data.
  132943. * @param uniformBuffer defines the Uniform buffer to fill in.
  132944. * @param scene defines the scene the material belongs to.
  132945. * @param isFrozen defines wether the material is frozen or not.
  132946. */
  132947. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  132948. /**
  132949. * Checks to see if a texture is used in the material.
  132950. * @param texture - Base texture to use.
  132951. * @returns - Boolean specifying if a texture is used in the material.
  132952. */
  132953. hasTexture(texture: BaseTexture): boolean;
  132954. /**
  132955. * Returns an array of the actively used textures.
  132956. * @param activeTextures Array of BaseTextures
  132957. */
  132958. getActiveTextures(activeTextures: BaseTexture[]): void;
  132959. /**
  132960. * Returns the animatable textures.
  132961. * @param animatables Array of animatable textures.
  132962. */
  132963. getAnimatables(animatables: IAnimatable[]): void;
  132964. /**
  132965. * Disposes the resources of the material.
  132966. * @param forceDisposeTextures - Forces the disposal of all textures.
  132967. */
  132968. dispose(forceDisposeTextures?: boolean): void;
  132969. /**
  132970. * Get the current class name of the texture useful for serialization or dynamic coding.
  132971. * @returns "PBRSheenConfiguration"
  132972. */
  132973. getClassName(): string;
  132974. /**
  132975. * Add fallbacks to the effect fallbacks list.
  132976. * @param defines defines the Base texture to use.
  132977. * @param fallbacks defines the current fallback list.
  132978. * @param currentRank defines the current fallback rank.
  132979. * @returns the new fallback rank.
  132980. */
  132981. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  132982. /**
  132983. * Add the required uniforms to the current list.
  132984. * @param uniforms defines the current uniform list.
  132985. */
  132986. static AddUniforms(uniforms: string[]): void;
  132987. /**
  132988. * Add the required uniforms to the current buffer.
  132989. * @param uniformBuffer defines the current uniform buffer.
  132990. */
  132991. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  132992. /**
  132993. * Add the required samplers to the current list.
  132994. * @param samplers defines the current sampler list.
  132995. */
  132996. static AddSamplers(samplers: string[]): void;
  132997. /**
  132998. * Makes a duplicate of the current configuration into another one.
  132999. * @param sheenConfiguration define the config where to copy the info
  133000. */
  133001. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  133002. /**
  133003. * Serializes this BRDF configuration.
  133004. * @returns - An object with the serialized config.
  133005. */
  133006. serialize(): any;
  133007. /**
  133008. * Parses a anisotropy Configuration from a serialized object.
  133009. * @param source - Serialized object.
  133010. * @param scene Defines the scene we are parsing for
  133011. * @param rootUrl Defines the rootUrl to load from
  133012. */
  133013. parse(source: any, scene: Scene, rootUrl: string): void;
  133014. }
  133015. }
  133016. declare module BABYLON {
  133017. /**
  133018. * @hidden
  133019. */
  133020. export interface IMaterialSubSurfaceDefines {
  133021. SUBSURFACE: boolean;
  133022. SS_REFRACTION: boolean;
  133023. SS_TRANSLUCENCY: boolean;
  133024. SS_SCATTERING: boolean;
  133025. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133026. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133027. SS_REFRACTIONMAP_3D: boolean;
  133028. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133029. SS_LODINREFRACTIONALPHA: boolean;
  133030. SS_GAMMAREFRACTION: boolean;
  133031. SS_RGBDREFRACTION: boolean;
  133032. SS_LINEARSPECULARREFRACTION: boolean;
  133033. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133034. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133035. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133036. /** @hidden */
  133037. _areTexturesDirty: boolean;
  133038. }
  133039. /**
  133040. * Define the code related to the sub surface parameters of the pbr material.
  133041. */
  133042. export class PBRSubSurfaceConfiguration {
  133043. private _isRefractionEnabled;
  133044. /**
  133045. * Defines if the refraction is enabled in the material.
  133046. */
  133047. isRefractionEnabled: boolean;
  133048. private _isTranslucencyEnabled;
  133049. /**
  133050. * Defines if the translucency is enabled in the material.
  133051. */
  133052. isTranslucencyEnabled: boolean;
  133053. private _isScatteringEnabled;
  133054. /**
  133055. * Defines if the sub surface scattering is enabled in the material.
  133056. */
  133057. isScatteringEnabled: boolean;
  133058. private _scatteringDiffusionProfileIndex;
  133059. /**
  133060. * Diffusion profile for subsurface scattering.
  133061. * Useful for better scattering in the skins or foliages.
  133062. */
  133063. get scatteringDiffusionProfile(): Nullable<Color3>;
  133064. set scatteringDiffusionProfile(c: Nullable<Color3>);
  133065. /**
  133066. * Defines the refraction intensity of the material.
  133067. * The refraction when enabled replaces the Diffuse part of the material.
  133068. * The intensity helps transitionning between diffuse and refraction.
  133069. */
  133070. refractionIntensity: number;
  133071. /**
  133072. * Defines the translucency intensity of the material.
  133073. * When translucency has been enabled, this defines how much of the "translucency"
  133074. * is addded to the diffuse part of the material.
  133075. */
  133076. translucencyIntensity: number;
  133077. /**
  133078. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  133079. */
  133080. useAlbedoToTintRefraction: boolean;
  133081. private _thicknessTexture;
  133082. /**
  133083. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  133084. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  133085. * 0 would mean minimumThickness
  133086. * 1 would mean maximumThickness
  133087. * The other channels might be use as a mask to vary the different effects intensity.
  133088. */
  133089. thicknessTexture: Nullable<BaseTexture>;
  133090. private _refractionTexture;
  133091. /**
  133092. * Defines the texture to use for refraction.
  133093. */
  133094. refractionTexture: Nullable<BaseTexture>;
  133095. private _indexOfRefraction;
  133096. /**
  133097. * Index of refraction of the material base layer.
  133098. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133099. *
  133100. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  133101. *
  133102. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  133103. */
  133104. indexOfRefraction: number;
  133105. private _volumeIndexOfRefraction;
  133106. /**
  133107. * Index of refraction of the material's volume.
  133108. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  133109. *
  133110. * This ONLY impacts refraction. If not provided or given a non-valid value,
  133111. * the volume will use the same IOR as the surface.
  133112. */
  133113. get volumeIndexOfRefraction(): number;
  133114. set volumeIndexOfRefraction(value: number);
  133115. private _invertRefractionY;
  133116. /**
  133117. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  133118. */
  133119. invertRefractionY: boolean;
  133120. private _linkRefractionWithTransparency;
  133121. /**
  133122. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  133123. * Materials half opaque for instance using refraction could benefit from this control.
  133124. */
  133125. linkRefractionWithTransparency: boolean;
  133126. /**
  133127. * Defines the minimum thickness stored in the thickness map.
  133128. * If no thickness map is defined, this value will be used to simulate thickness.
  133129. */
  133130. minimumThickness: number;
  133131. /**
  133132. * Defines the maximum thickness stored in the thickness map.
  133133. */
  133134. maximumThickness: number;
  133135. /**
  133136. * Defines the volume tint of the material.
  133137. * This is used for both translucency and scattering.
  133138. */
  133139. tintColor: Color3;
  133140. /**
  133141. * Defines the distance at which the tint color should be found in the media.
  133142. * This is used for refraction only.
  133143. */
  133144. tintColorAtDistance: number;
  133145. /**
  133146. * Defines how far each channel transmit through the media.
  133147. * It is defined as a color to simplify it selection.
  133148. */
  133149. diffusionDistance: Color3;
  133150. private _useMaskFromThicknessTexture;
  133151. /**
  133152. * Stores the intensity of the different subsurface effects in the thickness texture.
  133153. * * the green channel is the translucency intensity.
  133154. * * the blue channel is the scattering intensity.
  133155. * * the alpha channel is the refraction intensity.
  133156. */
  133157. useMaskFromThicknessTexture: boolean;
  133158. private _scene;
  133159. /** @hidden */
  133160. private _internalMarkAllSubMeshesAsTexturesDirty;
  133161. private _internalMarkScenePrePassDirty;
  133162. /** @hidden */
  133163. _markAllSubMeshesAsTexturesDirty(): void;
  133164. /** @hidden */
  133165. _markScenePrePassDirty(): void;
  133166. /**
  133167. * Instantiate a new istance of sub surface configuration.
  133168. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  133169. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  133170. * @param scene The scene
  133171. */
  133172. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  133173. /**
  133174. * Gets wehter the submesh is ready to be used or not.
  133175. * @param defines the list of "defines" to update.
  133176. * @param scene defines the scene the material belongs to.
  133177. * @returns - boolean indicating that the submesh is ready or not.
  133178. */
  133179. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  133180. /**
  133181. * Checks to see if a texture is used in the material.
  133182. * @param defines the list of "defines" to update.
  133183. * @param scene defines the scene to the material belongs to.
  133184. */
  133185. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  133186. /**
  133187. * Binds the material data.
  133188. * @param uniformBuffer defines the Uniform buffer to fill in.
  133189. * @param scene defines the scene the material belongs to.
  133190. * @param engine defines the engine the material belongs to.
  133191. * @param isFrozen defines whether the material is frozen or not.
  133192. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  133193. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  133194. */
  133195. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  133196. /**
  133197. * Unbinds the material from the mesh.
  133198. * @param activeEffect defines the effect that should be unbound from.
  133199. * @returns true if unbound, otherwise false
  133200. */
  133201. unbind(activeEffect: Effect): boolean;
  133202. /**
  133203. * Returns the texture used for refraction or null if none is used.
  133204. * @param scene defines the scene the material belongs to.
  133205. * @returns - Refraction texture if present. If no refraction texture and refraction
  133206. * is linked with transparency, returns environment texture. Otherwise, returns null.
  133207. */
  133208. private _getRefractionTexture;
  133209. /**
  133210. * Returns true if alpha blending should be disabled.
  133211. */
  133212. get disableAlphaBlending(): boolean;
  133213. /**
  133214. * Fills the list of render target textures.
  133215. * @param renderTargets the list of render targets to update
  133216. */
  133217. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  133218. /**
  133219. * Checks to see if a texture is used in the material.
  133220. * @param texture - Base texture to use.
  133221. * @returns - Boolean specifying if a texture is used in the material.
  133222. */
  133223. hasTexture(texture: BaseTexture): boolean;
  133224. /**
  133225. * Gets a boolean indicating that current material needs to register RTT
  133226. * @returns true if this uses a render target otherwise false.
  133227. */
  133228. hasRenderTargetTextures(): boolean;
  133229. /**
  133230. * Returns an array of the actively used textures.
  133231. * @param activeTextures Array of BaseTextures
  133232. */
  133233. getActiveTextures(activeTextures: BaseTexture[]): void;
  133234. /**
  133235. * Returns the animatable textures.
  133236. * @param animatables Array of animatable textures.
  133237. */
  133238. getAnimatables(animatables: IAnimatable[]): void;
  133239. /**
  133240. * Disposes the resources of the material.
  133241. * @param forceDisposeTextures - Forces the disposal of all textures.
  133242. */
  133243. dispose(forceDisposeTextures?: boolean): void;
  133244. /**
  133245. * Get the current class name of the texture useful for serialization or dynamic coding.
  133246. * @returns "PBRSubSurfaceConfiguration"
  133247. */
  133248. getClassName(): string;
  133249. /**
  133250. * Add fallbacks to the effect fallbacks list.
  133251. * @param defines defines the Base texture to use.
  133252. * @param fallbacks defines the current fallback list.
  133253. * @param currentRank defines the current fallback rank.
  133254. * @returns the new fallback rank.
  133255. */
  133256. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  133257. /**
  133258. * Add the required uniforms to the current list.
  133259. * @param uniforms defines the current uniform list.
  133260. */
  133261. static AddUniforms(uniforms: string[]): void;
  133262. /**
  133263. * Add the required samplers to the current list.
  133264. * @param samplers defines the current sampler list.
  133265. */
  133266. static AddSamplers(samplers: string[]): void;
  133267. /**
  133268. * Add the required uniforms to the current buffer.
  133269. * @param uniformBuffer defines the current uniform buffer.
  133270. */
  133271. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  133272. /**
  133273. * Makes a duplicate of the current configuration into another one.
  133274. * @param configuration define the config where to copy the info
  133275. */
  133276. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  133277. /**
  133278. * Serializes this Sub Surface configuration.
  133279. * @returns - An object with the serialized config.
  133280. */
  133281. serialize(): any;
  133282. /**
  133283. * Parses a anisotropy Configuration from a serialized object.
  133284. * @param source - Serialized object.
  133285. * @param scene Defines the scene we are parsing for
  133286. * @param rootUrl Defines the rootUrl to load from
  133287. */
  133288. parse(source: any, scene: Scene, rootUrl: string): void;
  133289. }
  133290. }
  133291. declare module BABYLON {
  133292. /** @hidden */
  133293. export var pbrFragmentDeclaration: {
  133294. name: string;
  133295. shader: string;
  133296. };
  133297. }
  133298. declare module BABYLON {
  133299. /** @hidden */
  133300. export var pbrUboDeclaration: {
  133301. name: string;
  133302. shader: string;
  133303. };
  133304. }
  133305. declare module BABYLON {
  133306. /** @hidden */
  133307. export var pbrFragmentExtraDeclaration: {
  133308. name: string;
  133309. shader: string;
  133310. };
  133311. }
  133312. declare module BABYLON {
  133313. /** @hidden */
  133314. export var pbrFragmentSamplersDeclaration: {
  133315. name: string;
  133316. shader: string;
  133317. };
  133318. }
  133319. declare module BABYLON {
  133320. /** @hidden */
  133321. export var subSurfaceScatteringFunctions: {
  133322. name: string;
  133323. shader: string;
  133324. };
  133325. }
  133326. declare module BABYLON {
  133327. /** @hidden */
  133328. export var importanceSampling: {
  133329. name: string;
  133330. shader: string;
  133331. };
  133332. }
  133333. declare module BABYLON {
  133334. /** @hidden */
  133335. export var pbrHelperFunctions: {
  133336. name: string;
  133337. shader: string;
  133338. };
  133339. }
  133340. declare module BABYLON {
  133341. /** @hidden */
  133342. export var harmonicsFunctions: {
  133343. name: string;
  133344. shader: string;
  133345. };
  133346. }
  133347. declare module BABYLON {
  133348. /** @hidden */
  133349. export var pbrDirectLightingSetupFunctions: {
  133350. name: string;
  133351. shader: string;
  133352. };
  133353. }
  133354. declare module BABYLON {
  133355. /** @hidden */
  133356. export var pbrDirectLightingFalloffFunctions: {
  133357. name: string;
  133358. shader: string;
  133359. };
  133360. }
  133361. declare module BABYLON {
  133362. /** @hidden */
  133363. export var pbrBRDFFunctions: {
  133364. name: string;
  133365. shader: string;
  133366. };
  133367. }
  133368. declare module BABYLON {
  133369. /** @hidden */
  133370. export var hdrFilteringFunctions: {
  133371. name: string;
  133372. shader: string;
  133373. };
  133374. }
  133375. declare module BABYLON {
  133376. /** @hidden */
  133377. export var pbrDirectLightingFunctions: {
  133378. name: string;
  133379. shader: string;
  133380. };
  133381. }
  133382. declare module BABYLON {
  133383. /** @hidden */
  133384. export var pbrIBLFunctions: {
  133385. name: string;
  133386. shader: string;
  133387. };
  133388. }
  133389. declare module BABYLON {
  133390. /** @hidden */
  133391. export var pbrBlockAlbedoOpacity: {
  133392. name: string;
  133393. shader: string;
  133394. };
  133395. }
  133396. declare module BABYLON {
  133397. /** @hidden */
  133398. export var pbrBlockReflectivity: {
  133399. name: string;
  133400. shader: string;
  133401. };
  133402. }
  133403. declare module BABYLON {
  133404. /** @hidden */
  133405. export var pbrBlockAmbientOcclusion: {
  133406. name: string;
  133407. shader: string;
  133408. };
  133409. }
  133410. declare module BABYLON {
  133411. /** @hidden */
  133412. export var pbrBlockAlphaFresnel: {
  133413. name: string;
  133414. shader: string;
  133415. };
  133416. }
  133417. declare module BABYLON {
  133418. /** @hidden */
  133419. export var pbrBlockAnisotropic: {
  133420. name: string;
  133421. shader: string;
  133422. };
  133423. }
  133424. declare module BABYLON {
  133425. /** @hidden */
  133426. export var pbrBlockReflection: {
  133427. name: string;
  133428. shader: string;
  133429. };
  133430. }
  133431. declare module BABYLON {
  133432. /** @hidden */
  133433. export var pbrBlockSheen: {
  133434. name: string;
  133435. shader: string;
  133436. };
  133437. }
  133438. declare module BABYLON {
  133439. /** @hidden */
  133440. export var pbrBlockClearcoat: {
  133441. name: string;
  133442. shader: string;
  133443. };
  133444. }
  133445. declare module BABYLON {
  133446. /** @hidden */
  133447. export var pbrBlockSubSurface: {
  133448. name: string;
  133449. shader: string;
  133450. };
  133451. }
  133452. declare module BABYLON {
  133453. /** @hidden */
  133454. export var pbrBlockNormalGeometric: {
  133455. name: string;
  133456. shader: string;
  133457. };
  133458. }
  133459. declare module BABYLON {
  133460. /** @hidden */
  133461. export var pbrBlockNormalFinal: {
  133462. name: string;
  133463. shader: string;
  133464. };
  133465. }
  133466. declare module BABYLON {
  133467. /** @hidden */
  133468. export var pbrBlockGeometryInfo: {
  133469. name: string;
  133470. shader: string;
  133471. };
  133472. }
  133473. declare module BABYLON {
  133474. /** @hidden */
  133475. export var pbrBlockReflectance0: {
  133476. name: string;
  133477. shader: string;
  133478. };
  133479. }
  133480. declare module BABYLON {
  133481. /** @hidden */
  133482. export var pbrBlockReflectance: {
  133483. name: string;
  133484. shader: string;
  133485. };
  133486. }
  133487. declare module BABYLON {
  133488. /** @hidden */
  133489. export var pbrBlockDirectLighting: {
  133490. name: string;
  133491. shader: string;
  133492. };
  133493. }
  133494. declare module BABYLON {
  133495. /** @hidden */
  133496. export var pbrBlockFinalLitComponents: {
  133497. name: string;
  133498. shader: string;
  133499. };
  133500. }
  133501. declare module BABYLON {
  133502. /** @hidden */
  133503. export var pbrBlockFinalUnlitComponents: {
  133504. name: string;
  133505. shader: string;
  133506. };
  133507. }
  133508. declare module BABYLON {
  133509. /** @hidden */
  133510. export var pbrBlockFinalColorComposition: {
  133511. name: string;
  133512. shader: string;
  133513. };
  133514. }
  133515. declare module BABYLON {
  133516. /** @hidden */
  133517. export var pbrBlockImageProcessing: {
  133518. name: string;
  133519. shader: string;
  133520. };
  133521. }
  133522. declare module BABYLON {
  133523. /** @hidden */
  133524. export var pbrDebug: {
  133525. name: string;
  133526. shader: string;
  133527. };
  133528. }
  133529. declare module BABYLON {
  133530. /** @hidden */
  133531. export var pbrPixelShader: {
  133532. name: string;
  133533. shader: string;
  133534. };
  133535. }
  133536. declare module BABYLON {
  133537. /** @hidden */
  133538. export var pbrVertexDeclaration: {
  133539. name: string;
  133540. shader: string;
  133541. };
  133542. }
  133543. declare module BABYLON {
  133544. /** @hidden */
  133545. export var pbrVertexShader: {
  133546. name: string;
  133547. shader: string;
  133548. };
  133549. }
  133550. declare module BABYLON {
  133551. /**
  133552. * Manages the defines for the PBR Material.
  133553. * @hidden
  133554. */
  133555. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  133556. PBR: boolean;
  133557. NUM_SAMPLES: string;
  133558. REALTIME_FILTERING: boolean;
  133559. MAINUV1: boolean;
  133560. MAINUV2: boolean;
  133561. UV1: boolean;
  133562. UV2: boolean;
  133563. ALBEDO: boolean;
  133564. GAMMAALBEDO: boolean;
  133565. ALBEDODIRECTUV: number;
  133566. VERTEXCOLOR: boolean;
  133567. DETAIL: boolean;
  133568. DETAILDIRECTUV: number;
  133569. DETAIL_NORMALBLENDMETHOD: number;
  133570. AMBIENT: boolean;
  133571. AMBIENTDIRECTUV: number;
  133572. AMBIENTINGRAYSCALE: boolean;
  133573. OPACITY: boolean;
  133574. VERTEXALPHA: boolean;
  133575. OPACITYDIRECTUV: number;
  133576. OPACITYRGB: boolean;
  133577. ALPHATEST: boolean;
  133578. DEPTHPREPASS: boolean;
  133579. ALPHABLEND: boolean;
  133580. ALPHAFROMALBEDO: boolean;
  133581. ALPHATESTVALUE: string;
  133582. SPECULAROVERALPHA: boolean;
  133583. RADIANCEOVERALPHA: boolean;
  133584. ALPHAFRESNEL: boolean;
  133585. LINEARALPHAFRESNEL: boolean;
  133586. PREMULTIPLYALPHA: boolean;
  133587. EMISSIVE: boolean;
  133588. EMISSIVEDIRECTUV: number;
  133589. REFLECTIVITY: boolean;
  133590. REFLECTIVITYDIRECTUV: number;
  133591. SPECULARTERM: boolean;
  133592. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  133593. MICROSURFACEAUTOMATIC: boolean;
  133594. LODBASEDMICROSFURACE: boolean;
  133595. MICROSURFACEMAP: boolean;
  133596. MICROSURFACEMAPDIRECTUV: number;
  133597. METALLICWORKFLOW: boolean;
  133598. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  133599. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  133600. METALLNESSSTOREINMETALMAPBLUE: boolean;
  133601. AOSTOREINMETALMAPRED: boolean;
  133602. METALLIC_REFLECTANCE: boolean;
  133603. METALLIC_REFLECTANCEDIRECTUV: number;
  133604. ENVIRONMENTBRDF: boolean;
  133605. ENVIRONMENTBRDF_RGBD: boolean;
  133606. NORMAL: boolean;
  133607. TANGENT: boolean;
  133608. BUMP: boolean;
  133609. BUMPDIRECTUV: number;
  133610. OBJECTSPACE_NORMALMAP: boolean;
  133611. PARALLAX: boolean;
  133612. PARALLAXOCCLUSION: boolean;
  133613. NORMALXYSCALE: boolean;
  133614. LIGHTMAP: boolean;
  133615. LIGHTMAPDIRECTUV: number;
  133616. USELIGHTMAPASSHADOWMAP: boolean;
  133617. GAMMALIGHTMAP: boolean;
  133618. RGBDLIGHTMAP: boolean;
  133619. REFLECTION: boolean;
  133620. REFLECTIONMAP_3D: boolean;
  133621. REFLECTIONMAP_SPHERICAL: boolean;
  133622. REFLECTIONMAP_PLANAR: boolean;
  133623. REFLECTIONMAP_CUBIC: boolean;
  133624. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  133625. REFLECTIONMAP_PROJECTION: boolean;
  133626. REFLECTIONMAP_SKYBOX: boolean;
  133627. REFLECTIONMAP_EXPLICIT: boolean;
  133628. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  133629. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  133630. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  133631. INVERTCUBICMAP: boolean;
  133632. USESPHERICALFROMREFLECTIONMAP: boolean;
  133633. USEIRRADIANCEMAP: boolean;
  133634. SPHERICAL_HARMONICS: boolean;
  133635. USESPHERICALINVERTEX: boolean;
  133636. REFLECTIONMAP_OPPOSITEZ: boolean;
  133637. LODINREFLECTIONALPHA: boolean;
  133638. GAMMAREFLECTION: boolean;
  133639. RGBDREFLECTION: boolean;
  133640. LINEARSPECULARREFLECTION: boolean;
  133641. RADIANCEOCCLUSION: boolean;
  133642. HORIZONOCCLUSION: boolean;
  133643. INSTANCES: boolean;
  133644. THIN_INSTANCES: boolean;
  133645. PREPASS: boolean;
  133646. SCENE_MRT_COUNT: number;
  133647. NUM_BONE_INFLUENCERS: number;
  133648. BonesPerMesh: number;
  133649. BONETEXTURE: boolean;
  133650. NONUNIFORMSCALING: boolean;
  133651. MORPHTARGETS: boolean;
  133652. MORPHTARGETS_NORMAL: boolean;
  133653. MORPHTARGETS_TANGENT: boolean;
  133654. MORPHTARGETS_UV: boolean;
  133655. NUM_MORPH_INFLUENCERS: number;
  133656. IMAGEPROCESSING: boolean;
  133657. VIGNETTE: boolean;
  133658. VIGNETTEBLENDMODEMULTIPLY: boolean;
  133659. VIGNETTEBLENDMODEOPAQUE: boolean;
  133660. TONEMAPPING: boolean;
  133661. TONEMAPPING_ACES: boolean;
  133662. CONTRAST: boolean;
  133663. COLORCURVES: boolean;
  133664. COLORGRADING: boolean;
  133665. COLORGRADING3D: boolean;
  133666. SAMPLER3DGREENDEPTH: boolean;
  133667. SAMPLER3DBGRMAP: boolean;
  133668. IMAGEPROCESSINGPOSTPROCESS: boolean;
  133669. EXPOSURE: boolean;
  133670. MULTIVIEW: boolean;
  133671. USEPHYSICALLIGHTFALLOFF: boolean;
  133672. USEGLTFLIGHTFALLOFF: boolean;
  133673. TWOSIDEDLIGHTING: boolean;
  133674. SHADOWFLOAT: boolean;
  133675. CLIPPLANE: boolean;
  133676. CLIPPLANE2: boolean;
  133677. CLIPPLANE3: boolean;
  133678. CLIPPLANE4: boolean;
  133679. CLIPPLANE5: boolean;
  133680. CLIPPLANE6: boolean;
  133681. POINTSIZE: boolean;
  133682. FOG: boolean;
  133683. LOGARITHMICDEPTH: boolean;
  133684. FORCENORMALFORWARD: boolean;
  133685. SPECULARAA: boolean;
  133686. CLEARCOAT: boolean;
  133687. CLEARCOAT_DEFAULTIOR: boolean;
  133688. CLEARCOAT_TEXTURE: boolean;
  133689. CLEARCOAT_TEXTUREDIRECTUV: number;
  133690. CLEARCOAT_BUMP: boolean;
  133691. CLEARCOAT_BUMPDIRECTUV: number;
  133692. CLEARCOAT_TINT: boolean;
  133693. CLEARCOAT_TINT_TEXTURE: boolean;
  133694. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  133695. ANISOTROPIC: boolean;
  133696. ANISOTROPIC_TEXTURE: boolean;
  133697. ANISOTROPIC_TEXTUREDIRECTUV: number;
  133698. BRDF_V_HEIGHT_CORRELATED: boolean;
  133699. MS_BRDF_ENERGY_CONSERVATION: boolean;
  133700. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  133701. SHEEN: boolean;
  133702. SHEEN_TEXTURE: boolean;
  133703. SHEEN_TEXTUREDIRECTUV: number;
  133704. SHEEN_LINKWITHALBEDO: boolean;
  133705. SHEEN_ROUGHNESS: boolean;
  133706. SHEEN_ALBEDOSCALING: boolean;
  133707. SUBSURFACE: boolean;
  133708. SS_REFRACTION: boolean;
  133709. SS_TRANSLUCENCY: boolean;
  133710. SS_SCATTERING: boolean;
  133711. SS_THICKNESSANDMASK_TEXTURE: boolean;
  133712. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  133713. SS_REFRACTIONMAP_3D: boolean;
  133714. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  133715. SS_LODINREFRACTIONALPHA: boolean;
  133716. SS_GAMMAREFRACTION: boolean;
  133717. SS_RGBDREFRACTION: boolean;
  133718. SS_LINEARSPECULARREFRACTION: boolean;
  133719. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  133720. SS_ALBEDOFORREFRACTIONTINT: boolean;
  133721. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  133722. UNLIT: boolean;
  133723. DEBUGMODE: number;
  133724. /**
  133725. * Initializes the PBR Material defines.
  133726. */
  133727. constructor();
  133728. /**
  133729. * Resets the PBR Material defines.
  133730. */
  133731. reset(): void;
  133732. }
  133733. /**
  133734. * The Physically based material base class of BJS.
  133735. *
  133736. * This offers the main features of a standard PBR material.
  133737. * For more information, please refer to the documentation :
  133738. * https://doc.babylonjs.com/how_to/physically_based_rendering
  133739. */
  133740. export abstract class PBRBaseMaterial extends PushMaterial {
  133741. /**
  133742. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  133743. */
  133744. static readonly PBRMATERIAL_OPAQUE: number;
  133745. /**
  133746. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  133747. */
  133748. static readonly PBRMATERIAL_ALPHATEST: number;
  133749. /**
  133750. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133751. */
  133752. static readonly PBRMATERIAL_ALPHABLEND: number;
  133753. /**
  133754. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  133755. * They are also discarded below the alpha cutoff threshold to improve performances.
  133756. */
  133757. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  133758. /**
  133759. * Defines the default value of how much AO map is occluding the analytical lights
  133760. * (point spot...).
  133761. */
  133762. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  133763. /**
  133764. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  133765. */
  133766. static readonly LIGHTFALLOFF_PHYSICAL: number;
  133767. /**
  133768. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  133769. * to enhance interoperability with other engines.
  133770. */
  133771. static readonly LIGHTFALLOFF_GLTF: number;
  133772. /**
  133773. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  133774. * to enhance interoperability with other materials.
  133775. */
  133776. static readonly LIGHTFALLOFF_STANDARD: number;
  133777. /**
  133778. * Intensity of the direct lights e.g. the four lights available in your scene.
  133779. * This impacts both the direct diffuse and specular highlights.
  133780. */
  133781. protected _directIntensity: number;
  133782. /**
  133783. * Intensity of the emissive part of the material.
  133784. * This helps controlling the emissive effect without modifying the emissive color.
  133785. */
  133786. protected _emissiveIntensity: number;
  133787. /**
  133788. * Intensity of the environment e.g. how much the environment will light the object
  133789. * either through harmonics for rough material or through the refelction for shiny ones.
  133790. */
  133791. protected _environmentIntensity: number;
  133792. /**
  133793. * This is a special control allowing the reduction of the specular highlights coming from the
  133794. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  133795. */
  133796. protected _specularIntensity: number;
  133797. /**
  133798. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  133799. */
  133800. private _lightingInfos;
  133801. /**
  133802. * Debug Control allowing disabling the bump map on this material.
  133803. */
  133804. protected _disableBumpMap: boolean;
  133805. /**
  133806. * AKA Diffuse Texture in standard nomenclature.
  133807. */
  133808. protected _albedoTexture: Nullable<BaseTexture>;
  133809. /**
  133810. * AKA Occlusion Texture in other nomenclature.
  133811. */
  133812. protected _ambientTexture: Nullable<BaseTexture>;
  133813. /**
  133814. * AKA Occlusion Texture Intensity in other nomenclature.
  133815. */
  133816. protected _ambientTextureStrength: number;
  133817. /**
  133818. * Defines how much the AO map is occluding the analytical lights (point spot...).
  133819. * 1 means it completely occludes it
  133820. * 0 mean it has no impact
  133821. */
  133822. protected _ambientTextureImpactOnAnalyticalLights: number;
  133823. /**
  133824. * Stores the alpha values in a texture.
  133825. */
  133826. protected _opacityTexture: Nullable<BaseTexture>;
  133827. /**
  133828. * Stores the reflection values in a texture.
  133829. */
  133830. protected _reflectionTexture: Nullable<BaseTexture>;
  133831. /**
  133832. * Stores the emissive values in a texture.
  133833. */
  133834. protected _emissiveTexture: Nullable<BaseTexture>;
  133835. /**
  133836. * AKA Specular texture in other nomenclature.
  133837. */
  133838. protected _reflectivityTexture: Nullable<BaseTexture>;
  133839. /**
  133840. * Used to switch from specular/glossiness to metallic/roughness workflow.
  133841. */
  133842. protected _metallicTexture: Nullable<BaseTexture>;
  133843. /**
  133844. * Specifies the metallic scalar of the metallic/roughness workflow.
  133845. * Can also be used to scale the metalness values of the metallic texture.
  133846. */
  133847. protected _metallic: Nullable<number>;
  133848. /**
  133849. * Specifies the roughness scalar of the metallic/roughness workflow.
  133850. * Can also be used to scale the roughness values of the metallic texture.
  133851. */
  133852. protected _roughness: Nullable<number>;
  133853. /**
  133854. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  133855. * By default the indexOfrefraction is used to compute F0;
  133856. *
  133857. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  133858. *
  133859. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  133860. * F90 = metallicReflectanceColor;
  133861. */
  133862. protected _metallicF0Factor: number;
  133863. /**
  133864. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  133865. * By default the F90 is always 1;
  133866. *
  133867. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  133868. *
  133869. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  133870. * F90 = metallicReflectanceColor;
  133871. */
  133872. protected _metallicReflectanceColor: Color3;
  133873. /**
  133874. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  133875. * This is multiply against the scalar values defined in the material.
  133876. */
  133877. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  133878. /**
  133879. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  133880. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  133881. */
  133882. protected _microSurfaceTexture: Nullable<BaseTexture>;
  133883. /**
  133884. * Stores surface normal data used to displace a mesh in a texture.
  133885. */
  133886. protected _bumpTexture: Nullable<BaseTexture>;
  133887. /**
  133888. * Stores the pre-calculated light information of a mesh in a texture.
  133889. */
  133890. protected _lightmapTexture: Nullable<BaseTexture>;
  133891. /**
  133892. * The color of a material in ambient lighting.
  133893. */
  133894. protected _ambientColor: Color3;
  133895. /**
  133896. * AKA Diffuse Color in other nomenclature.
  133897. */
  133898. protected _albedoColor: Color3;
  133899. /**
  133900. * AKA Specular Color in other nomenclature.
  133901. */
  133902. protected _reflectivityColor: Color3;
  133903. /**
  133904. * The color applied when light is reflected from a material.
  133905. */
  133906. protected _reflectionColor: Color3;
  133907. /**
  133908. * The color applied when light is emitted from a material.
  133909. */
  133910. protected _emissiveColor: Color3;
  133911. /**
  133912. * AKA Glossiness in other nomenclature.
  133913. */
  133914. protected _microSurface: number;
  133915. /**
  133916. * Specifies that the material will use the light map as a show map.
  133917. */
  133918. protected _useLightmapAsShadowmap: boolean;
  133919. /**
  133920. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  133921. * makes the reflect vector face the model (under horizon).
  133922. */
  133923. protected _useHorizonOcclusion: boolean;
  133924. /**
  133925. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  133926. * too much the area relying on ambient texture to define their ambient occlusion.
  133927. */
  133928. protected _useRadianceOcclusion: boolean;
  133929. /**
  133930. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  133931. */
  133932. protected _useAlphaFromAlbedoTexture: boolean;
  133933. /**
  133934. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  133935. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  133936. */
  133937. protected _useSpecularOverAlpha: boolean;
  133938. /**
  133939. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  133940. */
  133941. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  133942. /**
  133943. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  133944. */
  133945. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  133946. /**
  133947. * Specifies if the metallic texture contains the roughness information in its green channel.
  133948. */
  133949. protected _useRoughnessFromMetallicTextureGreen: boolean;
  133950. /**
  133951. * Specifies if the metallic texture contains the metallness information in its blue channel.
  133952. */
  133953. protected _useMetallnessFromMetallicTextureBlue: boolean;
  133954. /**
  133955. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  133956. */
  133957. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  133958. /**
  133959. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  133960. */
  133961. protected _useAmbientInGrayScale: boolean;
  133962. /**
  133963. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  133964. * The material will try to infer what glossiness each pixel should be.
  133965. */
  133966. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  133967. /**
  133968. * Defines the falloff type used in this material.
  133969. * It by default is Physical.
  133970. */
  133971. protected _lightFalloff: number;
  133972. /**
  133973. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  133974. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  133975. */
  133976. protected _useRadianceOverAlpha: boolean;
  133977. /**
  133978. * Allows using an object space normal map (instead of tangent space).
  133979. */
  133980. protected _useObjectSpaceNormalMap: boolean;
  133981. /**
  133982. * Allows using the bump map in parallax mode.
  133983. */
  133984. protected _useParallax: boolean;
  133985. /**
  133986. * Allows using the bump map in parallax occlusion mode.
  133987. */
  133988. protected _useParallaxOcclusion: boolean;
  133989. /**
  133990. * Controls the scale bias of the parallax mode.
  133991. */
  133992. protected _parallaxScaleBias: number;
  133993. /**
  133994. * If sets to true, disables all the lights affecting the material.
  133995. */
  133996. protected _disableLighting: boolean;
  133997. /**
  133998. * Number of Simultaneous lights allowed on the material.
  133999. */
  134000. protected _maxSimultaneousLights: number;
  134001. /**
  134002. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  134003. */
  134004. protected _invertNormalMapX: boolean;
  134005. /**
  134006. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  134007. */
  134008. protected _invertNormalMapY: boolean;
  134009. /**
  134010. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134011. */
  134012. protected _twoSidedLighting: boolean;
  134013. /**
  134014. * Defines the alpha limits in alpha test mode.
  134015. */
  134016. protected _alphaCutOff: number;
  134017. /**
  134018. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134019. */
  134020. protected _forceAlphaTest: boolean;
  134021. /**
  134022. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134023. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134024. */
  134025. protected _useAlphaFresnel: boolean;
  134026. /**
  134027. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134028. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134029. */
  134030. protected _useLinearAlphaFresnel: boolean;
  134031. /**
  134032. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  134033. * from cos thetav and roughness:
  134034. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  134035. */
  134036. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  134037. /**
  134038. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134039. */
  134040. protected _forceIrradianceInFragment: boolean;
  134041. private _realTimeFiltering;
  134042. /**
  134043. * Enables realtime filtering on the texture.
  134044. */
  134045. get realTimeFiltering(): boolean;
  134046. set realTimeFiltering(b: boolean);
  134047. private _realTimeFilteringQuality;
  134048. /**
  134049. * Quality switch for realtime filtering
  134050. */
  134051. get realTimeFilteringQuality(): number;
  134052. set realTimeFilteringQuality(n: number);
  134053. /**
  134054. * Should this material render to several textures at once
  134055. */
  134056. get shouldRenderToMRT(): boolean;
  134057. /**
  134058. * Force normal to face away from face.
  134059. */
  134060. protected _forceNormalForward: boolean;
  134061. /**
  134062. * Enables specular anti aliasing in the PBR shader.
  134063. * It will both interacts on the Geometry for analytical and IBL lighting.
  134064. * It also prefilter the roughness map based on the bump values.
  134065. */
  134066. protected _enableSpecularAntiAliasing: boolean;
  134067. /**
  134068. * Default configuration related to image processing available in the PBR Material.
  134069. */
  134070. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134071. /**
  134072. * Keep track of the image processing observer to allow dispose and replace.
  134073. */
  134074. private _imageProcessingObserver;
  134075. /**
  134076. * Attaches a new image processing configuration to the PBR Material.
  134077. * @param configuration
  134078. */
  134079. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134080. /**
  134081. * Stores the available render targets.
  134082. */
  134083. private _renderTargets;
  134084. /**
  134085. * Sets the global ambient color for the material used in lighting calculations.
  134086. */
  134087. private _globalAmbientColor;
  134088. /**
  134089. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  134090. */
  134091. private _useLogarithmicDepth;
  134092. /**
  134093. * If set to true, no lighting calculations will be applied.
  134094. */
  134095. private _unlit;
  134096. private _debugMode;
  134097. /**
  134098. * @hidden
  134099. * This is reserved for the inspector.
  134100. * Defines the material debug mode.
  134101. * It helps seeing only some components of the material while troubleshooting.
  134102. */
  134103. debugMode: number;
  134104. /**
  134105. * @hidden
  134106. * This is reserved for the inspector.
  134107. * Specify from where on screen the debug mode should start.
  134108. * The value goes from -1 (full screen) to 1 (not visible)
  134109. * It helps with side by side comparison against the final render
  134110. * This defaults to -1
  134111. */
  134112. private debugLimit;
  134113. /**
  134114. * @hidden
  134115. * This is reserved for the inspector.
  134116. * As the default viewing range might not be enough (if the ambient is really small for instance)
  134117. * You can use the factor to better multiply the final value.
  134118. */
  134119. private debugFactor;
  134120. /**
  134121. * Defines the clear coat layer parameters for the material.
  134122. */
  134123. readonly clearCoat: PBRClearCoatConfiguration;
  134124. /**
  134125. * Defines the anisotropic parameters for the material.
  134126. */
  134127. readonly anisotropy: PBRAnisotropicConfiguration;
  134128. /**
  134129. * Defines the BRDF parameters for the material.
  134130. */
  134131. readonly brdf: PBRBRDFConfiguration;
  134132. /**
  134133. * Defines the Sheen parameters for the material.
  134134. */
  134135. readonly sheen: PBRSheenConfiguration;
  134136. /**
  134137. * Defines the SubSurface parameters for the material.
  134138. */
  134139. readonly subSurface: PBRSubSurfaceConfiguration;
  134140. /**
  134141. * Defines the detail map parameters for the material.
  134142. */
  134143. readonly detailMap: DetailMapConfiguration;
  134144. protected _rebuildInParallel: boolean;
  134145. /**
  134146. * Instantiates a new PBRMaterial instance.
  134147. *
  134148. * @param name The material name
  134149. * @param scene The scene the material will be use in.
  134150. */
  134151. constructor(name: string, scene: Scene);
  134152. /**
  134153. * Gets a boolean indicating that current material needs to register RTT
  134154. */
  134155. get hasRenderTargetTextures(): boolean;
  134156. /**
  134157. * Gets the name of the material class.
  134158. */
  134159. getClassName(): string;
  134160. /**
  134161. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134162. */
  134163. get useLogarithmicDepth(): boolean;
  134164. /**
  134165. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  134166. */
  134167. set useLogarithmicDepth(value: boolean);
  134168. /**
  134169. * Returns true if alpha blending should be disabled.
  134170. */
  134171. protected get _disableAlphaBlending(): boolean;
  134172. /**
  134173. * Specifies whether or not this material should be rendered in alpha blend mode.
  134174. */
  134175. needAlphaBlending(): boolean;
  134176. /**
  134177. * Specifies whether or not this material should be rendered in alpha test mode.
  134178. */
  134179. needAlphaTesting(): boolean;
  134180. /**
  134181. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  134182. */
  134183. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  134184. /**
  134185. * Gets the texture used for the alpha test.
  134186. */
  134187. getAlphaTestTexture(): Nullable<BaseTexture>;
  134188. /**
  134189. * Specifies that the submesh is ready to be used.
  134190. * @param mesh - BJS mesh.
  134191. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  134192. * @param useInstances - Specifies that instances should be used.
  134193. * @returns - boolean indicating that the submesh is ready or not.
  134194. */
  134195. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  134196. /**
  134197. * Specifies if the material uses metallic roughness workflow.
  134198. * @returns boolean specifiying if the material uses metallic roughness workflow.
  134199. */
  134200. isMetallicWorkflow(): boolean;
  134201. private _prepareEffect;
  134202. private _prepareDefines;
  134203. /**
  134204. * Force shader compilation
  134205. */
  134206. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  134207. /**
  134208. * Initializes the uniform buffer layout for the shader.
  134209. */
  134210. buildUniformLayout(): void;
  134211. /**
  134212. * Unbinds the material from the mesh
  134213. */
  134214. unbind(): void;
  134215. /**
  134216. * Binds the submesh data.
  134217. * @param world - The world matrix.
  134218. * @param mesh - The BJS mesh.
  134219. * @param subMesh - A submesh of the BJS mesh.
  134220. */
  134221. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  134222. /**
  134223. * Returns the animatable textures.
  134224. * @returns - Array of animatable textures.
  134225. */
  134226. getAnimatables(): IAnimatable[];
  134227. /**
  134228. * Returns the texture used for reflections.
  134229. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  134230. */
  134231. private _getReflectionTexture;
  134232. /**
  134233. * Returns an array of the actively used textures.
  134234. * @returns - Array of BaseTextures
  134235. */
  134236. getActiveTextures(): BaseTexture[];
  134237. /**
  134238. * Checks to see if a texture is used in the material.
  134239. * @param texture - Base texture to use.
  134240. * @returns - Boolean specifying if a texture is used in the material.
  134241. */
  134242. hasTexture(texture: BaseTexture): boolean;
  134243. /**
  134244. * Disposes the resources of the material.
  134245. * @param forceDisposeEffect - Forces the disposal of effects.
  134246. * @param forceDisposeTextures - Forces the disposal of all textures.
  134247. */
  134248. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  134249. }
  134250. }
  134251. declare module BABYLON {
  134252. /**
  134253. * The Physically based material of BJS.
  134254. *
  134255. * This offers the main features of a standard PBR material.
  134256. * For more information, please refer to the documentation :
  134257. * https://doc.babylonjs.com/how_to/physically_based_rendering
  134258. */
  134259. export class PBRMaterial extends PBRBaseMaterial {
  134260. /**
  134261. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  134262. */
  134263. static readonly PBRMATERIAL_OPAQUE: number;
  134264. /**
  134265. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  134266. */
  134267. static readonly PBRMATERIAL_ALPHATEST: number;
  134268. /**
  134269. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134270. */
  134271. static readonly PBRMATERIAL_ALPHABLEND: number;
  134272. /**
  134273. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  134274. * They are also discarded below the alpha cutoff threshold to improve performances.
  134275. */
  134276. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  134277. /**
  134278. * Defines the default value of how much AO map is occluding the analytical lights
  134279. * (point spot...).
  134280. */
  134281. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  134282. /**
  134283. * Intensity of the direct lights e.g. the four lights available in your scene.
  134284. * This impacts both the direct diffuse and specular highlights.
  134285. */
  134286. directIntensity: number;
  134287. /**
  134288. * Intensity of the emissive part of the material.
  134289. * This helps controlling the emissive effect without modifying the emissive color.
  134290. */
  134291. emissiveIntensity: number;
  134292. /**
  134293. * Intensity of the environment e.g. how much the environment will light the object
  134294. * either through harmonics for rough material or through the refelction for shiny ones.
  134295. */
  134296. environmentIntensity: number;
  134297. /**
  134298. * This is a special control allowing the reduction of the specular highlights coming from the
  134299. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  134300. */
  134301. specularIntensity: number;
  134302. /**
  134303. * Debug Control allowing disabling the bump map on this material.
  134304. */
  134305. disableBumpMap: boolean;
  134306. /**
  134307. * AKA Diffuse Texture in standard nomenclature.
  134308. */
  134309. albedoTexture: BaseTexture;
  134310. /**
  134311. * AKA Occlusion Texture in other nomenclature.
  134312. */
  134313. ambientTexture: BaseTexture;
  134314. /**
  134315. * AKA Occlusion Texture Intensity in other nomenclature.
  134316. */
  134317. ambientTextureStrength: number;
  134318. /**
  134319. * Defines how much the AO map is occluding the analytical lights (point spot...).
  134320. * 1 means it completely occludes it
  134321. * 0 mean it has no impact
  134322. */
  134323. ambientTextureImpactOnAnalyticalLights: number;
  134324. /**
  134325. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  134326. */
  134327. opacityTexture: BaseTexture;
  134328. /**
  134329. * Stores the reflection values in a texture.
  134330. */
  134331. reflectionTexture: Nullable<BaseTexture>;
  134332. /**
  134333. * Stores the emissive values in a texture.
  134334. */
  134335. emissiveTexture: BaseTexture;
  134336. /**
  134337. * AKA Specular texture in other nomenclature.
  134338. */
  134339. reflectivityTexture: BaseTexture;
  134340. /**
  134341. * Used to switch from specular/glossiness to metallic/roughness workflow.
  134342. */
  134343. metallicTexture: BaseTexture;
  134344. /**
  134345. * Specifies the metallic scalar of the metallic/roughness workflow.
  134346. * Can also be used to scale the metalness values of the metallic texture.
  134347. */
  134348. metallic: Nullable<number>;
  134349. /**
  134350. * Specifies the roughness scalar of the metallic/roughness workflow.
  134351. * Can also be used to scale the roughness values of the metallic texture.
  134352. */
  134353. roughness: Nullable<number>;
  134354. /**
  134355. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  134356. * By default the indexOfrefraction is used to compute F0;
  134357. *
  134358. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  134359. *
  134360. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  134361. * F90 = metallicReflectanceColor;
  134362. */
  134363. metallicF0Factor: number;
  134364. /**
  134365. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  134366. * By default the F90 is always 1;
  134367. *
  134368. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  134369. *
  134370. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  134371. * F90 = metallicReflectanceColor;
  134372. */
  134373. metallicReflectanceColor: Color3;
  134374. /**
  134375. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  134376. * This is multiply against the scalar values defined in the material.
  134377. */
  134378. metallicReflectanceTexture: Nullable<BaseTexture>;
  134379. /**
  134380. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  134381. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  134382. */
  134383. microSurfaceTexture: BaseTexture;
  134384. /**
  134385. * Stores surface normal data used to displace a mesh in a texture.
  134386. */
  134387. bumpTexture: BaseTexture;
  134388. /**
  134389. * Stores the pre-calculated light information of a mesh in a texture.
  134390. */
  134391. lightmapTexture: BaseTexture;
  134392. /**
  134393. * Stores the refracted light information in a texture.
  134394. */
  134395. get refractionTexture(): Nullable<BaseTexture>;
  134396. set refractionTexture(value: Nullable<BaseTexture>);
  134397. /**
  134398. * The color of a material in ambient lighting.
  134399. */
  134400. ambientColor: Color3;
  134401. /**
  134402. * AKA Diffuse Color in other nomenclature.
  134403. */
  134404. albedoColor: Color3;
  134405. /**
  134406. * AKA Specular Color in other nomenclature.
  134407. */
  134408. reflectivityColor: Color3;
  134409. /**
  134410. * The color reflected from the material.
  134411. */
  134412. reflectionColor: Color3;
  134413. /**
  134414. * The color emitted from the material.
  134415. */
  134416. emissiveColor: Color3;
  134417. /**
  134418. * AKA Glossiness in other nomenclature.
  134419. */
  134420. microSurface: number;
  134421. /**
  134422. * Index of refraction of the material base layer.
  134423. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  134424. *
  134425. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  134426. *
  134427. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  134428. */
  134429. get indexOfRefraction(): number;
  134430. set indexOfRefraction(value: number);
  134431. /**
  134432. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  134433. */
  134434. get invertRefractionY(): boolean;
  134435. set invertRefractionY(value: boolean);
  134436. /**
  134437. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  134438. * Materials half opaque for instance using refraction could benefit from this control.
  134439. */
  134440. get linkRefractionWithTransparency(): boolean;
  134441. set linkRefractionWithTransparency(value: boolean);
  134442. /**
  134443. * If true, the light map contains occlusion information instead of lighting info.
  134444. */
  134445. useLightmapAsShadowmap: boolean;
  134446. /**
  134447. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  134448. */
  134449. useAlphaFromAlbedoTexture: boolean;
  134450. /**
  134451. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  134452. */
  134453. forceAlphaTest: boolean;
  134454. /**
  134455. * Defines the alpha limits in alpha test mode.
  134456. */
  134457. alphaCutOff: number;
  134458. /**
  134459. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  134460. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  134461. */
  134462. useSpecularOverAlpha: boolean;
  134463. /**
  134464. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  134465. */
  134466. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  134467. /**
  134468. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  134469. */
  134470. useRoughnessFromMetallicTextureAlpha: boolean;
  134471. /**
  134472. * Specifies if the metallic texture contains the roughness information in its green channel.
  134473. */
  134474. useRoughnessFromMetallicTextureGreen: boolean;
  134475. /**
  134476. * Specifies if the metallic texture contains the metallness information in its blue channel.
  134477. */
  134478. useMetallnessFromMetallicTextureBlue: boolean;
  134479. /**
  134480. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  134481. */
  134482. useAmbientOcclusionFromMetallicTextureRed: boolean;
  134483. /**
  134484. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  134485. */
  134486. useAmbientInGrayScale: boolean;
  134487. /**
  134488. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  134489. * The material will try to infer what glossiness each pixel should be.
  134490. */
  134491. useAutoMicroSurfaceFromReflectivityMap: boolean;
  134492. /**
  134493. * BJS is using an harcoded light falloff based on a manually sets up range.
  134494. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134495. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134496. */
  134497. get usePhysicalLightFalloff(): boolean;
  134498. /**
  134499. * BJS is using an harcoded light falloff based on a manually sets up range.
  134500. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  134501. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  134502. */
  134503. set usePhysicalLightFalloff(value: boolean);
  134504. /**
  134505. * In order to support the falloff compatibility with gltf, a special mode has been added
  134506. * to reproduce the gltf light falloff.
  134507. */
  134508. get useGLTFLightFalloff(): boolean;
  134509. /**
  134510. * In order to support the falloff compatibility with gltf, a special mode has been added
  134511. * to reproduce the gltf light falloff.
  134512. */
  134513. set useGLTFLightFalloff(value: boolean);
  134514. /**
  134515. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  134516. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  134517. */
  134518. useRadianceOverAlpha: boolean;
  134519. /**
  134520. * Allows using an object space normal map (instead of tangent space).
  134521. */
  134522. useObjectSpaceNormalMap: boolean;
  134523. /**
  134524. * Allows using the bump map in parallax mode.
  134525. */
  134526. useParallax: boolean;
  134527. /**
  134528. * Allows using the bump map in parallax occlusion mode.
  134529. */
  134530. useParallaxOcclusion: boolean;
  134531. /**
  134532. * Controls the scale bias of the parallax mode.
  134533. */
  134534. parallaxScaleBias: number;
  134535. /**
  134536. * If sets to true, disables all the lights affecting the material.
  134537. */
  134538. disableLighting: boolean;
  134539. /**
  134540. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  134541. */
  134542. forceIrradianceInFragment: boolean;
  134543. /**
  134544. * Number of Simultaneous lights allowed on the material.
  134545. */
  134546. maxSimultaneousLights: number;
  134547. /**
  134548. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  134549. */
  134550. invertNormalMapX: boolean;
  134551. /**
  134552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  134553. */
  134554. invertNormalMapY: boolean;
  134555. /**
  134556. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  134557. */
  134558. twoSidedLighting: boolean;
  134559. /**
  134560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134561. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  134562. */
  134563. useAlphaFresnel: boolean;
  134564. /**
  134565. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  134566. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  134567. */
  134568. useLinearAlphaFresnel: boolean;
  134569. /**
  134570. * Let user defines the brdf lookup texture used for IBL.
  134571. * A default 8bit version is embedded but you could point at :
  134572. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  134573. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  134574. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  134575. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  134576. */
  134577. environmentBRDFTexture: Nullable<BaseTexture>;
  134578. /**
  134579. * Force normal to face away from face.
  134580. */
  134581. forceNormalForward: boolean;
  134582. /**
  134583. * Enables specular anti aliasing in the PBR shader.
  134584. * It will both interacts on the Geometry for analytical and IBL lighting.
  134585. * It also prefilter the roughness map based on the bump values.
  134586. */
  134587. enableSpecularAntiAliasing: boolean;
  134588. /**
  134589. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  134590. * makes the reflect vector face the model (under horizon).
  134591. */
  134592. useHorizonOcclusion: boolean;
  134593. /**
  134594. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  134595. * too much the area relying on ambient texture to define their ambient occlusion.
  134596. */
  134597. useRadianceOcclusion: boolean;
  134598. /**
  134599. * If set to true, no lighting calculations will be applied.
  134600. */
  134601. unlit: boolean;
  134602. /**
  134603. * Gets the image processing configuration used either in this material.
  134604. */
  134605. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  134606. /**
  134607. * Sets the Default image processing configuration used either in the this material.
  134608. *
  134609. * If sets to null, the scene one is in use.
  134610. */
  134611. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  134612. /**
  134613. * Gets wether the color curves effect is enabled.
  134614. */
  134615. get cameraColorCurvesEnabled(): boolean;
  134616. /**
  134617. * Sets wether the color curves effect is enabled.
  134618. */
  134619. set cameraColorCurvesEnabled(value: boolean);
  134620. /**
  134621. * Gets wether the color grading effect is enabled.
  134622. */
  134623. get cameraColorGradingEnabled(): boolean;
  134624. /**
  134625. * Gets wether the color grading effect is enabled.
  134626. */
  134627. set cameraColorGradingEnabled(value: boolean);
  134628. /**
  134629. * Gets wether tonemapping is enabled or not.
  134630. */
  134631. get cameraToneMappingEnabled(): boolean;
  134632. /**
  134633. * Sets wether tonemapping is enabled or not
  134634. */
  134635. set cameraToneMappingEnabled(value: boolean);
  134636. /**
  134637. * The camera exposure used on this material.
  134638. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134639. * This corresponds to a photographic exposure.
  134640. */
  134641. get cameraExposure(): number;
  134642. /**
  134643. * The camera exposure used on this material.
  134644. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134645. * This corresponds to a photographic exposure.
  134646. */
  134647. set cameraExposure(value: number);
  134648. /**
  134649. * Gets The camera contrast used on this material.
  134650. */
  134651. get cameraContrast(): number;
  134652. /**
  134653. * Sets The camera contrast used on this material.
  134654. */
  134655. set cameraContrast(value: number);
  134656. /**
  134657. * Gets the Color Grading 2D Lookup Texture.
  134658. */
  134659. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134660. /**
  134661. * Sets the Color Grading 2D Lookup Texture.
  134662. */
  134663. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134664. /**
  134665. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134666. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134667. * 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;
  134668. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134669. */
  134670. get cameraColorCurves(): Nullable<ColorCurves>;
  134671. /**
  134672. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134673. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134674. * 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;
  134675. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134676. */
  134677. set cameraColorCurves(value: Nullable<ColorCurves>);
  134678. /**
  134679. * Instantiates a new PBRMaterial instance.
  134680. *
  134681. * @param name The material name
  134682. * @param scene The scene the material will be use in.
  134683. */
  134684. constructor(name: string, scene: Scene);
  134685. /**
  134686. * Returns the name of this material class.
  134687. */
  134688. getClassName(): string;
  134689. /**
  134690. * Makes a duplicate of the current material.
  134691. * @param name - name to use for the new material.
  134692. */
  134693. clone(name: string): PBRMaterial;
  134694. /**
  134695. * Serializes this PBR Material.
  134696. * @returns - An object with the serialized material.
  134697. */
  134698. serialize(): any;
  134699. /**
  134700. * Parses a PBR Material from a serialized object.
  134701. * @param source - Serialized object.
  134702. * @param scene - BJS scene instance.
  134703. * @param rootUrl - url for the scene object
  134704. * @returns - PBRMaterial
  134705. */
  134706. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  134707. }
  134708. }
  134709. declare module BABYLON {
  134710. /**
  134711. * Direct draw surface info
  134712. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  134713. */
  134714. export interface DDSInfo {
  134715. /**
  134716. * Width of the texture
  134717. */
  134718. width: number;
  134719. /**
  134720. * Width of the texture
  134721. */
  134722. height: number;
  134723. /**
  134724. * Number of Mipmaps for the texture
  134725. * @see https://en.wikipedia.org/wiki/Mipmap
  134726. */
  134727. mipmapCount: number;
  134728. /**
  134729. * If the textures format is a known fourCC format
  134730. * @see https://www.fourcc.org/
  134731. */
  134732. isFourCC: boolean;
  134733. /**
  134734. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  134735. */
  134736. isRGB: boolean;
  134737. /**
  134738. * If the texture is a lumincance format
  134739. */
  134740. isLuminance: boolean;
  134741. /**
  134742. * If this is a cube texture
  134743. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  134744. */
  134745. isCube: boolean;
  134746. /**
  134747. * If the texture is a compressed format eg. FOURCC_DXT1
  134748. */
  134749. isCompressed: boolean;
  134750. /**
  134751. * The dxgiFormat of the texture
  134752. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  134753. */
  134754. dxgiFormat: number;
  134755. /**
  134756. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  134757. */
  134758. textureType: number;
  134759. /**
  134760. * Sphericle polynomial created for the dds texture
  134761. */
  134762. sphericalPolynomial?: SphericalPolynomial;
  134763. }
  134764. /**
  134765. * Class used to provide DDS decompression tools
  134766. */
  134767. export class DDSTools {
  134768. /**
  134769. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  134770. */
  134771. static StoreLODInAlphaChannel: boolean;
  134772. /**
  134773. * Gets DDS information from an array buffer
  134774. * @param data defines the array buffer view to read data from
  134775. * @returns the DDS information
  134776. */
  134777. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  134778. private static _FloatView;
  134779. private static _Int32View;
  134780. private static _ToHalfFloat;
  134781. private static _FromHalfFloat;
  134782. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  134783. private static _GetHalfFloatRGBAArrayBuffer;
  134784. private static _GetFloatRGBAArrayBuffer;
  134785. private static _GetFloatAsUIntRGBAArrayBuffer;
  134786. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  134787. private static _GetRGBAArrayBuffer;
  134788. private static _ExtractLongWordOrder;
  134789. private static _GetRGBArrayBuffer;
  134790. private static _GetLuminanceArrayBuffer;
  134791. /**
  134792. * Uploads DDS Levels to a Babylon Texture
  134793. * @hidden
  134794. */
  134795. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  134796. }
  134797. interface ThinEngine {
  134798. /**
  134799. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  134800. * @param rootUrl defines the url where the file to load is located
  134801. * @param scene defines the current scene
  134802. * @param lodScale defines scale to apply to the mip map selection
  134803. * @param lodOffset defines offset to apply to the mip map selection
  134804. * @param onLoad defines an optional callback raised when the texture is loaded
  134805. * @param onError defines an optional callback raised if there is an issue to load the texture
  134806. * @param format defines the format of the data
  134807. * @param forcedExtension defines the extension to use to pick the right loader
  134808. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  134809. * @returns the cube texture as an InternalTexture
  134810. */
  134811. 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;
  134812. }
  134813. }
  134814. declare module BABYLON {
  134815. /**
  134816. * Implementation of the DDS Texture Loader.
  134817. * @hidden
  134818. */
  134819. export class _DDSTextureLoader implements IInternalTextureLoader {
  134820. /**
  134821. * Defines wether the loader supports cascade loading the different faces.
  134822. */
  134823. readonly supportCascades: boolean;
  134824. /**
  134825. * This returns if the loader support the current file information.
  134826. * @param extension defines the file extension of the file being loaded
  134827. * @returns true if the loader can load the specified file
  134828. */
  134829. canLoad(extension: string): boolean;
  134830. /**
  134831. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134832. * @param data contains the texture data
  134833. * @param texture defines the BabylonJS internal texture
  134834. * @param createPolynomials will be true if polynomials have been requested
  134835. * @param onLoad defines the callback to trigger once the texture is ready
  134836. * @param onError defines the callback to trigger in case of error
  134837. */
  134838. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134839. /**
  134840. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134841. * @param data contains the texture data
  134842. * @param texture defines the BabylonJS internal texture
  134843. * @param callback defines the method to call once ready to upload
  134844. */
  134845. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134846. }
  134847. }
  134848. declare module BABYLON {
  134849. /**
  134850. * Implementation of the ENV Texture Loader.
  134851. * @hidden
  134852. */
  134853. export class _ENVTextureLoader implements IInternalTextureLoader {
  134854. /**
  134855. * Defines wether the loader supports cascade loading the different faces.
  134856. */
  134857. readonly supportCascades: boolean;
  134858. /**
  134859. * This returns if the loader support the current file information.
  134860. * @param extension defines the file extension of the file being loaded
  134861. * @returns true if the loader can load the specified file
  134862. */
  134863. canLoad(extension: string): boolean;
  134864. /**
  134865. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  134866. * @param data contains the texture data
  134867. * @param texture defines the BabylonJS internal texture
  134868. * @param createPolynomials will be true if polynomials have been requested
  134869. * @param onLoad defines the callback to trigger once the texture is ready
  134870. * @param onError defines the callback to trigger in case of error
  134871. */
  134872. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  134873. /**
  134874. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  134875. * @param data contains the texture data
  134876. * @param texture defines the BabylonJS internal texture
  134877. * @param callback defines the method to call once ready to upload
  134878. */
  134879. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  134880. }
  134881. }
  134882. declare module BABYLON {
  134883. /**
  134884. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  134885. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  134886. */
  134887. export class KhronosTextureContainer {
  134888. /** contents of the KTX container file */
  134889. data: ArrayBufferView;
  134890. private static HEADER_LEN;
  134891. private static COMPRESSED_2D;
  134892. private static COMPRESSED_3D;
  134893. private static TEX_2D;
  134894. private static TEX_3D;
  134895. /**
  134896. * Gets the openGL type
  134897. */
  134898. glType: number;
  134899. /**
  134900. * Gets the openGL type size
  134901. */
  134902. glTypeSize: number;
  134903. /**
  134904. * Gets the openGL format
  134905. */
  134906. glFormat: number;
  134907. /**
  134908. * Gets the openGL internal format
  134909. */
  134910. glInternalFormat: number;
  134911. /**
  134912. * Gets the base internal format
  134913. */
  134914. glBaseInternalFormat: number;
  134915. /**
  134916. * Gets image width in pixel
  134917. */
  134918. pixelWidth: number;
  134919. /**
  134920. * Gets image height in pixel
  134921. */
  134922. pixelHeight: number;
  134923. /**
  134924. * Gets image depth in pixels
  134925. */
  134926. pixelDepth: number;
  134927. /**
  134928. * Gets the number of array elements
  134929. */
  134930. numberOfArrayElements: number;
  134931. /**
  134932. * Gets the number of faces
  134933. */
  134934. numberOfFaces: number;
  134935. /**
  134936. * Gets the number of mipmap levels
  134937. */
  134938. numberOfMipmapLevels: number;
  134939. /**
  134940. * Gets the bytes of key value data
  134941. */
  134942. bytesOfKeyValueData: number;
  134943. /**
  134944. * Gets the load type
  134945. */
  134946. loadType: number;
  134947. /**
  134948. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  134949. */
  134950. isInvalid: boolean;
  134951. /**
  134952. * Creates a new KhronosTextureContainer
  134953. * @param data contents of the KTX container file
  134954. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  134955. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  134956. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  134957. */
  134958. constructor(
  134959. /** contents of the KTX container file */
  134960. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  134961. /**
  134962. * Uploads KTX content to a Babylon Texture.
  134963. * It is assumed that the texture has already been created & is currently bound
  134964. * @hidden
  134965. */
  134966. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  134967. private _upload2DCompressedLevels;
  134968. /**
  134969. * Checks if the given data starts with a KTX file identifier.
  134970. * @param data the data to check
  134971. * @returns true if the data is a KTX file or false otherwise
  134972. */
  134973. static IsValid(data: ArrayBufferView): boolean;
  134974. }
  134975. }
  134976. declare module BABYLON {
  134977. /**
  134978. * Class for loading KTX2 files
  134979. * !!! Experimental Extension Subject to Changes !!!
  134980. * @hidden
  134981. */
  134982. export class KhronosTextureContainer2 {
  134983. private static _ModulePromise;
  134984. private static _TranscodeFormat;
  134985. constructor(engine: ThinEngine);
  134986. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  134987. private _determineTranscodeFormat;
  134988. /**
  134989. * Checks if the given data starts with a KTX2 file identifier.
  134990. * @param data the data to check
  134991. * @returns true if the data is a KTX2 file or false otherwise
  134992. */
  134993. static IsValid(data: ArrayBufferView): boolean;
  134994. }
  134995. }
  134996. declare module BABYLON {
  134997. /**
  134998. * Implementation of the KTX Texture Loader.
  134999. * @hidden
  135000. */
  135001. export class _KTXTextureLoader implements IInternalTextureLoader {
  135002. /**
  135003. * Defines wether the loader supports cascade loading the different faces.
  135004. */
  135005. readonly supportCascades: boolean;
  135006. /**
  135007. * This returns if the loader support the current file information.
  135008. * @param extension defines the file extension of the file being loaded
  135009. * @param mimeType defines the optional mime type of the file being loaded
  135010. * @returns true if the loader can load the specified file
  135011. */
  135012. canLoad(extension: string, mimeType?: string): boolean;
  135013. /**
  135014. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  135015. * @param data contains the texture data
  135016. * @param texture defines the BabylonJS internal texture
  135017. * @param createPolynomials will be true if polynomials have been requested
  135018. * @param onLoad defines the callback to trigger once the texture is ready
  135019. * @param onError defines the callback to trigger in case of error
  135020. */
  135021. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  135022. /**
  135023. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  135024. * @param data contains the texture data
  135025. * @param texture defines the BabylonJS internal texture
  135026. * @param callback defines the method to call once ready to upload
  135027. */
  135028. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  135029. }
  135030. }
  135031. declare module BABYLON {
  135032. /** @hidden */
  135033. export var _forceSceneHelpersToBundle: boolean;
  135034. interface Scene {
  135035. /**
  135036. * Creates a default light for the scene.
  135037. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  135038. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  135039. */
  135040. createDefaultLight(replace?: boolean): void;
  135041. /**
  135042. * Creates a default camera for the scene.
  135043. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  135044. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135045. * @param replace has default false, when true replaces the active camera in the scene
  135046. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  135047. */
  135048. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135049. /**
  135050. * Creates a default camera and a default light.
  135051. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  135052. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  135053. * @param replace has the default false, when true replaces the active camera/light in the scene
  135054. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  135055. */
  135056. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  135057. /**
  135058. * Creates a new sky box
  135059. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  135060. * @param environmentTexture defines the texture to use as environment texture
  135061. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  135062. * @param scale defines the overall scale of the skybox
  135063. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  135064. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  135065. * @returns a new mesh holding the sky box
  135066. */
  135067. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  135068. /**
  135069. * Creates a new environment
  135070. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  135071. * @param options defines the options you can use to configure the environment
  135072. * @returns the new EnvironmentHelper
  135073. */
  135074. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  135075. /**
  135076. * Creates a new VREXperienceHelper
  135077. * @see https://doc.babylonjs.com/how_to/webvr_helper
  135078. * @param webVROptions defines the options used to create the new VREXperienceHelper
  135079. * @returns a new VREXperienceHelper
  135080. */
  135081. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  135082. /**
  135083. * Creates a new WebXRDefaultExperience
  135084. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  135085. * @param options experience options
  135086. * @returns a promise for a new WebXRDefaultExperience
  135087. */
  135088. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  135089. }
  135090. }
  135091. declare module BABYLON {
  135092. /**
  135093. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  135094. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  135095. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  135096. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135097. */
  135098. export class VideoDome extends TransformNode {
  135099. /**
  135100. * Define the video source as a Monoscopic panoramic 360 video.
  135101. */
  135102. static readonly MODE_MONOSCOPIC: number;
  135103. /**
  135104. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135105. */
  135106. static readonly MODE_TOPBOTTOM: number;
  135107. /**
  135108. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135109. */
  135110. static readonly MODE_SIDEBYSIDE: number;
  135111. private _halfDome;
  135112. private _useDirectMapping;
  135113. /**
  135114. * The video texture being displayed on the sphere
  135115. */
  135116. protected _videoTexture: VideoTexture;
  135117. /**
  135118. * Gets the video texture being displayed on the sphere
  135119. */
  135120. get videoTexture(): VideoTexture;
  135121. /**
  135122. * The skybox material
  135123. */
  135124. protected _material: BackgroundMaterial;
  135125. /**
  135126. * The surface used for the video dome
  135127. */
  135128. protected _mesh: Mesh;
  135129. /**
  135130. * Gets the mesh used for the video dome.
  135131. */
  135132. get mesh(): Mesh;
  135133. /**
  135134. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  135135. */
  135136. private _halfDomeMask;
  135137. /**
  135138. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135139. * Also see the options.resolution property.
  135140. */
  135141. get fovMultiplier(): number;
  135142. set fovMultiplier(value: number);
  135143. private _videoMode;
  135144. /**
  135145. * Gets or set the current video mode for the video. It can be:
  135146. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  135147. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  135148. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  135149. */
  135150. get videoMode(): number;
  135151. set videoMode(value: number);
  135152. /**
  135153. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  135154. *
  135155. */
  135156. get halfDome(): boolean;
  135157. /**
  135158. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135159. */
  135160. set halfDome(enabled: boolean);
  135161. /**
  135162. * Oberserver used in Stereoscopic VR Mode.
  135163. */
  135164. private _onBeforeCameraRenderObserver;
  135165. /**
  135166. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  135167. * @param name Element's name, child elements will append suffixes for their own names.
  135168. * @param urlsOrVideo defines the url(s) or the video element to use
  135169. * @param options An object containing optional or exposed sub element properties
  135170. */
  135171. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  135172. resolution?: number;
  135173. clickToPlay?: boolean;
  135174. autoPlay?: boolean;
  135175. loop?: boolean;
  135176. size?: number;
  135177. poster?: string;
  135178. faceForward?: boolean;
  135179. useDirectMapping?: boolean;
  135180. halfDomeMode?: boolean;
  135181. }, scene: Scene);
  135182. private _changeVideoMode;
  135183. /**
  135184. * Releases resources associated with this node.
  135185. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135186. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135187. */
  135188. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135189. }
  135190. }
  135191. declare module BABYLON {
  135192. /**
  135193. * This class can be used to get instrumentation data from a Babylon engine
  135194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135195. */
  135196. export class EngineInstrumentation implements IDisposable {
  135197. /**
  135198. * Define the instrumented engine.
  135199. */
  135200. engine: Engine;
  135201. private _captureGPUFrameTime;
  135202. private _gpuFrameTimeToken;
  135203. private _gpuFrameTime;
  135204. private _captureShaderCompilationTime;
  135205. private _shaderCompilationTime;
  135206. private _onBeginFrameObserver;
  135207. private _onEndFrameObserver;
  135208. private _onBeforeShaderCompilationObserver;
  135209. private _onAfterShaderCompilationObserver;
  135210. /**
  135211. * Gets the perf counter used for GPU frame time
  135212. */
  135213. get gpuFrameTimeCounter(): PerfCounter;
  135214. /**
  135215. * Gets the GPU frame time capture status
  135216. */
  135217. get captureGPUFrameTime(): boolean;
  135218. /**
  135219. * Enable or disable the GPU frame time capture
  135220. */
  135221. set captureGPUFrameTime(value: boolean);
  135222. /**
  135223. * Gets the perf counter used for shader compilation time
  135224. */
  135225. get shaderCompilationTimeCounter(): PerfCounter;
  135226. /**
  135227. * Gets the shader compilation time capture status
  135228. */
  135229. get captureShaderCompilationTime(): boolean;
  135230. /**
  135231. * Enable or disable the shader compilation time capture
  135232. */
  135233. set captureShaderCompilationTime(value: boolean);
  135234. /**
  135235. * Instantiates a new engine instrumentation.
  135236. * This class can be used to get instrumentation data from a Babylon engine
  135237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  135238. * @param engine Defines the engine to instrument
  135239. */
  135240. constructor(
  135241. /**
  135242. * Define the instrumented engine.
  135243. */
  135244. engine: Engine);
  135245. /**
  135246. * Dispose and release associated resources.
  135247. */
  135248. dispose(): void;
  135249. }
  135250. }
  135251. declare module BABYLON {
  135252. /**
  135253. * This class can be used to get instrumentation data from a Babylon engine
  135254. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135255. */
  135256. export class SceneInstrumentation implements IDisposable {
  135257. /**
  135258. * Defines the scene to instrument
  135259. */
  135260. scene: Scene;
  135261. private _captureActiveMeshesEvaluationTime;
  135262. private _activeMeshesEvaluationTime;
  135263. private _captureRenderTargetsRenderTime;
  135264. private _renderTargetsRenderTime;
  135265. private _captureFrameTime;
  135266. private _frameTime;
  135267. private _captureRenderTime;
  135268. private _renderTime;
  135269. private _captureInterFrameTime;
  135270. private _interFrameTime;
  135271. private _captureParticlesRenderTime;
  135272. private _particlesRenderTime;
  135273. private _captureSpritesRenderTime;
  135274. private _spritesRenderTime;
  135275. private _capturePhysicsTime;
  135276. private _physicsTime;
  135277. private _captureAnimationsTime;
  135278. private _animationsTime;
  135279. private _captureCameraRenderTime;
  135280. private _cameraRenderTime;
  135281. private _onBeforeActiveMeshesEvaluationObserver;
  135282. private _onAfterActiveMeshesEvaluationObserver;
  135283. private _onBeforeRenderTargetsRenderObserver;
  135284. private _onAfterRenderTargetsRenderObserver;
  135285. private _onAfterRenderObserver;
  135286. private _onBeforeDrawPhaseObserver;
  135287. private _onAfterDrawPhaseObserver;
  135288. private _onBeforeAnimationsObserver;
  135289. private _onBeforeParticlesRenderingObserver;
  135290. private _onAfterParticlesRenderingObserver;
  135291. private _onBeforeSpritesRenderingObserver;
  135292. private _onAfterSpritesRenderingObserver;
  135293. private _onBeforePhysicsObserver;
  135294. private _onAfterPhysicsObserver;
  135295. private _onAfterAnimationsObserver;
  135296. private _onBeforeCameraRenderObserver;
  135297. private _onAfterCameraRenderObserver;
  135298. /**
  135299. * Gets the perf counter used for active meshes evaluation time
  135300. */
  135301. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  135302. /**
  135303. * Gets the active meshes evaluation time capture status
  135304. */
  135305. get captureActiveMeshesEvaluationTime(): boolean;
  135306. /**
  135307. * Enable or disable the active meshes evaluation time capture
  135308. */
  135309. set captureActiveMeshesEvaluationTime(value: boolean);
  135310. /**
  135311. * Gets the perf counter used for render targets render time
  135312. */
  135313. get renderTargetsRenderTimeCounter(): PerfCounter;
  135314. /**
  135315. * Gets the render targets render time capture status
  135316. */
  135317. get captureRenderTargetsRenderTime(): boolean;
  135318. /**
  135319. * Enable or disable the render targets render time capture
  135320. */
  135321. set captureRenderTargetsRenderTime(value: boolean);
  135322. /**
  135323. * Gets the perf counter used for particles render time
  135324. */
  135325. get particlesRenderTimeCounter(): PerfCounter;
  135326. /**
  135327. * Gets the particles render time capture status
  135328. */
  135329. get captureParticlesRenderTime(): boolean;
  135330. /**
  135331. * Enable or disable the particles render time capture
  135332. */
  135333. set captureParticlesRenderTime(value: boolean);
  135334. /**
  135335. * Gets the perf counter used for sprites render time
  135336. */
  135337. get spritesRenderTimeCounter(): PerfCounter;
  135338. /**
  135339. * Gets the sprites render time capture status
  135340. */
  135341. get captureSpritesRenderTime(): boolean;
  135342. /**
  135343. * Enable or disable the sprites render time capture
  135344. */
  135345. set captureSpritesRenderTime(value: boolean);
  135346. /**
  135347. * Gets the perf counter used for physics time
  135348. */
  135349. get physicsTimeCounter(): PerfCounter;
  135350. /**
  135351. * Gets the physics time capture status
  135352. */
  135353. get capturePhysicsTime(): boolean;
  135354. /**
  135355. * Enable or disable the physics time capture
  135356. */
  135357. set capturePhysicsTime(value: boolean);
  135358. /**
  135359. * Gets the perf counter used for animations time
  135360. */
  135361. get animationsTimeCounter(): PerfCounter;
  135362. /**
  135363. * Gets the animations time capture status
  135364. */
  135365. get captureAnimationsTime(): boolean;
  135366. /**
  135367. * Enable or disable the animations time capture
  135368. */
  135369. set captureAnimationsTime(value: boolean);
  135370. /**
  135371. * Gets the perf counter used for frame time capture
  135372. */
  135373. get frameTimeCounter(): PerfCounter;
  135374. /**
  135375. * Gets the frame time capture status
  135376. */
  135377. get captureFrameTime(): boolean;
  135378. /**
  135379. * Enable or disable the frame time capture
  135380. */
  135381. set captureFrameTime(value: boolean);
  135382. /**
  135383. * Gets the perf counter used for inter-frames time capture
  135384. */
  135385. get interFrameTimeCounter(): PerfCounter;
  135386. /**
  135387. * Gets the inter-frames time capture status
  135388. */
  135389. get captureInterFrameTime(): boolean;
  135390. /**
  135391. * Enable or disable the inter-frames time capture
  135392. */
  135393. set captureInterFrameTime(value: boolean);
  135394. /**
  135395. * Gets the perf counter used for render time capture
  135396. */
  135397. get renderTimeCounter(): PerfCounter;
  135398. /**
  135399. * Gets the render time capture status
  135400. */
  135401. get captureRenderTime(): boolean;
  135402. /**
  135403. * Enable or disable the render time capture
  135404. */
  135405. set captureRenderTime(value: boolean);
  135406. /**
  135407. * Gets the perf counter used for camera render time capture
  135408. */
  135409. get cameraRenderTimeCounter(): PerfCounter;
  135410. /**
  135411. * Gets the camera render time capture status
  135412. */
  135413. get captureCameraRenderTime(): boolean;
  135414. /**
  135415. * Enable or disable the camera render time capture
  135416. */
  135417. set captureCameraRenderTime(value: boolean);
  135418. /**
  135419. * Gets the perf counter used for draw calls
  135420. */
  135421. get drawCallsCounter(): PerfCounter;
  135422. /**
  135423. * Instantiates a new scene instrumentation.
  135424. * This class can be used to get instrumentation data from a Babylon engine
  135425. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  135426. * @param scene Defines the scene to instrument
  135427. */
  135428. constructor(
  135429. /**
  135430. * Defines the scene to instrument
  135431. */
  135432. scene: Scene);
  135433. /**
  135434. * Dispose and release associated resources.
  135435. */
  135436. dispose(): void;
  135437. }
  135438. }
  135439. declare module BABYLON {
  135440. /** @hidden */
  135441. export var glowMapGenerationPixelShader: {
  135442. name: string;
  135443. shader: string;
  135444. };
  135445. }
  135446. declare module BABYLON {
  135447. /** @hidden */
  135448. export var glowMapGenerationVertexShader: {
  135449. name: string;
  135450. shader: string;
  135451. };
  135452. }
  135453. declare module BABYLON {
  135454. /**
  135455. * Effect layer options. This helps customizing the behaviour
  135456. * of the effect layer.
  135457. */
  135458. export interface IEffectLayerOptions {
  135459. /**
  135460. * Multiplication factor apply to the canvas size to compute the render target size
  135461. * used to generated the objects (the smaller the faster).
  135462. */
  135463. mainTextureRatio: number;
  135464. /**
  135465. * Enforces a fixed size texture to ensure effect stability across devices.
  135466. */
  135467. mainTextureFixedSize?: number;
  135468. /**
  135469. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  135470. */
  135471. alphaBlendingMode: number;
  135472. /**
  135473. * The camera attached to the layer.
  135474. */
  135475. camera: Nullable<Camera>;
  135476. /**
  135477. * The rendering group to draw the layer in.
  135478. */
  135479. renderingGroupId: number;
  135480. }
  135481. /**
  135482. * The effect layer Helps adding post process effect blended with the main pass.
  135483. *
  135484. * This can be for instance use to generate glow or higlight effects on the scene.
  135485. *
  135486. * The effect layer class can not be used directly and is intented to inherited from to be
  135487. * customized per effects.
  135488. */
  135489. export abstract class EffectLayer {
  135490. private _vertexBuffers;
  135491. private _indexBuffer;
  135492. private _cachedDefines;
  135493. private _effectLayerMapGenerationEffect;
  135494. private _effectLayerOptions;
  135495. private _mergeEffect;
  135496. protected _scene: Scene;
  135497. protected _engine: Engine;
  135498. protected _maxSize: number;
  135499. protected _mainTextureDesiredSize: ISize;
  135500. protected _mainTexture: RenderTargetTexture;
  135501. protected _shouldRender: boolean;
  135502. protected _postProcesses: PostProcess[];
  135503. protected _textures: BaseTexture[];
  135504. protected _emissiveTextureAndColor: {
  135505. texture: Nullable<BaseTexture>;
  135506. color: Color4;
  135507. };
  135508. /**
  135509. * The name of the layer
  135510. */
  135511. name: string;
  135512. /**
  135513. * The clear color of the texture used to generate the glow map.
  135514. */
  135515. neutralColor: Color4;
  135516. /**
  135517. * Specifies whether the highlight layer is enabled or not.
  135518. */
  135519. isEnabled: boolean;
  135520. /**
  135521. * Gets the camera attached to the layer.
  135522. */
  135523. get camera(): Nullable<Camera>;
  135524. /**
  135525. * Gets the rendering group id the layer should render in.
  135526. */
  135527. get renderingGroupId(): number;
  135528. set renderingGroupId(renderingGroupId: number);
  135529. /**
  135530. * An event triggered when the effect layer has been disposed.
  135531. */
  135532. onDisposeObservable: Observable<EffectLayer>;
  135533. /**
  135534. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  135535. */
  135536. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  135537. /**
  135538. * An event triggered when the generated texture is being merged in the scene.
  135539. */
  135540. onBeforeComposeObservable: Observable<EffectLayer>;
  135541. /**
  135542. * An event triggered when the mesh is rendered into the effect render target.
  135543. */
  135544. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  135545. /**
  135546. * An event triggered after the mesh has been rendered into the effect render target.
  135547. */
  135548. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  135549. /**
  135550. * An event triggered when the generated texture has been merged in the scene.
  135551. */
  135552. onAfterComposeObservable: Observable<EffectLayer>;
  135553. /**
  135554. * An event triggered when the efffect layer changes its size.
  135555. */
  135556. onSizeChangedObservable: Observable<EffectLayer>;
  135557. /** @hidden */
  135558. static _SceneComponentInitialization: (scene: Scene) => void;
  135559. /**
  135560. * Instantiates a new effect Layer and references it in the scene.
  135561. * @param name The name of the layer
  135562. * @param scene The scene to use the layer in
  135563. */
  135564. constructor(
  135565. /** The Friendly of the effect in the scene */
  135566. name: string, scene: Scene);
  135567. /**
  135568. * Get the effect name of the layer.
  135569. * @return The effect name
  135570. */
  135571. abstract getEffectName(): string;
  135572. /**
  135573. * Checks for the readiness of the element composing the layer.
  135574. * @param subMesh the mesh to check for
  135575. * @param useInstances specify whether or not to use instances to render the mesh
  135576. * @return true if ready otherwise, false
  135577. */
  135578. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135579. /**
  135580. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135581. * @returns true if the effect requires stencil during the main canvas render pass.
  135582. */
  135583. abstract needStencil(): boolean;
  135584. /**
  135585. * Create the merge effect. This is the shader use to blit the information back
  135586. * to the main canvas at the end of the scene rendering.
  135587. * @returns The effect containing the shader used to merge the effect on the main canvas
  135588. */
  135589. protected abstract _createMergeEffect(): Effect;
  135590. /**
  135591. * Creates the render target textures and post processes used in the effect layer.
  135592. */
  135593. protected abstract _createTextureAndPostProcesses(): void;
  135594. /**
  135595. * Implementation specific of rendering the generating effect on the main canvas.
  135596. * @param effect The effect used to render through
  135597. */
  135598. protected abstract _internalRender(effect: Effect): void;
  135599. /**
  135600. * Sets the required values for both the emissive texture and and the main color.
  135601. */
  135602. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135603. /**
  135604. * Free any resources and references associated to a mesh.
  135605. * Internal use
  135606. * @param mesh The mesh to free.
  135607. */
  135608. abstract _disposeMesh(mesh: Mesh): void;
  135609. /**
  135610. * Serializes this layer (Glow or Highlight for example)
  135611. * @returns a serialized layer object
  135612. */
  135613. abstract serialize?(): any;
  135614. /**
  135615. * Initializes the effect layer with the required options.
  135616. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  135617. */
  135618. protected _init(options: Partial<IEffectLayerOptions>): void;
  135619. /**
  135620. * Generates the index buffer of the full screen quad blending to the main canvas.
  135621. */
  135622. private _generateIndexBuffer;
  135623. /**
  135624. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  135625. */
  135626. private _generateVertexBuffer;
  135627. /**
  135628. * Sets the main texture desired size which is the closest power of two
  135629. * of the engine canvas size.
  135630. */
  135631. private _setMainTextureSize;
  135632. /**
  135633. * Creates the main texture for the effect layer.
  135634. */
  135635. protected _createMainTexture(): void;
  135636. /**
  135637. * Adds specific effects defines.
  135638. * @param defines The defines to add specifics to.
  135639. */
  135640. protected _addCustomEffectDefines(defines: string[]): void;
  135641. /**
  135642. * Checks for the readiness of the element composing the layer.
  135643. * @param subMesh the mesh to check for
  135644. * @param useInstances specify whether or not to use instances to render the mesh
  135645. * @param emissiveTexture the associated emissive texture used to generate the glow
  135646. * @return true if ready otherwise, false
  135647. */
  135648. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  135649. /**
  135650. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  135651. */
  135652. render(): void;
  135653. /**
  135654. * Determine if a given mesh will be used in the current effect.
  135655. * @param mesh mesh to test
  135656. * @returns true if the mesh will be used
  135657. */
  135658. hasMesh(mesh: AbstractMesh): boolean;
  135659. /**
  135660. * Returns true if the layer contains information to display, otherwise false.
  135661. * @returns true if the glow layer should be rendered
  135662. */
  135663. shouldRender(): boolean;
  135664. /**
  135665. * Returns true if the mesh should render, otherwise false.
  135666. * @param mesh The mesh to render
  135667. * @returns true if it should render otherwise false
  135668. */
  135669. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  135670. /**
  135671. * Returns true if the mesh can be rendered, otherwise false.
  135672. * @param mesh The mesh to render
  135673. * @param material The material used on the mesh
  135674. * @returns true if it can be rendered otherwise false
  135675. */
  135676. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135677. /**
  135678. * Returns true if the mesh should render, otherwise false.
  135679. * @param mesh The mesh to render
  135680. * @returns true if it should render otherwise false
  135681. */
  135682. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  135683. /**
  135684. * Renders the submesh passed in parameter to the generation map.
  135685. */
  135686. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  135687. /**
  135688. * Defines whether the current material of the mesh should be use to render the effect.
  135689. * @param mesh defines the current mesh to render
  135690. */
  135691. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  135692. /**
  135693. * Rebuild the required buffers.
  135694. * @hidden Internal use only.
  135695. */
  135696. _rebuild(): void;
  135697. /**
  135698. * Dispose only the render target textures and post process.
  135699. */
  135700. private _disposeTextureAndPostProcesses;
  135701. /**
  135702. * Dispose the highlight layer and free resources.
  135703. */
  135704. dispose(): void;
  135705. /**
  135706. * Gets the class name of the effect layer
  135707. * @returns the string with the class name of the effect layer
  135708. */
  135709. getClassName(): string;
  135710. /**
  135711. * Creates an effect layer from parsed effect layer data
  135712. * @param parsedEffectLayer defines effect layer data
  135713. * @param scene defines the current scene
  135714. * @param rootUrl defines the root URL containing the effect layer information
  135715. * @returns a parsed effect Layer
  135716. */
  135717. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  135718. }
  135719. }
  135720. declare module BABYLON {
  135721. interface AbstractScene {
  135722. /**
  135723. * The list of effect layers (highlights/glow) added to the scene
  135724. * @see https://doc.babylonjs.com/how_to/highlight_layer
  135725. * @see https://doc.babylonjs.com/how_to/glow_layer
  135726. */
  135727. effectLayers: Array<EffectLayer>;
  135728. /**
  135729. * Removes the given effect layer from this scene.
  135730. * @param toRemove defines the effect layer to remove
  135731. * @returns the index of the removed effect layer
  135732. */
  135733. removeEffectLayer(toRemove: EffectLayer): number;
  135734. /**
  135735. * Adds the given effect layer to this scene
  135736. * @param newEffectLayer defines the effect layer to add
  135737. */
  135738. addEffectLayer(newEffectLayer: EffectLayer): void;
  135739. }
  135740. /**
  135741. * Defines the layer scene component responsible to manage any effect layers
  135742. * in a given scene.
  135743. */
  135744. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  135745. /**
  135746. * The component name helpfull to identify the component in the list of scene components.
  135747. */
  135748. readonly name: string;
  135749. /**
  135750. * The scene the component belongs to.
  135751. */
  135752. scene: Scene;
  135753. private _engine;
  135754. private _renderEffects;
  135755. private _needStencil;
  135756. private _previousStencilState;
  135757. /**
  135758. * Creates a new instance of the component for the given scene
  135759. * @param scene Defines the scene to register the component in
  135760. */
  135761. constructor(scene: Scene);
  135762. /**
  135763. * Registers the component in a given scene
  135764. */
  135765. register(): void;
  135766. /**
  135767. * Rebuilds the elements related to this component in case of
  135768. * context lost for instance.
  135769. */
  135770. rebuild(): void;
  135771. /**
  135772. * Serializes the component data to the specified json object
  135773. * @param serializationObject The object to serialize to
  135774. */
  135775. serialize(serializationObject: any): void;
  135776. /**
  135777. * Adds all the elements from the container to the scene
  135778. * @param container the container holding the elements
  135779. */
  135780. addFromContainer(container: AbstractScene): void;
  135781. /**
  135782. * Removes all the elements in the container from the scene
  135783. * @param container contains the elements to remove
  135784. * @param dispose if the removed element should be disposed (default: false)
  135785. */
  135786. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  135787. /**
  135788. * Disposes the component and the associated ressources.
  135789. */
  135790. dispose(): void;
  135791. private _isReadyForMesh;
  135792. private _renderMainTexture;
  135793. private _setStencil;
  135794. private _setStencilBack;
  135795. private _draw;
  135796. private _drawCamera;
  135797. private _drawRenderingGroup;
  135798. }
  135799. }
  135800. declare module BABYLON {
  135801. /** @hidden */
  135802. export var glowMapMergePixelShader: {
  135803. name: string;
  135804. shader: string;
  135805. };
  135806. }
  135807. declare module BABYLON {
  135808. /** @hidden */
  135809. export var glowMapMergeVertexShader: {
  135810. name: string;
  135811. shader: string;
  135812. };
  135813. }
  135814. declare module BABYLON {
  135815. interface AbstractScene {
  135816. /**
  135817. * Return a the first highlight layer of the scene with a given name.
  135818. * @param name The name of the highlight layer to look for.
  135819. * @return The highlight layer if found otherwise null.
  135820. */
  135821. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  135822. }
  135823. /**
  135824. * Glow layer options. This helps customizing the behaviour
  135825. * of the glow layer.
  135826. */
  135827. export interface IGlowLayerOptions {
  135828. /**
  135829. * Multiplication factor apply to the canvas size to compute the render target size
  135830. * used to generated the glowing objects (the smaller the faster).
  135831. */
  135832. mainTextureRatio: number;
  135833. /**
  135834. * Enforces a fixed size texture to ensure resize independant blur.
  135835. */
  135836. mainTextureFixedSize?: number;
  135837. /**
  135838. * How big is the kernel of the blur texture.
  135839. */
  135840. blurKernelSize: number;
  135841. /**
  135842. * The camera attached to the layer.
  135843. */
  135844. camera: Nullable<Camera>;
  135845. /**
  135846. * Enable MSAA by chosing the number of samples.
  135847. */
  135848. mainTextureSamples?: number;
  135849. /**
  135850. * The rendering group to draw the layer in.
  135851. */
  135852. renderingGroupId: number;
  135853. }
  135854. /**
  135855. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  135856. *
  135857. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  135858. *
  135859. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  135860. */
  135861. export class GlowLayer extends EffectLayer {
  135862. /**
  135863. * Effect Name of the layer.
  135864. */
  135865. static readonly EffectName: string;
  135866. /**
  135867. * The default blur kernel size used for the glow.
  135868. */
  135869. static DefaultBlurKernelSize: number;
  135870. /**
  135871. * The default texture size ratio used for the glow.
  135872. */
  135873. static DefaultTextureRatio: number;
  135874. /**
  135875. * Sets the kernel size of the blur.
  135876. */
  135877. set blurKernelSize(value: number);
  135878. /**
  135879. * Gets the kernel size of the blur.
  135880. */
  135881. get blurKernelSize(): number;
  135882. /**
  135883. * Sets the glow intensity.
  135884. */
  135885. set intensity(value: number);
  135886. /**
  135887. * Gets the glow intensity.
  135888. */
  135889. get intensity(): number;
  135890. private _options;
  135891. private _intensity;
  135892. private _horizontalBlurPostprocess1;
  135893. private _verticalBlurPostprocess1;
  135894. private _horizontalBlurPostprocess2;
  135895. private _verticalBlurPostprocess2;
  135896. private _blurTexture1;
  135897. private _blurTexture2;
  135898. private _postProcesses1;
  135899. private _postProcesses2;
  135900. private _includedOnlyMeshes;
  135901. private _excludedMeshes;
  135902. private _meshesUsingTheirOwnMaterials;
  135903. /**
  135904. * Callback used to let the user override the color selection on a per mesh basis
  135905. */
  135906. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  135907. /**
  135908. * Callback used to let the user override the texture selection on a per mesh basis
  135909. */
  135910. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  135911. /**
  135912. * Instantiates a new glow Layer and references it to the scene.
  135913. * @param name The name of the layer
  135914. * @param scene The scene to use the layer in
  135915. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  135916. */
  135917. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  135918. /**
  135919. * Get the effect name of the layer.
  135920. * @return The effect name
  135921. */
  135922. getEffectName(): string;
  135923. /**
  135924. * Create the merge effect. This is the shader use to blit the information back
  135925. * to the main canvas at the end of the scene rendering.
  135926. */
  135927. protected _createMergeEffect(): Effect;
  135928. /**
  135929. * Creates the render target textures and post processes used in the glow layer.
  135930. */
  135931. protected _createTextureAndPostProcesses(): void;
  135932. /**
  135933. * Checks for the readiness of the element composing the layer.
  135934. * @param subMesh the mesh to check for
  135935. * @param useInstances specify wether or not to use instances to render the mesh
  135936. * @param emissiveTexture the associated emissive texture used to generate the glow
  135937. * @return true if ready otherwise, false
  135938. */
  135939. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  135940. /**
  135941. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  135942. */
  135943. needStencil(): boolean;
  135944. /**
  135945. * Returns true if the mesh can be rendered, otherwise false.
  135946. * @param mesh The mesh to render
  135947. * @param material The material used on the mesh
  135948. * @returns true if it can be rendered otherwise false
  135949. */
  135950. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  135951. /**
  135952. * Implementation specific of rendering the generating effect on the main canvas.
  135953. * @param effect The effect used to render through
  135954. */
  135955. protected _internalRender(effect: Effect): void;
  135956. /**
  135957. * Sets the required values for both the emissive texture and and the main color.
  135958. */
  135959. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  135960. /**
  135961. * Returns true if the mesh should render, otherwise false.
  135962. * @param mesh The mesh to render
  135963. * @returns true if it should render otherwise false
  135964. */
  135965. protected _shouldRenderMesh(mesh: Mesh): boolean;
  135966. /**
  135967. * Adds specific effects defines.
  135968. * @param defines The defines to add specifics to.
  135969. */
  135970. protected _addCustomEffectDefines(defines: string[]): void;
  135971. /**
  135972. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  135973. * @param mesh The mesh to exclude from the glow layer
  135974. */
  135975. addExcludedMesh(mesh: Mesh): void;
  135976. /**
  135977. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  135978. * @param mesh The mesh to remove
  135979. */
  135980. removeExcludedMesh(mesh: Mesh): void;
  135981. /**
  135982. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  135983. * @param mesh The mesh to include in the glow layer
  135984. */
  135985. addIncludedOnlyMesh(mesh: Mesh): void;
  135986. /**
  135987. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  135988. * @param mesh The mesh to remove
  135989. */
  135990. removeIncludedOnlyMesh(mesh: Mesh): void;
  135991. /**
  135992. * Determine if a given mesh will be used in the glow layer
  135993. * @param mesh The mesh to test
  135994. * @returns true if the mesh will be highlighted by the current glow layer
  135995. */
  135996. hasMesh(mesh: AbstractMesh): boolean;
  135997. /**
  135998. * Defines whether the current material of the mesh should be use to render the effect.
  135999. * @param mesh defines the current mesh to render
  136000. */
  136001. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  136002. /**
  136003. * Add a mesh to be rendered through its own material and not with emissive only.
  136004. * @param mesh The mesh for which we need to use its material
  136005. */
  136006. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  136007. /**
  136008. * Remove a mesh from being rendered through its own material and not with emissive only.
  136009. * @param mesh The mesh for which we need to not use its material
  136010. */
  136011. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  136012. /**
  136013. * Free any resources and references associated to a mesh.
  136014. * Internal use
  136015. * @param mesh The mesh to free.
  136016. * @hidden
  136017. */
  136018. _disposeMesh(mesh: Mesh): void;
  136019. /**
  136020. * Gets the class name of the effect layer
  136021. * @returns the string with the class name of the effect layer
  136022. */
  136023. getClassName(): string;
  136024. /**
  136025. * Serializes this glow layer
  136026. * @returns a serialized glow layer object
  136027. */
  136028. serialize(): any;
  136029. /**
  136030. * Creates a Glow Layer from parsed glow layer data
  136031. * @param parsedGlowLayer defines glow layer data
  136032. * @param scene defines the current scene
  136033. * @param rootUrl defines the root URL containing the glow layer information
  136034. * @returns a parsed Glow Layer
  136035. */
  136036. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  136037. }
  136038. }
  136039. declare module BABYLON {
  136040. /** @hidden */
  136041. export var glowBlurPostProcessPixelShader: {
  136042. name: string;
  136043. shader: string;
  136044. };
  136045. }
  136046. declare module BABYLON {
  136047. interface AbstractScene {
  136048. /**
  136049. * Return a the first highlight layer of the scene with a given name.
  136050. * @param name The name of the highlight layer to look for.
  136051. * @return The highlight layer if found otherwise null.
  136052. */
  136053. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  136054. }
  136055. /**
  136056. * Highlight layer options. This helps customizing the behaviour
  136057. * of the highlight layer.
  136058. */
  136059. export interface IHighlightLayerOptions {
  136060. /**
  136061. * Multiplication factor apply to the canvas size to compute the render target size
  136062. * used to generated the glowing objects (the smaller the faster).
  136063. */
  136064. mainTextureRatio: number;
  136065. /**
  136066. * Enforces a fixed size texture to ensure resize independant blur.
  136067. */
  136068. mainTextureFixedSize?: number;
  136069. /**
  136070. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  136071. * of the picture to blur (the smaller the faster).
  136072. */
  136073. blurTextureSizeRatio: number;
  136074. /**
  136075. * How big in texel of the blur texture is the vertical blur.
  136076. */
  136077. blurVerticalSize: number;
  136078. /**
  136079. * How big in texel of the blur texture is the horizontal blur.
  136080. */
  136081. blurHorizontalSize: number;
  136082. /**
  136083. * Alpha blending mode used to apply the blur. Default is combine.
  136084. */
  136085. alphaBlendingMode: number;
  136086. /**
  136087. * The camera attached to the layer.
  136088. */
  136089. camera: Nullable<Camera>;
  136090. /**
  136091. * Should we display highlight as a solid stroke?
  136092. */
  136093. isStroke?: boolean;
  136094. /**
  136095. * The rendering group to draw the layer in.
  136096. */
  136097. renderingGroupId: number;
  136098. }
  136099. /**
  136100. * The highlight layer Helps adding a glow effect around a mesh.
  136101. *
  136102. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  136103. * glowy meshes to your scene.
  136104. *
  136105. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  136106. */
  136107. export class HighlightLayer extends EffectLayer {
  136108. name: string;
  136109. /**
  136110. * Effect Name of the highlight layer.
  136111. */
  136112. static readonly EffectName: string;
  136113. /**
  136114. * The neutral color used during the preparation of the glow effect.
  136115. * This is black by default as the blend operation is a blend operation.
  136116. */
  136117. static NeutralColor: Color4;
  136118. /**
  136119. * Stencil value used for glowing meshes.
  136120. */
  136121. static GlowingMeshStencilReference: number;
  136122. /**
  136123. * Stencil value used for the other meshes in the scene.
  136124. */
  136125. static NormalMeshStencilReference: number;
  136126. /**
  136127. * Specifies whether or not the inner glow is ACTIVE in the layer.
  136128. */
  136129. innerGlow: boolean;
  136130. /**
  136131. * Specifies whether or not the outer glow is ACTIVE in the layer.
  136132. */
  136133. outerGlow: boolean;
  136134. /**
  136135. * Specifies the horizontal size of the blur.
  136136. */
  136137. set blurHorizontalSize(value: number);
  136138. /**
  136139. * Specifies the vertical size of the blur.
  136140. */
  136141. set blurVerticalSize(value: number);
  136142. /**
  136143. * Gets the horizontal size of the blur.
  136144. */
  136145. get blurHorizontalSize(): number;
  136146. /**
  136147. * Gets the vertical size of the blur.
  136148. */
  136149. get blurVerticalSize(): number;
  136150. /**
  136151. * An event triggered when the highlight layer is being blurred.
  136152. */
  136153. onBeforeBlurObservable: Observable<HighlightLayer>;
  136154. /**
  136155. * An event triggered when the highlight layer has been blurred.
  136156. */
  136157. onAfterBlurObservable: Observable<HighlightLayer>;
  136158. private _instanceGlowingMeshStencilReference;
  136159. private _options;
  136160. private _downSamplePostprocess;
  136161. private _horizontalBlurPostprocess;
  136162. private _verticalBlurPostprocess;
  136163. private _blurTexture;
  136164. private _meshes;
  136165. private _excludedMeshes;
  136166. /**
  136167. * Instantiates a new highlight Layer and references it to the scene..
  136168. * @param name The name of the layer
  136169. * @param scene The scene to use the layer in
  136170. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  136171. */
  136172. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  136173. /**
  136174. * Get the effect name of the layer.
  136175. * @return The effect name
  136176. */
  136177. getEffectName(): string;
  136178. /**
  136179. * Create the merge effect. This is the shader use to blit the information back
  136180. * to the main canvas at the end of the scene rendering.
  136181. */
  136182. protected _createMergeEffect(): Effect;
  136183. /**
  136184. * Creates the render target textures and post processes used in the highlight layer.
  136185. */
  136186. protected _createTextureAndPostProcesses(): void;
  136187. /**
  136188. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  136189. */
  136190. needStencil(): boolean;
  136191. /**
  136192. * Checks for the readiness of the element composing the layer.
  136193. * @param subMesh the mesh to check for
  136194. * @param useInstances specify wether or not to use instances to render the mesh
  136195. * @param emissiveTexture the associated emissive texture used to generate the glow
  136196. * @return true if ready otherwise, false
  136197. */
  136198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136199. /**
  136200. * Implementation specific of rendering the generating effect on the main canvas.
  136201. * @param effect The effect used to render through
  136202. */
  136203. protected _internalRender(effect: Effect): void;
  136204. /**
  136205. * Returns true if the layer contains information to display, otherwise false.
  136206. */
  136207. shouldRender(): boolean;
  136208. /**
  136209. * Returns true if the mesh should render, otherwise false.
  136210. * @param mesh The mesh to render
  136211. * @returns true if it should render otherwise false
  136212. */
  136213. protected _shouldRenderMesh(mesh: Mesh): boolean;
  136214. /**
  136215. * Returns true if the mesh can be rendered, otherwise false.
  136216. * @param mesh The mesh to render
  136217. * @param material The material used on the mesh
  136218. * @returns true if it can be rendered otherwise false
  136219. */
  136220. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  136221. /**
  136222. * Adds specific effects defines.
  136223. * @param defines The defines to add specifics to.
  136224. */
  136225. protected _addCustomEffectDefines(defines: string[]): void;
  136226. /**
  136227. * Sets the required values for both the emissive texture and and the main color.
  136228. */
  136229. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  136230. /**
  136231. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  136232. * @param mesh The mesh to exclude from the highlight layer
  136233. */
  136234. addExcludedMesh(mesh: Mesh): void;
  136235. /**
  136236. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  136237. * @param mesh The mesh to highlight
  136238. */
  136239. removeExcludedMesh(mesh: Mesh): void;
  136240. /**
  136241. * Determine if a given mesh will be highlighted by the current HighlightLayer
  136242. * @param mesh mesh to test
  136243. * @returns true if the mesh will be highlighted by the current HighlightLayer
  136244. */
  136245. hasMesh(mesh: AbstractMesh): boolean;
  136246. /**
  136247. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  136248. * @param mesh The mesh to highlight
  136249. * @param color The color of the highlight
  136250. * @param glowEmissiveOnly Extract the glow from the emissive texture
  136251. */
  136252. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  136253. /**
  136254. * Remove a mesh from the highlight layer in order to make it stop glowing.
  136255. * @param mesh The mesh to highlight
  136256. */
  136257. removeMesh(mesh: Mesh): void;
  136258. /**
  136259. * Remove all the meshes currently referenced in the highlight layer
  136260. */
  136261. removeAllMeshes(): void;
  136262. /**
  136263. * Force the stencil to the normal expected value for none glowing parts
  136264. */
  136265. private _defaultStencilReference;
  136266. /**
  136267. * Free any resources and references associated to a mesh.
  136268. * Internal use
  136269. * @param mesh The mesh to free.
  136270. * @hidden
  136271. */
  136272. _disposeMesh(mesh: Mesh): void;
  136273. /**
  136274. * Dispose the highlight layer and free resources.
  136275. */
  136276. dispose(): void;
  136277. /**
  136278. * Gets the class name of the effect layer
  136279. * @returns the string with the class name of the effect layer
  136280. */
  136281. getClassName(): string;
  136282. /**
  136283. * Serializes this Highlight layer
  136284. * @returns a serialized Highlight layer object
  136285. */
  136286. serialize(): any;
  136287. /**
  136288. * Creates a Highlight layer from parsed Highlight layer data
  136289. * @param parsedHightlightLayer defines the Highlight layer data
  136290. * @param scene defines the current scene
  136291. * @param rootUrl defines the root URL containing the Highlight layer information
  136292. * @returns a parsed Highlight layer
  136293. */
  136294. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  136295. }
  136296. }
  136297. declare module BABYLON {
  136298. interface AbstractScene {
  136299. /**
  136300. * The list of layers (background and foreground) of the scene
  136301. */
  136302. layers: Array<Layer>;
  136303. }
  136304. /**
  136305. * Defines the layer scene component responsible to manage any layers
  136306. * in a given scene.
  136307. */
  136308. export class LayerSceneComponent implements ISceneComponent {
  136309. /**
  136310. * The component name helpfull to identify the component in the list of scene components.
  136311. */
  136312. readonly name: string;
  136313. /**
  136314. * The scene the component belongs to.
  136315. */
  136316. scene: Scene;
  136317. private _engine;
  136318. /**
  136319. * Creates a new instance of the component for the given scene
  136320. * @param scene Defines the scene to register the component in
  136321. */
  136322. constructor(scene: Scene);
  136323. /**
  136324. * Registers the component in a given scene
  136325. */
  136326. register(): void;
  136327. /**
  136328. * Rebuilds the elements related to this component in case of
  136329. * context lost for instance.
  136330. */
  136331. rebuild(): void;
  136332. /**
  136333. * Disposes the component and the associated ressources.
  136334. */
  136335. dispose(): void;
  136336. private _draw;
  136337. private _drawCameraPredicate;
  136338. private _drawCameraBackground;
  136339. private _drawCameraForeground;
  136340. private _drawRenderTargetPredicate;
  136341. private _drawRenderTargetBackground;
  136342. private _drawRenderTargetForeground;
  136343. /**
  136344. * Adds all the elements from the container to the scene
  136345. * @param container the container holding the elements
  136346. */
  136347. addFromContainer(container: AbstractScene): void;
  136348. /**
  136349. * Removes all the elements in the container from the scene
  136350. * @param container contains the elements to remove
  136351. * @param dispose if the removed element should be disposed (default: false)
  136352. */
  136353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136354. }
  136355. }
  136356. declare module BABYLON {
  136357. /** @hidden */
  136358. export var layerPixelShader: {
  136359. name: string;
  136360. shader: string;
  136361. };
  136362. }
  136363. declare module BABYLON {
  136364. /** @hidden */
  136365. export var layerVertexShader: {
  136366. name: string;
  136367. shader: string;
  136368. };
  136369. }
  136370. declare module BABYLON {
  136371. /**
  136372. * This represents a full screen 2d layer.
  136373. * This can be useful to display a picture in the background of your scene for instance.
  136374. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136375. */
  136376. export class Layer {
  136377. /**
  136378. * Define the name of the layer.
  136379. */
  136380. name: string;
  136381. /**
  136382. * Define the texture the layer should display.
  136383. */
  136384. texture: Nullable<Texture>;
  136385. /**
  136386. * Is the layer in background or foreground.
  136387. */
  136388. isBackground: boolean;
  136389. /**
  136390. * Define the color of the layer (instead of texture).
  136391. */
  136392. color: Color4;
  136393. /**
  136394. * Define the scale of the layer in order to zoom in out of the texture.
  136395. */
  136396. scale: Vector2;
  136397. /**
  136398. * Define an offset for the layer in order to shift the texture.
  136399. */
  136400. offset: Vector2;
  136401. /**
  136402. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  136403. */
  136404. alphaBlendingMode: number;
  136405. /**
  136406. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  136407. * Alpha test will not mix with the background color in case of transparency.
  136408. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  136409. */
  136410. alphaTest: boolean;
  136411. /**
  136412. * Define a mask to restrict the layer to only some of the scene cameras.
  136413. */
  136414. layerMask: number;
  136415. /**
  136416. * Define the list of render target the layer is visible into.
  136417. */
  136418. renderTargetTextures: RenderTargetTexture[];
  136419. /**
  136420. * Define if the layer is only used in renderTarget or if it also
  136421. * renders in the main frame buffer of the canvas.
  136422. */
  136423. renderOnlyInRenderTargetTextures: boolean;
  136424. private _scene;
  136425. private _vertexBuffers;
  136426. private _indexBuffer;
  136427. private _effect;
  136428. private _previousDefines;
  136429. /**
  136430. * An event triggered when the layer is disposed.
  136431. */
  136432. onDisposeObservable: Observable<Layer>;
  136433. private _onDisposeObserver;
  136434. /**
  136435. * Back compatibility with callback before the onDisposeObservable existed.
  136436. * The set callback will be triggered when the layer has been disposed.
  136437. */
  136438. set onDispose(callback: () => void);
  136439. /**
  136440. * An event triggered before rendering the scene
  136441. */
  136442. onBeforeRenderObservable: Observable<Layer>;
  136443. private _onBeforeRenderObserver;
  136444. /**
  136445. * Back compatibility with callback before the onBeforeRenderObservable existed.
  136446. * The set callback will be triggered just before rendering the layer.
  136447. */
  136448. set onBeforeRender(callback: () => void);
  136449. /**
  136450. * An event triggered after rendering the scene
  136451. */
  136452. onAfterRenderObservable: Observable<Layer>;
  136453. private _onAfterRenderObserver;
  136454. /**
  136455. * Back compatibility with callback before the onAfterRenderObservable existed.
  136456. * The set callback will be triggered just after rendering the layer.
  136457. */
  136458. set onAfterRender(callback: () => void);
  136459. /**
  136460. * Instantiates a new layer.
  136461. * This represents a full screen 2d layer.
  136462. * This can be useful to display a picture in the background of your scene for instance.
  136463. * @see https://www.babylonjs-playground.com/#08A2BS#1
  136464. * @param name Define the name of the layer in the scene
  136465. * @param imgUrl Define the url of the texture to display in the layer
  136466. * @param scene Define the scene the layer belongs to
  136467. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  136468. * @param color Defines a color for the layer
  136469. */
  136470. constructor(
  136471. /**
  136472. * Define the name of the layer.
  136473. */
  136474. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  136475. private _createIndexBuffer;
  136476. /** @hidden */
  136477. _rebuild(): void;
  136478. /**
  136479. * Renders the layer in the scene.
  136480. */
  136481. render(): void;
  136482. /**
  136483. * Disposes and releases the associated ressources.
  136484. */
  136485. dispose(): void;
  136486. }
  136487. }
  136488. declare module BABYLON {
  136489. /** @hidden */
  136490. export var lensFlarePixelShader: {
  136491. name: string;
  136492. shader: string;
  136493. };
  136494. }
  136495. declare module BABYLON {
  136496. /** @hidden */
  136497. export var lensFlareVertexShader: {
  136498. name: string;
  136499. shader: string;
  136500. };
  136501. }
  136502. declare module BABYLON {
  136503. /**
  136504. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136505. * It is usually composed of several `lensFlare`.
  136506. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136507. */
  136508. export class LensFlareSystem {
  136509. /**
  136510. * Define the name of the lens flare system
  136511. */
  136512. name: string;
  136513. /**
  136514. * List of lens flares used in this system.
  136515. */
  136516. lensFlares: LensFlare[];
  136517. /**
  136518. * Define a limit from the border the lens flare can be visible.
  136519. */
  136520. borderLimit: number;
  136521. /**
  136522. * Define a viewport border we do not want to see the lens flare in.
  136523. */
  136524. viewportBorder: number;
  136525. /**
  136526. * Define a predicate which could limit the list of meshes able to occlude the effect.
  136527. */
  136528. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  136529. /**
  136530. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  136531. */
  136532. layerMask: number;
  136533. /**
  136534. * Define the id of the lens flare system in the scene.
  136535. * (equal to name by default)
  136536. */
  136537. id: string;
  136538. private _scene;
  136539. private _emitter;
  136540. private _vertexBuffers;
  136541. private _indexBuffer;
  136542. private _effect;
  136543. private _positionX;
  136544. private _positionY;
  136545. private _isEnabled;
  136546. /** @hidden */
  136547. static _SceneComponentInitialization: (scene: Scene) => void;
  136548. /**
  136549. * Instantiates a lens flare system.
  136550. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  136551. * It is usually composed of several `lensFlare`.
  136552. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136553. * @param name Define the name of the lens flare system in the scene
  136554. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  136555. * @param scene Define the scene the lens flare system belongs to
  136556. */
  136557. constructor(
  136558. /**
  136559. * Define the name of the lens flare system
  136560. */
  136561. name: string, emitter: any, scene: Scene);
  136562. /**
  136563. * Define if the lens flare system is enabled.
  136564. */
  136565. get isEnabled(): boolean;
  136566. set isEnabled(value: boolean);
  136567. /**
  136568. * Get the scene the effects belongs to.
  136569. * @returns the scene holding the lens flare system
  136570. */
  136571. getScene(): Scene;
  136572. /**
  136573. * Get the emitter of the lens flare system.
  136574. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136575. * @returns the emitter of the lens flare system
  136576. */
  136577. getEmitter(): any;
  136578. /**
  136579. * Set the emitter of the lens flare system.
  136580. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  136581. * @param newEmitter Define the new emitter of the system
  136582. */
  136583. setEmitter(newEmitter: any): void;
  136584. /**
  136585. * Get the lens flare system emitter position.
  136586. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  136587. * @returns the position
  136588. */
  136589. getEmitterPosition(): Vector3;
  136590. /**
  136591. * @hidden
  136592. */
  136593. computeEffectivePosition(globalViewport: Viewport): boolean;
  136594. /** @hidden */
  136595. _isVisible(): boolean;
  136596. /**
  136597. * @hidden
  136598. */
  136599. render(): boolean;
  136600. /**
  136601. * Dispose and release the lens flare with its associated resources.
  136602. */
  136603. dispose(): void;
  136604. /**
  136605. * Parse a lens flare system from a JSON repressentation
  136606. * @param parsedLensFlareSystem Define the JSON to parse
  136607. * @param scene Define the scene the parsed system should be instantiated in
  136608. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  136609. * @returns the parsed system
  136610. */
  136611. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  136612. /**
  136613. * Serialize the current Lens Flare System into a JSON representation.
  136614. * @returns the serialized JSON
  136615. */
  136616. serialize(): any;
  136617. }
  136618. }
  136619. declare module BABYLON {
  136620. /**
  136621. * This represents one of the lens effect in a `lensFlareSystem`.
  136622. * It controls one of the indiviual texture used in the effect.
  136623. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136624. */
  136625. export class LensFlare {
  136626. /**
  136627. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136628. */
  136629. size: number;
  136630. /**
  136631. * 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.
  136632. */
  136633. position: number;
  136634. /**
  136635. * Define the lens color.
  136636. */
  136637. color: Color3;
  136638. /**
  136639. * Define the lens texture.
  136640. */
  136641. texture: Nullable<Texture>;
  136642. /**
  136643. * Define the alpha mode to render this particular lens.
  136644. */
  136645. alphaMode: number;
  136646. private _system;
  136647. /**
  136648. * Creates a new Lens Flare.
  136649. * This represents one of the lens effect in a `lensFlareSystem`.
  136650. * It controls one of the indiviual texture used in the effect.
  136651. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136652. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  136653. * @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.
  136654. * @param color Define the lens color
  136655. * @param imgUrl Define the lens texture url
  136656. * @param system Define the `lensFlareSystem` this flare is part of
  136657. * @returns The newly created Lens Flare
  136658. */
  136659. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  136660. /**
  136661. * Instantiates a new Lens Flare.
  136662. * This represents one of the lens effect in a `lensFlareSystem`.
  136663. * It controls one of the indiviual texture used in the effect.
  136664. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136665. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  136666. * @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.
  136667. * @param color Define the lens color
  136668. * @param imgUrl Define the lens texture url
  136669. * @param system Define the `lensFlareSystem` this flare is part of
  136670. */
  136671. constructor(
  136672. /**
  136673. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  136674. */
  136675. size: number,
  136676. /**
  136677. * 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.
  136678. */
  136679. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  136680. /**
  136681. * Dispose and release the lens flare with its associated resources.
  136682. */
  136683. dispose(): void;
  136684. }
  136685. }
  136686. declare module BABYLON {
  136687. interface AbstractScene {
  136688. /**
  136689. * The list of lens flare system added to the scene
  136690. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  136691. */
  136692. lensFlareSystems: Array<LensFlareSystem>;
  136693. /**
  136694. * Removes the given lens flare system from this scene.
  136695. * @param toRemove The lens flare system to remove
  136696. * @returns The index of the removed lens flare system
  136697. */
  136698. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  136699. /**
  136700. * Adds the given lens flare system to this scene
  136701. * @param newLensFlareSystem The lens flare system to add
  136702. */
  136703. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  136704. /**
  136705. * Gets a lens flare system using its name
  136706. * @param name defines the name to look for
  136707. * @returns the lens flare system or null if not found
  136708. */
  136709. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  136710. /**
  136711. * Gets a lens flare system using its id
  136712. * @param id defines the id to look for
  136713. * @returns the lens flare system or null if not found
  136714. */
  136715. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  136716. }
  136717. /**
  136718. * Defines the lens flare scene component responsible to manage any lens flares
  136719. * in a given scene.
  136720. */
  136721. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  136722. /**
  136723. * The component name helpfull to identify the component in the list of scene components.
  136724. */
  136725. readonly name: string;
  136726. /**
  136727. * The scene the component belongs to.
  136728. */
  136729. scene: Scene;
  136730. /**
  136731. * Creates a new instance of the component for the given scene
  136732. * @param scene Defines the scene to register the component in
  136733. */
  136734. constructor(scene: Scene);
  136735. /**
  136736. * Registers the component in a given scene
  136737. */
  136738. register(): void;
  136739. /**
  136740. * Rebuilds the elements related to this component in case of
  136741. * context lost for instance.
  136742. */
  136743. rebuild(): void;
  136744. /**
  136745. * Adds all the elements from the container to the scene
  136746. * @param container the container holding the elements
  136747. */
  136748. addFromContainer(container: AbstractScene): void;
  136749. /**
  136750. * Removes all the elements in the container from the scene
  136751. * @param container contains the elements to remove
  136752. * @param dispose if the removed element should be disposed (default: false)
  136753. */
  136754. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  136755. /**
  136756. * Serializes the component data to the specified json object
  136757. * @param serializationObject The object to serialize to
  136758. */
  136759. serialize(serializationObject: any): void;
  136760. /**
  136761. * Disposes the component and the associated ressources.
  136762. */
  136763. dispose(): void;
  136764. private _draw;
  136765. }
  136766. }
  136767. declare module BABYLON {
  136768. /** @hidden */
  136769. export var depthPixelShader: {
  136770. name: string;
  136771. shader: string;
  136772. };
  136773. }
  136774. declare module BABYLON {
  136775. /** @hidden */
  136776. export var depthVertexShader: {
  136777. name: string;
  136778. shader: string;
  136779. };
  136780. }
  136781. declare module BABYLON {
  136782. /**
  136783. * This represents a depth renderer in Babylon.
  136784. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  136785. */
  136786. export class DepthRenderer {
  136787. private _scene;
  136788. private _depthMap;
  136789. private _effect;
  136790. private readonly _storeNonLinearDepth;
  136791. private readonly _clearColor;
  136792. /** Get if the depth renderer is using packed depth or not */
  136793. readonly isPacked: boolean;
  136794. private _cachedDefines;
  136795. private _camera;
  136796. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  136797. enabled: boolean;
  136798. /**
  136799. * Specifiess that the depth renderer will only be used within
  136800. * the camera it is created for.
  136801. * This can help forcing its rendering during the camera processing.
  136802. */
  136803. useOnlyInActiveCamera: boolean;
  136804. /** @hidden */
  136805. static _SceneComponentInitialization: (scene: Scene) => void;
  136806. /**
  136807. * Instantiates a depth renderer
  136808. * @param scene The scene the renderer belongs to
  136809. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  136810. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  136811. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  136812. */
  136813. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  136814. /**
  136815. * Creates the depth rendering effect and checks if the effect is ready.
  136816. * @param subMesh The submesh to be used to render the depth map of
  136817. * @param useInstances If multiple world instances should be used
  136818. * @returns if the depth renderer is ready to render the depth map
  136819. */
  136820. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  136821. /**
  136822. * Gets the texture which the depth map will be written to.
  136823. * @returns The depth map texture
  136824. */
  136825. getDepthMap(): RenderTargetTexture;
  136826. /**
  136827. * Disposes of the depth renderer.
  136828. */
  136829. dispose(): void;
  136830. }
  136831. }
  136832. declare module BABYLON {
  136833. /** @hidden */
  136834. export var minmaxReduxPixelShader: {
  136835. name: string;
  136836. shader: string;
  136837. };
  136838. }
  136839. declare module BABYLON {
  136840. /**
  136841. * This class computes a min/max reduction from a texture: it means it computes the minimum
  136842. * and maximum values from all values of the texture.
  136843. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  136844. * The source values are read from the red channel of the texture.
  136845. */
  136846. export class MinMaxReducer {
  136847. /**
  136848. * Observable triggered when the computation has been performed
  136849. */
  136850. onAfterReductionPerformed: Observable<{
  136851. min: number;
  136852. max: number;
  136853. }>;
  136854. protected _camera: Camera;
  136855. protected _sourceTexture: Nullable<RenderTargetTexture>;
  136856. protected _reductionSteps: Nullable<Array<PostProcess>>;
  136857. protected _postProcessManager: PostProcessManager;
  136858. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  136859. protected _forceFullscreenViewport: boolean;
  136860. /**
  136861. * Creates a min/max reducer
  136862. * @param camera The camera to use for the post processes
  136863. */
  136864. constructor(camera: Camera);
  136865. /**
  136866. * Gets the texture used to read the values from.
  136867. */
  136868. get sourceTexture(): Nullable<RenderTargetTexture>;
  136869. /**
  136870. * Sets the source texture to read the values from.
  136871. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  136872. * because in such textures '1' value must not be taken into account to compute the maximum
  136873. * as this value is used to clear the texture.
  136874. * Note that the computation is not activated by calling this function, you must call activate() for that!
  136875. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  136876. * @param depthRedux Indicates if the texture is a depth texture or not
  136877. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  136878. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136879. */
  136880. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136881. /**
  136882. * Defines the refresh rate of the computation.
  136883. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  136884. */
  136885. get refreshRate(): number;
  136886. set refreshRate(value: number);
  136887. protected _activated: boolean;
  136888. /**
  136889. * Gets the activation status of the reducer
  136890. */
  136891. get activated(): boolean;
  136892. /**
  136893. * Activates the reduction computation.
  136894. * When activated, the observers registered in onAfterReductionPerformed are
  136895. * called after the compuation is performed
  136896. */
  136897. activate(): void;
  136898. /**
  136899. * Deactivates the reduction computation.
  136900. */
  136901. deactivate(): void;
  136902. /**
  136903. * Disposes the min/max reducer
  136904. * @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.
  136905. */
  136906. dispose(disposeAll?: boolean): void;
  136907. }
  136908. }
  136909. declare module BABYLON {
  136910. /**
  136911. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  136912. */
  136913. export class DepthReducer extends MinMaxReducer {
  136914. private _depthRenderer;
  136915. private _depthRendererId;
  136916. /**
  136917. * Gets the depth renderer used for the computation.
  136918. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  136919. */
  136920. get depthRenderer(): Nullable<DepthRenderer>;
  136921. /**
  136922. * Creates a depth reducer
  136923. * @param camera The camera used to render the depth texture
  136924. */
  136925. constructor(camera: Camera);
  136926. /**
  136927. * Sets the depth renderer to use to generate the depth map
  136928. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  136929. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  136930. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  136931. */
  136932. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  136933. /** @hidden */
  136934. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  136935. /**
  136936. * Activates the reduction computation.
  136937. * When activated, the observers registered in onAfterReductionPerformed are
  136938. * called after the compuation is performed
  136939. */
  136940. activate(): void;
  136941. /**
  136942. * Deactivates the reduction computation.
  136943. */
  136944. deactivate(): void;
  136945. /**
  136946. * Disposes the depth reducer
  136947. * @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.
  136948. */
  136949. dispose(disposeAll?: boolean): void;
  136950. }
  136951. }
  136952. declare module BABYLON {
  136953. /**
  136954. * A CSM implementation allowing casting shadows on large scenes.
  136955. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  136956. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  136957. */
  136958. export class CascadedShadowGenerator extends ShadowGenerator {
  136959. private static readonly frustumCornersNDCSpace;
  136960. /**
  136961. * Name of the CSM class
  136962. */
  136963. static CLASSNAME: string;
  136964. /**
  136965. * Defines the default number of cascades used by the CSM.
  136966. */
  136967. static readonly DEFAULT_CASCADES_COUNT: number;
  136968. /**
  136969. * Defines the minimum number of cascades used by the CSM.
  136970. */
  136971. static readonly MIN_CASCADES_COUNT: number;
  136972. /**
  136973. * Defines the maximum number of cascades used by the CSM.
  136974. */
  136975. static readonly MAX_CASCADES_COUNT: number;
  136976. protected _validateFilter(filter: number): number;
  136977. /**
  136978. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  136979. */
  136980. penumbraDarkness: number;
  136981. private _numCascades;
  136982. /**
  136983. * Gets or set the number of cascades used by the CSM.
  136984. */
  136985. get numCascades(): number;
  136986. set numCascades(value: number);
  136987. /**
  136988. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  136989. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  136990. */
  136991. stabilizeCascades: boolean;
  136992. private _freezeShadowCastersBoundingInfo;
  136993. private _freezeShadowCastersBoundingInfoObservable;
  136994. /**
  136995. * Enables or disables the shadow casters bounding info computation.
  136996. * If your shadow casters don't move, you can disable this feature.
  136997. * If it is enabled, the bounding box computation is done every frame.
  136998. */
  136999. get freezeShadowCastersBoundingInfo(): boolean;
  137000. set freezeShadowCastersBoundingInfo(freeze: boolean);
  137001. private _scbiMin;
  137002. private _scbiMax;
  137003. protected _computeShadowCastersBoundingInfo(): void;
  137004. protected _shadowCastersBoundingInfo: BoundingInfo;
  137005. /**
  137006. * Gets or sets the shadow casters bounding info.
  137007. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  137008. * so that the system won't overwrite the bounds you provide
  137009. */
  137010. get shadowCastersBoundingInfo(): BoundingInfo;
  137011. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  137012. protected _breaksAreDirty: boolean;
  137013. protected _minDistance: number;
  137014. protected _maxDistance: number;
  137015. /**
  137016. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  137017. *
  137018. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  137019. * If you don't know these values, simply leave them to their defaults and don't call this function.
  137020. * @param min minimal distance for the breaks (default to 0.)
  137021. * @param max maximal distance for the breaks (default to 1.)
  137022. */
  137023. setMinMaxDistance(min: number, max: number): void;
  137024. /** Gets the minimal distance used in the cascade break computation */
  137025. get minDistance(): number;
  137026. /** Gets the maximal distance used in the cascade break computation */
  137027. get maxDistance(): number;
  137028. /**
  137029. * Gets the class name of that object
  137030. * @returns "CascadedShadowGenerator"
  137031. */
  137032. getClassName(): string;
  137033. private _cascadeMinExtents;
  137034. private _cascadeMaxExtents;
  137035. /**
  137036. * Gets a cascade minimum extents
  137037. * @param cascadeIndex index of the cascade
  137038. * @returns the minimum cascade extents
  137039. */
  137040. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  137041. /**
  137042. * Gets a cascade maximum extents
  137043. * @param cascadeIndex index of the cascade
  137044. * @returns the maximum cascade extents
  137045. */
  137046. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  137047. private _cascades;
  137048. private _currentLayer;
  137049. private _viewSpaceFrustumsZ;
  137050. private _viewMatrices;
  137051. private _projectionMatrices;
  137052. private _transformMatrices;
  137053. private _transformMatricesAsArray;
  137054. private _frustumLengths;
  137055. private _lightSizeUVCorrection;
  137056. private _depthCorrection;
  137057. private _frustumCornersWorldSpace;
  137058. private _frustumCenter;
  137059. private _shadowCameraPos;
  137060. private _shadowMaxZ;
  137061. /**
  137062. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  137063. * It defaults to camera.maxZ
  137064. */
  137065. get shadowMaxZ(): number;
  137066. /**
  137067. * Sets the shadow max z distance.
  137068. */
  137069. set shadowMaxZ(value: number);
  137070. protected _debug: boolean;
  137071. /**
  137072. * Gets or sets the debug flag.
  137073. * When enabled, the cascades are materialized by different colors on the screen.
  137074. */
  137075. get debug(): boolean;
  137076. set debug(dbg: boolean);
  137077. private _depthClamp;
  137078. /**
  137079. * Gets or sets the depth clamping value.
  137080. *
  137081. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  137082. * to account for the shadow casters far away.
  137083. *
  137084. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  137085. */
  137086. get depthClamp(): boolean;
  137087. set depthClamp(value: boolean);
  137088. private _cascadeBlendPercentage;
  137089. /**
  137090. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  137091. * It defaults to 0.1 (10% blending).
  137092. */
  137093. get cascadeBlendPercentage(): number;
  137094. set cascadeBlendPercentage(value: number);
  137095. private _lambda;
  137096. /**
  137097. * Gets or set the lambda parameter.
  137098. * This parameter is used to split the camera frustum and create the cascades.
  137099. * 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.
  137100. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  137101. */
  137102. get lambda(): number;
  137103. set lambda(value: number);
  137104. /**
  137105. * Gets the view matrix corresponding to a given cascade
  137106. * @param cascadeNum cascade to retrieve the view matrix from
  137107. * @returns the cascade view matrix
  137108. */
  137109. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  137110. /**
  137111. * Gets the projection matrix corresponding to a given cascade
  137112. * @param cascadeNum cascade to retrieve the projection matrix from
  137113. * @returns the cascade projection matrix
  137114. */
  137115. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  137116. /**
  137117. * Gets the transformation matrix corresponding to a given cascade
  137118. * @param cascadeNum cascade to retrieve the transformation matrix from
  137119. * @returns the cascade transformation matrix
  137120. */
  137121. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  137122. private _depthRenderer;
  137123. /**
  137124. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  137125. *
  137126. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  137127. *
  137128. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  137129. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  137130. * @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
  137131. */
  137132. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  137133. private _depthReducer;
  137134. private _autoCalcDepthBounds;
  137135. /**
  137136. * Gets or sets the autoCalcDepthBounds property.
  137137. *
  137138. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  137139. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  137140. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  137141. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  137142. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  137143. */
  137144. get autoCalcDepthBounds(): boolean;
  137145. set autoCalcDepthBounds(value: boolean);
  137146. /**
  137147. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  137148. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  137149. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  137150. * for setting the refresh rate on the renderer yourself!
  137151. */
  137152. get autoCalcDepthBoundsRefreshRate(): number;
  137153. set autoCalcDepthBoundsRefreshRate(value: number);
  137154. /**
  137155. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  137156. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  137157. * you change the camera near/far planes!
  137158. */
  137159. splitFrustum(): void;
  137160. private _splitFrustum;
  137161. private _computeMatrices;
  137162. private _computeFrustumInWorldSpace;
  137163. private _computeCascadeFrustum;
  137164. /**
  137165. * Support test.
  137166. */
  137167. static get IsSupported(): boolean;
  137168. /** @hidden */
  137169. static _SceneComponentInitialization: (scene: Scene) => void;
  137170. /**
  137171. * Creates a Cascaded Shadow Generator object.
  137172. * A ShadowGenerator is the required tool to use the shadows.
  137173. * Each directional light casting shadows needs to use its own ShadowGenerator.
  137174. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  137175. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  137176. * @param light The directional light object generating the shadows.
  137177. * @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.
  137178. */
  137179. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  137180. protected _initializeGenerator(): void;
  137181. protected _createTargetRenderTexture(): void;
  137182. protected _initializeShadowMap(): void;
  137183. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  137184. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  137185. /**
  137186. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  137187. * @param defines Defines of the material we want to update
  137188. * @param lightIndex Index of the light in the enabled light list of the material
  137189. */
  137190. prepareDefines(defines: any, lightIndex: number): void;
  137191. /**
  137192. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  137193. * defined in the generator but impacting the effect).
  137194. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  137195. * @param effect The effect we are binfing the information for
  137196. */
  137197. bindShadowLight(lightIndex: string, effect: Effect): void;
  137198. /**
  137199. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  137200. * (eq to view projection * shadow projection matrices)
  137201. * @returns The transform matrix used to create the shadow map
  137202. */
  137203. getTransformMatrix(): Matrix;
  137204. /**
  137205. * Disposes the ShadowGenerator.
  137206. * Returns nothing.
  137207. */
  137208. dispose(): void;
  137209. /**
  137210. * Serializes the shadow generator setup to a json object.
  137211. * @returns The serialized JSON object
  137212. */
  137213. serialize(): any;
  137214. /**
  137215. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  137216. * @param parsedShadowGenerator The JSON object to parse
  137217. * @param scene The scene to create the shadow map for
  137218. * @returns The parsed shadow generator
  137219. */
  137220. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  137221. }
  137222. }
  137223. declare module BABYLON {
  137224. /**
  137225. * Defines the shadow generator component responsible to manage any shadow generators
  137226. * in a given scene.
  137227. */
  137228. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  137229. /**
  137230. * The component name helpfull to identify the component in the list of scene components.
  137231. */
  137232. readonly name: string;
  137233. /**
  137234. * The scene the component belongs to.
  137235. */
  137236. scene: Scene;
  137237. /**
  137238. * Creates a new instance of the component for the given scene
  137239. * @param scene Defines the scene to register the component in
  137240. */
  137241. constructor(scene: Scene);
  137242. /**
  137243. * Registers the component in a given scene
  137244. */
  137245. register(): void;
  137246. /**
  137247. * Rebuilds the elements related to this component in case of
  137248. * context lost for instance.
  137249. */
  137250. rebuild(): void;
  137251. /**
  137252. * Serializes the component data to the specified json object
  137253. * @param serializationObject The object to serialize to
  137254. */
  137255. serialize(serializationObject: any): void;
  137256. /**
  137257. * Adds all the elements from the container to the scene
  137258. * @param container the container holding the elements
  137259. */
  137260. addFromContainer(container: AbstractScene): void;
  137261. /**
  137262. * Removes all the elements in the container from the scene
  137263. * @param container contains the elements to remove
  137264. * @param dispose if the removed element should be disposed (default: false)
  137265. */
  137266. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  137267. /**
  137268. * Rebuilds the elements related to this component in case of
  137269. * context lost for instance.
  137270. */
  137271. dispose(): void;
  137272. private _gatherRenderTargets;
  137273. }
  137274. }
  137275. declare module BABYLON {
  137276. /**
  137277. * A point light is a light defined by an unique point in world space.
  137278. * The light is emitted in every direction from this point.
  137279. * A good example of a point light is a standard light bulb.
  137280. * Documentation: https://doc.babylonjs.com/babylon101/lights
  137281. */
  137282. export class PointLight extends ShadowLight {
  137283. private _shadowAngle;
  137284. /**
  137285. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137286. * This specifies what angle the shadow will use to be created.
  137287. *
  137288. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137289. */
  137290. get shadowAngle(): number;
  137291. /**
  137292. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137293. * This specifies what angle the shadow will use to be created.
  137294. *
  137295. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  137296. */
  137297. set shadowAngle(value: number);
  137298. /**
  137299. * Gets the direction if it has been set.
  137300. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137301. */
  137302. get direction(): Vector3;
  137303. /**
  137304. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  137305. */
  137306. set direction(value: Vector3);
  137307. /**
  137308. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  137309. * A PointLight emits the light in every direction.
  137310. * It can cast shadows.
  137311. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  137312. * ```javascript
  137313. * var pointLight = new PointLight("pl", camera.position, scene);
  137314. * ```
  137315. * Documentation : https://doc.babylonjs.com/babylon101/lights
  137316. * @param name The light friendly name
  137317. * @param position The position of the point light in the scene
  137318. * @param scene The scene the lights belongs to
  137319. */
  137320. constructor(name: string, position: Vector3, scene: Scene);
  137321. /**
  137322. * Returns the string "PointLight"
  137323. * @returns the class name
  137324. */
  137325. getClassName(): string;
  137326. /**
  137327. * Returns the integer 0.
  137328. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  137329. */
  137330. getTypeID(): number;
  137331. /**
  137332. * Specifies wether or not the shadowmap should be a cube texture.
  137333. * @returns true if the shadowmap needs to be a cube texture.
  137334. */
  137335. needCube(): boolean;
  137336. /**
  137337. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  137338. * @param faceIndex The index of the face we are computed the direction to generate shadow
  137339. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  137340. */
  137341. getShadowDirection(faceIndex?: number): Vector3;
  137342. /**
  137343. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  137344. * - fov = PI / 2
  137345. * - aspect ratio : 1.0
  137346. * - z-near and far equal to the active camera minZ and maxZ.
  137347. * Returns the PointLight.
  137348. */
  137349. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  137350. protected _buildUniformLayout(): void;
  137351. /**
  137352. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  137353. * @param effect The effect to update
  137354. * @param lightIndex The index of the light in the effect to update
  137355. * @returns The point light
  137356. */
  137357. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  137358. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  137359. /**
  137360. * Prepares the list of defines specific to the light type.
  137361. * @param defines the list of defines
  137362. * @param lightIndex defines the index of the light for the effect
  137363. */
  137364. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  137365. }
  137366. }
  137367. declare module BABYLON {
  137368. /**
  137369. * Header information of HDR texture files.
  137370. */
  137371. export interface HDRInfo {
  137372. /**
  137373. * The height of the texture in pixels.
  137374. */
  137375. height: number;
  137376. /**
  137377. * The width of the texture in pixels.
  137378. */
  137379. width: number;
  137380. /**
  137381. * The index of the beginning of the data in the binary file.
  137382. */
  137383. dataPosition: number;
  137384. }
  137385. /**
  137386. * This groups tools to convert HDR texture to native colors array.
  137387. */
  137388. export class HDRTools {
  137389. private static Ldexp;
  137390. private static Rgbe2float;
  137391. private static readStringLine;
  137392. /**
  137393. * Reads header information from an RGBE texture stored in a native array.
  137394. * More information on this format are available here:
  137395. * https://en.wikipedia.org/wiki/RGBE_image_format
  137396. *
  137397. * @param uint8array The binary file stored in native array.
  137398. * @return The header information.
  137399. */
  137400. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  137401. /**
  137402. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  137403. * This RGBE texture needs to store the information as a panorama.
  137404. *
  137405. * More information on this format are available here:
  137406. * https://en.wikipedia.org/wiki/RGBE_image_format
  137407. *
  137408. * @param buffer The binary file stored in an array buffer.
  137409. * @param size The expected size of the extracted cubemap.
  137410. * @return The Cube Map information.
  137411. */
  137412. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  137413. /**
  137414. * Returns the pixels data extracted from an RGBE texture.
  137415. * This pixels will be stored left to right up to down in the R G B order in one array.
  137416. *
  137417. * More information on this format are available here:
  137418. * https://en.wikipedia.org/wiki/RGBE_image_format
  137419. *
  137420. * @param uint8array The binary file stored in an array buffer.
  137421. * @param hdrInfo The header information of the file.
  137422. * @return The pixels data in RGB right to left up to down order.
  137423. */
  137424. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  137425. private static RGBE_ReadPixels_RLE;
  137426. }
  137427. }
  137428. declare module BABYLON {
  137429. /**
  137430. * Effect Render Options
  137431. */
  137432. export interface IEffectRendererOptions {
  137433. /**
  137434. * Defines the vertices positions.
  137435. */
  137436. positions?: number[];
  137437. /**
  137438. * Defines the indices.
  137439. */
  137440. indices?: number[];
  137441. }
  137442. /**
  137443. * Helper class to render one or more effects.
  137444. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  137445. */
  137446. export class EffectRenderer {
  137447. private engine;
  137448. private static _DefaultOptions;
  137449. private _vertexBuffers;
  137450. private _indexBuffer;
  137451. private _fullscreenViewport;
  137452. /**
  137453. * Creates an effect renderer
  137454. * @param engine the engine to use for rendering
  137455. * @param options defines the options of the effect renderer
  137456. */
  137457. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  137458. /**
  137459. * Sets the current viewport in normalized coordinates 0-1
  137460. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  137461. */
  137462. setViewport(viewport?: Viewport): void;
  137463. /**
  137464. * Binds the embedded attributes buffer to the effect.
  137465. * @param effect Defines the effect to bind the attributes for
  137466. */
  137467. bindBuffers(effect: Effect): void;
  137468. /**
  137469. * Sets the current effect wrapper to use during draw.
  137470. * The effect needs to be ready before calling this api.
  137471. * This also sets the default full screen position attribute.
  137472. * @param effectWrapper Defines the effect to draw with
  137473. */
  137474. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  137475. /**
  137476. * Restores engine states
  137477. */
  137478. restoreStates(): void;
  137479. /**
  137480. * Draws a full screen quad.
  137481. */
  137482. draw(): void;
  137483. private isRenderTargetTexture;
  137484. /**
  137485. * renders one or more effects to a specified texture
  137486. * @param effectWrapper the effect to renderer
  137487. * @param outputTexture texture to draw to, if null it will render to the screen.
  137488. */
  137489. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  137490. /**
  137491. * Disposes of the effect renderer
  137492. */
  137493. dispose(): void;
  137494. }
  137495. /**
  137496. * Options to create an EffectWrapper
  137497. */
  137498. interface EffectWrapperCreationOptions {
  137499. /**
  137500. * Engine to use to create the effect
  137501. */
  137502. engine: ThinEngine;
  137503. /**
  137504. * Fragment shader for the effect
  137505. */
  137506. fragmentShader: string;
  137507. /**
  137508. * Use the shader store instead of direct source code
  137509. */
  137510. useShaderStore?: boolean;
  137511. /**
  137512. * Vertex shader for the effect
  137513. */
  137514. vertexShader?: string;
  137515. /**
  137516. * Attributes to use in the shader
  137517. */
  137518. attributeNames?: Array<string>;
  137519. /**
  137520. * Uniforms to use in the shader
  137521. */
  137522. uniformNames?: Array<string>;
  137523. /**
  137524. * Texture sampler names to use in the shader
  137525. */
  137526. samplerNames?: Array<string>;
  137527. /**
  137528. * Defines to use in the shader
  137529. */
  137530. defines?: Array<string>;
  137531. /**
  137532. * Callback when effect is compiled
  137533. */
  137534. onCompiled?: Nullable<(effect: Effect) => void>;
  137535. /**
  137536. * The friendly name of the effect displayed in Spector.
  137537. */
  137538. name?: string;
  137539. }
  137540. /**
  137541. * Wraps an effect to be used for rendering
  137542. */
  137543. export class EffectWrapper {
  137544. /**
  137545. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  137546. */
  137547. onApplyObservable: Observable<{}>;
  137548. /**
  137549. * The underlying effect
  137550. */
  137551. effect: Effect;
  137552. /**
  137553. * Creates an effect to be renderer
  137554. * @param creationOptions options to create the effect
  137555. */
  137556. constructor(creationOptions: EffectWrapperCreationOptions);
  137557. /**
  137558. * Disposes of the effect wrapper
  137559. */
  137560. dispose(): void;
  137561. }
  137562. }
  137563. declare module BABYLON {
  137564. /** @hidden */
  137565. export var hdrFilteringVertexShader: {
  137566. name: string;
  137567. shader: string;
  137568. };
  137569. }
  137570. declare module BABYLON {
  137571. /** @hidden */
  137572. export var hdrFilteringPixelShader: {
  137573. name: string;
  137574. shader: string;
  137575. };
  137576. }
  137577. declare module BABYLON {
  137578. /**
  137579. * Options for texture filtering
  137580. */
  137581. interface IHDRFilteringOptions {
  137582. /**
  137583. * Scales pixel intensity for the input HDR map.
  137584. */
  137585. hdrScale?: number;
  137586. /**
  137587. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  137588. */
  137589. quality?: number;
  137590. }
  137591. /**
  137592. * Filters HDR maps to get correct renderings of PBR reflections
  137593. */
  137594. export class HDRFiltering {
  137595. private _engine;
  137596. private _effectRenderer;
  137597. private _effectWrapper;
  137598. private _lodGenerationOffset;
  137599. private _lodGenerationScale;
  137600. /**
  137601. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  137602. * you care about baking speed.
  137603. */
  137604. quality: number;
  137605. /**
  137606. * Scales pixel intensity for the input HDR map.
  137607. */
  137608. hdrScale: number;
  137609. /**
  137610. * Instantiates HDR filter for reflection maps
  137611. *
  137612. * @param engine Thin engine
  137613. * @param options Options
  137614. */
  137615. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  137616. private _createRenderTarget;
  137617. private _prefilterInternal;
  137618. private _createEffect;
  137619. /**
  137620. * Get a value indicating if the filter is ready to be used
  137621. * @param texture Texture to filter
  137622. * @returns true if the filter is ready
  137623. */
  137624. isReady(texture: BaseTexture): boolean;
  137625. /**
  137626. * Prefilters a cube texture to have mipmap levels representing roughness values.
  137627. * Prefiltering will be invoked at the end of next rendering pass.
  137628. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  137629. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  137630. * @param texture Texture to filter
  137631. * @param onFinished Callback when filtering is done
  137632. * @return Promise called when prefiltering is done
  137633. */
  137634. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  137635. }
  137636. }
  137637. declare module BABYLON {
  137638. /**
  137639. * This represents a texture coming from an HDR input.
  137640. *
  137641. * The only supported format is currently panorama picture stored in RGBE format.
  137642. * Example of such files can be found on HDRLib: http://hdrlib.com/
  137643. */
  137644. export class HDRCubeTexture extends BaseTexture {
  137645. private static _facesMapping;
  137646. private _generateHarmonics;
  137647. private _noMipmap;
  137648. private _prefilterOnLoad;
  137649. private _textureMatrix;
  137650. private _size;
  137651. private _onLoad;
  137652. private _onError;
  137653. /**
  137654. * The texture URL.
  137655. */
  137656. url: string;
  137657. /**
  137658. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  137659. */
  137660. coordinatesMode: number;
  137661. protected _isBlocking: boolean;
  137662. /**
  137663. * Sets wether or not the texture is blocking during loading.
  137664. */
  137665. set isBlocking(value: boolean);
  137666. /**
  137667. * Gets wether or not the texture is blocking during loading.
  137668. */
  137669. get isBlocking(): boolean;
  137670. protected _rotationY: number;
  137671. /**
  137672. * Sets texture matrix rotation angle around Y axis in radians.
  137673. */
  137674. set rotationY(value: number);
  137675. /**
  137676. * Gets texture matrix rotation angle around Y axis radians.
  137677. */
  137678. get rotationY(): number;
  137679. /**
  137680. * Gets or sets the center of the bounding box associated with the cube texture
  137681. * It must define where the camera used to render the texture was set
  137682. */
  137683. boundingBoxPosition: Vector3;
  137684. private _boundingBoxSize;
  137685. /**
  137686. * Gets or sets the size of the bounding box associated with the cube texture
  137687. * When defined, the cubemap will switch to local mode
  137688. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  137689. * @example https://www.babylonjs-playground.com/#RNASML
  137690. */
  137691. set boundingBoxSize(value: Vector3);
  137692. get boundingBoxSize(): Vector3;
  137693. /**
  137694. * Instantiates an HDRTexture from the following parameters.
  137695. *
  137696. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  137697. * @param sceneOrEngine The scene or engine the texture will be used in
  137698. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  137699. * @param noMipmap Forces to not generate the mipmap if true
  137700. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  137701. * @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)
  137702. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  137703. */
  137704. 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>);
  137705. /**
  137706. * Get the current class name of the texture useful for serialization or dynamic coding.
  137707. * @returns "HDRCubeTexture"
  137708. */
  137709. getClassName(): string;
  137710. /**
  137711. * Occurs when the file is raw .hdr file.
  137712. */
  137713. private loadTexture;
  137714. clone(): HDRCubeTexture;
  137715. delayLoad(): void;
  137716. /**
  137717. * Get the texture reflection matrix used to rotate/transform the reflection.
  137718. * @returns the reflection matrix
  137719. */
  137720. getReflectionTextureMatrix(): Matrix;
  137721. /**
  137722. * Set the texture reflection matrix used to rotate/transform the reflection.
  137723. * @param value Define the reflection matrix to set
  137724. */
  137725. setReflectionTextureMatrix(value: Matrix): void;
  137726. /**
  137727. * Parses a JSON representation of an HDR Texture in order to create the texture
  137728. * @param parsedTexture Define the JSON representation
  137729. * @param scene Define the scene the texture should be created in
  137730. * @param rootUrl Define the root url in case we need to load relative dependencies
  137731. * @returns the newly created texture after parsing
  137732. */
  137733. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  137734. serialize(): any;
  137735. }
  137736. }
  137737. declare module BABYLON {
  137738. /**
  137739. * Class used to control physics engine
  137740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  137741. */
  137742. export class PhysicsEngine implements IPhysicsEngine {
  137743. private _physicsPlugin;
  137744. /**
  137745. * Global value used to control the smallest number supported by the simulation
  137746. */
  137747. static Epsilon: number;
  137748. private _impostors;
  137749. private _joints;
  137750. private _subTimeStep;
  137751. /**
  137752. * Gets the gravity vector used by the simulation
  137753. */
  137754. gravity: Vector3;
  137755. /**
  137756. * Factory used to create the default physics plugin.
  137757. * @returns The default physics plugin
  137758. */
  137759. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  137760. /**
  137761. * Creates a new Physics Engine
  137762. * @param gravity defines the gravity vector used by the simulation
  137763. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  137764. */
  137765. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  137766. /**
  137767. * Sets the gravity vector used by the simulation
  137768. * @param gravity defines the gravity vector to use
  137769. */
  137770. setGravity(gravity: Vector3): void;
  137771. /**
  137772. * Set the time step of the physics engine.
  137773. * Default is 1/60.
  137774. * To slow it down, enter 1/600 for example.
  137775. * To speed it up, 1/30
  137776. * @param newTimeStep defines the new timestep to apply to this world.
  137777. */
  137778. setTimeStep(newTimeStep?: number): void;
  137779. /**
  137780. * Get the time step of the physics engine.
  137781. * @returns the current time step
  137782. */
  137783. getTimeStep(): number;
  137784. /**
  137785. * Set the sub time step of the physics engine.
  137786. * Default is 0 meaning there is no sub steps
  137787. * To increase physics resolution precision, set a small value (like 1 ms)
  137788. * @param subTimeStep defines the new sub timestep used for physics resolution.
  137789. */
  137790. setSubTimeStep(subTimeStep?: number): void;
  137791. /**
  137792. * Get the sub time step of the physics engine.
  137793. * @returns the current sub time step
  137794. */
  137795. getSubTimeStep(): number;
  137796. /**
  137797. * Release all resources
  137798. */
  137799. dispose(): void;
  137800. /**
  137801. * Gets the name of the current physics plugin
  137802. * @returns the name of the plugin
  137803. */
  137804. getPhysicsPluginName(): string;
  137805. /**
  137806. * Adding a new impostor for the impostor tracking.
  137807. * This will be done by the impostor itself.
  137808. * @param impostor the impostor to add
  137809. */
  137810. addImpostor(impostor: PhysicsImpostor): void;
  137811. /**
  137812. * Remove an impostor from the engine.
  137813. * This impostor and its mesh will not longer be updated by the physics engine.
  137814. * @param impostor the impostor to remove
  137815. */
  137816. removeImpostor(impostor: PhysicsImpostor): void;
  137817. /**
  137818. * Add a joint to the physics engine
  137819. * @param mainImpostor defines the main impostor to which the joint is added.
  137820. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  137821. * @param joint defines the joint that will connect both impostors.
  137822. */
  137823. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137824. /**
  137825. * Removes a joint from the simulation
  137826. * @param mainImpostor defines the impostor used with the joint
  137827. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  137828. * @param joint defines the joint to remove
  137829. */
  137830. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  137831. /**
  137832. * Called by the scene. No need to call it.
  137833. * @param delta defines the timespam between frames
  137834. */
  137835. _step(delta: number): void;
  137836. /**
  137837. * Gets the current plugin used to run the simulation
  137838. * @returns current plugin
  137839. */
  137840. getPhysicsPlugin(): IPhysicsEnginePlugin;
  137841. /**
  137842. * Gets the list of physic impostors
  137843. * @returns an array of PhysicsImpostor
  137844. */
  137845. getImpostors(): Array<PhysicsImpostor>;
  137846. /**
  137847. * Gets the impostor for a physics enabled object
  137848. * @param object defines the object impersonated by the impostor
  137849. * @returns the PhysicsImpostor or null if not found
  137850. */
  137851. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  137852. /**
  137853. * Gets the impostor for a physics body object
  137854. * @param body defines physics body used by the impostor
  137855. * @returns the PhysicsImpostor or null if not found
  137856. */
  137857. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  137858. /**
  137859. * Does a raycast in the physics world
  137860. * @param from when should the ray start?
  137861. * @param to when should the ray end?
  137862. * @returns PhysicsRaycastResult
  137863. */
  137864. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137865. }
  137866. }
  137867. declare module BABYLON {
  137868. /** @hidden */
  137869. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  137870. private _useDeltaForWorldStep;
  137871. world: any;
  137872. name: string;
  137873. private _physicsMaterials;
  137874. private _fixedTimeStep;
  137875. private _cannonRaycastResult;
  137876. private _raycastResult;
  137877. private _physicsBodysToRemoveAfterStep;
  137878. private _firstFrame;
  137879. BJSCANNON: any;
  137880. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  137881. setGravity(gravity: Vector3): void;
  137882. setTimeStep(timeStep: number): void;
  137883. getTimeStep(): number;
  137884. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137885. private _removeMarkedPhysicsBodiesFromWorld;
  137886. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137888. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137889. private _processChildMeshes;
  137890. removePhysicsBody(impostor: PhysicsImpostor): void;
  137891. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137892. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137893. private _addMaterial;
  137894. private _checkWithEpsilon;
  137895. private _createShape;
  137896. private _createHeightmap;
  137897. private _minus90X;
  137898. private _plus90X;
  137899. private _tmpPosition;
  137900. private _tmpDeltaPosition;
  137901. private _tmpUnityRotation;
  137902. private _updatePhysicsBodyTransformation;
  137903. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137904. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137905. isSupported(): boolean;
  137906. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137907. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137908. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137909. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137910. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137911. getBodyMass(impostor: PhysicsImpostor): number;
  137912. getBodyFriction(impostor: PhysicsImpostor): number;
  137913. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137914. getBodyRestitution(impostor: PhysicsImpostor): number;
  137915. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137916. sleepBody(impostor: PhysicsImpostor): void;
  137917. wakeUpBody(impostor: PhysicsImpostor): void;
  137918. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  137919. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  137920. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  137921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137922. getRadius(impostor: PhysicsImpostor): number;
  137923. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137924. dispose(): void;
  137925. private _extendNamespace;
  137926. /**
  137927. * Does a raycast in the physics world
  137928. * @param from when should the ray start?
  137929. * @param to when should the ray end?
  137930. * @returns PhysicsRaycastResult
  137931. */
  137932. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137933. }
  137934. }
  137935. declare module BABYLON {
  137936. /** @hidden */
  137937. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  137938. private _useDeltaForWorldStep;
  137939. world: any;
  137940. name: string;
  137941. BJSOIMO: any;
  137942. private _raycastResult;
  137943. private _fixedTimeStep;
  137944. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  137945. setGravity(gravity: Vector3): void;
  137946. setTimeStep(timeStep: number): void;
  137947. getTimeStep(): number;
  137948. private _tmpImpostorsArray;
  137949. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  137950. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137951. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  137952. generatePhysicsBody(impostor: PhysicsImpostor): void;
  137953. private _tmpPositionVector;
  137954. removePhysicsBody(impostor: PhysicsImpostor): void;
  137955. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  137956. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  137957. isSupported(): boolean;
  137958. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  137959. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  137960. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137961. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  137962. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137963. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  137964. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  137965. getBodyMass(impostor: PhysicsImpostor): number;
  137966. getBodyFriction(impostor: PhysicsImpostor): number;
  137967. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  137968. getBodyRestitution(impostor: PhysicsImpostor): number;
  137969. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  137970. sleepBody(impostor: PhysicsImpostor): void;
  137971. wakeUpBody(impostor: PhysicsImpostor): void;
  137972. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  137973. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  137974. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  137975. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  137976. getRadius(impostor: PhysicsImpostor): number;
  137977. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  137978. dispose(): void;
  137979. /**
  137980. * Does a raycast in the physics world
  137981. * @param from when should the ray start?
  137982. * @param to when should the ray end?
  137983. * @returns PhysicsRaycastResult
  137984. */
  137985. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  137986. }
  137987. }
  137988. declare module BABYLON {
  137989. /**
  137990. * Class containing static functions to help procedurally build meshes
  137991. */
  137992. export class RibbonBuilder {
  137993. /**
  137994. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  137995. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  137996. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  137997. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  137998. * * 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
  137999. * * 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
  138000. * * 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
  138001. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138002. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138003. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138004. * * 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
  138005. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  138006. * * 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
  138007. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  138008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138009. * @param name defines the name of the mesh
  138010. * @param options defines the options used to create the mesh
  138011. * @param scene defines the hosting scene
  138012. * @returns the ribbon mesh
  138013. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  138014. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138015. */
  138016. static CreateRibbon(name: string, options: {
  138017. pathArray: Vector3[][];
  138018. closeArray?: boolean;
  138019. closePath?: boolean;
  138020. offset?: number;
  138021. updatable?: boolean;
  138022. sideOrientation?: number;
  138023. frontUVs?: Vector4;
  138024. backUVs?: Vector4;
  138025. instance?: Mesh;
  138026. invertUV?: boolean;
  138027. uvs?: Vector2[];
  138028. colors?: Color4[];
  138029. }, scene?: Nullable<Scene>): Mesh;
  138030. }
  138031. }
  138032. declare module BABYLON {
  138033. /**
  138034. * Class containing static functions to help procedurally build meshes
  138035. */
  138036. export class ShapeBuilder {
  138037. /**
  138038. * 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.
  138039. * * 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.
  138040. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138041. * * 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.
  138042. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  138043. * * 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
  138044. * * 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
  138045. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  138046. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138047. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138048. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  138049. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  138050. * @param name defines the name of the mesh
  138051. * @param options defines the options used to create the mesh
  138052. * @param scene defines the hosting scene
  138053. * @returns the extruded shape mesh
  138054. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138055. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138056. */
  138057. static ExtrudeShape(name: string, options: {
  138058. shape: Vector3[];
  138059. path: Vector3[];
  138060. scale?: number;
  138061. rotation?: number;
  138062. cap?: number;
  138063. updatable?: boolean;
  138064. sideOrientation?: number;
  138065. frontUVs?: Vector4;
  138066. backUVs?: Vector4;
  138067. instance?: Mesh;
  138068. invertUV?: boolean;
  138069. }, scene?: Nullable<Scene>): Mesh;
  138070. /**
  138071. * Creates an custom extruded shape mesh.
  138072. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  138073. * * 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.
  138074. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  138075. * * 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
  138076. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  138077. * * 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
  138078. * * It must returns a float value that will be the scale value applied to the shape on each path point
  138079. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  138080. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  138081. * * 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
  138082. * * 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
  138083. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  138084. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  138085. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  138086. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  138087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  138088. * @param name defines the name of the mesh
  138089. * @param options defines the options used to create the mesh
  138090. * @param scene defines the hosting scene
  138091. * @returns the custom extruded shape mesh
  138092. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  138093. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  138094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  138095. */
  138096. static ExtrudeShapeCustom(name: string, options: {
  138097. shape: Vector3[];
  138098. path: Vector3[];
  138099. scaleFunction?: any;
  138100. rotationFunction?: any;
  138101. ribbonCloseArray?: boolean;
  138102. ribbonClosePath?: boolean;
  138103. cap?: number;
  138104. updatable?: boolean;
  138105. sideOrientation?: number;
  138106. frontUVs?: Vector4;
  138107. backUVs?: Vector4;
  138108. instance?: Mesh;
  138109. invertUV?: boolean;
  138110. }, scene?: Nullable<Scene>): Mesh;
  138111. private static _ExtrudeShapeGeneric;
  138112. }
  138113. }
  138114. declare module BABYLON {
  138115. /**
  138116. * AmmoJS Physics plugin
  138117. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  138118. * @see https://github.com/kripken/ammo.js/
  138119. */
  138120. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  138121. private _useDeltaForWorldStep;
  138122. /**
  138123. * Reference to the Ammo library
  138124. */
  138125. bjsAMMO: any;
  138126. /**
  138127. * Created ammoJS world which physics bodies are added to
  138128. */
  138129. world: any;
  138130. /**
  138131. * Name of the plugin
  138132. */
  138133. name: string;
  138134. private _timeStep;
  138135. private _fixedTimeStep;
  138136. private _maxSteps;
  138137. private _tmpQuaternion;
  138138. private _tmpAmmoTransform;
  138139. private _tmpAmmoQuaternion;
  138140. private _tmpAmmoConcreteContactResultCallback;
  138141. private _collisionConfiguration;
  138142. private _dispatcher;
  138143. private _overlappingPairCache;
  138144. private _solver;
  138145. private _softBodySolver;
  138146. private _tmpAmmoVectorA;
  138147. private _tmpAmmoVectorB;
  138148. private _tmpAmmoVectorC;
  138149. private _tmpAmmoVectorD;
  138150. private _tmpContactCallbackResult;
  138151. private _tmpAmmoVectorRCA;
  138152. private _tmpAmmoVectorRCB;
  138153. private _raycastResult;
  138154. private static readonly DISABLE_COLLISION_FLAG;
  138155. private static readonly KINEMATIC_FLAG;
  138156. private static readonly DISABLE_DEACTIVATION_FLAG;
  138157. /**
  138158. * Initializes the ammoJS plugin
  138159. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  138160. * @param ammoInjection can be used to inject your own ammo reference
  138161. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  138162. */
  138163. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  138164. /**
  138165. * Sets the gravity of the physics world (m/(s^2))
  138166. * @param gravity Gravity to set
  138167. */
  138168. setGravity(gravity: Vector3): void;
  138169. /**
  138170. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  138171. * @param timeStep timestep to use in seconds
  138172. */
  138173. setTimeStep(timeStep: number): void;
  138174. /**
  138175. * 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)
  138176. * @param fixedTimeStep fixedTimeStep to use in seconds
  138177. */
  138178. setFixedTimeStep(fixedTimeStep: number): void;
  138179. /**
  138180. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  138181. * @param maxSteps the maximum number of steps by the physics engine per frame
  138182. */
  138183. setMaxSteps(maxSteps: number): void;
  138184. /**
  138185. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  138186. * @returns the current timestep in seconds
  138187. */
  138188. getTimeStep(): number;
  138189. /**
  138190. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  138191. */
  138192. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  138193. private _isImpostorInContact;
  138194. private _isImpostorPairInContact;
  138195. private _stepSimulation;
  138196. /**
  138197. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  138198. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  138199. * After the step the babylon meshes are set to the position of the physics imposters
  138200. * @param delta amount of time to step forward
  138201. * @param impostors array of imposters to update before/after the step
  138202. */
  138203. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  138204. /**
  138205. * Update babylon mesh to match physics world object
  138206. * @param impostor imposter to match
  138207. */
  138208. private _afterSoftStep;
  138209. /**
  138210. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138211. * @param impostor imposter to match
  138212. */
  138213. private _ropeStep;
  138214. /**
  138215. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  138216. * @param impostor imposter to match
  138217. */
  138218. private _softbodyOrClothStep;
  138219. private _tmpMatrix;
  138220. /**
  138221. * Applies an impulse on the imposter
  138222. * @param impostor imposter to apply impulse to
  138223. * @param force amount of force to be applied to the imposter
  138224. * @param contactPoint the location to apply the impulse on the imposter
  138225. */
  138226. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138227. /**
  138228. * Applies a force on the imposter
  138229. * @param impostor imposter to apply force
  138230. * @param force amount of force to be applied to the imposter
  138231. * @param contactPoint the location to apply the force on the imposter
  138232. */
  138233. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  138234. /**
  138235. * Creates a physics body using the plugin
  138236. * @param impostor the imposter to create the physics body on
  138237. */
  138238. generatePhysicsBody(impostor: PhysicsImpostor): void;
  138239. /**
  138240. * Removes the physics body from the imposter and disposes of the body's memory
  138241. * @param impostor imposter to remove the physics body from
  138242. */
  138243. removePhysicsBody(impostor: PhysicsImpostor): void;
  138244. /**
  138245. * Generates a joint
  138246. * @param impostorJoint the imposter joint to create the joint with
  138247. */
  138248. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  138249. /**
  138250. * Removes a joint
  138251. * @param impostorJoint the imposter joint to remove the joint from
  138252. */
  138253. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  138254. private _addMeshVerts;
  138255. /**
  138256. * Initialise the soft body vertices to match its object's (mesh) vertices
  138257. * Softbody vertices (nodes) are in world space and to match this
  138258. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  138259. * @param impostor to create the softbody for
  138260. */
  138261. private _softVertexData;
  138262. /**
  138263. * Create an impostor's soft body
  138264. * @param impostor to create the softbody for
  138265. */
  138266. private _createSoftbody;
  138267. /**
  138268. * Create cloth for an impostor
  138269. * @param impostor to create the softbody for
  138270. */
  138271. private _createCloth;
  138272. /**
  138273. * Create rope for an impostor
  138274. * @param impostor to create the softbody for
  138275. */
  138276. private _createRope;
  138277. /**
  138278. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  138279. * @param impostor to create the custom physics shape for
  138280. */
  138281. private _createCustom;
  138282. private _addHullVerts;
  138283. private _createShape;
  138284. /**
  138285. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  138286. * @param impostor imposter containing the physics body and babylon object
  138287. */
  138288. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  138289. /**
  138290. * Sets the babylon object's position/rotation from the physics body's position/rotation
  138291. * @param impostor imposter containing the physics body and babylon object
  138292. * @param newPosition new position
  138293. * @param newRotation new rotation
  138294. */
  138295. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  138296. /**
  138297. * If this plugin is supported
  138298. * @returns true if its supported
  138299. */
  138300. isSupported(): boolean;
  138301. /**
  138302. * Sets the linear velocity of the physics body
  138303. * @param impostor imposter to set the velocity on
  138304. * @param velocity velocity to set
  138305. */
  138306. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138307. /**
  138308. * Sets the angular velocity of the physics body
  138309. * @param impostor imposter to set the velocity on
  138310. * @param velocity velocity to set
  138311. */
  138312. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  138313. /**
  138314. * gets the linear velocity
  138315. * @param impostor imposter to get linear velocity from
  138316. * @returns linear velocity
  138317. */
  138318. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138319. /**
  138320. * gets the angular velocity
  138321. * @param impostor imposter to get angular velocity from
  138322. * @returns angular velocity
  138323. */
  138324. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  138325. /**
  138326. * Sets the mass of physics body
  138327. * @param impostor imposter to set the mass on
  138328. * @param mass mass to set
  138329. */
  138330. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  138331. /**
  138332. * Gets the mass of the physics body
  138333. * @param impostor imposter to get the mass from
  138334. * @returns mass
  138335. */
  138336. getBodyMass(impostor: PhysicsImpostor): number;
  138337. /**
  138338. * Gets friction of the impostor
  138339. * @param impostor impostor to get friction from
  138340. * @returns friction value
  138341. */
  138342. getBodyFriction(impostor: PhysicsImpostor): number;
  138343. /**
  138344. * Sets friction of the impostor
  138345. * @param impostor impostor to set friction on
  138346. * @param friction friction value
  138347. */
  138348. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  138349. /**
  138350. * Gets restitution of the impostor
  138351. * @param impostor impostor to get restitution from
  138352. * @returns restitution value
  138353. */
  138354. getBodyRestitution(impostor: PhysicsImpostor): number;
  138355. /**
  138356. * Sets resitution of the impostor
  138357. * @param impostor impostor to set resitution on
  138358. * @param restitution resitution value
  138359. */
  138360. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  138361. /**
  138362. * Gets pressure inside the impostor
  138363. * @param impostor impostor to get pressure from
  138364. * @returns pressure value
  138365. */
  138366. getBodyPressure(impostor: PhysicsImpostor): number;
  138367. /**
  138368. * Sets pressure inside a soft body impostor
  138369. * Cloth and rope must remain 0 pressure
  138370. * @param impostor impostor to set pressure on
  138371. * @param pressure pressure value
  138372. */
  138373. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  138374. /**
  138375. * Gets stiffness of the impostor
  138376. * @param impostor impostor to get stiffness from
  138377. * @returns pressure value
  138378. */
  138379. getBodyStiffness(impostor: PhysicsImpostor): number;
  138380. /**
  138381. * Sets stiffness of the impostor
  138382. * @param impostor impostor to set stiffness on
  138383. * @param stiffness stiffness value from 0 to 1
  138384. */
  138385. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  138386. /**
  138387. * Gets velocityIterations of the impostor
  138388. * @param impostor impostor to get velocity iterations from
  138389. * @returns velocityIterations value
  138390. */
  138391. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  138392. /**
  138393. * Sets velocityIterations of the impostor
  138394. * @param impostor impostor to set velocity iterations on
  138395. * @param velocityIterations velocityIterations value
  138396. */
  138397. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  138398. /**
  138399. * Gets positionIterations of the impostor
  138400. * @param impostor impostor to get position iterations from
  138401. * @returns positionIterations value
  138402. */
  138403. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  138404. /**
  138405. * Sets positionIterations of the impostor
  138406. * @param impostor impostor to set position on
  138407. * @param positionIterations positionIterations value
  138408. */
  138409. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  138410. /**
  138411. * Append an anchor to a cloth object
  138412. * @param impostor is the cloth impostor to add anchor to
  138413. * @param otherImpostor is the rigid impostor to anchor to
  138414. * @param width ratio across width from 0 to 1
  138415. * @param height ratio up height from 0 to 1
  138416. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  138417. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138418. */
  138419. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138420. /**
  138421. * Append an hook to a rope object
  138422. * @param impostor is the rope impostor to add hook to
  138423. * @param otherImpostor is the rigid impostor to hook to
  138424. * @param length ratio along the rope from 0 to 1
  138425. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  138426. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  138427. */
  138428. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  138429. /**
  138430. * Sleeps the physics body and stops it from being active
  138431. * @param impostor impostor to sleep
  138432. */
  138433. sleepBody(impostor: PhysicsImpostor): void;
  138434. /**
  138435. * Activates the physics body
  138436. * @param impostor impostor to activate
  138437. */
  138438. wakeUpBody(impostor: PhysicsImpostor): void;
  138439. /**
  138440. * Updates the distance parameters of the joint
  138441. * @param joint joint to update
  138442. * @param maxDistance maximum distance of the joint
  138443. * @param minDistance minimum distance of the joint
  138444. */
  138445. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  138446. /**
  138447. * Sets a motor on the joint
  138448. * @param joint joint to set motor on
  138449. * @param speed speed of the motor
  138450. * @param maxForce maximum force of the motor
  138451. * @param motorIndex index of the motor
  138452. */
  138453. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  138454. /**
  138455. * Sets the motors limit
  138456. * @param joint joint to set limit on
  138457. * @param upperLimit upper limit
  138458. * @param lowerLimit lower limit
  138459. */
  138460. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  138461. /**
  138462. * Syncs the position and rotation of a mesh with the impostor
  138463. * @param mesh mesh to sync
  138464. * @param impostor impostor to update the mesh with
  138465. */
  138466. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  138467. /**
  138468. * Gets the radius of the impostor
  138469. * @param impostor impostor to get radius from
  138470. * @returns the radius
  138471. */
  138472. getRadius(impostor: PhysicsImpostor): number;
  138473. /**
  138474. * Gets the box size of the impostor
  138475. * @param impostor impostor to get box size from
  138476. * @param result the resulting box size
  138477. */
  138478. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  138479. /**
  138480. * Disposes of the impostor
  138481. */
  138482. dispose(): void;
  138483. /**
  138484. * Does a raycast in the physics world
  138485. * @param from when should the ray start?
  138486. * @param to when should the ray end?
  138487. * @returns PhysicsRaycastResult
  138488. */
  138489. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  138490. }
  138491. }
  138492. declare module BABYLON {
  138493. interface AbstractScene {
  138494. /**
  138495. * The list of reflection probes added to the scene
  138496. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138497. */
  138498. reflectionProbes: Array<ReflectionProbe>;
  138499. /**
  138500. * Removes the given reflection probe from this scene.
  138501. * @param toRemove The reflection probe to remove
  138502. * @returns The index of the removed reflection probe
  138503. */
  138504. removeReflectionProbe(toRemove: ReflectionProbe): number;
  138505. /**
  138506. * Adds the given reflection probe to this scene.
  138507. * @param newReflectionProbe The reflection probe to add
  138508. */
  138509. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  138510. }
  138511. /**
  138512. * Class used to generate realtime reflection / refraction cube textures
  138513. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  138514. */
  138515. export class ReflectionProbe {
  138516. /** defines the name of the probe */
  138517. name: string;
  138518. private _scene;
  138519. private _renderTargetTexture;
  138520. private _projectionMatrix;
  138521. private _viewMatrix;
  138522. private _target;
  138523. private _add;
  138524. private _attachedMesh;
  138525. private _invertYAxis;
  138526. /** Gets or sets probe position (center of the cube map) */
  138527. position: Vector3;
  138528. /**
  138529. * Creates a new reflection probe
  138530. * @param name defines the name of the probe
  138531. * @param size defines the texture resolution (for each face)
  138532. * @param scene defines the hosting scene
  138533. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  138534. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  138535. */
  138536. constructor(
  138537. /** defines the name of the probe */
  138538. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  138539. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  138540. get samples(): number;
  138541. set samples(value: number);
  138542. /** Gets or sets the refresh rate to use (on every frame by default) */
  138543. get refreshRate(): number;
  138544. set refreshRate(value: number);
  138545. /**
  138546. * Gets the hosting scene
  138547. * @returns a Scene
  138548. */
  138549. getScene(): Scene;
  138550. /** Gets the internal CubeTexture used to render to */
  138551. get cubeTexture(): RenderTargetTexture;
  138552. /** Gets the list of meshes to render */
  138553. get renderList(): Nullable<AbstractMesh[]>;
  138554. /**
  138555. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  138556. * @param mesh defines the mesh to attach to
  138557. */
  138558. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  138559. /**
  138560. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  138561. * @param renderingGroupId The rendering group id corresponding to its index
  138562. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  138563. */
  138564. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  138565. /**
  138566. * Clean all associated resources
  138567. */
  138568. dispose(): void;
  138569. /**
  138570. * Converts the reflection probe information to a readable string for debug purpose.
  138571. * @param fullDetails Supports for multiple levels of logging within scene loading
  138572. * @returns the human readable reflection probe info
  138573. */
  138574. toString(fullDetails?: boolean): string;
  138575. /**
  138576. * Get the class name of the relfection probe.
  138577. * @returns "ReflectionProbe"
  138578. */
  138579. getClassName(): string;
  138580. /**
  138581. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  138582. * @returns The JSON representation of the texture
  138583. */
  138584. serialize(): any;
  138585. /**
  138586. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  138587. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  138588. * @param scene Define the scene the parsed reflection probe should be instantiated in
  138589. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  138590. * @returns The parsed reflection probe if successful
  138591. */
  138592. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  138593. }
  138594. }
  138595. declare module BABYLON {
  138596. /** @hidden */
  138597. export var _BabylonLoaderRegistered: boolean;
  138598. /**
  138599. * Helps setting up some configuration for the babylon file loader.
  138600. */
  138601. export class BabylonFileLoaderConfiguration {
  138602. /**
  138603. * The loader does not allow injecting custom physix engine into the plugins.
  138604. * Unfortunately in ES6, we need to manually inject them into the plugin.
  138605. * So you could set this variable to your engine import to make it work.
  138606. */
  138607. static LoaderInjectedPhysicsEngine: any;
  138608. }
  138609. }
  138610. declare module BABYLON {
  138611. /**
  138612. * The Physically based simple base material of BJS.
  138613. *
  138614. * This enables better naming and convention enforcements on top of the pbrMaterial.
  138615. * It is used as the base class for both the specGloss and metalRough conventions.
  138616. */
  138617. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  138618. /**
  138619. * Number of Simultaneous lights allowed on the material.
  138620. */
  138621. maxSimultaneousLights: number;
  138622. /**
  138623. * If sets to true, disables all the lights affecting the material.
  138624. */
  138625. disableLighting: boolean;
  138626. /**
  138627. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  138628. */
  138629. environmentTexture: BaseTexture;
  138630. /**
  138631. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138632. */
  138633. invertNormalMapX: boolean;
  138634. /**
  138635. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138636. */
  138637. invertNormalMapY: boolean;
  138638. /**
  138639. * Normal map used in the model.
  138640. */
  138641. normalTexture: BaseTexture;
  138642. /**
  138643. * Emissivie color used to self-illuminate the model.
  138644. */
  138645. emissiveColor: Color3;
  138646. /**
  138647. * Emissivie texture used to self-illuminate the model.
  138648. */
  138649. emissiveTexture: BaseTexture;
  138650. /**
  138651. * Occlusion Channel Strenght.
  138652. */
  138653. occlusionStrength: number;
  138654. /**
  138655. * Occlusion Texture of the material (adding extra occlusion effects).
  138656. */
  138657. occlusionTexture: BaseTexture;
  138658. /**
  138659. * Defines the alpha limits in alpha test mode.
  138660. */
  138661. alphaCutOff: number;
  138662. /**
  138663. * Gets the current double sided mode.
  138664. */
  138665. get doubleSided(): boolean;
  138666. /**
  138667. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138668. */
  138669. set doubleSided(value: boolean);
  138670. /**
  138671. * Stores the pre-calculated light information of a mesh in a texture.
  138672. */
  138673. lightmapTexture: BaseTexture;
  138674. /**
  138675. * If true, the light map contains occlusion information instead of lighting info.
  138676. */
  138677. useLightmapAsShadowmap: boolean;
  138678. /**
  138679. * Instantiates a new PBRMaterial instance.
  138680. *
  138681. * @param name The material name
  138682. * @param scene The scene the material will be use in.
  138683. */
  138684. constructor(name: string, scene: Scene);
  138685. getClassName(): string;
  138686. }
  138687. }
  138688. declare module BABYLON {
  138689. /**
  138690. * The PBR material of BJS following the metal roughness convention.
  138691. *
  138692. * This fits to the PBR convention in the GLTF definition:
  138693. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  138694. */
  138695. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  138696. /**
  138697. * The base color has two different interpretations depending on the value of metalness.
  138698. * When the material is a metal, the base color is the specific measured reflectance value
  138699. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  138700. * of the material.
  138701. */
  138702. baseColor: Color3;
  138703. /**
  138704. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  138705. * well as opacity information in the alpha channel.
  138706. */
  138707. baseTexture: BaseTexture;
  138708. /**
  138709. * Specifies the metallic scalar value of the material.
  138710. * Can also be used to scale the metalness values of the metallic texture.
  138711. */
  138712. metallic: number;
  138713. /**
  138714. * Specifies the roughness scalar value of the material.
  138715. * Can also be used to scale the roughness values of the metallic texture.
  138716. */
  138717. roughness: number;
  138718. /**
  138719. * Texture containing both the metallic value in the B channel and the
  138720. * roughness value in the G channel to keep better precision.
  138721. */
  138722. metallicRoughnessTexture: BaseTexture;
  138723. /**
  138724. * Instantiates a new PBRMetalRoughnessMaterial instance.
  138725. *
  138726. * @param name The material name
  138727. * @param scene The scene the material will be use in.
  138728. */
  138729. constructor(name: string, scene: Scene);
  138730. /**
  138731. * Return the currrent class name of the material.
  138732. */
  138733. getClassName(): string;
  138734. /**
  138735. * Makes a duplicate of the current material.
  138736. * @param name - name to use for the new material.
  138737. */
  138738. clone(name: string): PBRMetallicRoughnessMaterial;
  138739. /**
  138740. * Serialize the material to a parsable JSON object.
  138741. */
  138742. serialize(): any;
  138743. /**
  138744. * Parses a JSON object correponding to the serialize function.
  138745. */
  138746. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  138747. }
  138748. }
  138749. declare module BABYLON {
  138750. /**
  138751. * The PBR material of BJS following the specular glossiness convention.
  138752. *
  138753. * This fits to the PBR convention in the GLTF definition:
  138754. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  138755. */
  138756. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  138757. /**
  138758. * Specifies the diffuse color of the material.
  138759. */
  138760. diffuseColor: Color3;
  138761. /**
  138762. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  138763. * channel.
  138764. */
  138765. diffuseTexture: BaseTexture;
  138766. /**
  138767. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  138768. */
  138769. specularColor: Color3;
  138770. /**
  138771. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  138772. */
  138773. glossiness: number;
  138774. /**
  138775. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  138776. */
  138777. specularGlossinessTexture: BaseTexture;
  138778. /**
  138779. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  138780. *
  138781. * @param name The material name
  138782. * @param scene The scene the material will be use in.
  138783. */
  138784. constructor(name: string, scene: Scene);
  138785. /**
  138786. * Return the currrent class name of the material.
  138787. */
  138788. getClassName(): string;
  138789. /**
  138790. * Makes a duplicate of the current material.
  138791. * @param name - name to use for the new material.
  138792. */
  138793. clone(name: string): PBRSpecularGlossinessMaterial;
  138794. /**
  138795. * Serialize the material to a parsable JSON object.
  138796. */
  138797. serialize(): any;
  138798. /**
  138799. * Parses a JSON object correponding to the serialize function.
  138800. */
  138801. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  138802. }
  138803. }
  138804. declare module BABYLON {
  138805. /**
  138806. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  138807. * It can help converting any input color in a desired output one. This can then be used to create effects
  138808. * from sepia, black and white to sixties or futuristic rendering...
  138809. *
  138810. * The only supported format is currently 3dl.
  138811. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  138812. */
  138813. export class ColorGradingTexture extends BaseTexture {
  138814. /**
  138815. * The texture URL.
  138816. */
  138817. url: string;
  138818. /**
  138819. * Empty line regex stored for GC.
  138820. */
  138821. private static _noneEmptyLineRegex;
  138822. private _textureMatrix;
  138823. private _onLoad;
  138824. /**
  138825. * Instantiates a ColorGradingTexture from the following parameters.
  138826. *
  138827. * @param url The location of the color gradind data (currently only supporting 3dl)
  138828. * @param sceneOrEngine The scene or engine the texture will be used in
  138829. * @param onLoad defines a callback triggered when the texture has been loaded
  138830. */
  138831. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  138832. /**
  138833. * Fires the onload event from the constructor if requested.
  138834. */
  138835. private _triggerOnLoad;
  138836. /**
  138837. * Returns the texture matrix used in most of the material.
  138838. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  138839. */
  138840. getTextureMatrix(): Matrix;
  138841. /**
  138842. * Occurs when the file being loaded is a .3dl LUT file.
  138843. */
  138844. private load3dlTexture;
  138845. /**
  138846. * Starts the loading process of the texture.
  138847. */
  138848. private loadTexture;
  138849. /**
  138850. * Clones the color gradind texture.
  138851. */
  138852. clone(): ColorGradingTexture;
  138853. /**
  138854. * Called during delayed load for textures.
  138855. */
  138856. delayLoad(): void;
  138857. /**
  138858. * Parses a color grading texture serialized by Babylon.
  138859. * @param parsedTexture The texture information being parsedTexture
  138860. * @param scene The scene to load the texture in
  138861. * @param rootUrl The root url of the data assets to load
  138862. * @return A color gradind texture
  138863. */
  138864. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  138865. /**
  138866. * Serializes the LUT texture to json format.
  138867. */
  138868. serialize(): any;
  138869. }
  138870. }
  138871. declare module BABYLON {
  138872. /**
  138873. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  138874. */
  138875. export class EquiRectangularCubeTexture extends BaseTexture {
  138876. /** The six faces of the cube. */
  138877. private static _FacesMapping;
  138878. private _noMipmap;
  138879. private _onLoad;
  138880. private _onError;
  138881. /** The size of the cubemap. */
  138882. private _size;
  138883. /** The buffer of the image. */
  138884. private _buffer;
  138885. /** The width of the input image. */
  138886. private _width;
  138887. /** The height of the input image. */
  138888. private _height;
  138889. /** The URL to the image. */
  138890. url: string;
  138891. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  138892. coordinatesMode: number;
  138893. /**
  138894. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  138895. * @param url The location of the image
  138896. * @param scene The scene the texture will be used in
  138897. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  138898. * @param noMipmap Forces to not generate the mipmap if true
  138899. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  138900. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  138901. * @param onLoad — defines a callback called when texture is loaded
  138902. * @param onError — defines a callback called if there is an error
  138903. */
  138904. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  138905. /**
  138906. * Load the image data, by putting the image on a canvas and extracting its buffer.
  138907. */
  138908. private loadImage;
  138909. /**
  138910. * Convert the image buffer into a cubemap and create a CubeTexture.
  138911. */
  138912. private loadTexture;
  138913. /**
  138914. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  138915. * @param buffer The ArrayBuffer that should be converted.
  138916. * @returns The buffer as Float32Array.
  138917. */
  138918. private getFloat32ArrayFromArrayBuffer;
  138919. /**
  138920. * Get the current class name of the texture useful for serialization or dynamic coding.
  138921. * @returns "EquiRectangularCubeTexture"
  138922. */
  138923. getClassName(): string;
  138924. /**
  138925. * Create a clone of the current EquiRectangularCubeTexture and return it.
  138926. * @returns A clone of the current EquiRectangularCubeTexture.
  138927. */
  138928. clone(): EquiRectangularCubeTexture;
  138929. }
  138930. }
  138931. declare module BABYLON {
  138932. /**
  138933. * Defines the options related to the creation of an HtmlElementTexture
  138934. */
  138935. export interface IHtmlElementTextureOptions {
  138936. /**
  138937. * Defines wether mip maps should be created or not.
  138938. */
  138939. generateMipMaps?: boolean;
  138940. /**
  138941. * Defines the sampling mode of the texture.
  138942. */
  138943. samplingMode?: number;
  138944. /**
  138945. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  138946. */
  138947. engine: Nullable<ThinEngine>;
  138948. /**
  138949. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  138950. */
  138951. scene: Nullable<Scene>;
  138952. }
  138953. /**
  138954. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  138955. * To be as efficient as possible depending on your constraints nothing aside the first upload
  138956. * is automatically managed.
  138957. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  138958. * in your application.
  138959. *
  138960. * As the update is not automatic, you need to call them manually.
  138961. */
  138962. export class HtmlElementTexture extends BaseTexture {
  138963. /**
  138964. * The texture URL.
  138965. */
  138966. element: HTMLVideoElement | HTMLCanvasElement;
  138967. private static readonly DefaultOptions;
  138968. private _textureMatrix;
  138969. private _isVideo;
  138970. private _generateMipMaps;
  138971. private _samplingMode;
  138972. /**
  138973. * Instantiates a HtmlElementTexture from the following parameters.
  138974. *
  138975. * @param name Defines the name of the texture
  138976. * @param element Defines the video or canvas the texture is filled with
  138977. * @param options Defines the other none mandatory texture creation options
  138978. */
  138979. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  138980. private _createInternalTexture;
  138981. /**
  138982. * Returns the texture matrix used in most of the material.
  138983. */
  138984. getTextureMatrix(): Matrix;
  138985. /**
  138986. * Updates the content of the texture.
  138987. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  138988. */
  138989. update(invertY?: Nullable<boolean>): void;
  138990. }
  138991. }
  138992. declare module BABYLON {
  138993. /**
  138994. * Based on jsTGALoader - Javascript loader for TGA file
  138995. * By Vincent Thibault
  138996. * @see http://blog.robrowser.com/javascript-tga-loader.html
  138997. */
  138998. export class TGATools {
  138999. private static _TYPE_INDEXED;
  139000. private static _TYPE_RGB;
  139001. private static _TYPE_GREY;
  139002. private static _TYPE_RLE_INDEXED;
  139003. private static _TYPE_RLE_RGB;
  139004. private static _TYPE_RLE_GREY;
  139005. private static _ORIGIN_MASK;
  139006. private static _ORIGIN_SHIFT;
  139007. private static _ORIGIN_BL;
  139008. private static _ORIGIN_BR;
  139009. private static _ORIGIN_UL;
  139010. private static _ORIGIN_UR;
  139011. /**
  139012. * Gets the header of a TGA file
  139013. * @param data defines the TGA data
  139014. * @returns the header
  139015. */
  139016. static GetTGAHeader(data: Uint8Array): any;
  139017. /**
  139018. * Uploads TGA content to a Babylon Texture
  139019. * @hidden
  139020. */
  139021. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  139022. /** @hidden */
  139023. 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;
  139024. /** @hidden */
  139025. 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;
  139026. /** @hidden */
  139027. 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;
  139028. /** @hidden */
  139029. 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;
  139030. /** @hidden */
  139031. 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;
  139032. /** @hidden */
  139033. 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;
  139034. }
  139035. }
  139036. declare module BABYLON {
  139037. /**
  139038. * Implementation of the TGA Texture Loader.
  139039. * @hidden
  139040. */
  139041. export class _TGATextureLoader implements IInternalTextureLoader {
  139042. /**
  139043. * Defines wether the loader supports cascade loading the different faces.
  139044. */
  139045. readonly supportCascades: boolean;
  139046. /**
  139047. * This returns if the loader support the current file information.
  139048. * @param extension defines the file extension of the file being loaded
  139049. * @returns true if the loader can load the specified file
  139050. */
  139051. canLoad(extension: string): boolean;
  139052. /**
  139053. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139054. * @param data contains the texture data
  139055. * @param texture defines the BabylonJS internal texture
  139056. * @param createPolynomials will be true if polynomials have been requested
  139057. * @param onLoad defines the callback to trigger once the texture is ready
  139058. * @param onError defines the callback to trigger in case of error
  139059. */
  139060. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139061. /**
  139062. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139063. * @param data contains the texture data
  139064. * @param texture defines the BabylonJS internal texture
  139065. * @param callback defines the method to call once ready to upload
  139066. */
  139067. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139068. }
  139069. }
  139070. declare module BABYLON {
  139071. /**
  139072. * Info about the .basis files
  139073. */
  139074. class BasisFileInfo {
  139075. /**
  139076. * If the file has alpha
  139077. */
  139078. hasAlpha: boolean;
  139079. /**
  139080. * Info about each image of the basis file
  139081. */
  139082. images: Array<{
  139083. levels: Array<{
  139084. width: number;
  139085. height: number;
  139086. transcodedPixels: ArrayBufferView;
  139087. }>;
  139088. }>;
  139089. }
  139090. /**
  139091. * Result of transcoding a basis file
  139092. */
  139093. class TranscodeResult {
  139094. /**
  139095. * Info about the .basis file
  139096. */
  139097. fileInfo: BasisFileInfo;
  139098. /**
  139099. * Format to use when loading the file
  139100. */
  139101. format: number;
  139102. }
  139103. /**
  139104. * Configuration options for the Basis transcoder
  139105. */
  139106. export class BasisTranscodeConfiguration {
  139107. /**
  139108. * Supported compression formats used to determine the supported output format of the transcoder
  139109. */
  139110. supportedCompressionFormats?: {
  139111. /**
  139112. * etc1 compression format
  139113. */
  139114. etc1?: boolean;
  139115. /**
  139116. * s3tc compression format
  139117. */
  139118. s3tc?: boolean;
  139119. /**
  139120. * pvrtc compression format
  139121. */
  139122. pvrtc?: boolean;
  139123. /**
  139124. * etc2 compression format
  139125. */
  139126. etc2?: boolean;
  139127. };
  139128. /**
  139129. * If mipmap levels should be loaded for transcoded images (Default: true)
  139130. */
  139131. loadMipmapLevels?: boolean;
  139132. /**
  139133. * Index of a single image to load (Default: all images)
  139134. */
  139135. loadSingleImage?: number;
  139136. }
  139137. /**
  139138. * Used to load .Basis files
  139139. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  139140. */
  139141. export class BasisTools {
  139142. private static _IgnoreSupportedFormats;
  139143. /**
  139144. * URL to use when loading the basis transcoder
  139145. */
  139146. static JSModuleURL: string;
  139147. /**
  139148. * URL to use when loading the wasm module for the transcoder
  139149. */
  139150. static WasmModuleURL: string;
  139151. /**
  139152. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  139153. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  139154. * @returns internal format corresponding to the Basis format
  139155. */
  139156. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  139157. private static _WorkerPromise;
  139158. private static _Worker;
  139159. private static _actionId;
  139160. private static _CreateWorkerAsync;
  139161. /**
  139162. * Transcodes a loaded image file to compressed pixel data
  139163. * @param data image data to transcode
  139164. * @param config configuration options for the transcoding
  139165. * @returns a promise resulting in the transcoded image
  139166. */
  139167. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  139168. /**
  139169. * Loads a texture from the transcode result
  139170. * @param texture texture load to
  139171. * @param transcodeResult the result of transcoding the basis file to load from
  139172. */
  139173. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  139174. }
  139175. }
  139176. declare module BABYLON {
  139177. /**
  139178. * Loader for .basis file format
  139179. */
  139180. export class _BasisTextureLoader implements IInternalTextureLoader {
  139181. /**
  139182. * Defines whether the loader supports cascade loading the different faces.
  139183. */
  139184. readonly supportCascades: boolean;
  139185. /**
  139186. * This returns if the loader support the current file information.
  139187. * @param extension defines the file extension of the file being loaded
  139188. * @returns true if the loader can load the specified file
  139189. */
  139190. canLoad(extension: string): boolean;
  139191. /**
  139192. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  139193. * @param data contains the texture data
  139194. * @param texture defines the BabylonJS internal texture
  139195. * @param createPolynomials will be true if polynomials have been requested
  139196. * @param onLoad defines the callback to trigger once the texture is ready
  139197. * @param onError defines the callback to trigger in case of error
  139198. */
  139199. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  139200. /**
  139201. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  139202. * @param data contains the texture data
  139203. * @param texture defines the BabylonJS internal texture
  139204. * @param callback defines the method to call once ready to upload
  139205. */
  139206. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  139207. }
  139208. }
  139209. declare module BABYLON {
  139210. /**
  139211. * Defines the basic options interface of a TexturePacker Frame
  139212. */
  139213. export interface ITexturePackerFrame {
  139214. /**
  139215. * The frame ID
  139216. */
  139217. id: number;
  139218. /**
  139219. * The frames Scale
  139220. */
  139221. scale: Vector2;
  139222. /**
  139223. * The Frames offset
  139224. */
  139225. offset: Vector2;
  139226. }
  139227. /**
  139228. * This is a support class for frame Data on texture packer sets.
  139229. */
  139230. export class TexturePackerFrame implements ITexturePackerFrame {
  139231. /**
  139232. * The frame ID
  139233. */
  139234. id: number;
  139235. /**
  139236. * The frames Scale
  139237. */
  139238. scale: Vector2;
  139239. /**
  139240. * The Frames offset
  139241. */
  139242. offset: Vector2;
  139243. /**
  139244. * Initializes a texture package frame.
  139245. * @param id The numerical frame identifier
  139246. * @param scale Scalar Vector2 for UV frame
  139247. * @param offset Vector2 for the frame position in UV units.
  139248. * @returns TexturePackerFrame
  139249. */
  139250. constructor(id: number, scale: Vector2, offset: Vector2);
  139251. }
  139252. }
  139253. declare module BABYLON {
  139254. /**
  139255. * Defines the basic options interface of a TexturePacker
  139256. */
  139257. export interface ITexturePackerOptions {
  139258. /**
  139259. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  139260. */
  139261. map?: string[];
  139262. /**
  139263. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139264. */
  139265. uvsIn?: string;
  139266. /**
  139267. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  139268. */
  139269. uvsOut?: string;
  139270. /**
  139271. * number representing the layout style. Defaults to LAYOUT_STRIP
  139272. */
  139273. layout?: number;
  139274. /**
  139275. * number of columns if using custom column count layout(2). This defaults to 4.
  139276. */
  139277. colnum?: number;
  139278. /**
  139279. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  139280. */
  139281. updateInputMeshes?: boolean;
  139282. /**
  139283. * boolean flag to dispose all the source textures. Defaults to true.
  139284. */
  139285. disposeSources?: boolean;
  139286. /**
  139287. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  139288. */
  139289. fillBlanks?: boolean;
  139290. /**
  139291. * string value representing the context fill style color. Defaults to 'black'.
  139292. */
  139293. customFillColor?: string;
  139294. /**
  139295. * Width and Height Value of each Frame in the TexturePacker Sets
  139296. */
  139297. frameSize?: number;
  139298. /**
  139299. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  139300. */
  139301. paddingRatio?: number;
  139302. /**
  139303. * Number that declares the fill method for the padding gutter.
  139304. */
  139305. paddingMode?: number;
  139306. /**
  139307. * If in SUBUV_COLOR padding mode what color to use.
  139308. */
  139309. paddingColor?: Color3 | Color4;
  139310. }
  139311. /**
  139312. * Defines the basic interface of a TexturePacker JSON File
  139313. */
  139314. export interface ITexturePackerJSON {
  139315. /**
  139316. * The frame ID
  139317. */
  139318. name: string;
  139319. /**
  139320. * The base64 channel data
  139321. */
  139322. sets: any;
  139323. /**
  139324. * The options of the Packer
  139325. */
  139326. options: ITexturePackerOptions;
  139327. /**
  139328. * The frame data of the Packer
  139329. */
  139330. frames: Array<number>;
  139331. }
  139332. /**
  139333. * This is a support class that generates a series of packed texture sets.
  139334. * @see https://doc.babylonjs.com/babylon101/materials
  139335. */
  139336. export class TexturePacker {
  139337. /** Packer Layout Constant 0 */
  139338. static readonly LAYOUT_STRIP: number;
  139339. /** Packer Layout Constant 1 */
  139340. static readonly LAYOUT_POWER2: number;
  139341. /** Packer Layout Constant 2 */
  139342. static readonly LAYOUT_COLNUM: number;
  139343. /** Packer Layout Constant 0 */
  139344. static readonly SUBUV_WRAP: number;
  139345. /** Packer Layout Constant 1 */
  139346. static readonly SUBUV_EXTEND: number;
  139347. /** Packer Layout Constant 2 */
  139348. static readonly SUBUV_COLOR: number;
  139349. /** The Name of the Texture Package */
  139350. name: string;
  139351. /** The scene scope of the TexturePacker */
  139352. scene: Scene;
  139353. /** The Meshes to target */
  139354. meshes: AbstractMesh[];
  139355. /** Arguments passed with the Constructor */
  139356. options: ITexturePackerOptions;
  139357. /** The promise that is started upon initialization */
  139358. promise: Nullable<Promise<TexturePacker | string>>;
  139359. /** The Container object for the channel sets that are generated */
  139360. sets: object;
  139361. /** The Container array for the frames that are generated */
  139362. frames: TexturePackerFrame[];
  139363. /** The expected number of textures the system is parsing. */
  139364. private _expecting;
  139365. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  139366. private _paddingValue;
  139367. /**
  139368. * Initializes a texture package series from an array of meshes or a single mesh.
  139369. * @param name The name of the package
  139370. * @param meshes The target meshes to compose the package from
  139371. * @param options The arguments that texture packer should follow while building.
  139372. * @param scene The scene which the textures are scoped to.
  139373. * @returns TexturePacker
  139374. */
  139375. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  139376. /**
  139377. * Starts the package process
  139378. * @param resolve The promises resolution function
  139379. * @returns TexturePacker
  139380. */
  139381. private _createFrames;
  139382. /**
  139383. * Calculates the Size of the Channel Sets
  139384. * @returns Vector2
  139385. */
  139386. private _calculateSize;
  139387. /**
  139388. * Calculates the UV data for the frames.
  139389. * @param baseSize the base frameSize
  139390. * @param padding the base frame padding
  139391. * @param dtSize size of the Dynamic Texture for that channel
  139392. * @param dtUnits is 1/dtSize
  139393. * @param update flag to update the input meshes
  139394. */
  139395. private _calculateMeshUVFrames;
  139396. /**
  139397. * Calculates the frames Offset.
  139398. * @param index of the frame
  139399. * @returns Vector2
  139400. */
  139401. private _getFrameOffset;
  139402. /**
  139403. * Updates a Mesh to the frame data
  139404. * @param mesh that is the target
  139405. * @param frameID or the frame index
  139406. */
  139407. private _updateMeshUV;
  139408. /**
  139409. * Updates a Meshes materials to use the texture packer channels
  139410. * @param m is the mesh to target
  139411. * @param force all channels on the packer to be set.
  139412. */
  139413. private _updateTextureReferences;
  139414. /**
  139415. * Public method to set a Mesh to a frame
  139416. * @param m that is the target
  139417. * @param frameID or the frame index
  139418. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  139419. */
  139420. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  139421. /**
  139422. * Starts the async promise to compile the texture packer.
  139423. * @returns Promise<void>
  139424. */
  139425. processAsync(): Promise<void>;
  139426. /**
  139427. * Disposes all textures associated with this packer
  139428. */
  139429. dispose(): void;
  139430. /**
  139431. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  139432. * @param imageType is the image type to use.
  139433. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  139434. */
  139435. download(imageType?: string, quality?: number): void;
  139436. /**
  139437. * Public method to load a texturePacker JSON file.
  139438. * @param data of the JSON file in string format.
  139439. */
  139440. updateFromJSON(data: string): void;
  139441. }
  139442. }
  139443. declare module BABYLON {
  139444. /**
  139445. * 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.
  139446. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139447. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139448. */
  139449. export class CustomProceduralTexture extends ProceduralTexture {
  139450. private _animate;
  139451. private _time;
  139452. private _config;
  139453. private _texturePath;
  139454. /**
  139455. * Instantiates a new Custom Procedural Texture.
  139456. * 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.
  139457. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  139458. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  139459. * @param name Define the name of the texture
  139460. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  139461. * @param size Define the size of the texture to create
  139462. * @param scene Define the scene the texture belongs to
  139463. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  139464. * @param generateMipMaps Define if the texture should creates mip maps or not
  139465. */
  139466. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139467. private _loadJson;
  139468. /**
  139469. * Is the texture ready to be used ? (rendered at least once)
  139470. * @returns true if ready, otherwise, false.
  139471. */
  139472. isReady(): boolean;
  139473. /**
  139474. * Render the texture to its associated render target.
  139475. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  139476. */
  139477. render(useCameraPostProcess?: boolean): void;
  139478. /**
  139479. * Update the list of dependant textures samplers in the shader.
  139480. */
  139481. updateTextures(): void;
  139482. /**
  139483. * Update the uniform values of the procedural texture in the shader.
  139484. */
  139485. updateShaderUniforms(): void;
  139486. /**
  139487. * Define if the texture animates or not.
  139488. */
  139489. get animate(): boolean;
  139490. set animate(value: boolean);
  139491. }
  139492. }
  139493. declare module BABYLON {
  139494. /** @hidden */
  139495. export var noisePixelShader: {
  139496. name: string;
  139497. shader: string;
  139498. };
  139499. }
  139500. declare module BABYLON {
  139501. /**
  139502. * Class used to generate noise procedural textures
  139503. */
  139504. export class NoiseProceduralTexture extends ProceduralTexture {
  139505. private _time;
  139506. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  139507. brightness: number;
  139508. /** Defines the number of octaves to process */
  139509. octaves: number;
  139510. /** Defines the level of persistence (0.8 by default) */
  139511. persistence: number;
  139512. /** Gets or sets animation speed factor (default is 1) */
  139513. animationSpeedFactor: number;
  139514. /**
  139515. * Creates a new NoiseProceduralTexture
  139516. * @param name defines the name fo the texture
  139517. * @param size defines the size of the texture (default is 256)
  139518. * @param scene defines the hosting scene
  139519. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  139520. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  139521. */
  139522. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  139523. private _updateShaderUniforms;
  139524. protected _getDefines(): string;
  139525. /** Generate the current state of the procedural texture */
  139526. render(useCameraPostProcess?: boolean): void;
  139527. /**
  139528. * Serializes this noise procedural texture
  139529. * @returns a serialized noise procedural texture object
  139530. */
  139531. serialize(): any;
  139532. /**
  139533. * Clone the texture.
  139534. * @returns the cloned texture
  139535. */
  139536. clone(): NoiseProceduralTexture;
  139537. /**
  139538. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  139539. * @param parsedTexture defines parsed texture data
  139540. * @param scene defines the current scene
  139541. * @param rootUrl defines the root URL containing noise procedural texture information
  139542. * @returns a parsed NoiseProceduralTexture
  139543. */
  139544. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  139545. }
  139546. }
  139547. declare module BABYLON {
  139548. /**
  139549. * Raw cube texture where the raw buffers are passed in
  139550. */
  139551. export class RawCubeTexture extends CubeTexture {
  139552. /**
  139553. * Creates a cube texture where the raw buffers are passed in.
  139554. * @param scene defines the scene the texture is attached to
  139555. * @param data defines the array of data to use to create each face
  139556. * @param size defines the size of the textures
  139557. * @param format defines the format of the data
  139558. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  139559. * @param generateMipMaps defines if the engine should generate the mip levels
  139560. * @param invertY defines if data must be stored with Y axis inverted
  139561. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  139562. * @param compression defines the compression used (null by default)
  139563. */
  139564. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  139565. /**
  139566. * Updates the raw cube texture.
  139567. * @param data defines the data to store
  139568. * @param format defines the data format
  139569. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139570. * @param invertY defines if data must be stored with Y axis inverted
  139571. * @param compression defines the compression used (null by default)
  139572. * @param level defines which level of the texture to update
  139573. */
  139574. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  139575. /**
  139576. * Updates a raw cube texture with RGBD encoded data.
  139577. * @param data defines the array of data [mipmap][face] to use to create each face
  139578. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  139579. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  139580. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  139581. * @returns a promsie that resolves when the operation is complete
  139582. */
  139583. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  139584. /**
  139585. * Clones the raw cube texture.
  139586. * @return a new cube texture
  139587. */
  139588. clone(): CubeTexture;
  139589. /** @hidden */
  139590. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  139591. }
  139592. }
  139593. declare module BABYLON {
  139594. /**
  139595. * Class used to store 2D array textures containing user data
  139596. */
  139597. export class RawTexture2DArray extends Texture {
  139598. /** Gets or sets the texture format to use */
  139599. format: number;
  139600. /**
  139601. * Create a new RawTexture2DArray
  139602. * @param data defines the data of the texture
  139603. * @param width defines the width of the texture
  139604. * @param height defines the height of the texture
  139605. * @param depth defines the number of layers of the texture
  139606. * @param format defines the texture format to use
  139607. * @param scene defines the hosting scene
  139608. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139609. * @param invertY defines if texture must be stored with Y axis inverted
  139610. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139611. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139612. */
  139613. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139614. /** Gets or sets the texture format to use */
  139615. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139616. /**
  139617. * Update the texture with new data
  139618. * @param data defines the data to store in the texture
  139619. */
  139620. update(data: ArrayBufferView): void;
  139621. }
  139622. }
  139623. declare module BABYLON {
  139624. /**
  139625. * Class used to store 3D textures containing user data
  139626. */
  139627. export class RawTexture3D extends Texture {
  139628. /** Gets or sets the texture format to use */
  139629. format: number;
  139630. /**
  139631. * Create a new RawTexture3D
  139632. * @param data defines the data of the texture
  139633. * @param width defines the width of the texture
  139634. * @param height defines the height of the texture
  139635. * @param depth defines the depth of the texture
  139636. * @param format defines the texture format to use
  139637. * @param scene defines the hosting scene
  139638. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  139639. * @param invertY defines if texture must be stored with Y axis inverted
  139640. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  139641. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  139642. */
  139643. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  139644. /** Gets or sets the texture format to use */
  139645. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  139646. /**
  139647. * Update the texture with new data
  139648. * @param data defines the data to store in the texture
  139649. */
  139650. update(data: ArrayBufferView): void;
  139651. }
  139652. }
  139653. declare module BABYLON {
  139654. /**
  139655. * Creates a refraction texture used by refraction channel of the standard material.
  139656. * It is like a mirror but to see through a material.
  139657. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139658. */
  139659. export class RefractionTexture extends RenderTargetTexture {
  139660. /**
  139661. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  139662. * 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.
  139663. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139664. */
  139665. refractionPlane: Plane;
  139666. /**
  139667. * Define how deep under the surface we should see.
  139668. */
  139669. depth: number;
  139670. /**
  139671. * Creates a refraction texture used by refraction channel of the standard material.
  139672. * It is like a mirror but to see through a material.
  139673. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  139674. * @param name Define the texture name
  139675. * @param size Define the size of the underlying texture
  139676. * @param scene Define the scene the refraction belongs to
  139677. * @param generateMipMaps Define if we need to generate mips level for the refraction
  139678. */
  139679. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  139680. /**
  139681. * Clone the refraction texture.
  139682. * @returns the cloned texture
  139683. */
  139684. clone(): RefractionTexture;
  139685. /**
  139686. * Serialize the texture to a JSON representation you could use in Parse later on
  139687. * @returns the serialized JSON representation
  139688. */
  139689. serialize(): any;
  139690. }
  139691. }
  139692. declare module BABYLON {
  139693. /**
  139694. * Block used to add support for vertex skinning (bones)
  139695. */
  139696. export class BonesBlock extends NodeMaterialBlock {
  139697. /**
  139698. * Creates a new BonesBlock
  139699. * @param name defines the block name
  139700. */
  139701. constructor(name: string);
  139702. /**
  139703. * Initialize the block and prepare the context for build
  139704. * @param state defines the state that will be used for the build
  139705. */
  139706. initialize(state: NodeMaterialBuildState): void;
  139707. /**
  139708. * Gets the current class name
  139709. * @returns the class name
  139710. */
  139711. getClassName(): string;
  139712. /**
  139713. * Gets the matrix indices input component
  139714. */
  139715. get matricesIndices(): NodeMaterialConnectionPoint;
  139716. /**
  139717. * Gets the matrix weights input component
  139718. */
  139719. get matricesWeights(): NodeMaterialConnectionPoint;
  139720. /**
  139721. * Gets the extra matrix indices input component
  139722. */
  139723. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  139724. /**
  139725. * Gets the extra matrix weights input component
  139726. */
  139727. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  139728. /**
  139729. * Gets the world input component
  139730. */
  139731. get world(): NodeMaterialConnectionPoint;
  139732. /**
  139733. * Gets the output component
  139734. */
  139735. get output(): NodeMaterialConnectionPoint;
  139736. autoConfigure(material: NodeMaterial): void;
  139737. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  139738. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139739. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139740. protected _buildBlock(state: NodeMaterialBuildState): this;
  139741. }
  139742. }
  139743. declare module BABYLON {
  139744. /**
  139745. * Block used to add support for instances
  139746. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  139747. */
  139748. export class InstancesBlock extends NodeMaterialBlock {
  139749. /**
  139750. * Creates a new InstancesBlock
  139751. * @param name defines the block name
  139752. */
  139753. constructor(name: string);
  139754. /**
  139755. * Gets the current class name
  139756. * @returns the class name
  139757. */
  139758. getClassName(): string;
  139759. /**
  139760. * Gets the first world row input component
  139761. */
  139762. get world0(): NodeMaterialConnectionPoint;
  139763. /**
  139764. * Gets the second world row input component
  139765. */
  139766. get world1(): NodeMaterialConnectionPoint;
  139767. /**
  139768. * Gets the third world row input component
  139769. */
  139770. get world2(): NodeMaterialConnectionPoint;
  139771. /**
  139772. * Gets the forth world row input component
  139773. */
  139774. get world3(): NodeMaterialConnectionPoint;
  139775. /**
  139776. * Gets the world input component
  139777. */
  139778. get world(): NodeMaterialConnectionPoint;
  139779. /**
  139780. * Gets the output component
  139781. */
  139782. get output(): NodeMaterialConnectionPoint;
  139783. /**
  139784. * Gets the isntanceID component
  139785. */
  139786. get instanceID(): NodeMaterialConnectionPoint;
  139787. autoConfigure(material: NodeMaterial): void;
  139788. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  139789. protected _buildBlock(state: NodeMaterialBuildState): this;
  139790. }
  139791. }
  139792. declare module BABYLON {
  139793. /**
  139794. * Block used to add morph targets support to vertex shader
  139795. */
  139796. export class MorphTargetsBlock extends NodeMaterialBlock {
  139797. private _repeatableContentAnchor;
  139798. /**
  139799. * Create a new MorphTargetsBlock
  139800. * @param name defines the block name
  139801. */
  139802. constructor(name: string);
  139803. /**
  139804. * Gets the current class name
  139805. * @returns the class name
  139806. */
  139807. getClassName(): string;
  139808. /**
  139809. * Gets the position input component
  139810. */
  139811. get position(): NodeMaterialConnectionPoint;
  139812. /**
  139813. * Gets the normal input component
  139814. */
  139815. get normal(): NodeMaterialConnectionPoint;
  139816. /**
  139817. * Gets the tangent input component
  139818. */
  139819. get tangent(): NodeMaterialConnectionPoint;
  139820. /**
  139821. * Gets the tangent input component
  139822. */
  139823. get uv(): NodeMaterialConnectionPoint;
  139824. /**
  139825. * Gets the position output component
  139826. */
  139827. get positionOutput(): NodeMaterialConnectionPoint;
  139828. /**
  139829. * Gets the normal output component
  139830. */
  139831. get normalOutput(): NodeMaterialConnectionPoint;
  139832. /**
  139833. * Gets the tangent output component
  139834. */
  139835. get tangentOutput(): NodeMaterialConnectionPoint;
  139836. /**
  139837. * Gets the tangent output component
  139838. */
  139839. get uvOutput(): NodeMaterialConnectionPoint;
  139840. initialize(state: NodeMaterialBuildState): void;
  139841. autoConfigure(material: NodeMaterial): void;
  139842. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139843. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139844. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  139845. protected _buildBlock(state: NodeMaterialBuildState): this;
  139846. }
  139847. }
  139848. declare module BABYLON {
  139849. /**
  139850. * Block used to get data information from a light
  139851. */
  139852. export class LightInformationBlock extends NodeMaterialBlock {
  139853. private _lightDataUniformName;
  139854. private _lightColorUniformName;
  139855. private _lightTypeDefineName;
  139856. /**
  139857. * Gets or sets the light associated with this block
  139858. */
  139859. light: Nullable<Light>;
  139860. /**
  139861. * Creates a new LightInformationBlock
  139862. * @param name defines the block name
  139863. */
  139864. constructor(name: string);
  139865. /**
  139866. * Gets the current class name
  139867. * @returns the class name
  139868. */
  139869. getClassName(): string;
  139870. /**
  139871. * Gets the world position input component
  139872. */
  139873. get worldPosition(): NodeMaterialConnectionPoint;
  139874. /**
  139875. * Gets the direction output component
  139876. */
  139877. get direction(): NodeMaterialConnectionPoint;
  139878. /**
  139879. * Gets the direction output component
  139880. */
  139881. get color(): NodeMaterialConnectionPoint;
  139882. /**
  139883. * Gets the direction output component
  139884. */
  139885. get intensity(): NodeMaterialConnectionPoint;
  139886. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139887. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139888. protected _buildBlock(state: NodeMaterialBuildState): this;
  139889. serialize(): any;
  139890. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139891. }
  139892. }
  139893. declare module BABYLON {
  139894. /**
  139895. * Block used to add image processing support to fragment shader
  139896. */
  139897. export class ImageProcessingBlock extends NodeMaterialBlock {
  139898. /**
  139899. * Create a new ImageProcessingBlock
  139900. * @param name defines the block name
  139901. */
  139902. constructor(name: string);
  139903. /**
  139904. * Gets the current class name
  139905. * @returns the class name
  139906. */
  139907. getClassName(): string;
  139908. /**
  139909. * Gets the color input component
  139910. */
  139911. get color(): NodeMaterialConnectionPoint;
  139912. /**
  139913. * Gets the output component
  139914. */
  139915. get output(): NodeMaterialConnectionPoint;
  139916. /**
  139917. * Initialize the block and prepare the context for build
  139918. * @param state defines the state that will be used for the build
  139919. */
  139920. initialize(state: NodeMaterialBuildState): void;
  139921. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  139922. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139923. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139924. protected _buildBlock(state: NodeMaterialBuildState): this;
  139925. }
  139926. }
  139927. declare module BABYLON {
  139928. /**
  139929. * Block used to pertub normals based on a normal map
  139930. */
  139931. export class PerturbNormalBlock extends NodeMaterialBlock {
  139932. private _tangentSpaceParameterName;
  139933. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  139934. invertX: boolean;
  139935. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  139936. invertY: boolean;
  139937. /**
  139938. * Create a new PerturbNormalBlock
  139939. * @param name defines the block name
  139940. */
  139941. constructor(name: string);
  139942. /**
  139943. * Gets the current class name
  139944. * @returns the class name
  139945. */
  139946. getClassName(): string;
  139947. /**
  139948. * Gets the world position input component
  139949. */
  139950. get worldPosition(): NodeMaterialConnectionPoint;
  139951. /**
  139952. * Gets the world normal input component
  139953. */
  139954. get worldNormal(): NodeMaterialConnectionPoint;
  139955. /**
  139956. * Gets the world tangent input component
  139957. */
  139958. get worldTangent(): NodeMaterialConnectionPoint;
  139959. /**
  139960. * Gets the uv input component
  139961. */
  139962. get uv(): NodeMaterialConnectionPoint;
  139963. /**
  139964. * Gets the normal map color input component
  139965. */
  139966. get normalMapColor(): NodeMaterialConnectionPoint;
  139967. /**
  139968. * Gets the strength input component
  139969. */
  139970. get strength(): NodeMaterialConnectionPoint;
  139971. /**
  139972. * Gets the output component
  139973. */
  139974. get output(): NodeMaterialConnectionPoint;
  139975. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  139976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  139977. autoConfigure(material: NodeMaterial): void;
  139978. protected _buildBlock(state: NodeMaterialBuildState): this;
  139979. protected _dumpPropertiesCode(): string;
  139980. serialize(): any;
  139981. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  139982. }
  139983. }
  139984. declare module BABYLON {
  139985. /**
  139986. * Block used to discard a pixel if a value is smaller than a cutoff
  139987. */
  139988. export class DiscardBlock extends NodeMaterialBlock {
  139989. /**
  139990. * Create a new DiscardBlock
  139991. * @param name defines the block name
  139992. */
  139993. constructor(name: string);
  139994. /**
  139995. * Gets the current class name
  139996. * @returns the class name
  139997. */
  139998. getClassName(): string;
  139999. /**
  140000. * Gets the color input component
  140001. */
  140002. get value(): NodeMaterialConnectionPoint;
  140003. /**
  140004. * Gets the cutoff input component
  140005. */
  140006. get cutoff(): NodeMaterialConnectionPoint;
  140007. protected _buildBlock(state: NodeMaterialBuildState): this;
  140008. }
  140009. }
  140010. declare module BABYLON {
  140011. /**
  140012. * Block used to test if the fragment shader is front facing
  140013. */
  140014. export class FrontFacingBlock extends NodeMaterialBlock {
  140015. /**
  140016. * Creates a new FrontFacingBlock
  140017. * @param name defines the block name
  140018. */
  140019. constructor(name: string);
  140020. /**
  140021. * Gets the current class name
  140022. * @returns the class name
  140023. */
  140024. getClassName(): string;
  140025. /**
  140026. * Gets the output component
  140027. */
  140028. get output(): NodeMaterialConnectionPoint;
  140029. protected _buildBlock(state: NodeMaterialBuildState): this;
  140030. }
  140031. }
  140032. declare module BABYLON {
  140033. /**
  140034. * Block used to get the derivative value on x and y of a given input
  140035. */
  140036. export class DerivativeBlock extends NodeMaterialBlock {
  140037. /**
  140038. * Create a new DerivativeBlock
  140039. * @param name defines the block name
  140040. */
  140041. constructor(name: string);
  140042. /**
  140043. * Gets the current class name
  140044. * @returns the class name
  140045. */
  140046. getClassName(): string;
  140047. /**
  140048. * Gets the input component
  140049. */
  140050. get input(): NodeMaterialConnectionPoint;
  140051. /**
  140052. * Gets the derivative output on x
  140053. */
  140054. get dx(): NodeMaterialConnectionPoint;
  140055. /**
  140056. * Gets the derivative output on y
  140057. */
  140058. get dy(): NodeMaterialConnectionPoint;
  140059. protected _buildBlock(state: NodeMaterialBuildState): this;
  140060. }
  140061. }
  140062. declare module BABYLON {
  140063. /**
  140064. * Block used to make gl_FragCoord available
  140065. */
  140066. export class FragCoordBlock extends NodeMaterialBlock {
  140067. /**
  140068. * Creates a new FragCoordBlock
  140069. * @param name defines the block name
  140070. */
  140071. constructor(name: string);
  140072. /**
  140073. * Gets the current class name
  140074. * @returns the class name
  140075. */
  140076. getClassName(): string;
  140077. /**
  140078. * Gets the xy component
  140079. */
  140080. get xy(): NodeMaterialConnectionPoint;
  140081. /**
  140082. * Gets the xyz component
  140083. */
  140084. get xyz(): NodeMaterialConnectionPoint;
  140085. /**
  140086. * Gets the xyzw component
  140087. */
  140088. get xyzw(): NodeMaterialConnectionPoint;
  140089. /**
  140090. * Gets the x component
  140091. */
  140092. get x(): NodeMaterialConnectionPoint;
  140093. /**
  140094. * Gets the y component
  140095. */
  140096. get y(): NodeMaterialConnectionPoint;
  140097. /**
  140098. * Gets the z component
  140099. */
  140100. get z(): NodeMaterialConnectionPoint;
  140101. /**
  140102. * Gets the w component
  140103. */
  140104. get output(): NodeMaterialConnectionPoint;
  140105. protected writeOutputs(state: NodeMaterialBuildState): string;
  140106. protected _buildBlock(state: NodeMaterialBuildState): this;
  140107. }
  140108. }
  140109. declare module BABYLON {
  140110. /**
  140111. * Block used to get the screen sizes
  140112. */
  140113. export class ScreenSizeBlock extends NodeMaterialBlock {
  140114. private _varName;
  140115. private _scene;
  140116. /**
  140117. * Creates a new ScreenSizeBlock
  140118. * @param name defines the block name
  140119. */
  140120. constructor(name: string);
  140121. /**
  140122. * Gets the current class name
  140123. * @returns the class name
  140124. */
  140125. getClassName(): string;
  140126. /**
  140127. * Gets the xy component
  140128. */
  140129. get xy(): NodeMaterialConnectionPoint;
  140130. /**
  140131. * Gets the x component
  140132. */
  140133. get x(): NodeMaterialConnectionPoint;
  140134. /**
  140135. * Gets the y component
  140136. */
  140137. get y(): NodeMaterialConnectionPoint;
  140138. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140139. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  140140. protected _buildBlock(state: NodeMaterialBuildState): this;
  140141. }
  140142. }
  140143. declare module BABYLON {
  140144. /**
  140145. * Block used to add support for scene fog
  140146. */
  140147. export class FogBlock extends NodeMaterialBlock {
  140148. private _fogDistanceName;
  140149. private _fogParameters;
  140150. /**
  140151. * Create a new FogBlock
  140152. * @param name defines the block name
  140153. */
  140154. constructor(name: string);
  140155. /**
  140156. * Gets the current class name
  140157. * @returns the class name
  140158. */
  140159. getClassName(): string;
  140160. /**
  140161. * Gets the world position input component
  140162. */
  140163. get worldPosition(): NodeMaterialConnectionPoint;
  140164. /**
  140165. * Gets the view input component
  140166. */
  140167. get view(): NodeMaterialConnectionPoint;
  140168. /**
  140169. * Gets the color input component
  140170. */
  140171. get input(): NodeMaterialConnectionPoint;
  140172. /**
  140173. * Gets the fog color input component
  140174. */
  140175. get fogColor(): NodeMaterialConnectionPoint;
  140176. /**
  140177. * Gets the output component
  140178. */
  140179. get output(): NodeMaterialConnectionPoint;
  140180. autoConfigure(material: NodeMaterial): void;
  140181. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140182. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140183. protected _buildBlock(state: NodeMaterialBuildState): this;
  140184. }
  140185. }
  140186. declare module BABYLON {
  140187. /**
  140188. * Block used to add light in the fragment shader
  140189. */
  140190. export class LightBlock extends NodeMaterialBlock {
  140191. private _lightId;
  140192. /**
  140193. * Gets or sets the light associated with this block
  140194. */
  140195. light: Nullable<Light>;
  140196. /**
  140197. * Create a new LightBlock
  140198. * @param name defines the block name
  140199. */
  140200. constructor(name: string);
  140201. /**
  140202. * Gets the current class name
  140203. * @returns the class name
  140204. */
  140205. getClassName(): string;
  140206. /**
  140207. * Gets the world position input component
  140208. */
  140209. get worldPosition(): NodeMaterialConnectionPoint;
  140210. /**
  140211. * Gets the world normal input component
  140212. */
  140213. get worldNormal(): NodeMaterialConnectionPoint;
  140214. /**
  140215. * Gets the camera (or eye) position component
  140216. */
  140217. get cameraPosition(): NodeMaterialConnectionPoint;
  140218. /**
  140219. * Gets the glossiness component
  140220. */
  140221. get glossiness(): NodeMaterialConnectionPoint;
  140222. /**
  140223. * Gets the glossinness power component
  140224. */
  140225. get glossPower(): NodeMaterialConnectionPoint;
  140226. /**
  140227. * Gets the diffuse color component
  140228. */
  140229. get diffuseColor(): NodeMaterialConnectionPoint;
  140230. /**
  140231. * Gets the specular color component
  140232. */
  140233. get specularColor(): NodeMaterialConnectionPoint;
  140234. /**
  140235. * Gets the diffuse output component
  140236. */
  140237. get diffuseOutput(): NodeMaterialConnectionPoint;
  140238. /**
  140239. * Gets the specular output component
  140240. */
  140241. get specularOutput(): NodeMaterialConnectionPoint;
  140242. /**
  140243. * Gets the shadow output component
  140244. */
  140245. get shadow(): NodeMaterialConnectionPoint;
  140246. autoConfigure(material: NodeMaterial): void;
  140247. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  140248. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  140249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  140250. private _injectVertexCode;
  140251. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  140252. serialize(): any;
  140253. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140254. }
  140255. }
  140256. declare module BABYLON {
  140257. /**
  140258. * Block used to read a reflection texture from a sampler
  140259. */
  140260. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  140261. /**
  140262. * Create a new ReflectionTextureBlock
  140263. * @param name defines the block name
  140264. */
  140265. constructor(name: string);
  140266. /**
  140267. * Gets the current class name
  140268. * @returns the class name
  140269. */
  140270. getClassName(): string;
  140271. /**
  140272. * Gets the world position input component
  140273. */
  140274. get position(): NodeMaterialConnectionPoint;
  140275. /**
  140276. * Gets the world position input component
  140277. */
  140278. get worldPosition(): NodeMaterialConnectionPoint;
  140279. /**
  140280. * Gets the world normal input component
  140281. */
  140282. get worldNormal(): NodeMaterialConnectionPoint;
  140283. /**
  140284. * Gets the world input component
  140285. */
  140286. get world(): NodeMaterialConnectionPoint;
  140287. /**
  140288. * Gets the camera (or eye) position component
  140289. */
  140290. get cameraPosition(): NodeMaterialConnectionPoint;
  140291. /**
  140292. * Gets the view input component
  140293. */
  140294. get view(): NodeMaterialConnectionPoint;
  140295. /**
  140296. * Gets the rgb output component
  140297. */
  140298. get rgb(): NodeMaterialConnectionPoint;
  140299. /**
  140300. * Gets the rgba output component
  140301. */
  140302. get rgba(): NodeMaterialConnectionPoint;
  140303. /**
  140304. * Gets the r output component
  140305. */
  140306. get r(): NodeMaterialConnectionPoint;
  140307. /**
  140308. * Gets the g output component
  140309. */
  140310. get g(): NodeMaterialConnectionPoint;
  140311. /**
  140312. * Gets the b output component
  140313. */
  140314. get b(): NodeMaterialConnectionPoint;
  140315. /**
  140316. * Gets the a output component
  140317. */
  140318. get a(): NodeMaterialConnectionPoint;
  140319. autoConfigure(material: NodeMaterial): void;
  140320. protected _buildBlock(state: NodeMaterialBuildState): this;
  140321. }
  140322. }
  140323. declare module BABYLON {
  140324. /**
  140325. * Block used to add 2 vectors
  140326. */
  140327. export class AddBlock extends NodeMaterialBlock {
  140328. /**
  140329. * Creates a new AddBlock
  140330. * @param name defines the block name
  140331. */
  140332. constructor(name: string);
  140333. /**
  140334. * Gets the current class name
  140335. * @returns the class name
  140336. */
  140337. getClassName(): string;
  140338. /**
  140339. * Gets the left operand input component
  140340. */
  140341. get left(): NodeMaterialConnectionPoint;
  140342. /**
  140343. * Gets the right operand input component
  140344. */
  140345. get right(): NodeMaterialConnectionPoint;
  140346. /**
  140347. * Gets the output component
  140348. */
  140349. get output(): NodeMaterialConnectionPoint;
  140350. protected _buildBlock(state: NodeMaterialBuildState): this;
  140351. }
  140352. }
  140353. declare module BABYLON {
  140354. /**
  140355. * Block used to scale a vector by a float
  140356. */
  140357. export class ScaleBlock extends NodeMaterialBlock {
  140358. /**
  140359. * Creates a new ScaleBlock
  140360. * @param name defines the block name
  140361. */
  140362. constructor(name: string);
  140363. /**
  140364. * Gets the current class name
  140365. * @returns the class name
  140366. */
  140367. getClassName(): string;
  140368. /**
  140369. * Gets the input component
  140370. */
  140371. get input(): NodeMaterialConnectionPoint;
  140372. /**
  140373. * Gets the factor input component
  140374. */
  140375. get factor(): NodeMaterialConnectionPoint;
  140376. /**
  140377. * Gets the output component
  140378. */
  140379. get output(): NodeMaterialConnectionPoint;
  140380. protected _buildBlock(state: NodeMaterialBuildState): this;
  140381. }
  140382. }
  140383. declare module BABYLON {
  140384. /**
  140385. * Block used to clamp a float
  140386. */
  140387. export class ClampBlock extends NodeMaterialBlock {
  140388. /** Gets or sets the minimum range */
  140389. minimum: number;
  140390. /** Gets or sets the maximum range */
  140391. maximum: number;
  140392. /**
  140393. * Creates a new ClampBlock
  140394. * @param name defines the block name
  140395. */
  140396. constructor(name: string);
  140397. /**
  140398. * Gets the current class name
  140399. * @returns the class name
  140400. */
  140401. getClassName(): string;
  140402. /**
  140403. * Gets the value input component
  140404. */
  140405. get value(): NodeMaterialConnectionPoint;
  140406. /**
  140407. * Gets the output component
  140408. */
  140409. get output(): NodeMaterialConnectionPoint;
  140410. protected _buildBlock(state: NodeMaterialBuildState): this;
  140411. protected _dumpPropertiesCode(): string;
  140412. serialize(): any;
  140413. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140414. }
  140415. }
  140416. declare module BABYLON {
  140417. /**
  140418. * Block used to apply a cross product between 2 vectors
  140419. */
  140420. export class CrossBlock extends NodeMaterialBlock {
  140421. /**
  140422. * Creates a new CrossBlock
  140423. * @param name defines the block name
  140424. */
  140425. constructor(name: string);
  140426. /**
  140427. * Gets the current class name
  140428. * @returns the class name
  140429. */
  140430. getClassName(): string;
  140431. /**
  140432. * Gets the left operand input component
  140433. */
  140434. get left(): NodeMaterialConnectionPoint;
  140435. /**
  140436. * Gets the right operand input component
  140437. */
  140438. get right(): NodeMaterialConnectionPoint;
  140439. /**
  140440. * Gets the output component
  140441. */
  140442. get output(): NodeMaterialConnectionPoint;
  140443. protected _buildBlock(state: NodeMaterialBuildState): this;
  140444. }
  140445. }
  140446. declare module BABYLON {
  140447. /**
  140448. * Block used to apply a dot product between 2 vectors
  140449. */
  140450. export class DotBlock extends NodeMaterialBlock {
  140451. /**
  140452. * Creates a new DotBlock
  140453. * @param name defines the block name
  140454. */
  140455. constructor(name: string);
  140456. /**
  140457. * Gets the current class name
  140458. * @returns the class name
  140459. */
  140460. getClassName(): string;
  140461. /**
  140462. * Gets the left operand input component
  140463. */
  140464. get left(): NodeMaterialConnectionPoint;
  140465. /**
  140466. * Gets the right operand input component
  140467. */
  140468. get right(): NodeMaterialConnectionPoint;
  140469. /**
  140470. * Gets the output component
  140471. */
  140472. get output(): NodeMaterialConnectionPoint;
  140473. protected _buildBlock(state: NodeMaterialBuildState): this;
  140474. }
  140475. }
  140476. declare module BABYLON {
  140477. /**
  140478. * Block used to normalize a vector
  140479. */
  140480. export class NormalizeBlock extends NodeMaterialBlock {
  140481. /**
  140482. * Creates a new NormalizeBlock
  140483. * @param name defines the block name
  140484. */
  140485. constructor(name: string);
  140486. /**
  140487. * Gets the current class name
  140488. * @returns the class name
  140489. */
  140490. getClassName(): string;
  140491. /**
  140492. * Gets the input component
  140493. */
  140494. get input(): NodeMaterialConnectionPoint;
  140495. /**
  140496. * Gets the output component
  140497. */
  140498. get output(): NodeMaterialConnectionPoint;
  140499. protected _buildBlock(state: NodeMaterialBuildState): this;
  140500. }
  140501. }
  140502. declare module BABYLON {
  140503. /**
  140504. * Operations supported by the Trigonometry block
  140505. */
  140506. export enum TrigonometryBlockOperations {
  140507. /** Cos */
  140508. Cos = 0,
  140509. /** Sin */
  140510. Sin = 1,
  140511. /** Abs */
  140512. Abs = 2,
  140513. /** Exp */
  140514. Exp = 3,
  140515. /** Exp2 */
  140516. Exp2 = 4,
  140517. /** Round */
  140518. Round = 5,
  140519. /** Floor */
  140520. Floor = 6,
  140521. /** Ceiling */
  140522. Ceiling = 7,
  140523. /** Square root */
  140524. Sqrt = 8,
  140525. /** Log */
  140526. Log = 9,
  140527. /** Tangent */
  140528. Tan = 10,
  140529. /** Arc tangent */
  140530. ArcTan = 11,
  140531. /** Arc cosinus */
  140532. ArcCos = 12,
  140533. /** Arc sinus */
  140534. ArcSin = 13,
  140535. /** Fraction */
  140536. Fract = 14,
  140537. /** Sign */
  140538. Sign = 15,
  140539. /** To radians (from degrees) */
  140540. Radians = 16,
  140541. /** To degrees (from radians) */
  140542. Degrees = 17
  140543. }
  140544. /**
  140545. * Block used to apply trigonometry operation to floats
  140546. */
  140547. export class TrigonometryBlock extends NodeMaterialBlock {
  140548. /**
  140549. * Gets or sets the operation applied by the block
  140550. */
  140551. operation: TrigonometryBlockOperations;
  140552. /**
  140553. * Creates a new TrigonometryBlock
  140554. * @param name defines the block name
  140555. */
  140556. constructor(name: string);
  140557. /**
  140558. * Gets the current class name
  140559. * @returns the class name
  140560. */
  140561. getClassName(): string;
  140562. /**
  140563. * Gets the input component
  140564. */
  140565. get input(): NodeMaterialConnectionPoint;
  140566. /**
  140567. * Gets the output component
  140568. */
  140569. get output(): NodeMaterialConnectionPoint;
  140570. protected _buildBlock(state: NodeMaterialBuildState): this;
  140571. serialize(): any;
  140572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  140573. protected _dumpPropertiesCode(): string;
  140574. }
  140575. }
  140576. declare module BABYLON {
  140577. /**
  140578. * Block used to create a Color3/4 out of individual inputs (one for each component)
  140579. */
  140580. export class ColorMergerBlock extends NodeMaterialBlock {
  140581. /**
  140582. * Create a new ColorMergerBlock
  140583. * @param name defines the block name
  140584. */
  140585. constructor(name: string);
  140586. /**
  140587. * Gets the current class name
  140588. * @returns the class name
  140589. */
  140590. getClassName(): string;
  140591. /**
  140592. * Gets the rgb component (input)
  140593. */
  140594. get rgbIn(): NodeMaterialConnectionPoint;
  140595. /**
  140596. * Gets the r component (input)
  140597. */
  140598. get r(): NodeMaterialConnectionPoint;
  140599. /**
  140600. * Gets the g component (input)
  140601. */
  140602. get g(): NodeMaterialConnectionPoint;
  140603. /**
  140604. * Gets the b component (input)
  140605. */
  140606. get b(): NodeMaterialConnectionPoint;
  140607. /**
  140608. * Gets the a component (input)
  140609. */
  140610. get a(): NodeMaterialConnectionPoint;
  140611. /**
  140612. * Gets the rgba component (output)
  140613. */
  140614. get rgba(): NodeMaterialConnectionPoint;
  140615. /**
  140616. * Gets the rgb component (output)
  140617. */
  140618. get rgbOut(): NodeMaterialConnectionPoint;
  140619. /**
  140620. * Gets the rgb component (output)
  140621. * @deprecated Please use rgbOut instead.
  140622. */
  140623. get rgb(): NodeMaterialConnectionPoint;
  140624. protected _buildBlock(state: NodeMaterialBuildState): this;
  140625. }
  140626. }
  140627. declare module BABYLON {
  140628. /**
  140629. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  140630. */
  140631. export class VectorSplitterBlock extends NodeMaterialBlock {
  140632. /**
  140633. * Create a new VectorSplitterBlock
  140634. * @param name defines the block name
  140635. */
  140636. constructor(name: string);
  140637. /**
  140638. * Gets the current class name
  140639. * @returns the class name
  140640. */
  140641. getClassName(): string;
  140642. /**
  140643. * Gets the xyzw component (input)
  140644. */
  140645. get xyzw(): NodeMaterialConnectionPoint;
  140646. /**
  140647. * Gets the xyz component (input)
  140648. */
  140649. get xyzIn(): NodeMaterialConnectionPoint;
  140650. /**
  140651. * Gets the xy component (input)
  140652. */
  140653. get xyIn(): NodeMaterialConnectionPoint;
  140654. /**
  140655. * Gets the xyz component (output)
  140656. */
  140657. get xyzOut(): NodeMaterialConnectionPoint;
  140658. /**
  140659. * Gets the xy component (output)
  140660. */
  140661. get xyOut(): NodeMaterialConnectionPoint;
  140662. /**
  140663. * Gets the x component (output)
  140664. */
  140665. get x(): NodeMaterialConnectionPoint;
  140666. /**
  140667. * Gets the y component (output)
  140668. */
  140669. get y(): NodeMaterialConnectionPoint;
  140670. /**
  140671. * Gets the z component (output)
  140672. */
  140673. get z(): NodeMaterialConnectionPoint;
  140674. /**
  140675. * Gets the w component (output)
  140676. */
  140677. get w(): NodeMaterialConnectionPoint;
  140678. protected _inputRename(name: string): string;
  140679. protected _outputRename(name: string): string;
  140680. protected _buildBlock(state: NodeMaterialBuildState): this;
  140681. }
  140682. }
  140683. declare module BABYLON {
  140684. /**
  140685. * Block used to lerp between 2 values
  140686. */
  140687. export class LerpBlock extends NodeMaterialBlock {
  140688. /**
  140689. * Creates a new LerpBlock
  140690. * @param name defines the block name
  140691. */
  140692. constructor(name: string);
  140693. /**
  140694. * Gets the current class name
  140695. * @returns the class name
  140696. */
  140697. getClassName(): string;
  140698. /**
  140699. * Gets the left operand input component
  140700. */
  140701. get left(): NodeMaterialConnectionPoint;
  140702. /**
  140703. * Gets the right operand input component
  140704. */
  140705. get right(): NodeMaterialConnectionPoint;
  140706. /**
  140707. * Gets the gradient operand input component
  140708. */
  140709. get gradient(): NodeMaterialConnectionPoint;
  140710. /**
  140711. * Gets the output component
  140712. */
  140713. get output(): NodeMaterialConnectionPoint;
  140714. protected _buildBlock(state: NodeMaterialBuildState): this;
  140715. }
  140716. }
  140717. declare module BABYLON {
  140718. /**
  140719. * Block used to divide 2 vectors
  140720. */
  140721. export class DivideBlock extends NodeMaterialBlock {
  140722. /**
  140723. * Creates a new DivideBlock
  140724. * @param name defines the block name
  140725. */
  140726. constructor(name: string);
  140727. /**
  140728. * Gets the current class name
  140729. * @returns the class name
  140730. */
  140731. getClassName(): string;
  140732. /**
  140733. * Gets the left operand input component
  140734. */
  140735. get left(): NodeMaterialConnectionPoint;
  140736. /**
  140737. * Gets the right operand input component
  140738. */
  140739. get right(): NodeMaterialConnectionPoint;
  140740. /**
  140741. * Gets the output component
  140742. */
  140743. get output(): NodeMaterialConnectionPoint;
  140744. protected _buildBlock(state: NodeMaterialBuildState): this;
  140745. }
  140746. }
  140747. declare module BABYLON {
  140748. /**
  140749. * Block used to subtract 2 vectors
  140750. */
  140751. export class SubtractBlock extends NodeMaterialBlock {
  140752. /**
  140753. * Creates a new SubtractBlock
  140754. * @param name defines the block name
  140755. */
  140756. constructor(name: string);
  140757. /**
  140758. * Gets the current class name
  140759. * @returns the class name
  140760. */
  140761. getClassName(): string;
  140762. /**
  140763. * Gets the left operand input component
  140764. */
  140765. get left(): NodeMaterialConnectionPoint;
  140766. /**
  140767. * Gets the right operand input component
  140768. */
  140769. get right(): NodeMaterialConnectionPoint;
  140770. /**
  140771. * Gets the output component
  140772. */
  140773. get output(): NodeMaterialConnectionPoint;
  140774. protected _buildBlock(state: NodeMaterialBuildState): this;
  140775. }
  140776. }
  140777. declare module BABYLON {
  140778. /**
  140779. * Block used to step a value
  140780. */
  140781. export class StepBlock extends NodeMaterialBlock {
  140782. /**
  140783. * Creates a new StepBlock
  140784. * @param name defines the block name
  140785. */
  140786. constructor(name: string);
  140787. /**
  140788. * Gets the current class name
  140789. * @returns the class name
  140790. */
  140791. getClassName(): string;
  140792. /**
  140793. * Gets the value operand input component
  140794. */
  140795. get value(): NodeMaterialConnectionPoint;
  140796. /**
  140797. * Gets the edge operand input component
  140798. */
  140799. get edge(): NodeMaterialConnectionPoint;
  140800. /**
  140801. * Gets the output component
  140802. */
  140803. get output(): NodeMaterialConnectionPoint;
  140804. protected _buildBlock(state: NodeMaterialBuildState): this;
  140805. }
  140806. }
  140807. declare module BABYLON {
  140808. /**
  140809. * Block used to get the opposite (1 - x) of a value
  140810. */
  140811. export class OneMinusBlock extends NodeMaterialBlock {
  140812. /**
  140813. * Creates a new OneMinusBlock
  140814. * @param name defines the block name
  140815. */
  140816. constructor(name: string);
  140817. /**
  140818. * Gets the current class name
  140819. * @returns the class name
  140820. */
  140821. getClassName(): string;
  140822. /**
  140823. * Gets the input component
  140824. */
  140825. get input(): NodeMaterialConnectionPoint;
  140826. /**
  140827. * Gets the output component
  140828. */
  140829. get output(): NodeMaterialConnectionPoint;
  140830. protected _buildBlock(state: NodeMaterialBuildState): this;
  140831. }
  140832. }
  140833. declare module BABYLON {
  140834. /**
  140835. * Block used to get the view direction
  140836. */
  140837. export class ViewDirectionBlock extends NodeMaterialBlock {
  140838. /**
  140839. * Creates a new ViewDirectionBlock
  140840. * @param name defines the block name
  140841. */
  140842. constructor(name: string);
  140843. /**
  140844. * Gets the current class name
  140845. * @returns the class name
  140846. */
  140847. getClassName(): string;
  140848. /**
  140849. * Gets the world position component
  140850. */
  140851. get worldPosition(): NodeMaterialConnectionPoint;
  140852. /**
  140853. * Gets the camera position component
  140854. */
  140855. get cameraPosition(): NodeMaterialConnectionPoint;
  140856. /**
  140857. * Gets the output component
  140858. */
  140859. get output(): NodeMaterialConnectionPoint;
  140860. autoConfigure(material: NodeMaterial): void;
  140861. protected _buildBlock(state: NodeMaterialBuildState): this;
  140862. }
  140863. }
  140864. declare module BABYLON {
  140865. /**
  140866. * Block used to compute fresnel value
  140867. */
  140868. export class FresnelBlock extends NodeMaterialBlock {
  140869. /**
  140870. * Create a new FresnelBlock
  140871. * @param name defines the block name
  140872. */
  140873. constructor(name: string);
  140874. /**
  140875. * Gets the current class name
  140876. * @returns the class name
  140877. */
  140878. getClassName(): string;
  140879. /**
  140880. * Gets the world normal input component
  140881. */
  140882. get worldNormal(): NodeMaterialConnectionPoint;
  140883. /**
  140884. * Gets the view direction input component
  140885. */
  140886. get viewDirection(): NodeMaterialConnectionPoint;
  140887. /**
  140888. * Gets the bias input component
  140889. */
  140890. get bias(): NodeMaterialConnectionPoint;
  140891. /**
  140892. * Gets the camera (or eye) position component
  140893. */
  140894. get power(): NodeMaterialConnectionPoint;
  140895. /**
  140896. * Gets the fresnel output component
  140897. */
  140898. get fresnel(): NodeMaterialConnectionPoint;
  140899. autoConfigure(material: NodeMaterial): void;
  140900. protected _buildBlock(state: NodeMaterialBuildState): this;
  140901. }
  140902. }
  140903. declare module BABYLON {
  140904. /**
  140905. * Block used to get the max of 2 values
  140906. */
  140907. export class MaxBlock extends NodeMaterialBlock {
  140908. /**
  140909. * Creates a new MaxBlock
  140910. * @param name defines the block name
  140911. */
  140912. constructor(name: string);
  140913. /**
  140914. * Gets the current class name
  140915. * @returns the class name
  140916. */
  140917. getClassName(): string;
  140918. /**
  140919. * Gets the left operand input component
  140920. */
  140921. get left(): NodeMaterialConnectionPoint;
  140922. /**
  140923. * Gets the right operand input component
  140924. */
  140925. get right(): NodeMaterialConnectionPoint;
  140926. /**
  140927. * Gets the output component
  140928. */
  140929. get output(): NodeMaterialConnectionPoint;
  140930. protected _buildBlock(state: NodeMaterialBuildState): this;
  140931. }
  140932. }
  140933. declare module BABYLON {
  140934. /**
  140935. * Block used to get the min of 2 values
  140936. */
  140937. export class MinBlock extends NodeMaterialBlock {
  140938. /**
  140939. * Creates a new MinBlock
  140940. * @param name defines the block name
  140941. */
  140942. constructor(name: string);
  140943. /**
  140944. * Gets the current class name
  140945. * @returns the class name
  140946. */
  140947. getClassName(): string;
  140948. /**
  140949. * Gets the left operand input component
  140950. */
  140951. get left(): NodeMaterialConnectionPoint;
  140952. /**
  140953. * Gets the right operand input component
  140954. */
  140955. get right(): NodeMaterialConnectionPoint;
  140956. /**
  140957. * Gets the output component
  140958. */
  140959. get output(): NodeMaterialConnectionPoint;
  140960. protected _buildBlock(state: NodeMaterialBuildState): this;
  140961. }
  140962. }
  140963. declare module BABYLON {
  140964. /**
  140965. * Block used to get the distance between 2 values
  140966. */
  140967. export class DistanceBlock extends NodeMaterialBlock {
  140968. /**
  140969. * Creates a new DistanceBlock
  140970. * @param name defines the block name
  140971. */
  140972. constructor(name: string);
  140973. /**
  140974. * Gets the current class name
  140975. * @returns the class name
  140976. */
  140977. getClassName(): string;
  140978. /**
  140979. * Gets the left operand input component
  140980. */
  140981. get left(): NodeMaterialConnectionPoint;
  140982. /**
  140983. * Gets the right operand input component
  140984. */
  140985. get right(): NodeMaterialConnectionPoint;
  140986. /**
  140987. * Gets the output component
  140988. */
  140989. get output(): NodeMaterialConnectionPoint;
  140990. protected _buildBlock(state: NodeMaterialBuildState): this;
  140991. }
  140992. }
  140993. declare module BABYLON {
  140994. /**
  140995. * Block used to get the length of a vector
  140996. */
  140997. export class LengthBlock extends NodeMaterialBlock {
  140998. /**
  140999. * Creates a new LengthBlock
  141000. * @param name defines the block name
  141001. */
  141002. constructor(name: string);
  141003. /**
  141004. * Gets the current class name
  141005. * @returns the class name
  141006. */
  141007. getClassName(): string;
  141008. /**
  141009. * Gets the value input component
  141010. */
  141011. get value(): NodeMaterialConnectionPoint;
  141012. /**
  141013. * Gets the output component
  141014. */
  141015. get output(): NodeMaterialConnectionPoint;
  141016. protected _buildBlock(state: NodeMaterialBuildState): this;
  141017. }
  141018. }
  141019. declare module BABYLON {
  141020. /**
  141021. * Block used to get negative version of a value (i.e. x * -1)
  141022. */
  141023. export class NegateBlock extends NodeMaterialBlock {
  141024. /**
  141025. * Creates a new NegateBlock
  141026. * @param name defines the block name
  141027. */
  141028. constructor(name: string);
  141029. /**
  141030. * Gets the current class name
  141031. * @returns the class name
  141032. */
  141033. getClassName(): string;
  141034. /**
  141035. * Gets the value input component
  141036. */
  141037. get value(): NodeMaterialConnectionPoint;
  141038. /**
  141039. * Gets the output component
  141040. */
  141041. get output(): NodeMaterialConnectionPoint;
  141042. protected _buildBlock(state: NodeMaterialBuildState): this;
  141043. }
  141044. }
  141045. declare module BABYLON {
  141046. /**
  141047. * Block used to get the value of the first parameter raised to the power of the second
  141048. */
  141049. export class PowBlock extends NodeMaterialBlock {
  141050. /**
  141051. * Creates a new PowBlock
  141052. * @param name defines the block name
  141053. */
  141054. constructor(name: string);
  141055. /**
  141056. * Gets the current class name
  141057. * @returns the class name
  141058. */
  141059. getClassName(): string;
  141060. /**
  141061. * Gets the value operand input component
  141062. */
  141063. get value(): NodeMaterialConnectionPoint;
  141064. /**
  141065. * Gets the power operand input component
  141066. */
  141067. get power(): NodeMaterialConnectionPoint;
  141068. /**
  141069. * Gets the output component
  141070. */
  141071. get output(): NodeMaterialConnectionPoint;
  141072. protected _buildBlock(state: NodeMaterialBuildState): this;
  141073. }
  141074. }
  141075. declare module BABYLON {
  141076. /**
  141077. * Block used to get a random number
  141078. */
  141079. export class RandomNumberBlock extends NodeMaterialBlock {
  141080. /**
  141081. * Creates a new RandomNumberBlock
  141082. * @param name defines the block name
  141083. */
  141084. constructor(name: string);
  141085. /**
  141086. * Gets the current class name
  141087. * @returns the class name
  141088. */
  141089. getClassName(): string;
  141090. /**
  141091. * Gets the seed input component
  141092. */
  141093. get seed(): NodeMaterialConnectionPoint;
  141094. /**
  141095. * Gets the output component
  141096. */
  141097. get output(): NodeMaterialConnectionPoint;
  141098. protected _buildBlock(state: NodeMaterialBuildState): this;
  141099. }
  141100. }
  141101. declare module BABYLON {
  141102. /**
  141103. * Block used to compute arc tangent of 2 values
  141104. */
  141105. export class ArcTan2Block extends NodeMaterialBlock {
  141106. /**
  141107. * Creates a new ArcTan2Block
  141108. * @param name defines the block name
  141109. */
  141110. constructor(name: string);
  141111. /**
  141112. * Gets the current class name
  141113. * @returns the class name
  141114. */
  141115. getClassName(): string;
  141116. /**
  141117. * Gets the x operand input component
  141118. */
  141119. get x(): NodeMaterialConnectionPoint;
  141120. /**
  141121. * Gets the y operand input component
  141122. */
  141123. get y(): NodeMaterialConnectionPoint;
  141124. /**
  141125. * Gets the output component
  141126. */
  141127. get output(): NodeMaterialConnectionPoint;
  141128. protected _buildBlock(state: NodeMaterialBuildState): this;
  141129. }
  141130. }
  141131. declare module BABYLON {
  141132. /**
  141133. * Block used to smooth step a value
  141134. */
  141135. export class SmoothStepBlock extends NodeMaterialBlock {
  141136. /**
  141137. * Creates a new SmoothStepBlock
  141138. * @param name defines the block name
  141139. */
  141140. constructor(name: string);
  141141. /**
  141142. * Gets the current class name
  141143. * @returns the class name
  141144. */
  141145. getClassName(): string;
  141146. /**
  141147. * Gets the value operand input component
  141148. */
  141149. get value(): NodeMaterialConnectionPoint;
  141150. /**
  141151. * Gets the first edge operand input component
  141152. */
  141153. get edge0(): NodeMaterialConnectionPoint;
  141154. /**
  141155. * Gets the second edge operand input component
  141156. */
  141157. get edge1(): NodeMaterialConnectionPoint;
  141158. /**
  141159. * Gets the output component
  141160. */
  141161. get output(): NodeMaterialConnectionPoint;
  141162. protected _buildBlock(state: NodeMaterialBuildState): this;
  141163. }
  141164. }
  141165. declare module BABYLON {
  141166. /**
  141167. * Block used to get the reciprocal (1 / x) of a value
  141168. */
  141169. export class ReciprocalBlock extends NodeMaterialBlock {
  141170. /**
  141171. * Creates a new ReciprocalBlock
  141172. * @param name defines the block name
  141173. */
  141174. constructor(name: string);
  141175. /**
  141176. * Gets the current class name
  141177. * @returns the class name
  141178. */
  141179. getClassName(): string;
  141180. /**
  141181. * Gets the input component
  141182. */
  141183. get input(): NodeMaterialConnectionPoint;
  141184. /**
  141185. * Gets the output component
  141186. */
  141187. get output(): NodeMaterialConnectionPoint;
  141188. protected _buildBlock(state: NodeMaterialBuildState): this;
  141189. }
  141190. }
  141191. declare module BABYLON {
  141192. /**
  141193. * Block used to replace a color by another one
  141194. */
  141195. export class ReplaceColorBlock extends NodeMaterialBlock {
  141196. /**
  141197. * Creates a new ReplaceColorBlock
  141198. * @param name defines the block name
  141199. */
  141200. constructor(name: string);
  141201. /**
  141202. * Gets the current class name
  141203. * @returns the class name
  141204. */
  141205. getClassName(): string;
  141206. /**
  141207. * Gets the value input component
  141208. */
  141209. get value(): NodeMaterialConnectionPoint;
  141210. /**
  141211. * Gets the reference input component
  141212. */
  141213. get reference(): NodeMaterialConnectionPoint;
  141214. /**
  141215. * Gets the distance input component
  141216. */
  141217. get distance(): NodeMaterialConnectionPoint;
  141218. /**
  141219. * Gets the replacement input component
  141220. */
  141221. get replacement(): NodeMaterialConnectionPoint;
  141222. /**
  141223. * Gets the output component
  141224. */
  141225. get output(): NodeMaterialConnectionPoint;
  141226. protected _buildBlock(state: NodeMaterialBuildState): this;
  141227. }
  141228. }
  141229. declare module BABYLON {
  141230. /**
  141231. * Block used to posterize a value
  141232. * @see https://en.wikipedia.org/wiki/Posterization
  141233. */
  141234. export class PosterizeBlock extends NodeMaterialBlock {
  141235. /**
  141236. * Creates a new PosterizeBlock
  141237. * @param name defines the block name
  141238. */
  141239. constructor(name: string);
  141240. /**
  141241. * Gets the current class name
  141242. * @returns the class name
  141243. */
  141244. getClassName(): string;
  141245. /**
  141246. * Gets the value input component
  141247. */
  141248. get value(): NodeMaterialConnectionPoint;
  141249. /**
  141250. * Gets the steps input component
  141251. */
  141252. get steps(): NodeMaterialConnectionPoint;
  141253. /**
  141254. * Gets the output component
  141255. */
  141256. get output(): NodeMaterialConnectionPoint;
  141257. protected _buildBlock(state: NodeMaterialBuildState): this;
  141258. }
  141259. }
  141260. declare module BABYLON {
  141261. /**
  141262. * Operations supported by the Wave block
  141263. */
  141264. export enum WaveBlockKind {
  141265. /** SawTooth */
  141266. SawTooth = 0,
  141267. /** Square */
  141268. Square = 1,
  141269. /** Triangle */
  141270. Triangle = 2
  141271. }
  141272. /**
  141273. * Block used to apply wave operation to floats
  141274. */
  141275. export class WaveBlock extends NodeMaterialBlock {
  141276. /**
  141277. * Gets or sets the kibnd of wave to be applied by the block
  141278. */
  141279. kind: WaveBlockKind;
  141280. /**
  141281. * Creates a new WaveBlock
  141282. * @param name defines the block name
  141283. */
  141284. constructor(name: string);
  141285. /**
  141286. * Gets the current class name
  141287. * @returns the class name
  141288. */
  141289. getClassName(): string;
  141290. /**
  141291. * Gets the input component
  141292. */
  141293. get input(): NodeMaterialConnectionPoint;
  141294. /**
  141295. * Gets the output component
  141296. */
  141297. get output(): NodeMaterialConnectionPoint;
  141298. protected _buildBlock(state: NodeMaterialBuildState): this;
  141299. serialize(): any;
  141300. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141301. }
  141302. }
  141303. declare module BABYLON {
  141304. /**
  141305. * Class used to store a color step for the GradientBlock
  141306. */
  141307. export class GradientBlockColorStep {
  141308. /**
  141309. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141310. */
  141311. step: number;
  141312. /**
  141313. * Gets or sets the color associated with this step
  141314. */
  141315. color: Color3;
  141316. /**
  141317. * Creates a new GradientBlockColorStep
  141318. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  141319. * @param color defines the color associated with this step
  141320. */
  141321. constructor(
  141322. /**
  141323. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  141324. */
  141325. step: number,
  141326. /**
  141327. * Gets or sets the color associated with this step
  141328. */
  141329. color: Color3);
  141330. }
  141331. /**
  141332. * Block used to return a color from a gradient based on an input value between 0 and 1
  141333. */
  141334. export class GradientBlock extends NodeMaterialBlock {
  141335. /**
  141336. * Gets or sets the list of color steps
  141337. */
  141338. colorSteps: GradientBlockColorStep[];
  141339. /**
  141340. * Creates a new GradientBlock
  141341. * @param name defines the block name
  141342. */
  141343. constructor(name: string);
  141344. /**
  141345. * Gets the current class name
  141346. * @returns the class name
  141347. */
  141348. getClassName(): string;
  141349. /**
  141350. * Gets the gradient input component
  141351. */
  141352. get gradient(): NodeMaterialConnectionPoint;
  141353. /**
  141354. * Gets the output component
  141355. */
  141356. get output(): NodeMaterialConnectionPoint;
  141357. private _writeColorConstant;
  141358. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141359. serialize(): any;
  141360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141361. protected _dumpPropertiesCode(): string;
  141362. }
  141363. }
  141364. declare module BABYLON {
  141365. /**
  141366. * Block used to normalize lerp between 2 values
  141367. */
  141368. export class NLerpBlock extends NodeMaterialBlock {
  141369. /**
  141370. * Creates a new NLerpBlock
  141371. * @param name defines the block name
  141372. */
  141373. constructor(name: string);
  141374. /**
  141375. * Gets the current class name
  141376. * @returns the class name
  141377. */
  141378. getClassName(): string;
  141379. /**
  141380. * Gets the left operand input component
  141381. */
  141382. get left(): NodeMaterialConnectionPoint;
  141383. /**
  141384. * Gets the right operand input component
  141385. */
  141386. get right(): NodeMaterialConnectionPoint;
  141387. /**
  141388. * Gets the gradient operand input component
  141389. */
  141390. get gradient(): NodeMaterialConnectionPoint;
  141391. /**
  141392. * Gets the output component
  141393. */
  141394. get output(): NodeMaterialConnectionPoint;
  141395. protected _buildBlock(state: NodeMaterialBuildState): this;
  141396. }
  141397. }
  141398. declare module BABYLON {
  141399. /**
  141400. * block used to Generate a Worley Noise 3D Noise Pattern
  141401. */
  141402. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  141403. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  141404. manhattanDistance: boolean;
  141405. /**
  141406. * Creates a new WorleyNoise3DBlock
  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 seed input component
  141417. */
  141418. get seed(): NodeMaterialConnectionPoint;
  141419. /**
  141420. * Gets the jitter input component
  141421. */
  141422. get jitter(): NodeMaterialConnectionPoint;
  141423. /**
  141424. * Gets the output component
  141425. */
  141426. get output(): NodeMaterialConnectionPoint;
  141427. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141428. /**
  141429. * Exposes the properties to the UI?
  141430. */
  141431. protected _dumpPropertiesCode(): string;
  141432. /**
  141433. * Exposes the properties to the Seralize?
  141434. */
  141435. serialize(): any;
  141436. /**
  141437. * Exposes the properties to the deseralize?
  141438. */
  141439. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141440. }
  141441. }
  141442. declare module BABYLON {
  141443. /**
  141444. * block used to Generate a Simplex Perlin 3d Noise Pattern
  141445. */
  141446. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  141447. /**
  141448. * Creates a new SimplexPerlin3DBlock
  141449. * @param name defines the block name
  141450. */
  141451. constructor(name: string);
  141452. /**
  141453. * Gets the current class name
  141454. * @returns the class name
  141455. */
  141456. getClassName(): string;
  141457. /**
  141458. * Gets the seed operand input component
  141459. */
  141460. get seed(): NodeMaterialConnectionPoint;
  141461. /**
  141462. * Gets the output component
  141463. */
  141464. get output(): NodeMaterialConnectionPoint;
  141465. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  141466. }
  141467. }
  141468. declare module BABYLON {
  141469. /**
  141470. * Block used to blend normals
  141471. */
  141472. export class NormalBlendBlock extends NodeMaterialBlock {
  141473. /**
  141474. * Creates a new NormalBlendBlock
  141475. * @param name defines the block name
  141476. */
  141477. constructor(name: string);
  141478. /**
  141479. * Gets the current class name
  141480. * @returns the class name
  141481. */
  141482. getClassName(): string;
  141483. /**
  141484. * Gets the first input component
  141485. */
  141486. get normalMap0(): NodeMaterialConnectionPoint;
  141487. /**
  141488. * Gets the second input component
  141489. */
  141490. get normalMap1(): NodeMaterialConnectionPoint;
  141491. /**
  141492. * Gets the output component
  141493. */
  141494. get output(): NodeMaterialConnectionPoint;
  141495. protected _buildBlock(state: NodeMaterialBuildState): this;
  141496. }
  141497. }
  141498. declare module BABYLON {
  141499. /**
  141500. * Block used to rotate a 2d vector by a given angle
  141501. */
  141502. export class Rotate2dBlock extends NodeMaterialBlock {
  141503. /**
  141504. * Creates a new Rotate2dBlock
  141505. * @param name defines the block name
  141506. */
  141507. constructor(name: string);
  141508. /**
  141509. * Gets the current class name
  141510. * @returns the class name
  141511. */
  141512. getClassName(): string;
  141513. /**
  141514. * Gets the input vector
  141515. */
  141516. get input(): NodeMaterialConnectionPoint;
  141517. /**
  141518. * Gets the input angle
  141519. */
  141520. get angle(): NodeMaterialConnectionPoint;
  141521. /**
  141522. * Gets the output component
  141523. */
  141524. get output(): NodeMaterialConnectionPoint;
  141525. autoConfigure(material: NodeMaterial): void;
  141526. protected _buildBlock(state: NodeMaterialBuildState): this;
  141527. }
  141528. }
  141529. declare module BABYLON {
  141530. /**
  141531. * Block used to get the reflected vector from a direction and a normal
  141532. */
  141533. export class ReflectBlock extends NodeMaterialBlock {
  141534. /**
  141535. * Creates a new ReflectBlock
  141536. * @param name defines the block name
  141537. */
  141538. constructor(name: string);
  141539. /**
  141540. * Gets the current class name
  141541. * @returns the class name
  141542. */
  141543. getClassName(): string;
  141544. /**
  141545. * Gets the incident component
  141546. */
  141547. get incident(): NodeMaterialConnectionPoint;
  141548. /**
  141549. * Gets the normal component
  141550. */
  141551. get normal(): NodeMaterialConnectionPoint;
  141552. /**
  141553. * Gets the output component
  141554. */
  141555. get output(): NodeMaterialConnectionPoint;
  141556. protected _buildBlock(state: NodeMaterialBuildState): this;
  141557. }
  141558. }
  141559. declare module BABYLON {
  141560. /**
  141561. * Block used to get the refracted vector from a direction and a normal
  141562. */
  141563. export class RefractBlock extends NodeMaterialBlock {
  141564. /**
  141565. * Creates a new RefractBlock
  141566. * @param name defines the block name
  141567. */
  141568. constructor(name: string);
  141569. /**
  141570. * Gets the current class name
  141571. * @returns the class name
  141572. */
  141573. getClassName(): string;
  141574. /**
  141575. * Gets the incident component
  141576. */
  141577. get incident(): NodeMaterialConnectionPoint;
  141578. /**
  141579. * Gets the normal component
  141580. */
  141581. get normal(): NodeMaterialConnectionPoint;
  141582. /**
  141583. * Gets the index of refraction component
  141584. */
  141585. get ior(): NodeMaterialConnectionPoint;
  141586. /**
  141587. * Gets the output component
  141588. */
  141589. get output(): NodeMaterialConnectionPoint;
  141590. protected _buildBlock(state: NodeMaterialBuildState): this;
  141591. }
  141592. }
  141593. declare module BABYLON {
  141594. /**
  141595. * Block used to desaturate a color
  141596. */
  141597. export class DesaturateBlock extends NodeMaterialBlock {
  141598. /**
  141599. * Creates a new DesaturateBlock
  141600. * @param name defines the block name
  141601. */
  141602. constructor(name: string);
  141603. /**
  141604. * Gets the current class name
  141605. * @returns the class name
  141606. */
  141607. getClassName(): string;
  141608. /**
  141609. * Gets the color operand input component
  141610. */
  141611. get color(): NodeMaterialConnectionPoint;
  141612. /**
  141613. * Gets the level operand input component
  141614. */
  141615. get level(): NodeMaterialConnectionPoint;
  141616. /**
  141617. * Gets the output component
  141618. */
  141619. get output(): NodeMaterialConnectionPoint;
  141620. protected _buildBlock(state: NodeMaterialBuildState): this;
  141621. }
  141622. }
  141623. declare module BABYLON {
  141624. /**
  141625. * Block used to implement the ambient occlusion module of the PBR material
  141626. */
  141627. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  141628. /**
  141629. * Create a new AmbientOcclusionBlock
  141630. * @param name defines the block name
  141631. */
  141632. constructor(name: string);
  141633. /**
  141634. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  141635. */
  141636. useAmbientInGrayScale: boolean;
  141637. /**
  141638. * Initialize the block and prepare the context for build
  141639. * @param state defines the state that will be used for the build
  141640. */
  141641. initialize(state: NodeMaterialBuildState): void;
  141642. /**
  141643. * Gets the current class name
  141644. * @returns the class name
  141645. */
  141646. getClassName(): string;
  141647. /**
  141648. * Gets the texture input component
  141649. */
  141650. get texture(): NodeMaterialConnectionPoint;
  141651. /**
  141652. * Gets the texture intensity component
  141653. */
  141654. get intensity(): NodeMaterialConnectionPoint;
  141655. /**
  141656. * Gets the direct light intensity input component
  141657. */
  141658. get directLightIntensity(): NodeMaterialConnectionPoint;
  141659. /**
  141660. * Gets the ambient occlusion object output component
  141661. */
  141662. get ambientOcclusion(): NodeMaterialConnectionPoint;
  141663. /**
  141664. * Gets the main code of the block (fragment side)
  141665. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  141666. * @returns the shader code
  141667. */
  141668. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  141669. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141670. protected _buildBlock(state: NodeMaterialBuildState): this;
  141671. protected _dumpPropertiesCode(): string;
  141672. serialize(): any;
  141673. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141674. }
  141675. }
  141676. declare module BABYLON {
  141677. /**
  141678. * Block used to implement the reflection module of the PBR material
  141679. */
  141680. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  141681. /** @hidden */
  141682. _defineLODReflectionAlpha: string;
  141683. /** @hidden */
  141684. _defineLinearSpecularReflection: string;
  141685. private _vEnvironmentIrradianceName;
  141686. /** @hidden */
  141687. _vReflectionMicrosurfaceInfosName: string;
  141688. /** @hidden */
  141689. _vReflectionInfosName: string;
  141690. /** @hidden */
  141691. _vReflectionFilteringInfoName: string;
  141692. private _scene;
  141693. /**
  141694. * The three properties below are set by the main PBR block prior to calling methods of this class.
  141695. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141696. * It's less burden on the user side in the editor part.
  141697. */
  141698. /** @hidden */
  141699. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141700. /** @hidden */
  141701. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141702. /** @hidden */
  141703. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  141704. /**
  141705. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  141706. * diffuse part of the IBL.
  141707. */
  141708. useSphericalHarmonics: boolean;
  141709. /**
  141710. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  141711. */
  141712. forceIrradianceInFragment: boolean;
  141713. /**
  141714. * Create a new ReflectionBlock
  141715. * @param name defines the block name
  141716. */
  141717. constructor(name: string);
  141718. /**
  141719. * Gets the current class name
  141720. * @returns the class name
  141721. */
  141722. getClassName(): string;
  141723. /**
  141724. * Gets the position input component
  141725. */
  141726. get position(): NodeMaterialConnectionPoint;
  141727. /**
  141728. * Gets the world position input component
  141729. */
  141730. get worldPosition(): NodeMaterialConnectionPoint;
  141731. /**
  141732. * Gets the world normal input component
  141733. */
  141734. get worldNormal(): NodeMaterialConnectionPoint;
  141735. /**
  141736. * Gets the world input component
  141737. */
  141738. get world(): NodeMaterialConnectionPoint;
  141739. /**
  141740. * Gets the camera (or eye) position component
  141741. */
  141742. get cameraPosition(): NodeMaterialConnectionPoint;
  141743. /**
  141744. * Gets the view input component
  141745. */
  141746. get view(): NodeMaterialConnectionPoint;
  141747. /**
  141748. * Gets the color input component
  141749. */
  141750. get color(): NodeMaterialConnectionPoint;
  141751. /**
  141752. * Gets the reflection object output component
  141753. */
  141754. get reflection(): NodeMaterialConnectionPoint;
  141755. /**
  141756. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  141757. */
  141758. get hasTexture(): boolean;
  141759. /**
  141760. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  141761. */
  141762. get reflectionColor(): string;
  141763. protected _getTexture(): Nullable<BaseTexture>;
  141764. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141765. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141766. /**
  141767. * Gets the code to inject in the vertex shader
  141768. * @param state current state of the node material building
  141769. * @returns the shader code
  141770. */
  141771. handleVertexSide(state: NodeMaterialBuildState): string;
  141772. /**
  141773. * Gets the main code of the block (fragment side)
  141774. * @param state current state of the node material building
  141775. * @param normalVarName name of the existing variable corresponding to the normal
  141776. * @returns the shader code
  141777. */
  141778. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  141779. protected _buildBlock(state: NodeMaterialBuildState): this;
  141780. protected _dumpPropertiesCode(): string;
  141781. serialize(): any;
  141782. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141783. }
  141784. }
  141785. declare module BABYLON {
  141786. /**
  141787. * Block used to implement the sheen module of the PBR material
  141788. */
  141789. export class SheenBlock extends NodeMaterialBlock {
  141790. /**
  141791. * Create a new SheenBlock
  141792. * @param name defines the block name
  141793. */
  141794. constructor(name: string);
  141795. /**
  141796. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  141797. * It allows the strength of the sheen effect to not depend on the base color of the material,
  141798. * making it easier to setup and tweak the effect
  141799. */
  141800. albedoScaling: boolean;
  141801. /**
  141802. * Defines if the sheen is linked to the sheen color.
  141803. */
  141804. linkSheenWithAlbedo: boolean;
  141805. /**
  141806. * Initialize the block and prepare the context for build
  141807. * @param state defines the state that will be used for the build
  141808. */
  141809. initialize(state: NodeMaterialBuildState): void;
  141810. /**
  141811. * Gets the current class name
  141812. * @returns the class name
  141813. */
  141814. getClassName(): string;
  141815. /**
  141816. * Gets the intensity input component
  141817. */
  141818. get intensity(): NodeMaterialConnectionPoint;
  141819. /**
  141820. * Gets the color input component
  141821. */
  141822. get color(): NodeMaterialConnectionPoint;
  141823. /**
  141824. * Gets the roughness input component
  141825. */
  141826. get roughness(): NodeMaterialConnectionPoint;
  141827. /**
  141828. * Gets the sheen object output component
  141829. */
  141830. get sheen(): NodeMaterialConnectionPoint;
  141831. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141832. /**
  141833. * Gets the main code of the block (fragment side)
  141834. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  141835. * @returns the shader code
  141836. */
  141837. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  141838. protected _buildBlock(state: NodeMaterialBuildState): this;
  141839. protected _dumpPropertiesCode(): string;
  141840. serialize(): any;
  141841. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141842. }
  141843. }
  141844. declare module BABYLON {
  141845. /**
  141846. * Block used to implement the reflectivity module of the PBR material
  141847. */
  141848. export class ReflectivityBlock extends NodeMaterialBlock {
  141849. private _metallicReflectanceColor;
  141850. private _metallicF0Factor;
  141851. /** @hidden */
  141852. _vMetallicReflectanceFactorsName: string;
  141853. /**
  141854. * The property below is set by the main PBR block prior to calling methods of this class.
  141855. */
  141856. /** @hidden */
  141857. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  141858. /**
  141859. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  141860. */
  141861. useAmbientOcclusionFromMetallicTextureRed: boolean;
  141862. /**
  141863. * Specifies if the metallic texture contains the metallness information in its blue channel.
  141864. */
  141865. useMetallnessFromMetallicTextureBlue: boolean;
  141866. /**
  141867. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  141868. */
  141869. useRoughnessFromMetallicTextureAlpha: boolean;
  141870. /**
  141871. * Specifies if the metallic texture contains the roughness information in its green channel.
  141872. */
  141873. useRoughnessFromMetallicTextureGreen: boolean;
  141874. /**
  141875. * Create a new ReflectivityBlock
  141876. * @param name defines the block name
  141877. */
  141878. constructor(name: string);
  141879. /**
  141880. * Initialize the block and prepare the context for build
  141881. * @param state defines the state that will be used for the build
  141882. */
  141883. initialize(state: NodeMaterialBuildState): void;
  141884. /**
  141885. * Gets the current class name
  141886. * @returns the class name
  141887. */
  141888. getClassName(): string;
  141889. /**
  141890. * Gets the metallic input component
  141891. */
  141892. get metallic(): NodeMaterialConnectionPoint;
  141893. /**
  141894. * Gets the roughness input component
  141895. */
  141896. get roughness(): NodeMaterialConnectionPoint;
  141897. /**
  141898. * Gets the texture input component
  141899. */
  141900. get texture(): NodeMaterialConnectionPoint;
  141901. /**
  141902. * Gets the reflectivity object output component
  141903. */
  141904. get reflectivity(): NodeMaterialConnectionPoint;
  141905. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  141906. /**
  141907. * Gets the main code of the block (fragment side)
  141908. * @param state current state of the node material building
  141909. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  141910. * @returns the shader code
  141911. */
  141912. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  141913. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141914. protected _buildBlock(state: NodeMaterialBuildState): this;
  141915. protected _dumpPropertiesCode(): string;
  141916. serialize(): any;
  141917. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  141918. }
  141919. }
  141920. declare module BABYLON {
  141921. /**
  141922. * Block used to implement the anisotropy module of the PBR material
  141923. */
  141924. export class AnisotropyBlock extends NodeMaterialBlock {
  141925. /**
  141926. * The two properties below are set by the main PBR block prior to calling methods of this class.
  141927. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  141928. * It's less burden on the user side in the editor part.
  141929. */
  141930. /** @hidden */
  141931. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  141932. /** @hidden */
  141933. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  141934. /**
  141935. * Create a new AnisotropyBlock
  141936. * @param name defines the block name
  141937. */
  141938. constructor(name: string);
  141939. /**
  141940. * Initialize the block and prepare the context for build
  141941. * @param state defines the state that will be used for the build
  141942. */
  141943. initialize(state: NodeMaterialBuildState): void;
  141944. /**
  141945. * Gets the current class name
  141946. * @returns the class name
  141947. */
  141948. getClassName(): string;
  141949. /**
  141950. * Gets the intensity input component
  141951. */
  141952. get intensity(): NodeMaterialConnectionPoint;
  141953. /**
  141954. * Gets the direction input component
  141955. */
  141956. get direction(): NodeMaterialConnectionPoint;
  141957. /**
  141958. * Gets the texture input component
  141959. */
  141960. get texture(): NodeMaterialConnectionPoint;
  141961. /**
  141962. * Gets the uv input component
  141963. */
  141964. get uv(): NodeMaterialConnectionPoint;
  141965. /**
  141966. * Gets the worldTangent input component
  141967. */
  141968. get worldTangent(): NodeMaterialConnectionPoint;
  141969. /**
  141970. * Gets the anisotropy object output component
  141971. */
  141972. get anisotropy(): NodeMaterialConnectionPoint;
  141973. private _generateTBNSpace;
  141974. /**
  141975. * Gets the main code of the block (fragment side)
  141976. * @param state current state of the node material building
  141977. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  141978. * @returns the shader code
  141979. */
  141980. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  141981. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  141982. protected _buildBlock(state: NodeMaterialBuildState): this;
  141983. }
  141984. }
  141985. declare module BABYLON {
  141986. /**
  141987. * Block used to implement the clear coat module of the PBR material
  141988. */
  141989. export class ClearCoatBlock extends NodeMaterialBlock {
  141990. private _scene;
  141991. /**
  141992. * Create a new ClearCoatBlock
  141993. * @param name defines the block name
  141994. */
  141995. constructor(name: string);
  141996. /**
  141997. * Initialize the block and prepare the context for build
  141998. * @param state defines the state that will be used for the build
  141999. */
  142000. initialize(state: NodeMaterialBuildState): void;
  142001. /**
  142002. * Gets the current class name
  142003. * @returns the class name
  142004. */
  142005. getClassName(): string;
  142006. /**
  142007. * Gets the intensity input component
  142008. */
  142009. get intensity(): NodeMaterialConnectionPoint;
  142010. /**
  142011. * Gets the roughness input component
  142012. */
  142013. get roughness(): NodeMaterialConnectionPoint;
  142014. /**
  142015. * Gets the ior input component
  142016. */
  142017. get ior(): NodeMaterialConnectionPoint;
  142018. /**
  142019. * Gets the texture input component
  142020. */
  142021. get texture(): NodeMaterialConnectionPoint;
  142022. /**
  142023. * Gets the bump texture input component
  142024. */
  142025. get bumpTexture(): NodeMaterialConnectionPoint;
  142026. /**
  142027. * Gets the uv input component
  142028. */
  142029. get uv(): NodeMaterialConnectionPoint;
  142030. /**
  142031. * Gets the tint color input component
  142032. */
  142033. get tintColor(): NodeMaterialConnectionPoint;
  142034. /**
  142035. * Gets the tint "at distance" input component
  142036. */
  142037. get tintAtDistance(): NodeMaterialConnectionPoint;
  142038. /**
  142039. * Gets the tint thickness input component
  142040. */
  142041. get tintThickness(): NodeMaterialConnectionPoint;
  142042. /**
  142043. * Gets the world tangent input component
  142044. */
  142045. get worldTangent(): NodeMaterialConnectionPoint;
  142046. /**
  142047. * Gets the clear coat object output component
  142048. */
  142049. get clearcoat(): NodeMaterialConnectionPoint;
  142050. autoConfigure(material: NodeMaterial): void;
  142051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  142053. private _generateTBNSpace;
  142054. /**
  142055. * Gets the main code of the block (fragment side)
  142056. * @param state current state of the node material building
  142057. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  142058. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142059. * @param worldPosVarName name of the variable holding the world position
  142060. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  142061. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  142062. * @param worldNormalVarName name of the variable holding the world normal
  142063. * @returns the shader code
  142064. */
  142065. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  142066. protected _buildBlock(state: NodeMaterialBuildState): this;
  142067. }
  142068. }
  142069. declare module BABYLON {
  142070. /**
  142071. * Block used to implement the sub surface module of the PBR material
  142072. */
  142073. export class SubSurfaceBlock extends NodeMaterialBlock {
  142074. /**
  142075. * Create a new SubSurfaceBlock
  142076. * @param name defines the block name
  142077. */
  142078. constructor(name: string);
  142079. /**
  142080. * Stores the intensity of the different subsurface effects in the thickness texture.
  142081. * * the green channel is the translucency intensity.
  142082. * * the blue channel is the scattering intensity.
  142083. * * the alpha channel is the refraction intensity.
  142084. */
  142085. useMaskFromThicknessTexture: boolean;
  142086. /**
  142087. * Initialize the block and prepare the context for build
  142088. * @param state defines the state that will be used for the build
  142089. */
  142090. initialize(state: NodeMaterialBuildState): void;
  142091. /**
  142092. * Gets the current class name
  142093. * @returns the class name
  142094. */
  142095. getClassName(): string;
  142096. /**
  142097. * Gets the min thickness input component
  142098. */
  142099. get minThickness(): NodeMaterialConnectionPoint;
  142100. /**
  142101. * Gets the max thickness input component
  142102. */
  142103. get maxThickness(): NodeMaterialConnectionPoint;
  142104. /**
  142105. * Gets the thickness texture component
  142106. */
  142107. get thicknessTexture(): NodeMaterialConnectionPoint;
  142108. /**
  142109. * Gets the tint color input component
  142110. */
  142111. get tintColor(): NodeMaterialConnectionPoint;
  142112. /**
  142113. * Gets the translucency intensity input component
  142114. */
  142115. get translucencyIntensity(): NodeMaterialConnectionPoint;
  142116. /**
  142117. * Gets the translucency diffusion distance input component
  142118. */
  142119. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  142120. /**
  142121. * Gets the refraction object parameters
  142122. */
  142123. get refraction(): NodeMaterialConnectionPoint;
  142124. /**
  142125. * Gets the sub surface object output component
  142126. */
  142127. get subsurface(): NodeMaterialConnectionPoint;
  142128. autoConfigure(material: NodeMaterial): void;
  142129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142130. /**
  142131. * Gets the main code of the block (fragment side)
  142132. * @param state current state of the node material building
  142133. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  142134. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  142135. * @param worldPosVarName name of the variable holding the world position
  142136. * @returns the shader code
  142137. */
  142138. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  142139. protected _buildBlock(state: NodeMaterialBuildState): this;
  142140. }
  142141. }
  142142. declare module BABYLON {
  142143. /**
  142144. * Block used to implement the PBR metallic/roughness model
  142145. */
  142146. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  142147. /**
  142148. * Gets or sets the light associated with this block
  142149. */
  142150. light: Nullable<Light>;
  142151. private _lightId;
  142152. private _scene;
  142153. private _environmentBRDFTexture;
  142154. private _environmentBrdfSamplerName;
  142155. private _vNormalWName;
  142156. private _invertNormalName;
  142157. /**
  142158. * Create a new ReflectionBlock
  142159. * @param name defines the block name
  142160. */
  142161. constructor(name: string);
  142162. /**
  142163. * Intensity of the direct lights e.g. the four lights available in your scene.
  142164. * This impacts both the direct diffuse and specular highlights.
  142165. */
  142166. directIntensity: number;
  142167. /**
  142168. * Intensity of the environment e.g. how much the environment will light the object
  142169. * either through harmonics for rough material or through the refelction for shiny ones.
  142170. */
  142171. environmentIntensity: number;
  142172. /**
  142173. * This is a special control allowing the reduction of the specular highlights coming from the
  142174. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  142175. */
  142176. specularIntensity: number;
  142177. /**
  142178. * Defines the falloff type used in this material.
  142179. * It by default is Physical.
  142180. */
  142181. lightFalloff: number;
  142182. /**
  142183. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  142184. */
  142185. useAlphaFromAlbedoTexture: boolean;
  142186. /**
  142187. * Specifies that alpha test should be used
  142188. */
  142189. useAlphaTest: boolean;
  142190. /**
  142191. * Defines the alpha limits in alpha test mode.
  142192. */
  142193. alphaTestCutoff: number;
  142194. /**
  142195. * Specifies that alpha blending should be used
  142196. */
  142197. useAlphaBlending: boolean;
  142198. /**
  142199. * Defines if the alpha value should be determined via the rgb values.
  142200. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  142201. */
  142202. opacityRGB: boolean;
  142203. /**
  142204. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  142205. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  142206. */
  142207. useRadianceOverAlpha: boolean;
  142208. /**
  142209. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  142210. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  142211. */
  142212. useSpecularOverAlpha: boolean;
  142213. /**
  142214. * Enables specular anti aliasing in the PBR shader.
  142215. * It will both interacts on the Geometry for analytical and IBL lighting.
  142216. * It also prefilter the roughness map based on the bump values.
  142217. */
  142218. enableSpecularAntiAliasing: boolean;
  142219. /**
  142220. * Enables realtime filtering on the texture.
  142221. */
  142222. realTimeFiltering: boolean;
  142223. /**
  142224. * Quality switch for realtime filtering
  142225. */
  142226. realTimeFilteringQuality: number;
  142227. /**
  142228. * Defines if the material uses energy conservation.
  142229. */
  142230. useEnergyConservation: boolean;
  142231. /**
  142232. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  142233. * too much the area relying on ambient texture to define their ambient occlusion.
  142234. */
  142235. useRadianceOcclusion: boolean;
  142236. /**
  142237. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  142238. * makes the reflect vector face the model (under horizon).
  142239. */
  142240. useHorizonOcclusion: boolean;
  142241. /**
  142242. * If set to true, no lighting calculations will be applied.
  142243. */
  142244. unlit: boolean;
  142245. /**
  142246. * Force normal to face away from face.
  142247. */
  142248. forceNormalForward: boolean;
  142249. /**
  142250. * Defines the material debug mode.
  142251. * It helps seeing only some components of the material while troubleshooting.
  142252. */
  142253. debugMode: number;
  142254. /**
  142255. * Specify from where on screen the debug mode should start.
  142256. * The value goes from -1 (full screen) to 1 (not visible)
  142257. * It helps with side by side comparison against the final render
  142258. * This defaults to 0
  142259. */
  142260. debugLimit: number;
  142261. /**
  142262. * As the default viewing range might not be enough (if the ambient is really small for instance)
  142263. * You can use the factor to better multiply the final value.
  142264. */
  142265. debugFactor: number;
  142266. /**
  142267. * Initialize the block and prepare the context for build
  142268. * @param state defines the state that will be used for the build
  142269. */
  142270. initialize(state: NodeMaterialBuildState): void;
  142271. /**
  142272. * Gets the current class name
  142273. * @returns the class name
  142274. */
  142275. getClassName(): string;
  142276. /**
  142277. * Gets the world position input component
  142278. */
  142279. get worldPosition(): NodeMaterialConnectionPoint;
  142280. /**
  142281. * Gets the world normal input component
  142282. */
  142283. get worldNormal(): NodeMaterialConnectionPoint;
  142284. /**
  142285. * Gets the perturbed normal input component
  142286. */
  142287. get perturbedNormal(): NodeMaterialConnectionPoint;
  142288. /**
  142289. * Gets the camera position input component
  142290. */
  142291. get cameraPosition(): NodeMaterialConnectionPoint;
  142292. /**
  142293. * Gets the base color input component
  142294. */
  142295. get baseColor(): NodeMaterialConnectionPoint;
  142296. /**
  142297. * Gets the opacity texture input component
  142298. */
  142299. get opacityTexture(): NodeMaterialConnectionPoint;
  142300. /**
  142301. * Gets the ambient color input component
  142302. */
  142303. get ambientColor(): NodeMaterialConnectionPoint;
  142304. /**
  142305. * Gets the reflectivity object parameters
  142306. */
  142307. get reflectivity(): NodeMaterialConnectionPoint;
  142308. /**
  142309. * Gets the ambient occlusion object parameters
  142310. */
  142311. get ambientOcclusion(): NodeMaterialConnectionPoint;
  142312. /**
  142313. * Gets the reflection object parameters
  142314. */
  142315. get reflection(): NodeMaterialConnectionPoint;
  142316. /**
  142317. * Gets the sheen object parameters
  142318. */
  142319. get sheen(): NodeMaterialConnectionPoint;
  142320. /**
  142321. * Gets the clear coat object parameters
  142322. */
  142323. get clearcoat(): NodeMaterialConnectionPoint;
  142324. /**
  142325. * Gets the sub surface object parameters
  142326. */
  142327. get subsurface(): NodeMaterialConnectionPoint;
  142328. /**
  142329. * Gets the anisotropy object parameters
  142330. */
  142331. get anisotropy(): NodeMaterialConnectionPoint;
  142332. /**
  142333. * Gets the ambient output component
  142334. */
  142335. get ambient(): NodeMaterialConnectionPoint;
  142336. /**
  142337. * Gets the diffuse output component
  142338. */
  142339. get diffuse(): NodeMaterialConnectionPoint;
  142340. /**
  142341. * Gets the specular output component
  142342. */
  142343. get specular(): NodeMaterialConnectionPoint;
  142344. /**
  142345. * Gets the sheen output component
  142346. */
  142347. get sheenDir(): NodeMaterialConnectionPoint;
  142348. /**
  142349. * Gets the clear coat output component
  142350. */
  142351. get clearcoatDir(): NodeMaterialConnectionPoint;
  142352. /**
  142353. * Gets the indirect diffuse output component
  142354. */
  142355. get diffuseIndirect(): NodeMaterialConnectionPoint;
  142356. /**
  142357. * Gets the indirect specular output component
  142358. */
  142359. get specularIndirect(): NodeMaterialConnectionPoint;
  142360. /**
  142361. * Gets the indirect sheen output component
  142362. */
  142363. get sheenIndirect(): NodeMaterialConnectionPoint;
  142364. /**
  142365. * Gets the indirect clear coat output component
  142366. */
  142367. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  142368. /**
  142369. * Gets the refraction output component
  142370. */
  142371. get refraction(): NodeMaterialConnectionPoint;
  142372. /**
  142373. * Gets the global lighting output component
  142374. */
  142375. get lighting(): NodeMaterialConnectionPoint;
  142376. /**
  142377. * Gets the shadow output component
  142378. */
  142379. get shadow(): NodeMaterialConnectionPoint;
  142380. /**
  142381. * Gets the alpha output component
  142382. */
  142383. get alpha(): NodeMaterialConnectionPoint;
  142384. autoConfigure(material: NodeMaterial): void;
  142385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142386. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  142387. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142388. private _injectVertexCode;
  142389. /**
  142390. * Gets the code corresponding to the albedo/opacity module
  142391. * @returns the shader code
  142392. */
  142393. getAlbedoOpacityCode(): string;
  142394. protected _buildBlock(state: NodeMaterialBuildState): this;
  142395. protected _dumpPropertiesCode(): string;
  142396. serialize(): any;
  142397. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142398. }
  142399. }
  142400. declare module BABYLON {
  142401. /**
  142402. * Block used to compute value of one parameter modulo another
  142403. */
  142404. export class ModBlock extends NodeMaterialBlock {
  142405. /**
  142406. * Creates a new ModBlock
  142407. * @param name defines the block name
  142408. */
  142409. constructor(name: string);
  142410. /**
  142411. * Gets the current class name
  142412. * @returns the class name
  142413. */
  142414. getClassName(): string;
  142415. /**
  142416. * Gets the left operand input component
  142417. */
  142418. get left(): NodeMaterialConnectionPoint;
  142419. /**
  142420. * Gets the right operand input component
  142421. */
  142422. get right(): NodeMaterialConnectionPoint;
  142423. /**
  142424. * Gets the output component
  142425. */
  142426. get output(): NodeMaterialConnectionPoint;
  142427. protected _buildBlock(state: NodeMaterialBuildState): this;
  142428. }
  142429. }
  142430. declare module BABYLON {
  142431. /**
  142432. * Helper class to push actions to a pool of workers.
  142433. */
  142434. export class WorkerPool implements IDisposable {
  142435. private _workerInfos;
  142436. private _pendingActions;
  142437. /**
  142438. * Constructor
  142439. * @param workers Array of workers to use for actions
  142440. */
  142441. constructor(workers: Array<Worker>);
  142442. /**
  142443. * Terminates all workers and clears any pending actions.
  142444. */
  142445. dispose(): void;
  142446. /**
  142447. * Pushes an action to the worker pool. If all the workers are active, the action will be
  142448. * pended until a worker has completed its action.
  142449. * @param action The action to perform. Call onComplete when the action is complete.
  142450. */
  142451. push(action: (worker: Worker, onComplete: () => void) => void): void;
  142452. private _execute;
  142453. }
  142454. }
  142455. declare module BABYLON {
  142456. /**
  142457. * Configuration for Draco compression
  142458. */
  142459. export interface IDracoCompressionConfiguration {
  142460. /**
  142461. * Configuration for the decoder.
  142462. */
  142463. decoder: {
  142464. /**
  142465. * The url to the WebAssembly module.
  142466. */
  142467. wasmUrl?: string;
  142468. /**
  142469. * The url to the WebAssembly binary.
  142470. */
  142471. wasmBinaryUrl?: string;
  142472. /**
  142473. * The url to the fallback JavaScript module.
  142474. */
  142475. fallbackUrl?: string;
  142476. };
  142477. }
  142478. /**
  142479. * Draco compression (https://google.github.io/draco/)
  142480. *
  142481. * This class wraps the Draco module.
  142482. *
  142483. * **Encoder**
  142484. *
  142485. * The encoder is not currently implemented.
  142486. *
  142487. * **Decoder**
  142488. *
  142489. * 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.
  142490. *
  142491. * To update the configuration, use the following code:
  142492. * ```javascript
  142493. * DracoCompression.Configuration = {
  142494. * decoder: {
  142495. * wasmUrl: "<url to the WebAssembly library>",
  142496. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  142497. * fallbackUrl: "<url to the fallback JavaScript library>",
  142498. * }
  142499. * };
  142500. * ```
  142501. *
  142502. * 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.
  142503. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  142504. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  142505. *
  142506. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  142507. * ```javascript
  142508. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  142509. * ```
  142510. *
  142511. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  142512. */
  142513. export class DracoCompression implements IDisposable {
  142514. private _workerPoolPromise?;
  142515. private _decoderModulePromise?;
  142516. /**
  142517. * The configuration. Defaults to the following urls:
  142518. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  142519. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  142520. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  142521. */
  142522. static Configuration: IDracoCompressionConfiguration;
  142523. /**
  142524. * Returns true if the decoder configuration is available.
  142525. */
  142526. static get DecoderAvailable(): boolean;
  142527. /**
  142528. * Default number of workers to create when creating the draco compression object.
  142529. */
  142530. static DefaultNumWorkers: number;
  142531. private static GetDefaultNumWorkers;
  142532. private static _Default;
  142533. /**
  142534. * Default instance for the draco compression object.
  142535. */
  142536. static get Default(): DracoCompression;
  142537. /**
  142538. * Constructor
  142539. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  142540. */
  142541. constructor(numWorkers?: number);
  142542. /**
  142543. * Stop all async operations and release resources.
  142544. */
  142545. dispose(): void;
  142546. /**
  142547. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  142548. * @returns a promise that resolves when ready
  142549. */
  142550. whenReadyAsync(): Promise<void>;
  142551. /**
  142552. * Decode Draco compressed mesh data to vertex data.
  142553. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  142554. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  142555. * @returns A promise that resolves with the decoded vertex data
  142556. */
  142557. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  142558. [kind: string]: number;
  142559. }): Promise<VertexData>;
  142560. }
  142561. }
  142562. declare module BABYLON {
  142563. /**
  142564. * Class for building Constructive Solid Geometry
  142565. */
  142566. export class CSG {
  142567. private polygons;
  142568. /**
  142569. * The world matrix
  142570. */
  142571. matrix: Matrix;
  142572. /**
  142573. * Stores the position
  142574. */
  142575. position: Vector3;
  142576. /**
  142577. * Stores the rotation
  142578. */
  142579. rotation: Vector3;
  142580. /**
  142581. * Stores the rotation quaternion
  142582. */
  142583. rotationQuaternion: Nullable<Quaternion>;
  142584. /**
  142585. * Stores the scaling vector
  142586. */
  142587. scaling: Vector3;
  142588. /**
  142589. * Convert the Mesh to CSG
  142590. * @param mesh The Mesh to convert to CSG
  142591. * @returns A new CSG from the Mesh
  142592. */
  142593. static FromMesh(mesh: Mesh): CSG;
  142594. /**
  142595. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  142596. * @param polygons Polygons used to construct a CSG solid
  142597. */
  142598. private static FromPolygons;
  142599. /**
  142600. * Clones, or makes a deep copy, of the CSG
  142601. * @returns A new CSG
  142602. */
  142603. clone(): CSG;
  142604. /**
  142605. * Unions this CSG with another CSG
  142606. * @param csg The CSG to union against this CSG
  142607. * @returns The unioned CSG
  142608. */
  142609. union(csg: CSG): CSG;
  142610. /**
  142611. * Unions this CSG with another CSG in place
  142612. * @param csg The CSG to union against this CSG
  142613. */
  142614. unionInPlace(csg: CSG): void;
  142615. /**
  142616. * Subtracts this CSG with another CSG
  142617. * @param csg The CSG to subtract against this CSG
  142618. * @returns A new CSG
  142619. */
  142620. subtract(csg: CSG): CSG;
  142621. /**
  142622. * Subtracts this CSG with another CSG in place
  142623. * @param csg The CSG to subtact against this CSG
  142624. */
  142625. subtractInPlace(csg: CSG): void;
  142626. /**
  142627. * Intersect this CSG with another CSG
  142628. * @param csg The CSG to intersect against this CSG
  142629. * @returns A new CSG
  142630. */
  142631. intersect(csg: CSG): CSG;
  142632. /**
  142633. * Intersects this CSG with another CSG in place
  142634. * @param csg The CSG to intersect against this CSG
  142635. */
  142636. intersectInPlace(csg: CSG): void;
  142637. /**
  142638. * Return a new CSG solid with solid and empty space switched. This solid is
  142639. * not modified.
  142640. * @returns A new CSG solid with solid and empty space switched
  142641. */
  142642. inverse(): CSG;
  142643. /**
  142644. * Inverses the CSG in place
  142645. */
  142646. inverseInPlace(): void;
  142647. /**
  142648. * This is used to keep meshes transformations so they can be restored
  142649. * when we build back a Babylon Mesh
  142650. * NB : All CSG operations are performed in world coordinates
  142651. * @param csg The CSG to copy the transform attributes from
  142652. * @returns This CSG
  142653. */
  142654. copyTransformAttributes(csg: CSG): CSG;
  142655. /**
  142656. * Build Raw mesh from CSG
  142657. * Coordinates here are in world space
  142658. * @param name The name of the mesh geometry
  142659. * @param scene The Scene
  142660. * @param keepSubMeshes Specifies if the submeshes should be kept
  142661. * @returns A new Mesh
  142662. */
  142663. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142664. /**
  142665. * Build Mesh from CSG taking material and transforms into account
  142666. * @param name The name of the Mesh
  142667. * @param material The material of the Mesh
  142668. * @param scene The Scene
  142669. * @param keepSubMeshes Specifies if submeshes should be kept
  142670. * @returns The new Mesh
  142671. */
  142672. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  142673. }
  142674. }
  142675. declare module BABYLON {
  142676. /**
  142677. * Class used to create a trail following a mesh
  142678. */
  142679. export class TrailMesh extends Mesh {
  142680. private _generator;
  142681. private _autoStart;
  142682. private _running;
  142683. private _diameter;
  142684. private _length;
  142685. private _sectionPolygonPointsCount;
  142686. private _sectionVectors;
  142687. private _sectionNormalVectors;
  142688. private _beforeRenderObserver;
  142689. /**
  142690. * @constructor
  142691. * @param name The value used by scene.getMeshByName() to do a lookup.
  142692. * @param generator The mesh or transform node to generate a trail.
  142693. * @param scene The scene to add this mesh to.
  142694. * @param diameter Diameter of trailing mesh. Default is 1.
  142695. * @param length Length of trailing mesh. Default is 60.
  142696. * @param autoStart Automatically start trailing mesh. Default true.
  142697. */
  142698. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  142699. /**
  142700. * "TrailMesh"
  142701. * @returns "TrailMesh"
  142702. */
  142703. getClassName(): string;
  142704. private _createMesh;
  142705. /**
  142706. * Start trailing mesh.
  142707. */
  142708. start(): void;
  142709. /**
  142710. * Stop trailing mesh.
  142711. */
  142712. stop(): void;
  142713. /**
  142714. * Update trailing mesh geometry.
  142715. */
  142716. update(): void;
  142717. /**
  142718. * Returns a new TrailMesh object.
  142719. * @param name is a string, the name given to the new mesh
  142720. * @param newGenerator use new generator object for cloned trail mesh
  142721. * @returns a new mesh
  142722. */
  142723. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  142724. /**
  142725. * Serializes this trail mesh
  142726. * @param serializationObject object to write serialization to
  142727. */
  142728. serialize(serializationObject: any): void;
  142729. /**
  142730. * Parses a serialized trail mesh
  142731. * @param parsedMesh the serialized mesh
  142732. * @param scene the scene to create the trail mesh in
  142733. * @returns the created trail mesh
  142734. */
  142735. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  142736. }
  142737. }
  142738. declare module BABYLON {
  142739. /**
  142740. * Class containing static functions to help procedurally build meshes
  142741. */
  142742. export class TiledBoxBuilder {
  142743. /**
  142744. * Creates a box mesh
  142745. * 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)
  142746. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142747. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142748. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142749. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142750. * @param name defines the name of the mesh
  142751. * @param options defines the options used to create the mesh
  142752. * @param scene defines the hosting scene
  142753. * @returns the box mesh
  142754. */
  142755. static CreateTiledBox(name: string, options: {
  142756. pattern?: number;
  142757. width?: number;
  142758. height?: number;
  142759. depth?: number;
  142760. tileSize?: number;
  142761. tileWidth?: number;
  142762. tileHeight?: number;
  142763. alignHorizontal?: number;
  142764. alignVertical?: number;
  142765. faceUV?: Vector4[];
  142766. faceColors?: Color4[];
  142767. sideOrientation?: number;
  142768. updatable?: boolean;
  142769. }, scene?: Nullable<Scene>): Mesh;
  142770. }
  142771. }
  142772. declare module BABYLON {
  142773. /**
  142774. * Class containing static functions to help procedurally build meshes
  142775. */
  142776. export class TorusKnotBuilder {
  142777. /**
  142778. * Creates a torus knot mesh
  142779. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  142780. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  142781. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  142782. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  142783. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142784. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142785. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  142786. * @param name defines the name of the mesh
  142787. * @param options defines the options used to create the mesh
  142788. * @param scene defines the hosting scene
  142789. * @returns the torus knot mesh
  142790. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  142791. */
  142792. static CreateTorusKnot(name: string, options: {
  142793. radius?: number;
  142794. tube?: number;
  142795. radialSegments?: number;
  142796. tubularSegments?: number;
  142797. p?: number;
  142798. q?: number;
  142799. updatable?: boolean;
  142800. sideOrientation?: number;
  142801. frontUVs?: Vector4;
  142802. backUVs?: Vector4;
  142803. }, scene: any): Mesh;
  142804. }
  142805. }
  142806. declare module BABYLON {
  142807. /**
  142808. * Polygon
  142809. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  142810. */
  142811. export class Polygon {
  142812. /**
  142813. * Creates a rectangle
  142814. * @param xmin bottom X coord
  142815. * @param ymin bottom Y coord
  142816. * @param xmax top X coord
  142817. * @param ymax top Y coord
  142818. * @returns points that make the resulting rectation
  142819. */
  142820. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  142821. /**
  142822. * Creates a circle
  142823. * @param radius radius of circle
  142824. * @param cx scale in x
  142825. * @param cy scale in y
  142826. * @param numberOfSides number of sides that make up the circle
  142827. * @returns points that make the resulting circle
  142828. */
  142829. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  142830. /**
  142831. * Creates a polygon from input string
  142832. * @param input Input polygon data
  142833. * @returns the parsed points
  142834. */
  142835. static Parse(input: string): Vector2[];
  142836. /**
  142837. * Starts building a polygon from x and y coordinates
  142838. * @param x x coordinate
  142839. * @param y y coordinate
  142840. * @returns the started path2
  142841. */
  142842. static StartingAt(x: number, y: number): Path2;
  142843. }
  142844. /**
  142845. * Builds a polygon
  142846. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  142847. */
  142848. export class PolygonMeshBuilder {
  142849. private _points;
  142850. private _outlinepoints;
  142851. private _holes;
  142852. private _name;
  142853. private _scene;
  142854. private _epoints;
  142855. private _eholes;
  142856. private _addToepoint;
  142857. /**
  142858. * Babylon reference to the earcut plugin.
  142859. */
  142860. bjsEarcut: any;
  142861. /**
  142862. * Creates a PolygonMeshBuilder
  142863. * @param name name of the builder
  142864. * @param contours Path of the polygon
  142865. * @param scene scene to add to when creating the mesh
  142866. * @param earcutInjection can be used to inject your own earcut reference
  142867. */
  142868. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  142869. /**
  142870. * Adds a whole within the polygon
  142871. * @param hole Array of points defining the hole
  142872. * @returns this
  142873. */
  142874. addHole(hole: Vector2[]): PolygonMeshBuilder;
  142875. /**
  142876. * Creates the polygon
  142877. * @param updatable If the mesh should be updatable
  142878. * @param depth The depth of the mesh created
  142879. * @returns the created mesh
  142880. */
  142881. build(updatable?: boolean, depth?: number): Mesh;
  142882. /**
  142883. * Creates the polygon
  142884. * @param depth The depth of the mesh created
  142885. * @returns the created VertexData
  142886. */
  142887. buildVertexData(depth?: number): VertexData;
  142888. /**
  142889. * Adds a side to the polygon
  142890. * @param positions points that make the polygon
  142891. * @param normals normals of the polygon
  142892. * @param uvs uvs of the polygon
  142893. * @param indices indices of the polygon
  142894. * @param bounds bounds of the polygon
  142895. * @param points points of the polygon
  142896. * @param depth depth of the polygon
  142897. * @param flip flip of the polygon
  142898. */
  142899. private addSide;
  142900. }
  142901. }
  142902. declare module BABYLON {
  142903. /**
  142904. * Class containing static functions to help procedurally build meshes
  142905. */
  142906. export class PolygonBuilder {
  142907. /**
  142908. * Creates a polygon mesh
  142909. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  142910. * * 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
  142911. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  142912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142913. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  142914. * * Remember you can only change the shape positions, not their number when updating a polygon
  142915. * @param name defines the name of the mesh
  142916. * @param options defines the options used to create the mesh
  142917. * @param scene defines the hosting scene
  142918. * @param earcutInjection can be used to inject your own earcut reference
  142919. * @returns the polygon mesh
  142920. */
  142921. static CreatePolygon(name: string, options: {
  142922. shape: Vector3[];
  142923. holes?: Vector3[][];
  142924. depth?: number;
  142925. faceUV?: Vector4[];
  142926. faceColors?: Color4[];
  142927. updatable?: boolean;
  142928. sideOrientation?: number;
  142929. frontUVs?: Vector4;
  142930. backUVs?: Vector4;
  142931. wrap?: boolean;
  142932. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142933. /**
  142934. * Creates an extruded polygon mesh, with depth in the Y direction.
  142935. * * 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)
  142936. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  142937. * @param name defines the name of the mesh
  142938. * @param options defines the options used to create the mesh
  142939. * @param scene defines the hosting scene
  142940. * @param earcutInjection can be used to inject your own earcut reference
  142941. * @returns the polygon mesh
  142942. */
  142943. static ExtrudePolygon(name: string, options: {
  142944. shape: Vector3[];
  142945. holes?: Vector3[][];
  142946. depth?: number;
  142947. faceUV?: Vector4[];
  142948. faceColors?: Color4[];
  142949. updatable?: boolean;
  142950. sideOrientation?: number;
  142951. frontUVs?: Vector4;
  142952. backUVs?: Vector4;
  142953. wrap?: boolean;
  142954. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  142955. }
  142956. }
  142957. declare module BABYLON {
  142958. /**
  142959. * Class containing static functions to help procedurally build meshes
  142960. */
  142961. export class LatheBuilder {
  142962. /**
  142963. * Creates lathe mesh.
  142964. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  142965. * * 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
  142966. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  142967. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  142968. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  142969. * * 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
  142970. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  142971. * * 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
  142972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  142973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  142974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  142975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  142976. * @param name defines the name of the mesh
  142977. * @param options defines the options used to create the mesh
  142978. * @param scene defines the hosting scene
  142979. * @returns the lathe mesh
  142980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  142981. */
  142982. static CreateLathe(name: string, options: {
  142983. shape: Vector3[];
  142984. radius?: number;
  142985. tessellation?: number;
  142986. clip?: number;
  142987. arc?: number;
  142988. closed?: boolean;
  142989. updatable?: boolean;
  142990. sideOrientation?: number;
  142991. frontUVs?: Vector4;
  142992. backUVs?: Vector4;
  142993. cap?: number;
  142994. invertUV?: boolean;
  142995. }, scene?: Nullable<Scene>): Mesh;
  142996. }
  142997. }
  142998. declare module BABYLON {
  142999. /**
  143000. * Class containing static functions to help procedurally build meshes
  143001. */
  143002. export class TiledPlaneBuilder {
  143003. /**
  143004. * Creates a tiled plane mesh
  143005. * * The parameter `pattern` will, depending on value, do nothing or
  143006. * * * flip (reflect about central vertical) alternate tiles across and up
  143007. * * * flip every tile on alternate rows
  143008. * * * rotate (180 degs) alternate tiles across and up
  143009. * * * rotate every tile on alternate rows
  143010. * * * flip and rotate alternate tiles across and up
  143011. * * * flip and rotate every tile on alternate rows
  143012. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  143013. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  143014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143016. * * 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)
  143017. * * 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)
  143018. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143019. * @param name defines the name of the mesh
  143020. * @param options defines the options used to create the mesh
  143021. * @param scene defines the hosting scene
  143022. * @returns the box mesh
  143023. */
  143024. static CreateTiledPlane(name: string, options: {
  143025. pattern?: number;
  143026. tileSize?: number;
  143027. tileWidth?: number;
  143028. tileHeight?: number;
  143029. size?: number;
  143030. width?: number;
  143031. height?: number;
  143032. alignHorizontal?: number;
  143033. alignVertical?: number;
  143034. sideOrientation?: number;
  143035. frontUVs?: Vector4;
  143036. backUVs?: Vector4;
  143037. updatable?: boolean;
  143038. }, scene?: Nullable<Scene>): Mesh;
  143039. }
  143040. }
  143041. declare module BABYLON {
  143042. /**
  143043. * Class containing static functions to help procedurally build meshes
  143044. */
  143045. export class TubeBuilder {
  143046. /**
  143047. * Creates a tube mesh.
  143048. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143049. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143050. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143051. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143052. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143053. * * 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)
  143054. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143055. * * 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
  143056. * * 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
  143057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143060. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143061. * @param name defines the name of the mesh
  143062. * @param options defines the options used to create the mesh
  143063. * @param scene defines the hosting scene
  143064. * @returns the tube mesh
  143065. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143066. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143067. */
  143068. static CreateTube(name: string, options: {
  143069. path: Vector3[];
  143070. radius?: number;
  143071. tessellation?: number;
  143072. radiusFunction?: {
  143073. (i: number, distance: number): number;
  143074. };
  143075. cap?: number;
  143076. arc?: number;
  143077. updatable?: boolean;
  143078. sideOrientation?: number;
  143079. frontUVs?: Vector4;
  143080. backUVs?: Vector4;
  143081. instance?: Mesh;
  143082. invertUV?: boolean;
  143083. }, scene?: Nullable<Scene>): Mesh;
  143084. }
  143085. }
  143086. declare module BABYLON {
  143087. /**
  143088. * Class containing static functions to help procedurally build meshes
  143089. */
  143090. export class IcoSphereBuilder {
  143091. /**
  143092. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143093. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143094. * * 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`)
  143095. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143096. * * 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
  143097. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143098. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143100. * @param name defines the name of the mesh
  143101. * @param options defines the options used to create the mesh
  143102. * @param scene defines the hosting scene
  143103. * @returns the icosahedron mesh
  143104. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143105. */
  143106. static CreateIcoSphere(name: string, options: {
  143107. radius?: number;
  143108. radiusX?: number;
  143109. radiusY?: number;
  143110. radiusZ?: number;
  143111. flat?: boolean;
  143112. subdivisions?: number;
  143113. sideOrientation?: number;
  143114. frontUVs?: Vector4;
  143115. backUVs?: Vector4;
  143116. updatable?: boolean;
  143117. }, scene?: Nullable<Scene>): Mesh;
  143118. }
  143119. }
  143120. declare module BABYLON {
  143121. /**
  143122. * Class containing static functions to help procedurally build meshes
  143123. */
  143124. export class DecalBuilder {
  143125. /**
  143126. * Creates a decal mesh.
  143127. * 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
  143128. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143129. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143130. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143131. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143132. * @param name defines the name of the mesh
  143133. * @param sourceMesh defines the mesh where the decal must be applied
  143134. * @param options defines the options used to create the mesh
  143135. * @param scene defines the hosting scene
  143136. * @returns the decal mesh
  143137. * @see https://doc.babylonjs.com/how_to/decals
  143138. */
  143139. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143140. position?: Vector3;
  143141. normal?: Vector3;
  143142. size?: Vector3;
  143143. angle?: number;
  143144. }): Mesh;
  143145. }
  143146. }
  143147. declare module BABYLON {
  143148. /**
  143149. * Class containing static functions to help procedurally build meshes
  143150. */
  143151. export class MeshBuilder {
  143152. /**
  143153. * Creates a box mesh
  143154. * * The parameter `size` sets the size (float) of each box side (default 1)
  143155. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  143156. * * 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)
  143157. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143158. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143159. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143160. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143161. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  143162. * @param name defines the name of the mesh
  143163. * @param options defines the options used to create the mesh
  143164. * @param scene defines the hosting scene
  143165. * @returns the box mesh
  143166. */
  143167. static CreateBox(name: string, options: {
  143168. size?: number;
  143169. width?: number;
  143170. height?: number;
  143171. depth?: number;
  143172. faceUV?: Vector4[];
  143173. faceColors?: Color4[];
  143174. sideOrientation?: number;
  143175. frontUVs?: Vector4;
  143176. backUVs?: Vector4;
  143177. wrap?: boolean;
  143178. topBaseAt?: number;
  143179. bottomBaseAt?: number;
  143180. updatable?: boolean;
  143181. }, scene?: Nullable<Scene>): Mesh;
  143182. /**
  143183. * Creates a tiled box mesh
  143184. * * faceTiles sets the pattern, tile size and number of tiles for a face
  143185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143186. * @param name defines the name of the mesh
  143187. * @param options defines the options used to create the mesh
  143188. * @param scene defines the hosting scene
  143189. * @returns the tiled box mesh
  143190. */
  143191. static CreateTiledBox(name: string, options: {
  143192. pattern?: number;
  143193. size?: number;
  143194. width?: number;
  143195. height?: number;
  143196. depth: number;
  143197. tileSize?: number;
  143198. tileWidth?: number;
  143199. tileHeight?: number;
  143200. faceUV?: Vector4[];
  143201. faceColors?: Color4[];
  143202. alignHorizontal?: number;
  143203. alignVertical?: number;
  143204. sideOrientation?: number;
  143205. updatable?: boolean;
  143206. }, scene?: Nullable<Scene>): Mesh;
  143207. /**
  143208. * Creates a sphere mesh
  143209. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  143210. * * 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`)
  143211. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  143212. * * 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
  143213. * * 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)
  143214. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143215. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143216. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143217. * @param name defines the name of the mesh
  143218. * @param options defines the options used to create the mesh
  143219. * @param scene defines the hosting scene
  143220. * @returns the sphere mesh
  143221. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  143222. */
  143223. static CreateSphere(name: string, options: {
  143224. segments?: number;
  143225. diameter?: number;
  143226. diameterX?: number;
  143227. diameterY?: number;
  143228. diameterZ?: number;
  143229. arc?: number;
  143230. slice?: number;
  143231. sideOrientation?: number;
  143232. frontUVs?: Vector4;
  143233. backUVs?: Vector4;
  143234. updatable?: boolean;
  143235. }, scene?: Nullable<Scene>): Mesh;
  143236. /**
  143237. * Creates a plane polygonal mesh. By default, this is a disc
  143238. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  143239. * * 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
  143240. * * 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
  143241. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143242. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143243. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143244. * @param name defines the name of the mesh
  143245. * @param options defines the options used to create the mesh
  143246. * @param scene defines the hosting scene
  143247. * @returns the plane polygonal mesh
  143248. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  143249. */
  143250. static CreateDisc(name: string, options: {
  143251. radius?: number;
  143252. tessellation?: number;
  143253. arc?: number;
  143254. updatable?: boolean;
  143255. sideOrientation?: number;
  143256. frontUVs?: Vector4;
  143257. backUVs?: Vector4;
  143258. }, scene?: Nullable<Scene>): Mesh;
  143259. /**
  143260. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  143261. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  143262. * * 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`)
  143263. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  143264. * * 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
  143265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143268. * @param name defines the name of the mesh
  143269. * @param options defines the options used to create the mesh
  143270. * @param scene defines the hosting scene
  143271. * @returns the icosahedron mesh
  143272. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  143273. */
  143274. static CreateIcoSphere(name: string, options: {
  143275. radius?: number;
  143276. radiusX?: number;
  143277. radiusY?: number;
  143278. radiusZ?: number;
  143279. flat?: boolean;
  143280. subdivisions?: number;
  143281. sideOrientation?: number;
  143282. frontUVs?: Vector4;
  143283. backUVs?: Vector4;
  143284. updatable?: boolean;
  143285. }, scene?: Nullable<Scene>): Mesh;
  143286. /**
  143287. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143288. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  143289. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  143290. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  143291. * * 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
  143292. * * 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
  143293. * * 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
  143294. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143295. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143296. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143297. * * 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
  143298. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  143299. * * 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
  143300. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  143301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143302. * @param name defines the name of the mesh
  143303. * @param options defines the options used to create the mesh
  143304. * @param scene defines the hosting scene
  143305. * @returns the ribbon mesh
  143306. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  143307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143308. */
  143309. static CreateRibbon(name: string, options: {
  143310. pathArray: Vector3[][];
  143311. closeArray?: boolean;
  143312. closePath?: boolean;
  143313. offset?: number;
  143314. updatable?: boolean;
  143315. sideOrientation?: number;
  143316. frontUVs?: Vector4;
  143317. backUVs?: Vector4;
  143318. instance?: Mesh;
  143319. invertUV?: boolean;
  143320. uvs?: Vector2[];
  143321. colors?: Color4[];
  143322. }, scene?: Nullable<Scene>): Mesh;
  143323. /**
  143324. * Creates a cylinder or a cone mesh
  143325. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  143326. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  143327. * * 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.
  143328. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  143329. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  143330. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  143331. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  143332. * * 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).
  143333. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  143334. * * 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).
  143335. * * 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
  143336. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  143337. * * 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
  143338. * * 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.
  143339. * * If `enclose` is false, a ring surface is one element.
  143340. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  143341. * * 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
  143342. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143343. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143345. * @param name defines the name of the mesh
  143346. * @param options defines the options used to create the mesh
  143347. * @param scene defines the hosting scene
  143348. * @returns the cylinder mesh
  143349. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  143350. */
  143351. static CreateCylinder(name: string, options: {
  143352. height?: number;
  143353. diameterTop?: number;
  143354. diameterBottom?: number;
  143355. diameter?: number;
  143356. tessellation?: number;
  143357. subdivisions?: number;
  143358. arc?: number;
  143359. faceColors?: Color4[];
  143360. faceUV?: Vector4[];
  143361. updatable?: boolean;
  143362. hasRings?: boolean;
  143363. enclose?: boolean;
  143364. cap?: number;
  143365. sideOrientation?: number;
  143366. frontUVs?: Vector4;
  143367. backUVs?: Vector4;
  143368. }, scene?: Nullable<Scene>): Mesh;
  143369. /**
  143370. * Creates a torus mesh
  143371. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  143372. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  143373. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  143374. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143376. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143377. * @param name defines the name of the mesh
  143378. * @param options defines the options used to create the mesh
  143379. * @param scene defines the hosting scene
  143380. * @returns the torus mesh
  143381. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  143382. */
  143383. static CreateTorus(name: string, options: {
  143384. diameter?: number;
  143385. thickness?: number;
  143386. tessellation?: number;
  143387. updatable?: boolean;
  143388. sideOrientation?: number;
  143389. frontUVs?: Vector4;
  143390. backUVs?: Vector4;
  143391. }, scene?: Nullable<Scene>): Mesh;
  143392. /**
  143393. * Creates a torus knot mesh
  143394. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  143395. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  143396. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  143397. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  143398. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143399. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143401. * @param name defines the name of the mesh
  143402. * @param options defines the options used to create the mesh
  143403. * @param scene defines the hosting scene
  143404. * @returns the torus knot mesh
  143405. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  143406. */
  143407. static CreateTorusKnot(name: string, options: {
  143408. radius?: number;
  143409. tube?: number;
  143410. radialSegments?: number;
  143411. tubularSegments?: number;
  143412. p?: number;
  143413. q?: number;
  143414. updatable?: boolean;
  143415. sideOrientation?: number;
  143416. frontUVs?: Vector4;
  143417. backUVs?: Vector4;
  143418. }, scene?: Nullable<Scene>): Mesh;
  143419. /**
  143420. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  143421. * * 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
  143422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  143423. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  143424. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  143425. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  143426. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  143427. * * 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
  143428. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  143429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  143431. * @param name defines the name of the new line system
  143432. * @param options defines the options used to create the line system
  143433. * @param scene defines the hosting scene
  143434. * @returns a new line system mesh
  143435. */
  143436. static CreateLineSystem(name: string, options: {
  143437. lines: Vector3[][];
  143438. updatable?: boolean;
  143439. instance?: Nullable<LinesMesh>;
  143440. colors?: Nullable<Color4[][]>;
  143441. useVertexAlpha?: boolean;
  143442. }, scene: Nullable<Scene>): LinesMesh;
  143443. /**
  143444. * Creates a line mesh
  143445. * 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
  143446. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143447. * * The parameter `points` is an array successive Vector3
  143448. * * 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
  143449. * * The optional parameter `colors` is an array of successive Color4, one per line point
  143450. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  143451. * * When updating an instance, remember that only point positions can change, not the number of points
  143452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143453. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  143454. * @param name defines the name of the new line system
  143455. * @param options defines the options used to create the line system
  143456. * @param scene defines the hosting scene
  143457. * @returns a new line mesh
  143458. */
  143459. static CreateLines(name: string, options: {
  143460. points: Vector3[];
  143461. updatable?: boolean;
  143462. instance?: Nullable<LinesMesh>;
  143463. colors?: Color4[];
  143464. useVertexAlpha?: boolean;
  143465. }, scene?: Nullable<Scene>): LinesMesh;
  143466. /**
  143467. * Creates a dashed line mesh
  143468. * * 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
  143469. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  143470. * * The parameter `points` is an array successive Vector3
  143471. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  143472. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  143473. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  143474. * * 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
  143475. * * When updating an instance, remember that only point positions can change, not the number of points
  143476. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143477. * @param name defines the name of the mesh
  143478. * @param options defines the options used to create the mesh
  143479. * @param scene defines the hosting scene
  143480. * @returns the dashed line mesh
  143481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  143482. */
  143483. static CreateDashedLines(name: string, options: {
  143484. points: Vector3[];
  143485. dashSize?: number;
  143486. gapSize?: number;
  143487. dashNb?: number;
  143488. updatable?: boolean;
  143489. instance?: LinesMesh;
  143490. }, scene?: Nullable<Scene>): LinesMesh;
  143491. /**
  143492. * 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.
  143493. * * 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.
  143494. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143495. * * 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.
  143496. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  143497. * * 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
  143498. * * 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
  143499. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  143500. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143501. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143502. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  143503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143504. * @param name defines the name of the mesh
  143505. * @param options defines the options used to create the mesh
  143506. * @param scene defines the hosting scene
  143507. * @returns the extruded shape mesh
  143508. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143510. */
  143511. static ExtrudeShape(name: string, options: {
  143512. shape: Vector3[];
  143513. path: Vector3[];
  143514. scale?: number;
  143515. rotation?: number;
  143516. cap?: number;
  143517. updatable?: boolean;
  143518. sideOrientation?: number;
  143519. frontUVs?: Vector4;
  143520. backUVs?: Vector4;
  143521. instance?: Mesh;
  143522. invertUV?: boolean;
  143523. }, scene?: Nullable<Scene>): Mesh;
  143524. /**
  143525. * Creates an custom extruded shape mesh.
  143526. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  143527. * * 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.
  143528. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  143529. * * 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
  143530. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  143531. * * 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
  143532. * * It must returns a float value that will be the scale value applied to the shape on each path point
  143533. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  143534. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  143535. * * 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
  143536. * * 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
  143537. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  143538. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143539. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143540. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143541. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143542. * @param name defines the name of the mesh
  143543. * @param options defines the options used to create the mesh
  143544. * @param scene defines the hosting scene
  143545. * @returns the custom extruded shape mesh
  143546. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  143547. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143548. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  143549. */
  143550. static ExtrudeShapeCustom(name: string, options: {
  143551. shape: Vector3[];
  143552. path: Vector3[];
  143553. scaleFunction?: any;
  143554. rotationFunction?: any;
  143555. ribbonCloseArray?: boolean;
  143556. ribbonClosePath?: boolean;
  143557. cap?: number;
  143558. updatable?: boolean;
  143559. sideOrientation?: number;
  143560. frontUVs?: Vector4;
  143561. backUVs?: Vector4;
  143562. instance?: Mesh;
  143563. invertUV?: boolean;
  143564. }, scene?: Nullable<Scene>): Mesh;
  143565. /**
  143566. * Creates lathe mesh.
  143567. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  143568. * * 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
  143569. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  143570. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  143571. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  143572. * * 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
  143573. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  143574. * * 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
  143575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143579. * @param name defines the name of the mesh
  143580. * @param options defines the options used to create the mesh
  143581. * @param scene defines the hosting scene
  143582. * @returns the lathe mesh
  143583. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  143584. */
  143585. static CreateLathe(name: string, options: {
  143586. shape: Vector3[];
  143587. radius?: number;
  143588. tessellation?: number;
  143589. clip?: number;
  143590. arc?: number;
  143591. closed?: boolean;
  143592. updatable?: boolean;
  143593. sideOrientation?: number;
  143594. frontUVs?: Vector4;
  143595. backUVs?: Vector4;
  143596. cap?: number;
  143597. invertUV?: boolean;
  143598. }, scene?: Nullable<Scene>): Mesh;
  143599. /**
  143600. * Creates a tiled plane mesh
  143601. * * You can set a limited pattern arrangement with the tiles
  143602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143605. * @param name defines the name of the mesh
  143606. * @param options defines the options used to create the mesh
  143607. * @param scene defines the hosting scene
  143608. * @returns the plane mesh
  143609. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143610. */
  143611. static CreateTiledPlane(name: string, options: {
  143612. pattern?: number;
  143613. tileSize?: number;
  143614. tileWidth?: number;
  143615. tileHeight?: number;
  143616. size?: number;
  143617. width?: number;
  143618. height?: number;
  143619. alignHorizontal?: number;
  143620. alignVertical?: number;
  143621. sideOrientation?: number;
  143622. frontUVs?: Vector4;
  143623. backUVs?: Vector4;
  143624. updatable?: boolean;
  143625. }, scene?: Nullable<Scene>): Mesh;
  143626. /**
  143627. * Creates a plane mesh
  143628. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  143629. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  143630. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  143631. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143632. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143633. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143634. * @param name defines the name of the mesh
  143635. * @param options defines the options used to create the mesh
  143636. * @param scene defines the hosting scene
  143637. * @returns the plane mesh
  143638. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  143639. */
  143640. static CreatePlane(name: string, options: {
  143641. size?: number;
  143642. width?: number;
  143643. height?: number;
  143644. sideOrientation?: number;
  143645. frontUVs?: Vector4;
  143646. backUVs?: Vector4;
  143647. updatable?: boolean;
  143648. sourcePlane?: Plane;
  143649. }, scene?: Nullable<Scene>): Mesh;
  143650. /**
  143651. * Creates a ground mesh
  143652. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  143653. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  143654. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143655. * @param name defines the name of the mesh
  143656. * @param options defines the options used to create the mesh
  143657. * @param scene defines the hosting scene
  143658. * @returns the ground mesh
  143659. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  143660. */
  143661. static CreateGround(name: string, options: {
  143662. width?: number;
  143663. height?: number;
  143664. subdivisions?: number;
  143665. subdivisionsX?: number;
  143666. subdivisionsY?: number;
  143667. updatable?: boolean;
  143668. }, scene?: Nullable<Scene>): Mesh;
  143669. /**
  143670. * Creates a tiled ground mesh
  143671. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  143672. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  143673. * * 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
  143674. * * 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
  143675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143676. * @param name defines the name of the mesh
  143677. * @param options defines the options used to create the mesh
  143678. * @param scene defines the hosting scene
  143679. * @returns the tiled ground mesh
  143680. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  143681. */
  143682. static CreateTiledGround(name: string, options: {
  143683. xmin: number;
  143684. zmin: number;
  143685. xmax: number;
  143686. zmax: number;
  143687. subdivisions?: {
  143688. w: number;
  143689. h: number;
  143690. };
  143691. precision?: {
  143692. w: number;
  143693. h: number;
  143694. };
  143695. updatable?: boolean;
  143696. }, scene?: Nullable<Scene>): Mesh;
  143697. /**
  143698. * Creates a ground mesh from a height map
  143699. * * The parameter `url` sets the URL of the height map image resource.
  143700. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  143701. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  143702. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  143703. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  143704. * * 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.
  143705. * * 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).
  143706. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  143707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  143708. * @param name defines the name of the mesh
  143709. * @param url defines the url to the height map
  143710. * @param options defines the options used to create the mesh
  143711. * @param scene defines the hosting scene
  143712. * @returns the ground mesh
  143713. * @see https://doc.babylonjs.com/babylon101/height_map
  143714. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  143715. */
  143716. static CreateGroundFromHeightMap(name: string, url: string, options: {
  143717. width?: number;
  143718. height?: number;
  143719. subdivisions?: number;
  143720. minHeight?: number;
  143721. maxHeight?: number;
  143722. colorFilter?: Color3;
  143723. alphaFilter?: number;
  143724. updatable?: boolean;
  143725. onReady?: (mesh: GroundMesh) => void;
  143726. }, scene?: Nullable<Scene>): GroundMesh;
  143727. /**
  143728. * Creates a polygon mesh
  143729. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  143730. * * 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
  143731. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  143732. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143733. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  143734. * * Remember you can only change the shape positions, not their number when updating a polygon
  143735. * @param name defines the name of the mesh
  143736. * @param options defines the options used to create the mesh
  143737. * @param scene defines the hosting scene
  143738. * @param earcutInjection can be used to inject your own earcut reference
  143739. * @returns the polygon mesh
  143740. */
  143741. static CreatePolygon(name: string, options: {
  143742. shape: Vector3[];
  143743. holes?: Vector3[][];
  143744. depth?: number;
  143745. faceUV?: Vector4[];
  143746. faceColors?: Color4[];
  143747. updatable?: boolean;
  143748. sideOrientation?: number;
  143749. frontUVs?: Vector4;
  143750. backUVs?: Vector4;
  143751. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143752. /**
  143753. * Creates an extruded polygon mesh, with depth in the Y direction.
  143754. * * 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)
  143755. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  143756. * @param name defines the name of the mesh
  143757. * @param options defines the options used to create the mesh
  143758. * @param scene defines the hosting scene
  143759. * @param earcutInjection can be used to inject your own earcut reference
  143760. * @returns the polygon mesh
  143761. */
  143762. static ExtrudePolygon(name: string, options: {
  143763. shape: Vector3[];
  143764. holes?: Vector3[][];
  143765. depth?: number;
  143766. faceUV?: Vector4[];
  143767. faceColors?: Color4[];
  143768. updatable?: boolean;
  143769. sideOrientation?: number;
  143770. frontUVs?: Vector4;
  143771. backUVs?: Vector4;
  143772. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  143773. /**
  143774. * Creates a tube mesh.
  143775. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  143776. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  143777. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  143778. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  143779. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  143780. * * 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)
  143781. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  143782. * * 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
  143783. * * 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
  143784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143786. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  143787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143788. * @param name defines the name of the mesh
  143789. * @param options defines the options used to create the mesh
  143790. * @param scene defines the hosting scene
  143791. * @returns the tube mesh
  143792. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  143793. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  143794. */
  143795. static CreateTube(name: string, options: {
  143796. path: Vector3[];
  143797. radius?: number;
  143798. tessellation?: number;
  143799. radiusFunction?: {
  143800. (i: number, distance: number): number;
  143801. };
  143802. cap?: number;
  143803. arc?: number;
  143804. updatable?: boolean;
  143805. sideOrientation?: number;
  143806. frontUVs?: Vector4;
  143807. backUVs?: Vector4;
  143808. instance?: Mesh;
  143809. invertUV?: boolean;
  143810. }, scene?: Nullable<Scene>): Mesh;
  143811. /**
  143812. * Creates a polyhedron mesh
  143813. * * 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
  143814. * * The parameter `size` (positive float, default 1) sets the polygon size
  143815. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  143816. * * 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`
  143817. * * 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
  143818. * * 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)`)
  143819. * * 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
  143820. * * 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
  143821. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  143822. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  143823. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  143824. * @param name defines the name of the mesh
  143825. * @param options defines the options used to create the mesh
  143826. * @param scene defines the hosting scene
  143827. * @returns the polyhedron mesh
  143828. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  143829. */
  143830. static CreatePolyhedron(name: string, options: {
  143831. type?: number;
  143832. size?: number;
  143833. sizeX?: number;
  143834. sizeY?: number;
  143835. sizeZ?: number;
  143836. custom?: any;
  143837. faceUV?: Vector4[];
  143838. faceColors?: Color4[];
  143839. flat?: boolean;
  143840. updatable?: boolean;
  143841. sideOrientation?: number;
  143842. frontUVs?: Vector4;
  143843. backUVs?: Vector4;
  143844. }, scene?: Nullable<Scene>): Mesh;
  143845. /**
  143846. * Creates a decal mesh.
  143847. * 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
  143848. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  143849. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  143850. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  143851. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  143852. * @param name defines the name of the mesh
  143853. * @param sourceMesh defines the mesh where the decal must be applied
  143854. * @param options defines the options used to create the mesh
  143855. * @param scene defines the hosting scene
  143856. * @returns the decal mesh
  143857. * @see https://doc.babylonjs.com/how_to/decals
  143858. */
  143859. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  143860. position?: Vector3;
  143861. normal?: Vector3;
  143862. size?: Vector3;
  143863. angle?: number;
  143864. }): Mesh;
  143865. }
  143866. }
  143867. declare module BABYLON {
  143868. /**
  143869. * A simplifier interface for future simplification implementations
  143870. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143871. */
  143872. export interface ISimplifier {
  143873. /**
  143874. * Simplification of a given mesh according to the given settings.
  143875. * Since this requires computation, it is assumed that the function runs async.
  143876. * @param settings The settings of the simplification, including quality and distance
  143877. * @param successCallback A callback that will be called after the mesh was simplified.
  143878. * @param errorCallback in case of an error, this callback will be called. optional.
  143879. */
  143880. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  143881. }
  143882. /**
  143883. * Expected simplification settings.
  143884. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  143885. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143886. */
  143887. export interface ISimplificationSettings {
  143888. /**
  143889. * Gets or sets the expected quality
  143890. */
  143891. quality: number;
  143892. /**
  143893. * Gets or sets the distance when this optimized version should be used
  143894. */
  143895. distance: number;
  143896. /**
  143897. * Gets an already optimized mesh
  143898. */
  143899. optimizeMesh?: boolean;
  143900. }
  143901. /**
  143902. * Class used to specify simplification options
  143903. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143904. */
  143905. export class SimplificationSettings implements ISimplificationSettings {
  143906. /** expected quality */
  143907. quality: number;
  143908. /** distance when this optimized version should be used */
  143909. distance: number;
  143910. /** already optimized mesh */
  143911. optimizeMesh?: boolean | undefined;
  143912. /**
  143913. * Creates a SimplificationSettings
  143914. * @param quality expected quality
  143915. * @param distance distance when this optimized version should be used
  143916. * @param optimizeMesh already optimized mesh
  143917. */
  143918. constructor(
  143919. /** expected quality */
  143920. quality: number,
  143921. /** distance when this optimized version should be used */
  143922. distance: number,
  143923. /** already optimized mesh */
  143924. optimizeMesh?: boolean | undefined);
  143925. }
  143926. /**
  143927. * Interface used to define a simplification task
  143928. */
  143929. export interface ISimplificationTask {
  143930. /**
  143931. * Array of settings
  143932. */
  143933. settings: Array<ISimplificationSettings>;
  143934. /**
  143935. * Simplification type
  143936. */
  143937. simplificationType: SimplificationType;
  143938. /**
  143939. * Mesh to simplify
  143940. */
  143941. mesh: Mesh;
  143942. /**
  143943. * Callback called on success
  143944. */
  143945. successCallback?: () => void;
  143946. /**
  143947. * Defines if parallel processing can be used
  143948. */
  143949. parallelProcessing: boolean;
  143950. }
  143951. /**
  143952. * Queue used to order the simplification tasks
  143953. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143954. */
  143955. export class SimplificationQueue {
  143956. private _simplificationArray;
  143957. /**
  143958. * Gets a boolean indicating that the process is still running
  143959. */
  143960. running: boolean;
  143961. /**
  143962. * Creates a new queue
  143963. */
  143964. constructor();
  143965. /**
  143966. * Adds a new simplification task
  143967. * @param task defines a task to add
  143968. */
  143969. addTask(task: ISimplificationTask): void;
  143970. /**
  143971. * Execute next task
  143972. */
  143973. executeNext(): void;
  143974. /**
  143975. * Execute a simplification task
  143976. * @param task defines the task to run
  143977. */
  143978. runSimplification(task: ISimplificationTask): void;
  143979. private getSimplifier;
  143980. }
  143981. /**
  143982. * The implemented types of simplification
  143983. * At the moment only Quadratic Error Decimation is implemented
  143984. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143985. */
  143986. export enum SimplificationType {
  143987. /** Quadratic error decimation */
  143988. QUADRATIC = 0
  143989. }
  143990. /**
  143991. * An implementation of the Quadratic Error simplification algorithm.
  143992. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  143993. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  143994. * @author RaananW
  143995. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  143996. */
  143997. export class QuadraticErrorSimplification implements ISimplifier {
  143998. private _mesh;
  143999. private triangles;
  144000. private vertices;
  144001. private references;
  144002. private _reconstructedMesh;
  144003. /** Gets or sets the number pf sync interations */
  144004. syncIterations: number;
  144005. /** Gets or sets the aggressiveness of the simplifier */
  144006. aggressiveness: number;
  144007. /** Gets or sets the number of allowed iterations for decimation */
  144008. decimationIterations: number;
  144009. /** Gets or sets the espilon to use for bounding box computation */
  144010. boundingBoxEpsilon: number;
  144011. /**
  144012. * Creates a new QuadraticErrorSimplification
  144013. * @param _mesh defines the target mesh
  144014. */
  144015. constructor(_mesh: Mesh);
  144016. /**
  144017. * Simplification of a given mesh according to the given settings.
  144018. * Since this requires computation, it is assumed that the function runs async.
  144019. * @param settings The settings of the simplification, including quality and distance
  144020. * @param successCallback A callback that will be called after the mesh was simplified.
  144021. */
  144022. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  144023. private runDecimation;
  144024. private initWithMesh;
  144025. private init;
  144026. private reconstructMesh;
  144027. private initDecimatedMesh;
  144028. private isFlipped;
  144029. private updateTriangles;
  144030. private identifyBorder;
  144031. private updateMesh;
  144032. private vertexError;
  144033. private calculateError;
  144034. }
  144035. }
  144036. declare module BABYLON {
  144037. interface Scene {
  144038. /** @hidden (Backing field) */
  144039. _simplificationQueue: SimplificationQueue;
  144040. /**
  144041. * Gets or sets the simplification queue attached to the scene
  144042. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  144043. */
  144044. simplificationQueue: SimplificationQueue;
  144045. }
  144046. interface Mesh {
  144047. /**
  144048. * Simplify the mesh according to the given array of settings.
  144049. * Function will return immediately and will simplify async
  144050. * @param settings a collection of simplification settings
  144051. * @param parallelProcessing should all levels calculate parallel or one after the other
  144052. * @param simplificationType the type of simplification to run
  144053. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  144054. * @returns the current mesh
  144055. */
  144056. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  144057. }
  144058. /**
  144059. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  144060. * created in a scene
  144061. */
  144062. export class SimplicationQueueSceneComponent implements ISceneComponent {
  144063. /**
  144064. * The component name helpfull to identify the component in the list of scene components.
  144065. */
  144066. readonly name: string;
  144067. /**
  144068. * The scene the component belongs to.
  144069. */
  144070. scene: Scene;
  144071. /**
  144072. * Creates a new instance of the component for the given scene
  144073. * @param scene Defines the scene to register the component in
  144074. */
  144075. constructor(scene: Scene);
  144076. /**
  144077. * Registers the component in a given scene
  144078. */
  144079. register(): void;
  144080. /**
  144081. * Rebuilds the elements related to this component in case of
  144082. * context lost for instance.
  144083. */
  144084. rebuild(): void;
  144085. /**
  144086. * Disposes the component and the associated ressources
  144087. */
  144088. dispose(): void;
  144089. private _beforeCameraUpdate;
  144090. }
  144091. }
  144092. declare module BABYLON {
  144093. interface Mesh {
  144094. /**
  144095. * Creates a new thin instance
  144096. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  144097. * @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
  144098. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  144099. */
  144100. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  144101. /**
  144102. * Adds the transformation (matrix) of the current mesh as a thin instance
  144103. * @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
  144104. * @returns the thin instance index number
  144105. */
  144106. thinInstanceAddSelf(refresh: boolean): number;
  144107. /**
  144108. * Registers a custom attribute to be used with thin instances
  144109. * @param kind name of the attribute
  144110. * @param stride size in floats of the attribute
  144111. */
  144112. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  144113. /**
  144114. * Sets the matrix of a thin instance
  144115. * @param index index of the thin instance
  144116. * @param matrix matrix to set
  144117. * @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
  144118. */
  144119. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  144120. /**
  144121. * Sets the value of a custom attribute for a thin instance
  144122. * @param kind name of the attribute
  144123. * @param index index of the thin instance
  144124. * @param value value to set
  144125. * @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
  144126. */
  144127. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  144128. /**
  144129. * 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.
  144130. */
  144131. thinInstanceCount: number;
  144132. /**
  144133. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  144134. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  144135. * @param buffer buffer to set
  144136. * @param stride size in floats of each value of the buffer
  144137. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  144138. */
  144139. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  144140. /**
  144141. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  144142. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  144143. */
  144144. thinInstanceBufferUpdated(kind: string): void;
  144145. /**
  144146. * Refreshes the bounding info, taking into account all the thin instances defined
  144147. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  144148. */
  144149. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  144150. /** @hidden */
  144151. _thinInstanceInitializeUserStorage(): void;
  144152. /** @hidden */
  144153. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  144154. /** @hidden */
  144155. _userThinInstanceBuffersStorage: {
  144156. data: {
  144157. [key: string]: Float32Array;
  144158. };
  144159. sizes: {
  144160. [key: string]: number;
  144161. };
  144162. vertexBuffers: {
  144163. [key: string]: Nullable<VertexBuffer>;
  144164. };
  144165. strides: {
  144166. [key: string]: number;
  144167. };
  144168. };
  144169. }
  144170. }
  144171. declare module BABYLON {
  144172. /**
  144173. * Navigation plugin interface to add navigation constrained by a navigation mesh
  144174. */
  144175. export interface INavigationEnginePlugin {
  144176. /**
  144177. * plugin name
  144178. */
  144179. name: string;
  144180. /**
  144181. * Creates a navigation mesh
  144182. * @param meshes array of all the geometry used to compute the navigatio mesh
  144183. * @param parameters bunch of parameters used to filter geometry
  144184. */
  144185. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144186. /**
  144187. * Create a navigation mesh debug mesh
  144188. * @param scene is where the mesh will be added
  144189. * @returns debug display mesh
  144190. */
  144191. createDebugNavMesh(scene: Scene): Mesh;
  144192. /**
  144193. * Get a navigation mesh constrained position, closest to the parameter position
  144194. * @param position world position
  144195. * @returns the closest point to position constrained by the navigation mesh
  144196. */
  144197. getClosestPoint(position: Vector3): Vector3;
  144198. /**
  144199. * Get a navigation mesh constrained position, closest to the parameter position
  144200. * @param position world position
  144201. * @param result output the closest point to position constrained by the navigation mesh
  144202. */
  144203. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144204. /**
  144205. * Get a navigation mesh constrained position, within a particular radius
  144206. * @param position world position
  144207. * @param maxRadius the maximum distance to the constrained world position
  144208. * @returns the closest point to position constrained by the navigation mesh
  144209. */
  144210. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144211. /**
  144212. * Get a navigation mesh constrained position, within a particular radius
  144213. * @param position world position
  144214. * @param maxRadius the maximum distance to the constrained world position
  144215. * @param result output the closest point to position constrained by the navigation mesh
  144216. */
  144217. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144218. /**
  144219. * Compute the final position from a segment made of destination-position
  144220. * @param position world position
  144221. * @param destination world position
  144222. * @returns the resulting point along the navmesh
  144223. */
  144224. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144225. /**
  144226. * Compute the final position from a segment made of destination-position
  144227. * @param position world position
  144228. * @param destination world position
  144229. * @param result output the resulting point along the navmesh
  144230. */
  144231. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144232. /**
  144233. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144234. * @param start world position
  144235. * @param end world position
  144236. * @returns array containing world position composing the path
  144237. */
  144238. computePath(start: Vector3, end: Vector3): Vector3[];
  144239. /**
  144240. * If this plugin is supported
  144241. * @returns true if plugin is supported
  144242. */
  144243. isSupported(): boolean;
  144244. /**
  144245. * Create a new Crowd so you can add agents
  144246. * @param maxAgents the maximum agent count in the crowd
  144247. * @param maxAgentRadius the maximum radius an agent can have
  144248. * @param scene to attach the crowd to
  144249. * @returns the crowd you can add agents to
  144250. */
  144251. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144252. /**
  144253. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144254. * The queries will try to find a solution within those bounds
  144255. * default is (1,1,1)
  144256. * @param extent x,y,z value that define the extent around the queries point of reference
  144257. */
  144258. setDefaultQueryExtent(extent: Vector3): void;
  144259. /**
  144260. * Get the Bounding box extent specified by setDefaultQueryExtent
  144261. * @returns the box extent values
  144262. */
  144263. getDefaultQueryExtent(): Vector3;
  144264. /**
  144265. * build the navmesh from a previously saved state using getNavmeshData
  144266. * @param data the Uint8Array returned by getNavmeshData
  144267. */
  144268. buildFromNavmeshData(data: Uint8Array): void;
  144269. /**
  144270. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144271. * @returns data the Uint8Array that can be saved and reused
  144272. */
  144273. getNavmeshData(): Uint8Array;
  144274. /**
  144275. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144276. * @param result output the box extent values
  144277. */
  144278. getDefaultQueryExtentToRef(result: Vector3): void;
  144279. /**
  144280. * Release all resources
  144281. */
  144282. dispose(): void;
  144283. }
  144284. /**
  144285. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  144286. */
  144287. export interface ICrowd {
  144288. /**
  144289. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144290. * You can attach anything to that node. The node position is updated in the scene update tick.
  144291. * @param pos world position that will be constrained by the navigation mesh
  144292. * @param parameters agent parameters
  144293. * @param transform hooked to the agent that will be update by the scene
  144294. * @returns agent index
  144295. */
  144296. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144297. /**
  144298. * Returns the agent position in world space
  144299. * @param index agent index returned by addAgent
  144300. * @returns world space position
  144301. */
  144302. getAgentPosition(index: number): Vector3;
  144303. /**
  144304. * Gets the agent position result in world space
  144305. * @param index agent index returned by addAgent
  144306. * @param result output world space position
  144307. */
  144308. getAgentPositionToRef(index: number, result: Vector3): void;
  144309. /**
  144310. * Gets the agent velocity in world space
  144311. * @param index agent index returned by addAgent
  144312. * @returns world space velocity
  144313. */
  144314. getAgentVelocity(index: number): Vector3;
  144315. /**
  144316. * Gets the agent velocity result in world space
  144317. * @param index agent index returned by addAgent
  144318. * @param result output world space velocity
  144319. */
  144320. getAgentVelocityToRef(index: number, result: Vector3): void;
  144321. /**
  144322. * remove a particular agent previously created
  144323. * @param index agent index returned by addAgent
  144324. */
  144325. removeAgent(index: number): void;
  144326. /**
  144327. * get the list of all agents attached to this crowd
  144328. * @returns list of agent indices
  144329. */
  144330. getAgents(): number[];
  144331. /**
  144332. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144333. * @param deltaTime in seconds
  144334. */
  144335. update(deltaTime: number): void;
  144336. /**
  144337. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144338. * @param index agent index returned by addAgent
  144339. * @param destination targeted world position
  144340. */
  144341. agentGoto(index: number, destination: Vector3): void;
  144342. /**
  144343. * Teleport the agent to a new position
  144344. * @param index agent index returned by addAgent
  144345. * @param destination targeted world position
  144346. */
  144347. agentTeleport(index: number, destination: Vector3): void;
  144348. /**
  144349. * Update agent parameters
  144350. * @param index agent index returned by addAgent
  144351. * @param parameters agent parameters
  144352. */
  144353. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144354. /**
  144355. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144356. * The queries will try to find a solution within those bounds
  144357. * default is (1,1,1)
  144358. * @param extent x,y,z value that define the extent around the queries point of reference
  144359. */
  144360. setDefaultQueryExtent(extent: Vector3): void;
  144361. /**
  144362. * Get the Bounding box extent specified by setDefaultQueryExtent
  144363. * @returns the box extent values
  144364. */
  144365. getDefaultQueryExtent(): Vector3;
  144366. /**
  144367. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144368. * @param result output the box extent values
  144369. */
  144370. getDefaultQueryExtentToRef(result: Vector3): void;
  144371. /**
  144372. * Release all resources
  144373. */
  144374. dispose(): void;
  144375. }
  144376. /**
  144377. * Configures an agent
  144378. */
  144379. export interface IAgentParameters {
  144380. /**
  144381. * Agent radius. [Limit: >= 0]
  144382. */
  144383. radius: number;
  144384. /**
  144385. * Agent height. [Limit: > 0]
  144386. */
  144387. height: number;
  144388. /**
  144389. * Maximum allowed acceleration. [Limit: >= 0]
  144390. */
  144391. maxAcceleration: number;
  144392. /**
  144393. * Maximum allowed speed. [Limit: >= 0]
  144394. */
  144395. maxSpeed: number;
  144396. /**
  144397. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  144398. */
  144399. collisionQueryRange: number;
  144400. /**
  144401. * The path visibility optimization range. [Limit: > 0]
  144402. */
  144403. pathOptimizationRange: number;
  144404. /**
  144405. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  144406. */
  144407. separationWeight: number;
  144408. }
  144409. /**
  144410. * Configures the navigation mesh creation
  144411. */
  144412. export interface INavMeshParameters {
  144413. /**
  144414. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  144415. */
  144416. cs: number;
  144417. /**
  144418. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  144419. */
  144420. ch: number;
  144421. /**
  144422. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  144423. */
  144424. walkableSlopeAngle: number;
  144425. /**
  144426. * Minimum floor to 'ceiling' height that will still allow the floor area to
  144427. * be considered walkable. [Limit: >= 3] [Units: vx]
  144428. */
  144429. walkableHeight: number;
  144430. /**
  144431. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  144432. */
  144433. walkableClimb: number;
  144434. /**
  144435. * The distance to erode/shrink the walkable area of the heightfield away from
  144436. * obstructions. [Limit: >=0] [Units: vx]
  144437. */
  144438. walkableRadius: number;
  144439. /**
  144440. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  144441. */
  144442. maxEdgeLen: number;
  144443. /**
  144444. * The maximum distance a simplfied contour's border edges should deviate
  144445. * the original raw contour. [Limit: >=0] [Units: vx]
  144446. */
  144447. maxSimplificationError: number;
  144448. /**
  144449. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  144450. */
  144451. minRegionArea: number;
  144452. /**
  144453. * Any regions with a span count smaller than this value will, if possible,
  144454. * be merged with larger regions. [Limit: >=0] [Units: vx]
  144455. */
  144456. mergeRegionArea: number;
  144457. /**
  144458. * The maximum number of vertices allowed for polygons generated during the
  144459. * contour to polygon conversion process. [Limit: >= 3]
  144460. */
  144461. maxVertsPerPoly: number;
  144462. /**
  144463. * Sets the sampling distance to use when generating the detail mesh.
  144464. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  144465. */
  144466. detailSampleDist: number;
  144467. /**
  144468. * The maximum distance the detail mesh surface should deviate from heightfield
  144469. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  144470. */
  144471. detailSampleMaxError: number;
  144472. }
  144473. }
  144474. declare module BABYLON {
  144475. /**
  144476. * RecastJS navigation plugin
  144477. */
  144478. export class RecastJSPlugin implements INavigationEnginePlugin {
  144479. /**
  144480. * Reference to the Recast library
  144481. */
  144482. bjsRECAST: any;
  144483. /**
  144484. * plugin name
  144485. */
  144486. name: string;
  144487. /**
  144488. * the first navmesh created. We might extend this to support multiple navmeshes
  144489. */
  144490. navMesh: any;
  144491. /**
  144492. * Initializes the recastJS plugin
  144493. * @param recastInjection can be used to inject your own recast reference
  144494. */
  144495. constructor(recastInjection?: any);
  144496. /**
  144497. * Creates a navigation mesh
  144498. * @param meshes array of all the geometry used to compute the navigatio mesh
  144499. * @param parameters bunch of parameters used to filter geometry
  144500. */
  144501. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  144502. /**
  144503. * Create a navigation mesh debug mesh
  144504. * @param scene is where the mesh will be added
  144505. * @returns debug display mesh
  144506. */
  144507. createDebugNavMesh(scene: Scene): Mesh;
  144508. /**
  144509. * Get a navigation mesh constrained position, closest to the parameter position
  144510. * @param position world position
  144511. * @returns the closest point to position constrained by the navigation mesh
  144512. */
  144513. getClosestPoint(position: Vector3): Vector3;
  144514. /**
  144515. * Get a navigation mesh constrained position, closest to the parameter position
  144516. * @param position world position
  144517. * @param result output the closest point to position constrained by the navigation mesh
  144518. */
  144519. getClosestPointToRef(position: Vector3, result: Vector3): void;
  144520. /**
  144521. * Get a navigation mesh constrained position, within a particular radius
  144522. * @param position world position
  144523. * @param maxRadius the maximum distance to the constrained world position
  144524. * @returns the closest point to position constrained by the navigation mesh
  144525. */
  144526. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  144527. /**
  144528. * Get a navigation mesh constrained position, within a particular radius
  144529. * @param position world position
  144530. * @param maxRadius the maximum distance to the constrained world position
  144531. * @param result output the closest point to position constrained by the navigation mesh
  144532. */
  144533. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  144534. /**
  144535. * Compute the final position from a segment made of destination-position
  144536. * @param position world position
  144537. * @param destination world position
  144538. * @returns the resulting point along the navmesh
  144539. */
  144540. moveAlong(position: Vector3, destination: Vector3): Vector3;
  144541. /**
  144542. * Compute the final position from a segment made of destination-position
  144543. * @param position world position
  144544. * @param destination world position
  144545. * @param result output the resulting point along the navmesh
  144546. */
  144547. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  144548. /**
  144549. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  144550. * @param start world position
  144551. * @param end world position
  144552. * @returns array containing world position composing the path
  144553. */
  144554. computePath(start: Vector3, end: Vector3): Vector3[];
  144555. /**
  144556. * Create a new Crowd so you can add agents
  144557. * @param maxAgents the maximum agent count in the crowd
  144558. * @param maxAgentRadius the maximum radius an agent can have
  144559. * @param scene to attach the crowd to
  144560. * @returns the crowd you can add agents to
  144561. */
  144562. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  144563. /**
  144564. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144565. * The queries will try to find a solution within those bounds
  144566. * default is (1,1,1)
  144567. * @param extent x,y,z value that define the extent around the queries point of reference
  144568. */
  144569. setDefaultQueryExtent(extent: Vector3): void;
  144570. /**
  144571. * Get the Bounding box extent specified by setDefaultQueryExtent
  144572. * @returns the box extent values
  144573. */
  144574. getDefaultQueryExtent(): Vector3;
  144575. /**
  144576. * build the navmesh from a previously saved state using getNavmeshData
  144577. * @param data the Uint8Array returned by getNavmeshData
  144578. */
  144579. buildFromNavmeshData(data: Uint8Array): void;
  144580. /**
  144581. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  144582. * @returns data the Uint8Array that can be saved and reused
  144583. */
  144584. getNavmeshData(): Uint8Array;
  144585. /**
  144586. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144587. * @param result output the box extent values
  144588. */
  144589. getDefaultQueryExtentToRef(result: Vector3): void;
  144590. /**
  144591. * Disposes
  144592. */
  144593. dispose(): void;
  144594. /**
  144595. * If this plugin is supported
  144596. * @returns true if plugin is supported
  144597. */
  144598. isSupported(): boolean;
  144599. }
  144600. /**
  144601. * Recast detour crowd implementation
  144602. */
  144603. export class RecastJSCrowd implements ICrowd {
  144604. /**
  144605. * Recast/detour plugin
  144606. */
  144607. bjsRECASTPlugin: RecastJSPlugin;
  144608. /**
  144609. * Link to the detour crowd
  144610. */
  144611. recastCrowd: any;
  144612. /**
  144613. * One transform per agent
  144614. */
  144615. transforms: TransformNode[];
  144616. /**
  144617. * All agents created
  144618. */
  144619. agents: number[];
  144620. /**
  144621. * Link to the scene is kept to unregister the crowd from the scene
  144622. */
  144623. private _scene;
  144624. /**
  144625. * Observer for crowd updates
  144626. */
  144627. private _onBeforeAnimationsObserver;
  144628. /**
  144629. * Constructor
  144630. * @param plugin recastJS plugin
  144631. * @param maxAgents the maximum agent count in the crowd
  144632. * @param maxAgentRadius the maximum radius an agent can have
  144633. * @param scene to attach the crowd to
  144634. * @returns the crowd you can add agents to
  144635. */
  144636. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  144637. /**
  144638. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  144639. * You can attach anything to that node. The node position is updated in the scene update tick.
  144640. * @param pos world position that will be constrained by the navigation mesh
  144641. * @param parameters agent parameters
  144642. * @param transform hooked to the agent that will be update by the scene
  144643. * @returns agent index
  144644. */
  144645. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  144646. /**
  144647. * Returns the agent position in world space
  144648. * @param index agent index returned by addAgent
  144649. * @returns world space position
  144650. */
  144651. getAgentPosition(index: number): Vector3;
  144652. /**
  144653. * Returns the agent position result in world space
  144654. * @param index agent index returned by addAgent
  144655. * @param result output world space position
  144656. */
  144657. getAgentPositionToRef(index: number, result: Vector3): void;
  144658. /**
  144659. * Returns the agent velocity in world space
  144660. * @param index agent index returned by addAgent
  144661. * @returns world space velocity
  144662. */
  144663. getAgentVelocity(index: number): Vector3;
  144664. /**
  144665. * Returns the agent velocity result in world space
  144666. * @param index agent index returned by addAgent
  144667. * @param result output world space velocity
  144668. */
  144669. getAgentVelocityToRef(index: number, result: Vector3): void;
  144670. /**
  144671. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  144672. * @param index agent index returned by addAgent
  144673. * @param destination targeted world position
  144674. */
  144675. agentGoto(index: number, destination: Vector3): void;
  144676. /**
  144677. * Teleport the agent to a new position
  144678. * @param index agent index returned by addAgent
  144679. * @param destination targeted world position
  144680. */
  144681. agentTeleport(index: number, destination: Vector3): void;
  144682. /**
  144683. * Update agent parameters
  144684. * @param index agent index returned by addAgent
  144685. * @param parameters agent parameters
  144686. */
  144687. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  144688. /**
  144689. * remove a particular agent previously created
  144690. * @param index agent index returned by addAgent
  144691. */
  144692. removeAgent(index: number): void;
  144693. /**
  144694. * get the list of all agents attached to this crowd
  144695. * @returns list of agent indices
  144696. */
  144697. getAgents(): number[];
  144698. /**
  144699. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  144700. * @param deltaTime in seconds
  144701. */
  144702. update(deltaTime: number): void;
  144703. /**
  144704. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  144705. * The queries will try to find a solution within those bounds
  144706. * default is (1,1,1)
  144707. * @param extent x,y,z value that define the extent around the queries point of reference
  144708. */
  144709. setDefaultQueryExtent(extent: Vector3): void;
  144710. /**
  144711. * Get the Bounding box extent specified by setDefaultQueryExtent
  144712. * @returns the box extent values
  144713. */
  144714. getDefaultQueryExtent(): Vector3;
  144715. /**
  144716. * Get the Bounding box extent result specified by setDefaultQueryExtent
  144717. * @param result output the box extent values
  144718. */
  144719. getDefaultQueryExtentToRef(result: Vector3): void;
  144720. /**
  144721. * Release all resources
  144722. */
  144723. dispose(): void;
  144724. }
  144725. }
  144726. declare module BABYLON {
  144727. /**
  144728. * Class used to enable access to IndexedDB
  144729. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  144730. */
  144731. export class Database implements IOfflineProvider {
  144732. private _callbackManifestChecked;
  144733. private _currentSceneUrl;
  144734. private _db;
  144735. private _enableSceneOffline;
  144736. private _enableTexturesOffline;
  144737. private _manifestVersionFound;
  144738. private _mustUpdateRessources;
  144739. private _hasReachedQuota;
  144740. private _isSupported;
  144741. private _idbFactory;
  144742. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  144743. private static IsUASupportingBlobStorage;
  144744. /**
  144745. * Gets a boolean indicating if Database storate is enabled (off by default)
  144746. */
  144747. static IDBStorageEnabled: boolean;
  144748. /**
  144749. * Gets a boolean indicating if scene must be saved in the database
  144750. */
  144751. get enableSceneOffline(): boolean;
  144752. /**
  144753. * Gets a boolean indicating if textures must be saved in the database
  144754. */
  144755. get enableTexturesOffline(): boolean;
  144756. /**
  144757. * Creates a new Database
  144758. * @param urlToScene defines the url to load the scene
  144759. * @param callbackManifestChecked defines the callback to use when manifest is checked
  144760. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  144761. */
  144762. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  144763. private static _ParseURL;
  144764. private static _ReturnFullUrlLocation;
  144765. private _checkManifestFile;
  144766. /**
  144767. * Open the database and make it available
  144768. * @param successCallback defines the callback to call on success
  144769. * @param errorCallback defines the callback to call on error
  144770. */
  144771. open(successCallback: () => void, errorCallback: () => void): void;
  144772. /**
  144773. * Loads an image from the database
  144774. * @param url defines the url to load from
  144775. * @param image defines the target DOM image
  144776. */
  144777. loadImage(url: string, image: HTMLImageElement): void;
  144778. private _loadImageFromDBAsync;
  144779. private _saveImageIntoDBAsync;
  144780. private _checkVersionFromDB;
  144781. private _loadVersionFromDBAsync;
  144782. private _saveVersionIntoDBAsync;
  144783. /**
  144784. * Loads a file from database
  144785. * @param url defines the URL to load from
  144786. * @param sceneLoaded defines a callback to call on success
  144787. * @param progressCallBack defines a callback to call when progress changed
  144788. * @param errorCallback defines a callback to call on error
  144789. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  144790. */
  144791. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  144792. private _loadFileAsync;
  144793. private _saveFileAsync;
  144794. /**
  144795. * Validates if xhr data is correct
  144796. * @param xhr defines the request to validate
  144797. * @param dataType defines the expected data type
  144798. * @returns true if data is correct
  144799. */
  144800. private static _ValidateXHRData;
  144801. }
  144802. }
  144803. declare module BABYLON {
  144804. /** @hidden */
  144805. export var gpuUpdateParticlesPixelShader: {
  144806. name: string;
  144807. shader: string;
  144808. };
  144809. }
  144810. declare module BABYLON {
  144811. /** @hidden */
  144812. export var gpuUpdateParticlesVertexShader: {
  144813. name: string;
  144814. shader: string;
  144815. };
  144816. }
  144817. declare module BABYLON {
  144818. /** @hidden */
  144819. export var clipPlaneFragmentDeclaration2: {
  144820. name: string;
  144821. shader: string;
  144822. };
  144823. }
  144824. declare module BABYLON {
  144825. /** @hidden */
  144826. export var gpuRenderParticlesPixelShader: {
  144827. name: string;
  144828. shader: string;
  144829. };
  144830. }
  144831. declare module BABYLON {
  144832. /** @hidden */
  144833. export var clipPlaneVertexDeclaration2: {
  144834. name: string;
  144835. shader: string;
  144836. };
  144837. }
  144838. declare module BABYLON {
  144839. /** @hidden */
  144840. export var gpuRenderParticlesVertexShader: {
  144841. name: string;
  144842. shader: string;
  144843. };
  144844. }
  144845. declare module BABYLON {
  144846. /**
  144847. * This represents a GPU particle system in Babylon
  144848. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  144849. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  144850. */
  144851. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  144852. /**
  144853. * The layer mask we are rendering the particles through.
  144854. */
  144855. layerMask: number;
  144856. private _capacity;
  144857. private _activeCount;
  144858. private _currentActiveCount;
  144859. private _accumulatedCount;
  144860. private _renderEffect;
  144861. private _updateEffect;
  144862. private _buffer0;
  144863. private _buffer1;
  144864. private _spriteBuffer;
  144865. private _updateVAO;
  144866. private _renderVAO;
  144867. private _targetIndex;
  144868. private _sourceBuffer;
  144869. private _targetBuffer;
  144870. private _engine;
  144871. private _currentRenderId;
  144872. private _started;
  144873. private _stopped;
  144874. private _timeDelta;
  144875. private _randomTexture;
  144876. private _randomTexture2;
  144877. private _attributesStrideSize;
  144878. private _updateEffectOptions;
  144879. private _randomTextureSize;
  144880. private _actualFrame;
  144881. private _customEffect;
  144882. private readonly _rawTextureWidth;
  144883. /**
  144884. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  144885. */
  144886. static get IsSupported(): boolean;
  144887. /**
  144888. * An event triggered when the system is disposed.
  144889. */
  144890. onDisposeObservable: Observable<IParticleSystem>;
  144891. /**
  144892. * Gets the maximum number of particles active at the same time.
  144893. * @returns The max number of active particles.
  144894. */
  144895. getCapacity(): number;
  144896. /**
  144897. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  144898. * to override the particles.
  144899. */
  144900. forceDepthWrite: boolean;
  144901. /**
  144902. * Gets or set the number of active particles
  144903. */
  144904. get activeParticleCount(): number;
  144905. set activeParticleCount(value: number);
  144906. private _preWarmDone;
  144907. /**
  144908. * Specifies if the particles are updated in emitter local space or world space.
  144909. */
  144910. isLocal: boolean;
  144911. /**
  144912. * Is this system ready to be used/rendered
  144913. * @return true if the system is ready
  144914. */
  144915. isReady(): boolean;
  144916. /**
  144917. * Gets if the system has been started. (Note: this will still be true after stop is called)
  144918. * @returns True if it has been started, otherwise false.
  144919. */
  144920. isStarted(): boolean;
  144921. /**
  144922. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  144923. * @returns True if it has been stopped, otherwise false.
  144924. */
  144925. isStopped(): boolean;
  144926. /**
  144927. * Gets a boolean indicating that the system is stopping
  144928. * @returns true if the system is currently stopping
  144929. */
  144930. isStopping(): boolean;
  144931. /**
  144932. * Gets the number of particles active at the same time.
  144933. * @returns The number of active particles.
  144934. */
  144935. getActiveCount(): number;
  144936. /**
  144937. * Starts the particle system and begins to emit
  144938. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  144939. */
  144940. start(delay?: number): void;
  144941. /**
  144942. * Stops the particle system.
  144943. */
  144944. stop(): void;
  144945. /**
  144946. * Remove all active particles
  144947. */
  144948. reset(): void;
  144949. /**
  144950. * Returns the string "GPUParticleSystem"
  144951. * @returns a string containing the class name
  144952. */
  144953. getClassName(): string;
  144954. /**
  144955. * Gets the custom effect used to render the particles
  144956. * @param blendMode Blend mode for which the effect should be retrieved
  144957. * @returns The effect
  144958. */
  144959. getCustomEffect(blendMode?: number): Nullable<Effect>;
  144960. /**
  144961. * Sets the custom effect used to render the particles
  144962. * @param effect The effect to set
  144963. * @param blendMode Blend mode for which the effect should be set
  144964. */
  144965. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  144966. /** @hidden */
  144967. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  144968. /**
  144969. * Observable that will be called just before the particles are drawn
  144970. */
  144971. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  144972. /**
  144973. * Gets the name of the particle vertex shader
  144974. */
  144975. get vertexShaderName(): string;
  144976. private _colorGradientsTexture;
  144977. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  144978. /**
  144979. * Adds a new color gradient
  144980. * @param gradient defines the gradient to use (between 0 and 1)
  144981. * @param color1 defines the color to affect to the specified gradient
  144982. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  144983. * @returns the current particle system
  144984. */
  144985. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  144986. private _refreshColorGradient;
  144987. /** Force the system to rebuild all gradients that need to be resync */
  144988. forceRefreshGradients(): void;
  144989. /**
  144990. * Remove a specific color gradient
  144991. * @param gradient defines the gradient to remove
  144992. * @returns the current particle system
  144993. */
  144994. removeColorGradient(gradient: number): GPUParticleSystem;
  144995. private _angularSpeedGradientsTexture;
  144996. private _sizeGradientsTexture;
  144997. private _velocityGradientsTexture;
  144998. private _limitVelocityGradientsTexture;
  144999. private _dragGradientsTexture;
  145000. private _addFactorGradient;
  145001. /**
  145002. * Adds a new size gradient
  145003. * @param gradient defines the gradient to use (between 0 and 1)
  145004. * @param factor defines the size factor to affect to the specified gradient
  145005. * @returns the current particle system
  145006. */
  145007. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  145008. /**
  145009. * Remove a specific size gradient
  145010. * @param gradient defines the gradient to remove
  145011. * @returns the current particle system
  145012. */
  145013. removeSizeGradient(gradient: number): GPUParticleSystem;
  145014. private _refreshFactorGradient;
  145015. /**
  145016. * Adds a new angular speed gradient
  145017. * @param gradient defines the gradient to use (between 0 and 1)
  145018. * @param factor defines the angular speed to affect to the specified gradient
  145019. * @returns the current particle system
  145020. */
  145021. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  145022. /**
  145023. * Remove a specific angular speed gradient
  145024. * @param gradient defines the gradient to remove
  145025. * @returns the current particle system
  145026. */
  145027. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  145028. /**
  145029. * Adds a new velocity gradient
  145030. * @param gradient defines the gradient to use (between 0 and 1)
  145031. * @param factor defines the velocity to affect to the specified gradient
  145032. * @returns the current particle system
  145033. */
  145034. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145035. /**
  145036. * Remove a specific velocity gradient
  145037. * @param gradient defines the gradient to remove
  145038. * @returns the current particle system
  145039. */
  145040. removeVelocityGradient(gradient: number): GPUParticleSystem;
  145041. /**
  145042. * Adds a new limit velocity gradient
  145043. * @param gradient defines the gradient to use (between 0 and 1)
  145044. * @param factor defines the limit velocity value to affect to the specified gradient
  145045. * @returns the current particle system
  145046. */
  145047. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  145048. /**
  145049. * Remove a specific limit velocity gradient
  145050. * @param gradient defines the gradient to remove
  145051. * @returns the current particle system
  145052. */
  145053. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  145054. /**
  145055. * Adds a new drag gradient
  145056. * @param gradient defines the gradient to use (between 0 and 1)
  145057. * @param factor defines the drag value to affect to the specified gradient
  145058. * @returns the current particle system
  145059. */
  145060. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  145061. /**
  145062. * Remove a specific drag gradient
  145063. * @param gradient defines the gradient to remove
  145064. * @returns the current particle system
  145065. */
  145066. removeDragGradient(gradient: number): GPUParticleSystem;
  145067. /**
  145068. * Not supported by GPUParticleSystem
  145069. * @param gradient defines the gradient to use (between 0 and 1)
  145070. * @param factor defines the emit rate value to affect to the specified gradient
  145071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145072. * @returns the current particle system
  145073. */
  145074. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145075. /**
  145076. * Not supported by GPUParticleSystem
  145077. * @param gradient defines the gradient to remove
  145078. * @returns the current particle system
  145079. */
  145080. removeEmitRateGradient(gradient: number): IParticleSystem;
  145081. /**
  145082. * Not supported by GPUParticleSystem
  145083. * @param gradient defines the gradient to use (between 0 and 1)
  145084. * @param factor defines the start size value to affect to the specified gradient
  145085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145086. * @returns the current particle system
  145087. */
  145088. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145089. /**
  145090. * Not supported by GPUParticleSystem
  145091. * @param gradient defines the gradient to remove
  145092. * @returns the current particle system
  145093. */
  145094. removeStartSizeGradient(gradient: number): IParticleSystem;
  145095. /**
  145096. * Not supported by GPUParticleSystem
  145097. * @param gradient defines the gradient to use (between 0 and 1)
  145098. * @param min defines the color remap minimal range
  145099. * @param max defines the color remap maximal range
  145100. * @returns the current particle system
  145101. */
  145102. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145103. /**
  145104. * Not supported by GPUParticleSystem
  145105. * @param gradient defines the gradient to remove
  145106. * @returns the current particle system
  145107. */
  145108. removeColorRemapGradient(): IParticleSystem;
  145109. /**
  145110. * Not supported by GPUParticleSystem
  145111. * @param gradient defines the gradient to use (between 0 and 1)
  145112. * @param min defines the alpha remap minimal range
  145113. * @param max defines the alpha remap maximal range
  145114. * @returns the current particle system
  145115. */
  145116. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  145117. /**
  145118. * Not supported by GPUParticleSystem
  145119. * @param gradient defines the gradient to remove
  145120. * @returns the current particle system
  145121. */
  145122. removeAlphaRemapGradient(): IParticleSystem;
  145123. /**
  145124. * Not supported by GPUParticleSystem
  145125. * @param gradient defines the gradient to use (between 0 and 1)
  145126. * @param color defines the color to affect to the specified gradient
  145127. * @returns the current particle system
  145128. */
  145129. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  145130. /**
  145131. * Not supported by GPUParticleSystem
  145132. * @param gradient defines the gradient to remove
  145133. * @returns the current particle system
  145134. */
  145135. removeRampGradient(): IParticleSystem;
  145136. /**
  145137. * Not supported by GPUParticleSystem
  145138. * @returns the list of ramp gradients
  145139. */
  145140. getRampGradients(): Nullable<Array<Color3Gradient>>;
  145141. /**
  145142. * Not supported by GPUParticleSystem
  145143. * Gets or sets a boolean indicating that ramp gradients must be used
  145144. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  145145. */
  145146. get useRampGradients(): boolean;
  145147. set useRampGradients(value: boolean);
  145148. /**
  145149. * Not supported by GPUParticleSystem
  145150. * @param gradient defines the gradient to use (between 0 and 1)
  145151. * @param factor defines the life time factor to affect to the specified gradient
  145152. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  145153. * @returns the current particle system
  145154. */
  145155. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  145156. /**
  145157. * Not supported by GPUParticleSystem
  145158. * @param gradient defines the gradient to remove
  145159. * @returns the current particle system
  145160. */
  145161. removeLifeTimeGradient(gradient: number): IParticleSystem;
  145162. /**
  145163. * Instantiates a GPU particle system.
  145164. * 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.
  145165. * @param name The name of the particle system
  145166. * @param options The options used to create the system
  145167. * @param scene The scene the particle system belongs to
  145168. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  145169. * @param customEffect a custom effect used to change the way particles are rendered by default
  145170. */
  145171. constructor(name: string, options: Partial<{
  145172. capacity: number;
  145173. randomTextureSize: number;
  145174. }>, scene: Scene, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  145175. protected _reset(): void;
  145176. private _createUpdateVAO;
  145177. private _createRenderVAO;
  145178. private _initialize;
  145179. /** @hidden */
  145180. _recreateUpdateEffect(): void;
  145181. private _getEffect;
  145182. /**
  145183. * Fill the defines array according to the current settings of the particle system
  145184. * @param defines Array to be updated
  145185. * @param blendMode blend mode to take into account when updating the array
  145186. */
  145187. fillDefines(defines: Array<string>, blendMode?: number): void;
  145188. /**
  145189. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  145190. * @param uniforms Uniforms array to fill
  145191. * @param attributes Attributes array to fill
  145192. * @param samplers Samplers array to fill
  145193. */
  145194. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  145195. /** @hidden */
  145196. _recreateRenderEffect(): Effect;
  145197. /**
  145198. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  145199. * @param preWarm defines if we are in the pre-warmimg phase
  145200. */
  145201. animate(preWarm?: boolean): void;
  145202. private _createFactorGradientTexture;
  145203. private _createSizeGradientTexture;
  145204. private _createAngularSpeedGradientTexture;
  145205. private _createVelocityGradientTexture;
  145206. private _createLimitVelocityGradientTexture;
  145207. private _createDragGradientTexture;
  145208. private _createColorGradientTexture;
  145209. /**
  145210. * Renders the particle system in its current state
  145211. * @param preWarm defines if the system should only update the particles but not render them
  145212. * @returns the current number of particles
  145213. */
  145214. render(preWarm?: boolean): number;
  145215. /**
  145216. * Rebuilds the particle system
  145217. */
  145218. rebuild(): void;
  145219. private _releaseBuffers;
  145220. private _releaseVAOs;
  145221. /**
  145222. * Disposes the particle system and free the associated resources
  145223. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  145224. */
  145225. dispose(disposeTexture?: boolean): void;
  145226. /**
  145227. * Clones the particle system.
  145228. * @param name The name of the cloned object
  145229. * @param newEmitter The new emitter to use
  145230. * @returns the cloned particle system
  145231. */
  145232. clone(name: string, newEmitter: any): GPUParticleSystem;
  145233. /**
  145234. * Serializes the particle system to a JSON object
  145235. * @param serializeTexture defines if the texture must be serialized as well
  145236. * @returns the JSON object
  145237. */
  145238. serialize(serializeTexture?: boolean): any;
  145239. /**
  145240. * Parses a JSON object to create a GPU particle system.
  145241. * @param parsedParticleSystem The JSON object to parse
  145242. * @param scene The scene to create the particle system in
  145243. * @param rootUrl The root url to use to load external dependencies like texture
  145244. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  145245. * @returns the parsed GPU particle system
  145246. */
  145247. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  145248. }
  145249. }
  145250. declare module BABYLON {
  145251. /**
  145252. * Represents a set of particle systems working together to create a specific effect
  145253. */
  145254. export class ParticleSystemSet implements IDisposable {
  145255. /**
  145256. * Gets or sets base Assets URL
  145257. */
  145258. static BaseAssetsUrl: string;
  145259. private _emitterCreationOptions;
  145260. private _emitterNode;
  145261. /**
  145262. * Gets the particle system list
  145263. */
  145264. systems: IParticleSystem[];
  145265. /**
  145266. * Gets the emitter node used with this set
  145267. */
  145268. get emitterNode(): Nullable<TransformNode>;
  145269. /**
  145270. * Creates a new emitter mesh as a sphere
  145271. * @param options defines the options used to create the sphere
  145272. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  145273. * @param scene defines the hosting scene
  145274. */
  145275. setEmitterAsSphere(options: {
  145276. diameter: number;
  145277. segments: number;
  145278. color: Color3;
  145279. }, renderingGroupId: number, scene: Scene): void;
  145280. /**
  145281. * Starts all particle systems of the set
  145282. * @param emitter defines an optional mesh to use as emitter for the particle systems
  145283. */
  145284. start(emitter?: AbstractMesh): void;
  145285. /**
  145286. * Release all associated resources
  145287. */
  145288. dispose(): void;
  145289. /**
  145290. * Serialize the set into a JSON compatible object
  145291. * @param serializeTexture defines if the texture must be serialized as well
  145292. * @returns a JSON compatible representation of the set
  145293. */
  145294. serialize(serializeTexture?: boolean): any;
  145295. /**
  145296. * Parse a new ParticleSystemSet from a serialized source
  145297. * @param data defines a JSON compatible representation of the set
  145298. * @param scene defines the hosting scene
  145299. * @param gpu defines if we want GPU particles or CPU particles
  145300. * @returns a new ParticleSystemSet
  145301. */
  145302. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  145303. }
  145304. }
  145305. declare module BABYLON {
  145306. /**
  145307. * This class is made for on one-liner static method to help creating particle system set.
  145308. */
  145309. export class ParticleHelper {
  145310. /**
  145311. * Gets or sets base Assets URL
  145312. */
  145313. static BaseAssetsUrl: string;
  145314. /** Define the Url to load snippets */
  145315. static SnippetUrl: string;
  145316. /**
  145317. * Create a default particle system that you can tweak
  145318. * @param emitter defines the emitter to use
  145319. * @param capacity defines the system capacity (default is 500 particles)
  145320. * @param scene defines the hosting scene
  145321. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  145322. * @returns the new Particle system
  145323. */
  145324. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  145325. /**
  145326. * This is the main static method (one-liner) of this helper to create different particle systems
  145327. * @param type This string represents the type to the particle system to create
  145328. * @param scene The scene where the particle system should live
  145329. * @param gpu If the system will use gpu
  145330. * @returns the ParticleSystemSet created
  145331. */
  145332. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  145333. /**
  145334. * Static function used to export a particle system to a ParticleSystemSet variable.
  145335. * Please note that the emitter shape is not exported
  145336. * @param systems defines the particle systems to export
  145337. * @returns the created particle system set
  145338. */
  145339. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  145340. /**
  145341. * Creates a particle system from a snippet saved in a remote file
  145342. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  145343. * @param url defines the url to load from
  145344. * @param scene defines the hosting scene
  145345. * @param gpu If the system will use gpu
  145346. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145347. * @returns a promise that will resolve to the new particle system
  145348. */
  145349. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145350. /**
  145351. * Creates a particle system from a snippet saved by the particle system editor
  145352. * @param snippetId defines the snippet to load
  145353. * @param scene defines the hosting scene
  145354. * @param gpu If the system will use gpu
  145355. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  145356. * @returns a promise that will resolve to the new particle system
  145357. */
  145358. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  145359. }
  145360. }
  145361. declare module BABYLON {
  145362. interface Engine {
  145363. /**
  145364. * Create an effect to use with particle systems.
  145365. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  145366. * the particle system for which you want to create a custom effect in the last parameter
  145367. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  145368. * @param uniformsNames defines a list of attribute names
  145369. * @param samplers defines an array of string used to represent textures
  145370. * @param defines defines the string containing the defines to use to compile the shaders
  145371. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  145372. * @param onCompiled defines a function to call when the effect creation is successful
  145373. * @param onError defines a function to call when the effect creation has failed
  145374. * @param particleSystem the particle system you want to create the effect for
  145375. * @returns the new Effect
  145376. */
  145377. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  145378. }
  145379. interface Mesh {
  145380. /**
  145381. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  145382. * @returns an array of IParticleSystem
  145383. */
  145384. getEmittedParticleSystems(): IParticleSystem[];
  145385. /**
  145386. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  145387. * @returns an array of IParticleSystem
  145388. */
  145389. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  145390. }
  145391. }
  145392. declare module BABYLON {
  145393. /** Defines the 4 color options */
  145394. export enum PointColor {
  145395. /** color value */
  145396. Color = 2,
  145397. /** uv value */
  145398. UV = 1,
  145399. /** random value */
  145400. Random = 0,
  145401. /** stated value */
  145402. Stated = 3
  145403. }
  145404. /**
  145405. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  145406. * 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.
  145407. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  145408. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  145409. *
  145410. * Full documentation here : TO BE ENTERED
  145411. */
  145412. export class PointsCloudSystem implements IDisposable {
  145413. /**
  145414. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  145415. * Example : var p = SPS.particles[i];
  145416. */
  145417. particles: CloudPoint[];
  145418. /**
  145419. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  145420. */
  145421. nbParticles: number;
  145422. /**
  145423. * This a counter for your own usage. It's not set by any SPS functions.
  145424. */
  145425. counter: number;
  145426. /**
  145427. * The PCS name. This name is also given to the underlying mesh.
  145428. */
  145429. name: string;
  145430. /**
  145431. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  145432. */
  145433. mesh: Mesh;
  145434. /**
  145435. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  145436. * Please read :
  145437. */
  145438. vars: any;
  145439. /**
  145440. * @hidden
  145441. */
  145442. _size: number;
  145443. private _scene;
  145444. private _promises;
  145445. private _positions;
  145446. private _indices;
  145447. private _normals;
  145448. private _colors;
  145449. private _uvs;
  145450. private _indices32;
  145451. private _positions32;
  145452. private _colors32;
  145453. private _uvs32;
  145454. private _updatable;
  145455. private _isVisibilityBoxLocked;
  145456. private _alwaysVisible;
  145457. private _groups;
  145458. private _groupCounter;
  145459. private _computeParticleColor;
  145460. private _computeParticleTexture;
  145461. private _computeParticleRotation;
  145462. private _computeBoundingBox;
  145463. private _isReady;
  145464. /**
  145465. * Creates a PCS (Points Cloud System) object
  145466. * @param name (String) is the PCS name, this will be the underlying mesh name
  145467. * @param pointSize (number) is the size for each point
  145468. * @param scene (Scene) is the scene in which the PCS is added
  145469. * @param options defines the options of the PCS e.g.
  145470. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  145471. */
  145472. constructor(name: string, pointSize: number, scene: Scene, options?: {
  145473. updatable?: boolean;
  145474. });
  145475. /**
  145476. * Builds the PCS underlying mesh. Returns a standard Mesh.
  145477. * If no points were added to the PCS, the returned mesh is just a single point.
  145478. * @returns a promise for the created mesh
  145479. */
  145480. buildMeshAsync(): Promise<Mesh>;
  145481. /**
  145482. * @hidden
  145483. */
  145484. private _buildMesh;
  145485. private _addParticle;
  145486. private _randomUnitVector;
  145487. private _getColorIndicesForCoord;
  145488. private _setPointsColorOrUV;
  145489. private _colorFromTexture;
  145490. private _calculateDensity;
  145491. /**
  145492. * Adds points to the PCS in random positions within a unit sphere
  145493. * @param nb (positive integer) the number of particles to be created from this model
  145494. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  145495. * @returns the number of groups in the system
  145496. */
  145497. addPoints(nb: number, pointFunction?: any): number;
  145498. /**
  145499. * Adds points to the PCS from the surface of the model shape
  145500. * @param mesh is any Mesh object that will be used as a surface model for the points
  145501. * @param nb (positive integer) the number of particles to be created from this model
  145502. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145503. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145504. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145505. * @returns the number of groups in the system
  145506. */
  145507. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145508. /**
  145509. * Adds points to the PCS inside the model shape
  145510. * @param mesh is any Mesh object that will be used as a surface model for the points
  145511. * @param nb (positive integer) the number of particles to be created from this model
  145512. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  145513. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  145514. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  145515. * @returns the number of groups in the system
  145516. */
  145517. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  145518. /**
  145519. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  145520. * This method calls `updateParticle()` for each particle of the SPS.
  145521. * For an animated SPS, it is usually called within the render loop.
  145522. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  145523. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  145524. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  145525. * @returns the PCS.
  145526. */
  145527. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  145528. /**
  145529. * Disposes the PCS.
  145530. */
  145531. dispose(): void;
  145532. /**
  145533. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  145534. * doc :
  145535. * @returns the PCS.
  145536. */
  145537. refreshVisibleSize(): PointsCloudSystem;
  145538. /**
  145539. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  145540. * @param size the size (float) of the visibility box
  145541. * note : this doesn't lock the PCS mesh bounding box.
  145542. * doc :
  145543. */
  145544. setVisibilityBox(size: number): void;
  145545. /**
  145546. * Gets whether the PCS is always visible or not
  145547. * doc :
  145548. */
  145549. get isAlwaysVisible(): boolean;
  145550. /**
  145551. * Sets the PCS as always visible or not
  145552. * doc :
  145553. */
  145554. set isAlwaysVisible(val: boolean);
  145555. /**
  145556. * Tells to `setParticles()` to compute the particle rotations or not
  145557. * Default value : false. The PCS is faster when it's set to false
  145558. * Note : particle rotations are only applied to parent particles
  145559. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  145560. */
  145561. set computeParticleRotation(val: boolean);
  145562. /**
  145563. * Tells to `setParticles()` to compute the particle colors or not.
  145564. * Default value : true. The PCS is faster when it's set to false.
  145565. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145566. */
  145567. set computeParticleColor(val: boolean);
  145568. set computeParticleTexture(val: boolean);
  145569. /**
  145570. * Gets if `setParticles()` computes the particle colors or not.
  145571. * Default value : false. The PCS is faster when it's set to false.
  145572. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  145573. */
  145574. get computeParticleColor(): boolean;
  145575. /**
  145576. * Gets if `setParticles()` computes the particle textures or not.
  145577. * Default value : false. The PCS is faster when it's set to false.
  145578. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  145579. */
  145580. get computeParticleTexture(): boolean;
  145581. /**
  145582. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  145583. */
  145584. set computeBoundingBox(val: boolean);
  145585. /**
  145586. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  145587. */
  145588. get computeBoundingBox(): boolean;
  145589. /**
  145590. * This function does nothing. It may be overwritten to set all the particle first values.
  145591. * The PCS doesn't call this function, you may have to call it by your own.
  145592. * doc :
  145593. */
  145594. initParticles(): void;
  145595. /**
  145596. * This function does nothing. It may be overwritten to recycle a particle
  145597. * The PCS doesn't call this function, you can to call it
  145598. * doc :
  145599. * @param particle The particle to recycle
  145600. * @returns the recycled particle
  145601. */
  145602. recycleParticle(particle: CloudPoint): CloudPoint;
  145603. /**
  145604. * Updates a particle : this function should be overwritten by the user.
  145605. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  145606. * doc :
  145607. * @example : just set a particle position or velocity and recycle conditions
  145608. * @param particle The particle to update
  145609. * @returns the updated particle
  145610. */
  145611. updateParticle(particle: CloudPoint): CloudPoint;
  145612. /**
  145613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  145614. * This does nothing and may be overwritten by the user.
  145615. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145617. * @param update the boolean update value actually passed to setParticles()
  145618. */
  145619. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145620. /**
  145621. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  145622. * This will be passed three parameters.
  145623. * This does nothing and may be overwritten by the user.
  145624. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  145625. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  145626. * @param update the boolean update value actually passed to setParticles()
  145627. */
  145628. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  145629. }
  145630. }
  145631. declare module BABYLON {
  145632. /**
  145633. * Represents one particle of a points cloud system.
  145634. */
  145635. export class CloudPoint {
  145636. /**
  145637. * particle global index
  145638. */
  145639. idx: number;
  145640. /**
  145641. * The color of the particle
  145642. */
  145643. color: Nullable<Color4>;
  145644. /**
  145645. * The world space position of the particle.
  145646. */
  145647. position: Vector3;
  145648. /**
  145649. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  145650. */
  145651. rotation: Vector3;
  145652. /**
  145653. * The world space rotation quaternion of the particle.
  145654. */
  145655. rotationQuaternion: Nullable<Quaternion>;
  145656. /**
  145657. * The uv of the particle.
  145658. */
  145659. uv: Nullable<Vector2>;
  145660. /**
  145661. * The current speed of the particle.
  145662. */
  145663. velocity: Vector3;
  145664. /**
  145665. * The pivot point in the particle local space.
  145666. */
  145667. pivot: Vector3;
  145668. /**
  145669. * Must the particle be translated from its pivot point in its local space ?
  145670. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  145671. * Default : false
  145672. */
  145673. translateFromPivot: boolean;
  145674. /**
  145675. * Index of this particle in the global "positions" array (Internal use)
  145676. * @hidden
  145677. */
  145678. _pos: number;
  145679. /**
  145680. * @hidden Index of this particle in the global "indices" array (Internal use)
  145681. */
  145682. _ind: number;
  145683. /**
  145684. * Group this particle belongs to
  145685. */
  145686. _group: PointsGroup;
  145687. /**
  145688. * Group id of this particle
  145689. */
  145690. groupId: number;
  145691. /**
  145692. * Index of the particle in its group id (Internal use)
  145693. */
  145694. idxInGroup: number;
  145695. /**
  145696. * @hidden Particle BoundingInfo object (Internal use)
  145697. */
  145698. _boundingInfo: BoundingInfo;
  145699. /**
  145700. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  145701. */
  145702. _pcs: PointsCloudSystem;
  145703. /**
  145704. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  145705. */
  145706. _stillInvisible: boolean;
  145707. /**
  145708. * @hidden Last computed particle rotation matrix
  145709. */
  145710. _rotationMatrix: number[];
  145711. /**
  145712. * Parent particle Id, if any.
  145713. * Default null.
  145714. */
  145715. parentId: Nullable<number>;
  145716. /**
  145717. * @hidden Internal global position in the PCS.
  145718. */
  145719. _globalPosition: Vector3;
  145720. /**
  145721. * Creates a Point Cloud object.
  145722. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  145723. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  145724. * @param group (PointsGroup) is the group the particle belongs to
  145725. * @param groupId (integer) is the group identifier in the PCS.
  145726. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  145727. * @param pcs defines the PCS it is associated to
  145728. */
  145729. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  145730. /**
  145731. * get point size
  145732. */
  145733. get size(): Vector3;
  145734. /**
  145735. * Set point size
  145736. */
  145737. set size(scale: Vector3);
  145738. /**
  145739. * Legacy support, changed quaternion to rotationQuaternion
  145740. */
  145741. get quaternion(): Nullable<Quaternion>;
  145742. /**
  145743. * Legacy support, changed quaternion to rotationQuaternion
  145744. */
  145745. set quaternion(q: Nullable<Quaternion>);
  145746. /**
  145747. * Returns a boolean. True if the particle intersects a mesh, else false
  145748. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  145749. * @param target is the object (point or mesh) what the intersection is computed against
  145750. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  145751. * @returns true if it intersects
  145752. */
  145753. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  145754. /**
  145755. * get the rotation matrix of the particle
  145756. * @hidden
  145757. */
  145758. getRotationMatrix(m: Matrix): void;
  145759. }
  145760. /**
  145761. * Represents a group of points in a points cloud system
  145762. * * PCS internal tool, don't use it manually.
  145763. */
  145764. export class PointsGroup {
  145765. /**
  145766. * The group id
  145767. * @hidden
  145768. */
  145769. groupID: number;
  145770. /**
  145771. * image data for group (internal use)
  145772. * @hidden
  145773. */
  145774. _groupImageData: Nullable<ArrayBufferView>;
  145775. /**
  145776. * Image Width (internal use)
  145777. * @hidden
  145778. */
  145779. _groupImgWidth: number;
  145780. /**
  145781. * Image Height (internal use)
  145782. * @hidden
  145783. */
  145784. _groupImgHeight: number;
  145785. /**
  145786. * Custom position function (internal use)
  145787. * @hidden
  145788. */
  145789. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  145790. /**
  145791. * density per facet for surface points
  145792. * @hidden
  145793. */
  145794. _groupDensity: number[];
  145795. /**
  145796. * Only when points are colored by texture carries pointer to texture list array
  145797. * @hidden
  145798. */
  145799. _textureNb: number;
  145800. /**
  145801. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  145802. * PCS internal tool, don't use it manually.
  145803. * @hidden
  145804. */
  145805. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  145806. }
  145807. }
  145808. declare module BABYLON {
  145809. interface Scene {
  145810. /** @hidden (Backing field) */
  145811. _physicsEngine: Nullable<IPhysicsEngine>;
  145812. /** @hidden */
  145813. _physicsTimeAccumulator: number;
  145814. /**
  145815. * Gets the current physics engine
  145816. * @returns a IPhysicsEngine or null if none attached
  145817. */
  145818. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  145819. /**
  145820. * Enables physics to the current scene
  145821. * @param gravity defines the scene's gravity for the physics engine
  145822. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  145823. * @return a boolean indicating if the physics engine was initialized
  145824. */
  145825. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  145826. /**
  145827. * Disables and disposes the physics engine associated with the scene
  145828. */
  145829. disablePhysicsEngine(): void;
  145830. /**
  145831. * Gets a boolean indicating if there is an active physics engine
  145832. * @returns a boolean indicating if there is an active physics engine
  145833. */
  145834. isPhysicsEnabled(): boolean;
  145835. /**
  145836. * Deletes a physics compound impostor
  145837. * @param compound defines the compound to delete
  145838. */
  145839. deleteCompoundImpostor(compound: any): void;
  145840. /**
  145841. * An event triggered when physic simulation is about to be run
  145842. */
  145843. onBeforePhysicsObservable: Observable<Scene>;
  145844. /**
  145845. * An event triggered when physic simulation has been done
  145846. */
  145847. onAfterPhysicsObservable: Observable<Scene>;
  145848. }
  145849. interface AbstractMesh {
  145850. /** @hidden */
  145851. _physicsImpostor: Nullable<PhysicsImpostor>;
  145852. /**
  145853. * Gets or sets impostor used for physic simulation
  145854. * @see https://doc.babylonjs.com/features/physics_engine
  145855. */
  145856. physicsImpostor: Nullable<PhysicsImpostor>;
  145857. /**
  145858. * Gets the current physics impostor
  145859. * @see https://doc.babylonjs.com/features/physics_engine
  145860. * @returns a physics impostor or null
  145861. */
  145862. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  145863. /** Apply a physic impulse to the mesh
  145864. * @param force defines the force to apply
  145865. * @param contactPoint defines where to apply the force
  145866. * @returns the current mesh
  145867. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  145868. */
  145869. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  145870. /**
  145871. * Creates a physic joint between two meshes
  145872. * @param otherMesh defines the other mesh to use
  145873. * @param pivot1 defines the pivot to use on this mesh
  145874. * @param pivot2 defines the pivot to use on the other mesh
  145875. * @param options defines additional options (can be plugin dependent)
  145876. * @returns the current mesh
  145877. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  145878. */
  145879. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  145880. /** @hidden */
  145881. _disposePhysicsObserver: Nullable<Observer<Node>>;
  145882. }
  145883. /**
  145884. * Defines the physics engine scene component responsible to manage a physics engine
  145885. */
  145886. export class PhysicsEngineSceneComponent implements ISceneComponent {
  145887. /**
  145888. * The component name helpful to identify the component in the list of scene components.
  145889. */
  145890. readonly name: string;
  145891. /**
  145892. * The scene the component belongs to.
  145893. */
  145894. scene: Scene;
  145895. /**
  145896. * Creates a new instance of the component for the given scene
  145897. * @param scene Defines the scene to register the component in
  145898. */
  145899. constructor(scene: Scene);
  145900. /**
  145901. * Registers the component in a given scene
  145902. */
  145903. register(): void;
  145904. /**
  145905. * Rebuilds the elements related to this component in case of
  145906. * context lost for instance.
  145907. */
  145908. rebuild(): void;
  145909. /**
  145910. * Disposes the component and the associated ressources
  145911. */
  145912. dispose(): void;
  145913. }
  145914. }
  145915. declare module BABYLON {
  145916. /**
  145917. * A helper for physics simulations
  145918. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  145919. */
  145920. export class PhysicsHelper {
  145921. private _scene;
  145922. private _physicsEngine;
  145923. /**
  145924. * Initializes the Physics helper
  145925. * @param scene Babylon.js scene
  145926. */
  145927. constructor(scene: Scene);
  145928. /**
  145929. * Applies a radial explosion impulse
  145930. * @param origin the origin of the explosion
  145931. * @param radiusOrEventOptions the radius or the options of radial explosion
  145932. * @param strength the explosion strength
  145933. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145934. * @returns A physics radial explosion event, or null
  145935. */
  145936. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145937. /**
  145938. * Applies a radial explosion force
  145939. * @param origin the origin of the explosion
  145940. * @param radiusOrEventOptions the radius or the options of radial explosion
  145941. * @param strength the explosion strength
  145942. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145943. * @returns A physics radial explosion event, or null
  145944. */
  145945. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  145946. /**
  145947. * Creates a gravitational field
  145948. * @param origin the origin of the explosion
  145949. * @param radiusOrEventOptions the radius or the options of radial explosion
  145950. * @param strength the explosion strength
  145951. * @param falloff possible options: Constant & Linear. Defaults to Constant
  145952. * @returns A physics gravitational field event, or null
  145953. */
  145954. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  145955. /**
  145956. * Creates a physics updraft event
  145957. * @param origin the origin of the updraft
  145958. * @param radiusOrEventOptions the radius or the options of the updraft
  145959. * @param strength the strength of the updraft
  145960. * @param height the height of the updraft
  145961. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  145962. * @returns A physics updraft event, or null
  145963. */
  145964. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  145965. /**
  145966. * Creates a physics vortex event
  145967. * @param origin the of the vortex
  145968. * @param radiusOrEventOptions the radius or the options of the vortex
  145969. * @param strength the strength of the vortex
  145970. * @param height the height of the vortex
  145971. * @returns a Physics vortex event, or null
  145972. * A physics vortex event or null
  145973. */
  145974. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  145975. }
  145976. /**
  145977. * Represents a physics radial explosion event
  145978. */
  145979. class PhysicsRadialExplosionEvent {
  145980. private _scene;
  145981. private _options;
  145982. private _sphere;
  145983. private _dataFetched;
  145984. /**
  145985. * Initializes a radial explosioin event
  145986. * @param _scene BabylonJS scene
  145987. * @param _options The options for the vortex event
  145988. */
  145989. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  145990. /**
  145991. * Returns the data related to the radial explosion event (sphere).
  145992. * @returns The radial explosion event data
  145993. */
  145994. getData(): PhysicsRadialExplosionEventData;
  145995. /**
  145996. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  145997. * @param impostor A physics imposter
  145998. * @param origin the origin of the explosion
  145999. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  146000. */
  146001. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  146002. /**
  146003. * Triggers affecterd impostors callbacks
  146004. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  146005. */
  146006. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  146007. /**
  146008. * Disposes the sphere.
  146009. * @param force Specifies if the sphere should be disposed by force
  146010. */
  146011. dispose(force?: boolean): void;
  146012. /*** Helpers ***/
  146013. private _prepareSphere;
  146014. private _intersectsWithSphere;
  146015. }
  146016. /**
  146017. * Represents a gravitational field event
  146018. */
  146019. class PhysicsGravitationalFieldEvent {
  146020. private _physicsHelper;
  146021. private _scene;
  146022. private _origin;
  146023. private _options;
  146024. private _tickCallback;
  146025. private _sphere;
  146026. private _dataFetched;
  146027. /**
  146028. * Initializes the physics gravitational field event
  146029. * @param _physicsHelper A physics helper
  146030. * @param _scene BabylonJS scene
  146031. * @param _origin The origin position of the gravitational field event
  146032. * @param _options The options for the vortex event
  146033. */
  146034. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  146035. /**
  146036. * Returns the data related to the gravitational field event (sphere).
  146037. * @returns A gravitational field event
  146038. */
  146039. getData(): PhysicsGravitationalFieldEventData;
  146040. /**
  146041. * Enables the gravitational field.
  146042. */
  146043. enable(): void;
  146044. /**
  146045. * Disables the gravitational field.
  146046. */
  146047. disable(): void;
  146048. /**
  146049. * Disposes the sphere.
  146050. * @param force The force to dispose from the gravitational field event
  146051. */
  146052. dispose(force?: boolean): void;
  146053. private _tick;
  146054. }
  146055. /**
  146056. * Represents a physics updraft event
  146057. */
  146058. class PhysicsUpdraftEvent {
  146059. private _scene;
  146060. private _origin;
  146061. private _options;
  146062. private _physicsEngine;
  146063. private _originTop;
  146064. private _originDirection;
  146065. private _tickCallback;
  146066. private _cylinder;
  146067. private _cylinderPosition;
  146068. private _dataFetched;
  146069. /**
  146070. * Initializes the physics updraft event
  146071. * @param _scene BabylonJS scene
  146072. * @param _origin The origin position of the updraft
  146073. * @param _options The options for the updraft event
  146074. */
  146075. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  146076. /**
  146077. * Returns the data related to the updraft event (cylinder).
  146078. * @returns A physics updraft event
  146079. */
  146080. getData(): PhysicsUpdraftEventData;
  146081. /**
  146082. * Enables the updraft.
  146083. */
  146084. enable(): void;
  146085. /**
  146086. * Disables the updraft.
  146087. */
  146088. disable(): void;
  146089. /**
  146090. * Disposes the cylinder.
  146091. * @param force Specifies if the updraft should be disposed by force
  146092. */
  146093. dispose(force?: boolean): void;
  146094. private getImpostorHitData;
  146095. private _tick;
  146096. /*** Helpers ***/
  146097. private _prepareCylinder;
  146098. private _intersectsWithCylinder;
  146099. }
  146100. /**
  146101. * Represents a physics vortex event
  146102. */
  146103. class PhysicsVortexEvent {
  146104. private _scene;
  146105. private _origin;
  146106. private _options;
  146107. private _physicsEngine;
  146108. private _originTop;
  146109. private _tickCallback;
  146110. private _cylinder;
  146111. private _cylinderPosition;
  146112. private _dataFetched;
  146113. /**
  146114. * Initializes the physics vortex event
  146115. * @param _scene The BabylonJS scene
  146116. * @param _origin The origin position of the vortex
  146117. * @param _options The options for the vortex event
  146118. */
  146119. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  146120. /**
  146121. * Returns the data related to the vortex event (cylinder).
  146122. * @returns The physics vortex event data
  146123. */
  146124. getData(): PhysicsVortexEventData;
  146125. /**
  146126. * Enables the vortex.
  146127. */
  146128. enable(): void;
  146129. /**
  146130. * Disables the cortex.
  146131. */
  146132. disable(): void;
  146133. /**
  146134. * Disposes the sphere.
  146135. * @param force
  146136. */
  146137. dispose(force?: boolean): void;
  146138. private getImpostorHitData;
  146139. private _tick;
  146140. /*** Helpers ***/
  146141. private _prepareCylinder;
  146142. private _intersectsWithCylinder;
  146143. }
  146144. /**
  146145. * Options fot the radial explosion event
  146146. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146147. */
  146148. export class PhysicsRadialExplosionEventOptions {
  146149. /**
  146150. * The radius of the sphere for the radial explosion.
  146151. */
  146152. radius: number;
  146153. /**
  146154. * The strenth of the explosion.
  146155. */
  146156. strength: number;
  146157. /**
  146158. * The strenght of the force in correspondence to the distance of the affected object
  146159. */
  146160. falloff: PhysicsRadialImpulseFalloff;
  146161. /**
  146162. * Sphere options for the radial explosion.
  146163. */
  146164. sphere: {
  146165. segments: number;
  146166. diameter: number;
  146167. };
  146168. /**
  146169. * Sphere options for the radial explosion.
  146170. */
  146171. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  146172. }
  146173. /**
  146174. * Options fot the updraft event
  146175. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146176. */
  146177. export class PhysicsUpdraftEventOptions {
  146178. /**
  146179. * The radius of the cylinder for the vortex
  146180. */
  146181. radius: number;
  146182. /**
  146183. * The strenth of the updraft.
  146184. */
  146185. strength: number;
  146186. /**
  146187. * The height of the cylinder for the updraft.
  146188. */
  146189. height: number;
  146190. /**
  146191. * The mode for the the updraft.
  146192. */
  146193. updraftMode: PhysicsUpdraftMode;
  146194. }
  146195. /**
  146196. * Options fot the vortex event
  146197. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146198. */
  146199. export class PhysicsVortexEventOptions {
  146200. /**
  146201. * The radius of the cylinder for the vortex
  146202. */
  146203. radius: number;
  146204. /**
  146205. * The strenth of the vortex.
  146206. */
  146207. strength: number;
  146208. /**
  146209. * The height of the cylinder for the vortex.
  146210. */
  146211. height: number;
  146212. /**
  146213. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  146214. */
  146215. centripetalForceThreshold: number;
  146216. /**
  146217. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  146218. */
  146219. centripetalForceMultiplier: number;
  146220. /**
  146221. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  146222. */
  146223. centrifugalForceMultiplier: number;
  146224. /**
  146225. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  146226. */
  146227. updraftForceMultiplier: number;
  146228. }
  146229. /**
  146230. * The strenght of the force in correspondence to the distance of the affected object
  146231. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146232. */
  146233. export enum PhysicsRadialImpulseFalloff {
  146234. /** Defines that impulse is constant in strength across it's whole radius */
  146235. Constant = 0,
  146236. /** Defines that impulse gets weaker if it's further from the origin */
  146237. Linear = 1
  146238. }
  146239. /**
  146240. * The strength of the force in correspondence to the distance of the affected object
  146241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146242. */
  146243. export enum PhysicsUpdraftMode {
  146244. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  146245. Center = 0,
  146246. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  146247. Perpendicular = 1
  146248. }
  146249. /**
  146250. * Interface for a physics hit data
  146251. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146252. */
  146253. export interface PhysicsHitData {
  146254. /**
  146255. * The force applied at the contact point
  146256. */
  146257. force: Vector3;
  146258. /**
  146259. * The contact point
  146260. */
  146261. contactPoint: Vector3;
  146262. /**
  146263. * The distance from the origin to the contact point
  146264. */
  146265. distanceFromOrigin: number;
  146266. }
  146267. /**
  146268. * Interface for radial explosion event data
  146269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146270. */
  146271. export interface PhysicsRadialExplosionEventData {
  146272. /**
  146273. * A sphere used for the radial explosion event
  146274. */
  146275. sphere: Mesh;
  146276. }
  146277. /**
  146278. * Interface for gravitational field event data
  146279. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146280. */
  146281. export interface PhysicsGravitationalFieldEventData {
  146282. /**
  146283. * A sphere mesh used for the gravitational field event
  146284. */
  146285. sphere: Mesh;
  146286. }
  146287. /**
  146288. * Interface for updraft event data
  146289. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146290. */
  146291. export interface PhysicsUpdraftEventData {
  146292. /**
  146293. * A cylinder used for the updraft event
  146294. */
  146295. cylinder: Mesh;
  146296. }
  146297. /**
  146298. * Interface for vortex event data
  146299. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146300. */
  146301. export interface PhysicsVortexEventData {
  146302. /**
  146303. * A cylinder used for the vortex event
  146304. */
  146305. cylinder: Mesh;
  146306. }
  146307. /**
  146308. * Interface for an affected physics impostor
  146309. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  146310. */
  146311. export interface PhysicsAffectedImpostorWithData {
  146312. /**
  146313. * The impostor affected by the effect
  146314. */
  146315. impostor: PhysicsImpostor;
  146316. /**
  146317. * The data about the hit/horce from the explosion
  146318. */
  146319. hitData: PhysicsHitData;
  146320. }
  146321. }
  146322. declare module BABYLON {
  146323. /** @hidden */
  146324. export var blackAndWhitePixelShader: {
  146325. name: string;
  146326. shader: string;
  146327. };
  146328. }
  146329. declare module BABYLON {
  146330. /**
  146331. * Post process used to render in black and white
  146332. */
  146333. export class BlackAndWhitePostProcess extends PostProcess {
  146334. /**
  146335. * Linear about to convert he result to black and white (default: 1)
  146336. */
  146337. degree: number;
  146338. /**
  146339. * Creates a black and white post process
  146340. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  146341. * @param name The name of the effect.
  146342. * @param options The required width/height ratio to downsize to before computing the render pass.
  146343. * @param camera The camera to apply the render pass to.
  146344. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146345. * @param engine The engine which the post process will be applied. (default: current engine)
  146346. * @param reusable If the post process can be reused on the same frame. (default: false)
  146347. */
  146348. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146349. }
  146350. }
  146351. declare module BABYLON {
  146352. /**
  146353. * This represents a set of one or more post processes in Babylon.
  146354. * A post process can be used to apply a shader to a texture after it is rendered.
  146355. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  146356. */
  146357. export class PostProcessRenderEffect {
  146358. private _postProcesses;
  146359. private _getPostProcesses;
  146360. private _singleInstance;
  146361. private _cameras;
  146362. private _indicesForCamera;
  146363. /**
  146364. * Name of the effect
  146365. * @hidden
  146366. */
  146367. _name: string;
  146368. /**
  146369. * Instantiates a post process render effect.
  146370. * A post process can be used to apply a shader to a texture after it is rendered.
  146371. * @param engine The engine the effect is tied to
  146372. * @param name The name of the effect
  146373. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  146374. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  146375. */
  146376. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  146377. /**
  146378. * Checks if all the post processes in the effect are supported.
  146379. */
  146380. get isSupported(): boolean;
  146381. /**
  146382. * Updates the current state of the effect
  146383. * @hidden
  146384. */
  146385. _update(): void;
  146386. /**
  146387. * Attaches the effect on cameras
  146388. * @param cameras The camera to attach to.
  146389. * @hidden
  146390. */
  146391. _attachCameras(cameras: Camera): void;
  146392. /**
  146393. * Attaches the effect on cameras
  146394. * @param cameras The camera to attach to.
  146395. * @hidden
  146396. */
  146397. _attachCameras(cameras: Camera[]): void;
  146398. /**
  146399. * Detaches the effect on cameras
  146400. * @param cameras The camera to detatch from.
  146401. * @hidden
  146402. */
  146403. _detachCameras(cameras: Camera): void;
  146404. /**
  146405. * Detatches the effect on cameras
  146406. * @param cameras The camera to detatch from.
  146407. * @hidden
  146408. */
  146409. _detachCameras(cameras: Camera[]): void;
  146410. /**
  146411. * Enables the effect on given cameras
  146412. * @param cameras The camera to enable.
  146413. * @hidden
  146414. */
  146415. _enable(cameras: Camera): void;
  146416. /**
  146417. * Enables the effect on given cameras
  146418. * @param cameras The camera to enable.
  146419. * @hidden
  146420. */
  146421. _enable(cameras: Nullable<Camera[]>): void;
  146422. /**
  146423. * Disables the effect on the given cameras
  146424. * @param cameras The camera to disable.
  146425. * @hidden
  146426. */
  146427. _disable(cameras: Camera): void;
  146428. /**
  146429. * Disables the effect on the given cameras
  146430. * @param cameras The camera to disable.
  146431. * @hidden
  146432. */
  146433. _disable(cameras: Nullable<Camera[]>): void;
  146434. /**
  146435. * Gets a list of the post processes contained in the effect.
  146436. * @param camera The camera to get the post processes on.
  146437. * @returns The list of the post processes in the effect.
  146438. */
  146439. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  146440. }
  146441. }
  146442. declare module BABYLON {
  146443. /** @hidden */
  146444. export var extractHighlightsPixelShader: {
  146445. name: string;
  146446. shader: string;
  146447. };
  146448. }
  146449. declare module BABYLON {
  146450. /**
  146451. * 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.
  146452. */
  146453. export class ExtractHighlightsPostProcess extends PostProcess {
  146454. /**
  146455. * The luminance threshold, pixels below this value will be set to black.
  146456. */
  146457. threshold: number;
  146458. /** @hidden */
  146459. _exposure: number;
  146460. /**
  146461. * Post process which has the input texture to be used when performing highlight extraction
  146462. * @hidden
  146463. */
  146464. _inputPostProcess: Nullable<PostProcess>;
  146465. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146466. }
  146467. }
  146468. declare module BABYLON {
  146469. /** @hidden */
  146470. export var bloomMergePixelShader: {
  146471. name: string;
  146472. shader: string;
  146473. };
  146474. }
  146475. declare module BABYLON {
  146476. /**
  146477. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146478. */
  146479. export class BloomMergePostProcess extends PostProcess {
  146480. /** Weight of the bloom to be added to the original input. */
  146481. weight: number;
  146482. /**
  146483. * Creates a new instance of @see BloomMergePostProcess
  146484. * @param name The name of the effect.
  146485. * @param originalFromInput Post process which's input will be used for the merge.
  146486. * @param blurred Blurred highlights post process which's output will be used.
  146487. * @param weight Weight of the bloom to be added to the original input.
  146488. * @param options The required width/height ratio to downsize to before computing the render pass.
  146489. * @param camera The camera to apply the render pass to.
  146490. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146491. * @param engine The engine which the post process will be applied. (default: current engine)
  146492. * @param reusable If the post process can be reused on the same frame. (default: false)
  146493. * @param textureType Type of textures used when performing the post process. (default: 0)
  146494. * @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)
  146495. */
  146496. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  146497. /** Weight of the bloom to be added to the original input. */
  146498. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146499. }
  146500. }
  146501. declare module BABYLON {
  146502. /**
  146503. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  146504. */
  146505. export class BloomEffect extends PostProcessRenderEffect {
  146506. private bloomScale;
  146507. /**
  146508. * @hidden Internal
  146509. */
  146510. _effects: Array<PostProcess>;
  146511. /**
  146512. * @hidden Internal
  146513. */
  146514. _downscale: ExtractHighlightsPostProcess;
  146515. private _blurX;
  146516. private _blurY;
  146517. private _merge;
  146518. /**
  146519. * The luminance threshold to find bright areas of the image to bloom.
  146520. */
  146521. get threshold(): number;
  146522. set threshold(value: number);
  146523. /**
  146524. * The strength of the bloom.
  146525. */
  146526. get weight(): number;
  146527. set weight(value: number);
  146528. /**
  146529. * Specifies the size of the bloom blur kernel, relative to the final output size
  146530. */
  146531. get kernel(): number;
  146532. set kernel(value: number);
  146533. /**
  146534. * Creates a new instance of @see BloomEffect
  146535. * @param scene The scene the effect belongs to.
  146536. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  146537. * @param bloomKernel The size of the kernel to be used when applying the blur.
  146538. * @param bloomWeight The the strength of bloom.
  146539. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146540. * @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)
  146541. */
  146542. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  146543. /**
  146544. * Disposes each of the internal effects for a given camera.
  146545. * @param camera The camera to dispose the effect on.
  146546. */
  146547. disposeEffects(camera: Camera): void;
  146548. /**
  146549. * @hidden Internal
  146550. */
  146551. _updateEffects(): void;
  146552. /**
  146553. * Internal
  146554. * @returns if all the contained post processes are ready.
  146555. * @hidden
  146556. */
  146557. _isReady(): boolean;
  146558. }
  146559. }
  146560. declare module BABYLON {
  146561. /** @hidden */
  146562. export var chromaticAberrationPixelShader: {
  146563. name: string;
  146564. shader: string;
  146565. };
  146566. }
  146567. declare module BABYLON {
  146568. /**
  146569. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  146570. */
  146571. export class ChromaticAberrationPostProcess extends PostProcess {
  146572. /**
  146573. * The amount of seperation of rgb channels (default: 30)
  146574. */
  146575. aberrationAmount: number;
  146576. /**
  146577. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  146578. */
  146579. radialIntensity: number;
  146580. /**
  146581. * 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))
  146582. */
  146583. direction: Vector2;
  146584. /**
  146585. * 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))
  146586. */
  146587. centerPosition: Vector2;
  146588. /**
  146589. * Creates a new instance ChromaticAberrationPostProcess
  146590. * @param name The name of the effect.
  146591. * @param screenWidth The width of the screen to apply the effect on.
  146592. * @param screenHeight The height of the screen to apply the effect on.
  146593. * @param options The required width/height ratio to downsize to before computing the render pass.
  146594. * @param camera The camera to apply the render pass to.
  146595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146596. * @param engine The engine which the post process will be applied. (default: current engine)
  146597. * @param reusable If the post process can be reused on the same frame. (default: false)
  146598. * @param textureType Type of textures used when performing the post process. (default: 0)
  146599. * @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)
  146600. */
  146601. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146602. }
  146603. }
  146604. declare module BABYLON {
  146605. /** @hidden */
  146606. export var circleOfConfusionPixelShader: {
  146607. name: string;
  146608. shader: string;
  146609. };
  146610. }
  146611. declare module BABYLON {
  146612. /**
  146613. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  146614. */
  146615. export class CircleOfConfusionPostProcess extends PostProcess {
  146616. /**
  146617. * 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.
  146618. */
  146619. lensSize: number;
  146620. /**
  146621. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146622. */
  146623. fStop: number;
  146624. /**
  146625. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146626. */
  146627. focusDistance: number;
  146628. /**
  146629. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  146630. */
  146631. focalLength: number;
  146632. private _depthTexture;
  146633. /**
  146634. * Creates a new instance CircleOfConfusionPostProcess
  146635. * @param name The name of the effect.
  146636. * @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.
  146637. * @param options The required width/height ratio to downsize to before computing the render pass.
  146638. * @param camera The camera to apply the render pass to.
  146639. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146640. * @param engine The engine which the post process will be applied. (default: current engine)
  146641. * @param reusable If the post process can be reused on the same frame. (default: false)
  146642. * @param textureType Type of textures used when performing the post process. (default: 0)
  146643. * @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)
  146644. */
  146645. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  146646. /**
  146647. * 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.
  146648. */
  146649. set depthTexture(value: RenderTargetTexture);
  146650. }
  146651. }
  146652. declare module BABYLON {
  146653. /** @hidden */
  146654. export var colorCorrectionPixelShader: {
  146655. name: string;
  146656. shader: string;
  146657. };
  146658. }
  146659. declare module BABYLON {
  146660. /**
  146661. *
  146662. * This post-process allows the modification of rendered colors by using
  146663. * a 'look-up table' (LUT). This effect is also called Color Grading.
  146664. *
  146665. * The object needs to be provided an url to a texture containing the color
  146666. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  146667. * Use an image editing software to tweak the LUT to match your needs.
  146668. *
  146669. * For an example of a color LUT, see here:
  146670. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  146671. * For explanations on color grading, see here:
  146672. * @see http://udn.epicgames.com/Three/ColorGrading.html
  146673. *
  146674. */
  146675. export class ColorCorrectionPostProcess extends PostProcess {
  146676. private _colorTableTexture;
  146677. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146678. }
  146679. }
  146680. declare module BABYLON {
  146681. /** @hidden */
  146682. export var convolutionPixelShader: {
  146683. name: string;
  146684. shader: string;
  146685. };
  146686. }
  146687. declare module BABYLON {
  146688. /**
  146689. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  146690. * input texture to perform effects such as edge detection or sharpening
  146691. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  146692. */
  146693. export class ConvolutionPostProcess extends PostProcess {
  146694. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146695. kernel: number[];
  146696. /**
  146697. * Creates a new instance ConvolutionPostProcess
  146698. * @param name The name of the effect.
  146699. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  146700. * @param options The required width/height ratio to downsize to before computing the render pass.
  146701. * @param camera The camera to apply the render pass to.
  146702. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146703. * @param engine The engine which the post process will be applied. (default: current engine)
  146704. * @param reusable If the post process can be reused on the same frame. (default: false)
  146705. * @param textureType Type of textures used when performing the post process. (default: 0)
  146706. */
  146707. constructor(name: string,
  146708. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  146709. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146710. /**
  146711. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146712. */
  146713. static EdgeDetect0Kernel: number[];
  146714. /**
  146715. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146716. */
  146717. static EdgeDetect1Kernel: number[];
  146718. /**
  146719. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146720. */
  146721. static EdgeDetect2Kernel: number[];
  146722. /**
  146723. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146724. */
  146725. static SharpenKernel: number[];
  146726. /**
  146727. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146728. */
  146729. static EmbossKernel: number[];
  146730. /**
  146731. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  146732. */
  146733. static GaussianKernel: number[];
  146734. }
  146735. }
  146736. declare module BABYLON {
  146737. /**
  146738. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  146739. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  146740. * based on samples that have a large difference in distance than the center pixel.
  146741. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  146742. */
  146743. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  146744. direction: Vector2;
  146745. /**
  146746. * Creates a new instance CircleOfConfusionPostProcess
  146747. * @param name The name of the effect.
  146748. * @param scene The scene the effect belongs to.
  146749. * @param direction The direction the blur should be applied.
  146750. * @param kernel The size of the kernel used to blur.
  146751. * @param options The required width/height ratio to downsize to before computing the render pass.
  146752. * @param camera The camera to apply the render pass to.
  146753. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  146754. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  146755. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146756. * @param engine The engine which the post process will be applied. (default: current engine)
  146757. * @param reusable If the post process can be reused on the same frame. (default: false)
  146758. * @param textureType Type of textures used when performing the post process. (default: 0)
  146759. * @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)
  146760. */
  146761. 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);
  146762. }
  146763. }
  146764. declare module BABYLON {
  146765. /** @hidden */
  146766. export var depthOfFieldMergePixelShader: {
  146767. name: string;
  146768. shader: string;
  146769. };
  146770. }
  146771. declare module BABYLON {
  146772. /**
  146773. * Options to be set when merging outputs from the default pipeline.
  146774. */
  146775. export class DepthOfFieldMergePostProcessOptions {
  146776. /**
  146777. * The original image to merge on top of
  146778. */
  146779. originalFromInput: PostProcess;
  146780. /**
  146781. * Parameters to perform the merge of the depth of field effect
  146782. */
  146783. depthOfField?: {
  146784. circleOfConfusion: PostProcess;
  146785. blurSteps: Array<PostProcess>;
  146786. };
  146787. /**
  146788. * Parameters to perform the merge of bloom effect
  146789. */
  146790. bloom?: {
  146791. blurred: PostProcess;
  146792. weight: number;
  146793. };
  146794. }
  146795. /**
  146796. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  146797. */
  146798. export class DepthOfFieldMergePostProcess extends PostProcess {
  146799. private blurSteps;
  146800. /**
  146801. * Creates a new instance of DepthOfFieldMergePostProcess
  146802. * @param name The name of the effect.
  146803. * @param originalFromInput Post process which's input will be used for the merge.
  146804. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  146805. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  146806. * @param options The required width/height ratio to downsize to before computing the render pass.
  146807. * @param camera The camera to apply the render pass to.
  146808. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146809. * @param engine The engine which the post process will be applied. (default: current engine)
  146810. * @param reusable If the post process can be reused on the same frame. (default: false)
  146811. * @param textureType Type of textures used when performing the post process. (default: 0)
  146812. * @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)
  146813. */
  146814. 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);
  146815. /**
  146816. * Updates the effect with the current post process compile time values and recompiles the shader.
  146817. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  146818. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  146819. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  146820. * @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
  146821. * @param onCompiled Called when the shader has been compiled.
  146822. * @param onError Called if there is an error when compiling a shader.
  146823. */
  146824. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  146825. }
  146826. }
  146827. declare module BABYLON {
  146828. /**
  146829. * Specifies the level of max blur that should be applied when using the depth of field effect
  146830. */
  146831. export enum DepthOfFieldEffectBlurLevel {
  146832. /**
  146833. * Subtle blur
  146834. */
  146835. Low = 0,
  146836. /**
  146837. * Medium blur
  146838. */
  146839. Medium = 1,
  146840. /**
  146841. * Large blur
  146842. */
  146843. High = 2
  146844. }
  146845. /**
  146846. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  146847. */
  146848. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  146849. private _circleOfConfusion;
  146850. /**
  146851. * @hidden Internal, blurs from high to low
  146852. */
  146853. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  146854. private _depthOfFieldBlurY;
  146855. private _dofMerge;
  146856. /**
  146857. * @hidden Internal post processes in depth of field effect
  146858. */
  146859. _effects: Array<PostProcess>;
  146860. /**
  146861. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  146862. */
  146863. set focalLength(value: number);
  146864. get focalLength(): number;
  146865. /**
  146866. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  146867. */
  146868. set fStop(value: number);
  146869. get fStop(): number;
  146870. /**
  146871. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  146872. */
  146873. set focusDistance(value: number);
  146874. get focusDistance(): number;
  146875. /**
  146876. * 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.
  146877. */
  146878. set lensSize(value: number);
  146879. get lensSize(): number;
  146880. /**
  146881. * Creates a new instance DepthOfFieldEffect
  146882. * @param scene The scene the effect belongs to.
  146883. * @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.
  146884. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  146885. * @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)
  146886. */
  146887. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  146888. /**
  146889. * Get the current class name of the current effet
  146890. * @returns "DepthOfFieldEffect"
  146891. */
  146892. getClassName(): string;
  146893. /**
  146894. * 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.
  146895. */
  146896. set depthTexture(value: RenderTargetTexture);
  146897. /**
  146898. * Disposes each of the internal effects for a given camera.
  146899. * @param camera The camera to dispose the effect on.
  146900. */
  146901. disposeEffects(camera: Camera): void;
  146902. /**
  146903. * @hidden Internal
  146904. */
  146905. _updateEffects(): void;
  146906. /**
  146907. * Internal
  146908. * @returns if all the contained post processes are ready.
  146909. * @hidden
  146910. */
  146911. _isReady(): boolean;
  146912. }
  146913. }
  146914. declare module BABYLON {
  146915. /** @hidden */
  146916. export var displayPassPixelShader: {
  146917. name: string;
  146918. shader: string;
  146919. };
  146920. }
  146921. declare module BABYLON {
  146922. /**
  146923. * DisplayPassPostProcess which produces an output the same as it's input
  146924. */
  146925. export class DisplayPassPostProcess extends PostProcess {
  146926. /**
  146927. * Creates the DisplayPassPostProcess
  146928. * @param name The name of the effect.
  146929. * @param options The required width/height ratio to downsize to before computing the render pass.
  146930. * @param camera The camera to apply the render pass to.
  146931. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146932. * @param engine The engine which the post process will be applied. (default: current engine)
  146933. * @param reusable If the post process can be reused on the same frame. (default: false)
  146934. */
  146935. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146936. }
  146937. }
  146938. declare module BABYLON {
  146939. /** @hidden */
  146940. export var filterPixelShader: {
  146941. name: string;
  146942. shader: string;
  146943. };
  146944. }
  146945. declare module BABYLON {
  146946. /**
  146947. * Applies a kernel filter to the image
  146948. */
  146949. export class FilterPostProcess extends PostProcess {
  146950. /** The matrix to be applied to the image */
  146951. kernelMatrix: Matrix;
  146952. /**
  146953. *
  146954. * @param name The name of the effect.
  146955. * @param kernelMatrix The matrix to be applied to the image
  146956. * @param options The required width/height ratio to downsize to before computing the render pass.
  146957. * @param camera The camera to apply the render pass to.
  146958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  146959. * @param engine The engine which the post process will be applied. (default: current engine)
  146960. * @param reusable If the post process can be reused on the same frame. (default: false)
  146961. */
  146962. constructor(name: string,
  146963. /** The matrix to be applied to the image */
  146964. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  146965. }
  146966. }
  146967. declare module BABYLON {
  146968. /** @hidden */
  146969. export var fxaaPixelShader: {
  146970. name: string;
  146971. shader: string;
  146972. };
  146973. }
  146974. declare module BABYLON {
  146975. /** @hidden */
  146976. export var fxaaVertexShader: {
  146977. name: string;
  146978. shader: string;
  146979. };
  146980. }
  146981. declare module BABYLON {
  146982. /**
  146983. * Fxaa post process
  146984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  146985. */
  146986. export class FxaaPostProcess extends PostProcess {
  146987. /** @hidden */
  146988. texelWidth: number;
  146989. /** @hidden */
  146990. texelHeight: number;
  146991. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  146992. private _getDefines;
  146993. }
  146994. }
  146995. declare module BABYLON {
  146996. /** @hidden */
  146997. export var grainPixelShader: {
  146998. name: string;
  146999. shader: string;
  147000. };
  147001. }
  147002. declare module BABYLON {
  147003. /**
  147004. * The GrainPostProcess adds noise to the image at mid luminance levels
  147005. */
  147006. export class GrainPostProcess extends PostProcess {
  147007. /**
  147008. * The intensity of the grain added (default: 30)
  147009. */
  147010. intensity: number;
  147011. /**
  147012. * If the grain should be randomized on every frame
  147013. */
  147014. animated: boolean;
  147015. /**
  147016. * Creates a new instance of @see GrainPostProcess
  147017. * @param name The name of the effect.
  147018. * @param options The required width/height ratio to downsize to before computing the render pass.
  147019. * @param camera The camera to apply the render pass to.
  147020. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147021. * @param engine The engine which the post process will be applied. (default: current engine)
  147022. * @param reusable If the post process can be reused on the same frame. (default: false)
  147023. * @param textureType Type of textures used when performing the post process. (default: 0)
  147024. * @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)
  147025. */
  147026. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147027. }
  147028. }
  147029. declare module BABYLON {
  147030. /** @hidden */
  147031. export var highlightsPixelShader: {
  147032. name: string;
  147033. shader: string;
  147034. };
  147035. }
  147036. declare module BABYLON {
  147037. /**
  147038. * Extracts highlights from the image
  147039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147040. */
  147041. export class HighlightsPostProcess extends PostProcess {
  147042. /**
  147043. * Extracts highlights from the image
  147044. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  147045. * @param name The name of the effect.
  147046. * @param options The required width/height ratio to downsize to before computing the render pass.
  147047. * @param camera The camera to apply the render pass to.
  147048. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147049. * @param engine The engine which the post process will be applied. (default: current engine)
  147050. * @param reusable If the post process can be reused on the same frame. (default: false)
  147051. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  147052. */
  147053. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  147054. }
  147055. }
  147056. declare module BABYLON {
  147057. /** @hidden */
  147058. export var mrtFragmentDeclaration: {
  147059. name: string;
  147060. shader: string;
  147061. };
  147062. }
  147063. declare module BABYLON {
  147064. /** @hidden */
  147065. export var geometryPixelShader: {
  147066. name: string;
  147067. shader: string;
  147068. };
  147069. }
  147070. declare module BABYLON {
  147071. /** @hidden */
  147072. export var geometryVertexShader: {
  147073. name: string;
  147074. shader: string;
  147075. };
  147076. }
  147077. declare module BABYLON {
  147078. /** @hidden */
  147079. interface ISavedTransformationMatrix {
  147080. world: Matrix;
  147081. viewProjection: Matrix;
  147082. }
  147083. /**
  147084. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  147085. */
  147086. export class GeometryBufferRenderer {
  147087. /**
  147088. * Constant used to retrieve the position texture index in the G-Buffer textures array
  147089. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  147090. */
  147091. static readonly POSITION_TEXTURE_TYPE: number;
  147092. /**
  147093. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  147094. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  147095. */
  147096. static readonly VELOCITY_TEXTURE_TYPE: number;
  147097. /**
  147098. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  147099. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  147100. */
  147101. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  147102. /**
  147103. * Dictionary used to store the previous transformation matrices of each rendered mesh
  147104. * in order to compute objects velocities when enableVelocity is set to "true"
  147105. * @hidden
  147106. */
  147107. _previousTransformationMatrices: {
  147108. [index: number]: ISavedTransformationMatrix;
  147109. };
  147110. /**
  147111. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  147112. * in order to compute objects velocities when enableVelocity is set to "true"
  147113. * @hidden
  147114. */
  147115. _previousBonesTransformationMatrices: {
  147116. [index: number]: Float32Array;
  147117. };
  147118. /**
  147119. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  147120. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  147121. */
  147122. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  147123. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  147124. renderTransparentMeshes: boolean;
  147125. private _scene;
  147126. private _multiRenderTarget;
  147127. private _ratio;
  147128. private _enablePosition;
  147129. private _enableVelocity;
  147130. private _enableReflectivity;
  147131. private _positionIndex;
  147132. private _velocityIndex;
  147133. private _reflectivityIndex;
  147134. protected _effect: Effect;
  147135. protected _cachedDefines: string;
  147136. /**
  147137. * Set the render list (meshes to be rendered) used in the G buffer.
  147138. */
  147139. set renderList(meshes: Mesh[]);
  147140. /**
  147141. * Gets wether or not G buffer are supported by the running hardware.
  147142. * This requires draw buffer supports
  147143. */
  147144. get isSupported(): boolean;
  147145. /**
  147146. * Returns the index of the given texture type in the G-Buffer textures array
  147147. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  147148. * @returns the index of the given texture type in the G-Buffer textures array
  147149. */
  147150. getTextureIndex(textureType: number): number;
  147151. /**
  147152. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  147153. */
  147154. get enablePosition(): boolean;
  147155. /**
  147156. * Sets whether or not objects positions are enabled for the G buffer.
  147157. */
  147158. set enablePosition(enable: boolean);
  147159. /**
  147160. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  147161. */
  147162. get enableVelocity(): boolean;
  147163. /**
  147164. * Sets wether or not objects velocities are enabled for the G buffer.
  147165. */
  147166. set enableVelocity(enable: boolean);
  147167. /**
  147168. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  147169. */
  147170. get enableReflectivity(): boolean;
  147171. /**
  147172. * Sets wether or not objects roughness are enabled for the G buffer.
  147173. */
  147174. set enableReflectivity(enable: boolean);
  147175. /**
  147176. * Gets the scene associated with the buffer.
  147177. */
  147178. get scene(): Scene;
  147179. /**
  147180. * Gets the ratio used by the buffer during its creation.
  147181. * How big is the buffer related to the main canvas.
  147182. */
  147183. get ratio(): number;
  147184. /** @hidden */
  147185. static _SceneComponentInitialization: (scene: Scene) => void;
  147186. /**
  147187. * Creates a new G Buffer for the scene
  147188. * @param scene The scene the buffer belongs to
  147189. * @param ratio How big is the buffer related to the main canvas.
  147190. */
  147191. constructor(scene: Scene, ratio?: number);
  147192. /**
  147193. * Checks wether everything is ready to render a submesh to the G buffer.
  147194. * @param subMesh the submesh to check readiness for
  147195. * @param useInstances is the mesh drawn using instance or not
  147196. * @returns true if ready otherwise false
  147197. */
  147198. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  147199. /**
  147200. * Gets the current underlying G Buffer.
  147201. * @returns the buffer
  147202. */
  147203. getGBuffer(): MultiRenderTarget;
  147204. /**
  147205. * Gets the number of samples used to render the buffer (anti aliasing).
  147206. */
  147207. get samples(): number;
  147208. /**
  147209. * Sets the number of samples used to render the buffer (anti aliasing).
  147210. */
  147211. set samples(value: number);
  147212. /**
  147213. * Disposes the renderer and frees up associated resources.
  147214. */
  147215. dispose(): void;
  147216. protected _createRenderTargets(): void;
  147217. private _copyBonesTransformationMatrices;
  147218. }
  147219. }
  147220. declare module BABYLON {
  147221. interface Scene {
  147222. /** @hidden (Backing field) */
  147223. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147224. /**
  147225. * Gets or Sets the current geometry buffer associated to the scene.
  147226. */
  147227. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  147228. /**
  147229. * Enables a GeometryBufferRender and associates it with the scene
  147230. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  147231. * @returns the GeometryBufferRenderer
  147232. */
  147233. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  147234. /**
  147235. * Disables the GeometryBufferRender associated with the scene
  147236. */
  147237. disableGeometryBufferRenderer(): void;
  147238. }
  147239. /**
  147240. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  147241. * in several rendering techniques.
  147242. */
  147243. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  147244. /**
  147245. * The component name helpful to identify the component in the list of scene components.
  147246. */
  147247. readonly name: string;
  147248. /**
  147249. * The scene the component belongs to.
  147250. */
  147251. scene: Scene;
  147252. /**
  147253. * Creates a new instance of the component for the given scene
  147254. * @param scene Defines the scene to register the component in
  147255. */
  147256. constructor(scene: Scene);
  147257. /**
  147258. * Registers the component in a given scene
  147259. */
  147260. register(): void;
  147261. /**
  147262. * Rebuilds the elements related to this component in case of
  147263. * context lost for instance.
  147264. */
  147265. rebuild(): void;
  147266. /**
  147267. * Disposes the component and the associated ressources
  147268. */
  147269. dispose(): void;
  147270. private _gatherRenderTargets;
  147271. }
  147272. }
  147273. declare module BABYLON {
  147274. /** @hidden */
  147275. export var motionBlurPixelShader: {
  147276. name: string;
  147277. shader: string;
  147278. };
  147279. }
  147280. declare module BABYLON {
  147281. /**
  147282. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  147283. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  147284. * As an example, all you have to do is to create the post-process:
  147285. * var mb = new BABYLON.MotionBlurPostProcess(
  147286. * 'mb', // The name of the effect.
  147287. * scene, // The scene containing the objects to blur according to their velocity.
  147288. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  147289. * camera // The camera to apply the render pass to.
  147290. * );
  147291. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  147292. */
  147293. export class MotionBlurPostProcess extends PostProcess {
  147294. /**
  147295. * Defines how much the image is blurred by the movement. Default value is equal to 1
  147296. */
  147297. motionStrength: number;
  147298. /**
  147299. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  147300. */
  147301. get motionBlurSamples(): number;
  147302. /**
  147303. * Sets the number of iterations to be used for motion blur quality
  147304. */
  147305. set motionBlurSamples(samples: number);
  147306. private _motionBlurSamples;
  147307. private _geometryBufferRenderer;
  147308. /**
  147309. * Creates a new instance MotionBlurPostProcess
  147310. * @param name The name of the effect.
  147311. * @param scene The scene containing the objects to blur according to their velocity.
  147312. * @param options The required width/height ratio to downsize to before computing the render pass.
  147313. * @param camera The camera to apply the render pass to.
  147314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147315. * @param engine The engine which the post process will be applied. (default: current engine)
  147316. * @param reusable If the post process can be reused on the same frame. (default: false)
  147317. * @param textureType Type of textures used when performing the post process. (default: 0)
  147318. * @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)
  147319. */
  147320. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147321. /**
  147322. * Excludes the given skinned mesh from computing bones velocities.
  147323. * 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.
  147324. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  147325. */
  147326. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147327. /**
  147328. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  147329. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  147330. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  147331. */
  147332. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  147333. /**
  147334. * Disposes the post process.
  147335. * @param camera The camera to dispose the post process on.
  147336. */
  147337. dispose(camera?: Camera): void;
  147338. }
  147339. }
  147340. declare module BABYLON {
  147341. /** @hidden */
  147342. export var refractionPixelShader: {
  147343. name: string;
  147344. shader: string;
  147345. };
  147346. }
  147347. declare module BABYLON {
  147348. /**
  147349. * Post process which applies a refractin texture
  147350. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147351. */
  147352. export class RefractionPostProcess extends PostProcess {
  147353. /** the base color of the refraction (used to taint the rendering) */
  147354. color: Color3;
  147355. /** simulated refraction depth */
  147356. depth: number;
  147357. /** the coefficient of the base color (0 to remove base color tainting) */
  147358. colorLevel: number;
  147359. private _refTexture;
  147360. private _ownRefractionTexture;
  147361. /**
  147362. * Gets or sets the refraction texture
  147363. * Please note that you are responsible for disposing the texture if you set it manually
  147364. */
  147365. get refractionTexture(): Texture;
  147366. set refractionTexture(value: Texture);
  147367. /**
  147368. * Initializes the RefractionPostProcess
  147369. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  147370. * @param name The name of the effect.
  147371. * @param refractionTextureUrl Url of the refraction texture to use
  147372. * @param color the base color of the refraction (used to taint the rendering)
  147373. * @param depth simulated refraction depth
  147374. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  147375. * @param camera The camera to apply the render pass to.
  147376. * @param options The required width/height ratio to downsize to before computing the render pass.
  147377. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147378. * @param engine The engine which the post process will be applied. (default: current engine)
  147379. * @param reusable If the post process can be reused on the same frame. (default: false)
  147380. */
  147381. constructor(name: string, refractionTextureUrl: string,
  147382. /** the base color of the refraction (used to taint the rendering) */
  147383. color: Color3,
  147384. /** simulated refraction depth */
  147385. depth: number,
  147386. /** the coefficient of the base color (0 to remove base color tainting) */
  147387. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  147388. /**
  147389. * Disposes of the post process
  147390. * @param camera Camera to dispose post process on
  147391. */
  147392. dispose(camera: Camera): void;
  147393. }
  147394. }
  147395. declare module BABYLON {
  147396. /** @hidden */
  147397. export var sharpenPixelShader: {
  147398. name: string;
  147399. shader: string;
  147400. };
  147401. }
  147402. declare module BABYLON {
  147403. /**
  147404. * The SharpenPostProcess applies a sharpen kernel to every pixel
  147405. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  147406. */
  147407. export class SharpenPostProcess extends PostProcess {
  147408. /**
  147409. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  147410. */
  147411. colorAmount: number;
  147412. /**
  147413. * How much sharpness should be applied (default: 0.3)
  147414. */
  147415. edgeAmount: number;
  147416. /**
  147417. * Creates a new instance ConvolutionPostProcess
  147418. * @param name The name of the effect.
  147419. * @param options The required width/height ratio to downsize to before computing the render pass.
  147420. * @param camera The camera to apply the render pass to.
  147421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  147422. * @param engine The engine which the post process will be applied. (default: current engine)
  147423. * @param reusable If the post process can be reused on the same frame. (default: false)
  147424. * @param textureType Type of textures used when performing the post process. (default: 0)
  147425. * @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)
  147426. */
  147427. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  147428. }
  147429. }
  147430. declare module BABYLON {
  147431. /**
  147432. * PostProcessRenderPipeline
  147433. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147434. */
  147435. export class PostProcessRenderPipeline {
  147436. private engine;
  147437. private _renderEffects;
  147438. private _renderEffectsForIsolatedPass;
  147439. /**
  147440. * List of inspectable custom properties (used by the Inspector)
  147441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  147442. */
  147443. inspectableCustomProperties: IInspectable[];
  147444. /**
  147445. * @hidden
  147446. */
  147447. protected _cameras: Camera[];
  147448. /** @hidden */
  147449. _name: string;
  147450. /**
  147451. * Gets pipeline name
  147452. */
  147453. get name(): string;
  147454. /** Gets the list of attached cameras */
  147455. get cameras(): Camera[];
  147456. /**
  147457. * Initializes a PostProcessRenderPipeline
  147458. * @param engine engine to add the pipeline to
  147459. * @param name name of the pipeline
  147460. */
  147461. constructor(engine: Engine, name: string);
  147462. /**
  147463. * Gets the class name
  147464. * @returns "PostProcessRenderPipeline"
  147465. */
  147466. getClassName(): string;
  147467. /**
  147468. * If all the render effects in the pipeline are supported
  147469. */
  147470. get isSupported(): boolean;
  147471. /**
  147472. * Adds an effect to the pipeline
  147473. * @param renderEffect the effect to add
  147474. */
  147475. addEffect(renderEffect: PostProcessRenderEffect): void;
  147476. /** @hidden */
  147477. _rebuild(): void;
  147478. /** @hidden */
  147479. _enableEffect(renderEffectName: string, cameras: Camera): void;
  147480. /** @hidden */
  147481. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  147482. /** @hidden */
  147483. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147484. /** @hidden */
  147485. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  147486. /** @hidden */
  147487. _attachCameras(cameras: Camera, unique: boolean): void;
  147488. /** @hidden */
  147489. _attachCameras(cameras: Camera[], unique: boolean): void;
  147490. /** @hidden */
  147491. _detachCameras(cameras: Camera): void;
  147492. /** @hidden */
  147493. _detachCameras(cameras: Nullable<Camera[]>): void;
  147494. /** @hidden */
  147495. _update(): void;
  147496. /** @hidden */
  147497. _reset(): void;
  147498. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  147499. /**
  147500. * Disposes of the pipeline
  147501. */
  147502. dispose(): void;
  147503. }
  147504. }
  147505. declare module BABYLON {
  147506. /**
  147507. * PostProcessRenderPipelineManager class
  147508. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147509. */
  147510. export class PostProcessRenderPipelineManager {
  147511. private _renderPipelines;
  147512. /**
  147513. * Initializes a PostProcessRenderPipelineManager
  147514. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147515. */
  147516. constructor();
  147517. /**
  147518. * Gets the list of supported render pipelines
  147519. */
  147520. get supportedPipelines(): PostProcessRenderPipeline[];
  147521. /**
  147522. * Adds a pipeline to the manager
  147523. * @param renderPipeline The pipeline to add
  147524. */
  147525. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  147526. /**
  147527. * Attaches a camera to the pipeline
  147528. * @param renderPipelineName The name of the pipeline to attach to
  147529. * @param cameras the camera to attach
  147530. * @param unique if the camera can be attached multiple times to the pipeline
  147531. */
  147532. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  147533. /**
  147534. * Detaches a camera from the pipeline
  147535. * @param renderPipelineName The name of the pipeline to detach from
  147536. * @param cameras the camera to detach
  147537. */
  147538. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  147539. /**
  147540. * Enables an effect by name on a pipeline
  147541. * @param renderPipelineName the name of the pipeline to enable the effect in
  147542. * @param renderEffectName the name of the effect to enable
  147543. * @param cameras the cameras that the effect should be enabled on
  147544. */
  147545. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147546. /**
  147547. * Disables an effect by name on a pipeline
  147548. * @param renderPipelineName the name of the pipeline to disable the effect in
  147549. * @param renderEffectName the name of the effect to disable
  147550. * @param cameras the cameras that the effect should be disabled on
  147551. */
  147552. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  147553. /**
  147554. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  147555. */
  147556. update(): void;
  147557. /** @hidden */
  147558. _rebuild(): void;
  147559. /**
  147560. * Disposes of the manager and pipelines
  147561. */
  147562. dispose(): void;
  147563. }
  147564. }
  147565. declare module BABYLON {
  147566. interface Scene {
  147567. /** @hidden (Backing field) */
  147568. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147569. /**
  147570. * Gets the postprocess render pipeline manager
  147571. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  147572. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147573. */
  147574. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  147575. }
  147576. /**
  147577. * Defines the Render Pipeline scene component responsible to rendering pipelines
  147578. */
  147579. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  147580. /**
  147581. * The component name helpfull to identify the component in the list of scene components.
  147582. */
  147583. readonly name: string;
  147584. /**
  147585. * The scene the component belongs to.
  147586. */
  147587. scene: Scene;
  147588. /**
  147589. * Creates a new instance of the component for the given scene
  147590. * @param scene Defines the scene to register the component in
  147591. */
  147592. constructor(scene: Scene);
  147593. /**
  147594. * Registers the component in a given scene
  147595. */
  147596. register(): void;
  147597. /**
  147598. * Rebuilds the elements related to this component in case of
  147599. * context lost for instance.
  147600. */
  147601. rebuild(): void;
  147602. /**
  147603. * Disposes the component and the associated ressources
  147604. */
  147605. dispose(): void;
  147606. private _gatherRenderTargets;
  147607. }
  147608. }
  147609. declare module BABYLON {
  147610. /**
  147611. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  147612. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  147613. */
  147614. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  147615. private _scene;
  147616. private _camerasToBeAttached;
  147617. /**
  147618. * ID of the sharpen post process,
  147619. */
  147620. private readonly SharpenPostProcessId;
  147621. /**
  147622. * @ignore
  147623. * ID of the image processing post process;
  147624. */
  147625. readonly ImageProcessingPostProcessId: string;
  147626. /**
  147627. * @ignore
  147628. * ID of the Fast Approximate Anti-Aliasing post process;
  147629. */
  147630. readonly FxaaPostProcessId: string;
  147631. /**
  147632. * ID of the chromatic aberration post process,
  147633. */
  147634. private readonly ChromaticAberrationPostProcessId;
  147635. /**
  147636. * ID of the grain post process
  147637. */
  147638. private readonly GrainPostProcessId;
  147639. /**
  147640. * Sharpen post process which will apply a sharpen convolution to enhance edges
  147641. */
  147642. sharpen: SharpenPostProcess;
  147643. private _sharpenEffect;
  147644. private bloom;
  147645. /**
  147646. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  147647. */
  147648. depthOfField: DepthOfFieldEffect;
  147649. /**
  147650. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  147651. */
  147652. fxaa: FxaaPostProcess;
  147653. /**
  147654. * Image post processing pass used to perform operations such as tone mapping or color grading.
  147655. */
  147656. imageProcessing: ImageProcessingPostProcess;
  147657. /**
  147658. * Chromatic aberration post process which will shift rgb colors in the image
  147659. */
  147660. chromaticAberration: ChromaticAberrationPostProcess;
  147661. private _chromaticAberrationEffect;
  147662. /**
  147663. * Grain post process which add noise to the image
  147664. */
  147665. grain: GrainPostProcess;
  147666. private _grainEffect;
  147667. /**
  147668. * Glow post process which adds a glow to emissive areas of the image
  147669. */
  147670. private _glowLayer;
  147671. /**
  147672. * Animations which can be used to tweak settings over a period of time
  147673. */
  147674. animations: Animation[];
  147675. private _imageProcessingConfigurationObserver;
  147676. private _sharpenEnabled;
  147677. private _bloomEnabled;
  147678. private _depthOfFieldEnabled;
  147679. private _depthOfFieldBlurLevel;
  147680. private _fxaaEnabled;
  147681. private _imageProcessingEnabled;
  147682. private _defaultPipelineTextureType;
  147683. private _bloomScale;
  147684. private _chromaticAberrationEnabled;
  147685. private _grainEnabled;
  147686. private _buildAllowed;
  147687. /**
  147688. * Gets active scene
  147689. */
  147690. get scene(): Scene;
  147691. /**
  147692. * Enable or disable the sharpen process from the pipeline
  147693. */
  147694. set sharpenEnabled(enabled: boolean);
  147695. get sharpenEnabled(): boolean;
  147696. private _resizeObserver;
  147697. private _hardwareScaleLevel;
  147698. private _bloomKernel;
  147699. /**
  147700. * Specifies the size of the bloom blur kernel, relative to the final output size
  147701. */
  147702. get bloomKernel(): number;
  147703. set bloomKernel(value: number);
  147704. /**
  147705. * Specifies the weight of the bloom in the final rendering
  147706. */
  147707. private _bloomWeight;
  147708. /**
  147709. * Specifies the luma threshold for the area that will be blurred by the bloom
  147710. */
  147711. private _bloomThreshold;
  147712. private _hdr;
  147713. /**
  147714. * The strength of the bloom.
  147715. */
  147716. set bloomWeight(value: number);
  147717. get bloomWeight(): number;
  147718. /**
  147719. * The strength of the bloom.
  147720. */
  147721. set bloomThreshold(value: number);
  147722. get bloomThreshold(): number;
  147723. /**
  147724. * The scale of the bloom, lower value will provide better performance.
  147725. */
  147726. set bloomScale(value: number);
  147727. get bloomScale(): number;
  147728. /**
  147729. * Enable or disable the bloom from the pipeline
  147730. */
  147731. set bloomEnabled(enabled: boolean);
  147732. get bloomEnabled(): boolean;
  147733. private _rebuildBloom;
  147734. /**
  147735. * If the depth of field is enabled.
  147736. */
  147737. get depthOfFieldEnabled(): boolean;
  147738. set depthOfFieldEnabled(enabled: boolean);
  147739. /**
  147740. * Blur level of the depth of field effect. (Higher blur will effect performance)
  147741. */
  147742. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  147743. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  147744. /**
  147745. * If the anti aliasing is enabled.
  147746. */
  147747. set fxaaEnabled(enabled: boolean);
  147748. get fxaaEnabled(): boolean;
  147749. private _samples;
  147750. /**
  147751. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  147752. */
  147753. set samples(sampleCount: number);
  147754. get samples(): number;
  147755. /**
  147756. * If image processing is enabled.
  147757. */
  147758. set imageProcessingEnabled(enabled: boolean);
  147759. get imageProcessingEnabled(): boolean;
  147760. /**
  147761. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  147762. */
  147763. set glowLayerEnabled(enabled: boolean);
  147764. get glowLayerEnabled(): boolean;
  147765. /**
  147766. * Gets the glow layer (or null if not defined)
  147767. */
  147768. get glowLayer(): Nullable<GlowLayer>;
  147769. /**
  147770. * Enable or disable the chromaticAberration process from the pipeline
  147771. */
  147772. set chromaticAberrationEnabled(enabled: boolean);
  147773. get chromaticAberrationEnabled(): boolean;
  147774. /**
  147775. * Enable or disable the grain process from the pipeline
  147776. */
  147777. set grainEnabled(enabled: boolean);
  147778. get grainEnabled(): boolean;
  147779. /**
  147780. * @constructor
  147781. * @param name - The rendering pipeline name (default: "")
  147782. * @param hdr - If high dynamic range textures should be used (default: true)
  147783. * @param scene - The scene linked to this pipeline (default: the last created scene)
  147784. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  147785. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  147786. */
  147787. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  147788. /**
  147789. * Get the class name
  147790. * @returns "DefaultRenderingPipeline"
  147791. */
  147792. getClassName(): string;
  147793. /**
  147794. * Force the compilation of the entire pipeline.
  147795. */
  147796. prepare(): void;
  147797. private _hasCleared;
  147798. private _prevPostProcess;
  147799. private _prevPrevPostProcess;
  147800. private _setAutoClearAndTextureSharing;
  147801. private _depthOfFieldSceneObserver;
  147802. private _buildPipeline;
  147803. private _disposePostProcesses;
  147804. /**
  147805. * Adds a camera to the pipeline
  147806. * @param camera the camera to be added
  147807. */
  147808. addCamera(camera: Camera): void;
  147809. /**
  147810. * Removes a camera from the pipeline
  147811. * @param camera the camera to remove
  147812. */
  147813. removeCamera(camera: Camera): void;
  147814. /**
  147815. * Dispose of the pipeline and stop all post processes
  147816. */
  147817. dispose(): void;
  147818. /**
  147819. * Serialize the rendering pipeline (Used when exporting)
  147820. * @returns the serialized object
  147821. */
  147822. serialize(): any;
  147823. /**
  147824. * Parse the serialized pipeline
  147825. * @param source Source pipeline.
  147826. * @param scene The scene to load the pipeline to.
  147827. * @param rootUrl The URL of the serialized pipeline.
  147828. * @returns An instantiated pipeline from the serialized object.
  147829. */
  147830. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  147831. }
  147832. }
  147833. declare module BABYLON {
  147834. /** @hidden */
  147835. export var lensHighlightsPixelShader: {
  147836. name: string;
  147837. shader: string;
  147838. };
  147839. }
  147840. declare module BABYLON {
  147841. /** @hidden */
  147842. export var depthOfFieldPixelShader: {
  147843. name: string;
  147844. shader: string;
  147845. };
  147846. }
  147847. declare module BABYLON {
  147848. /**
  147849. * BABYLON.JS Chromatic Aberration GLSL Shader
  147850. * Author: Olivier Guyot
  147851. * Separates very slightly R, G and B colors on the edges of the screen
  147852. * Inspired by Francois Tarlier & Martins Upitis
  147853. */
  147854. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  147855. /**
  147856. * @ignore
  147857. * The chromatic aberration PostProcess id in the pipeline
  147858. */
  147859. LensChromaticAberrationEffect: string;
  147860. /**
  147861. * @ignore
  147862. * The highlights enhancing PostProcess id in the pipeline
  147863. */
  147864. HighlightsEnhancingEffect: string;
  147865. /**
  147866. * @ignore
  147867. * The depth-of-field PostProcess id in the pipeline
  147868. */
  147869. LensDepthOfFieldEffect: string;
  147870. private _scene;
  147871. private _depthTexture;
  147872. private _grainTexture;
  147873. private _chromaticAberrationPostProcess;
  147874. private _highlightsPostProcess;
  147875. private _depthOfFieldPostProcess;
  147876. private _edgeBlur;
  147877. private _grainAmount;
  147878. private _chromaticAberration;
  147879. private _distortion;
  147880. private _highlightsGain;
  147881. private _highlightsThreshold;
  147882. private _dofDistance;
  147883. private _dofAperture;
  147884. private _dofDarken;
  147885. private _dofPentagon;
  147886. private _blurNoise;
  147887. /**
  147888. * @constructor
  147889. *
  147890. * Effect parameters are as follow:
  147891. * {
  147892. * chromatic_aberration: number; // from 0 to x (1 for realism)
  147893. * edge_blur: number; // from 0 to x (1 for realism)
  147894. * distortion: number; // from 0 to x (1 for realism)
  147895. * grain_amount: number; // from 0 to 1
  147896. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  147897. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  147898. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  147899. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  147900. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  147901. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  147902. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  147903. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  147904. * }
  147905. * Note: if an effect parameter is unset, effect is disabled
  147906. *
  147907. * @param name The rendering pipeline name
  147908. * @param parameters - An object containing all parameters (see above)
  147909. * @param scene The scene linked to this pipeline
  147910. * @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)
  147911. * @param cameras The array of cameras that the rendering pipeline will be attached to
  147912. */
  147913. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  147914. /**
  147915. * Get the class name
  147916. * @returns "LensRenderingPipeline"
  147917. */
  147918. getClassName(): string;
  147919. /**
  147920. * Gets associated scene
  147921. */
  147922. get scene(): Scene;
  147923. /**
  147924. * Gets or sets the edge blur
  147925. */
  147926. get edgeBlur(): number;
  147927. set edgeBlur(value: number);
  147928. /**
  147929. * Gets or sets the grain amount
  147930. */
  147931. get grainAmount(): number;
  147932. set grainAmount(value: number);
  147933. /**
  147934. * Gets or sets the chromatic aberration amount
  147935. */
  147936. get chromaticAberration(): number;
  147937. set chromaticAberration(value: number);
  147938. /**
  147939. * Gets or sets the depth of field aperture
  147940. */
  147941. get dofAperture(): number;
  147942. set dofAperture(value: number);
  147943. /**
  147944. * Gets or sets the edge distortion
  147945. */
  147946. get edgeDistortion(): number;
  147947. set edgeDistortion(value: number);
  147948. /**
  147949. * Gets or sets the depth of field distortion
  147950. */
  147951. get dofDistortion(): number;
  147952. set dofDistortion(value: number);
  147953. /**
  147954. * Gets or sets the darken out of focus amount
  147955. */
  147956. get darkenOutOfFocus(): number;
  147957. set darkenOutOfFocus(value: number);
  147958. /**
  147959. * Gets or sets a boolean indicating if blur noise is enabled
  147960. */
  147961. get blurNoise(): boolean;
  147962. set blurNoise(value: boolean);
  147963. /**
  147964. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  147965. */
  147966. get pentagonBokeh(): boolean;
  147967. set pentagonBokeh(value: boolean);
  147968. /**
  147969. * Gets or sets the highlight grain amount
  147970. */
  147971. get highlightsGain(): number;
  147972. set highlightsGain(value: number);
  147973. /**
  147974. * Gets or sets the highlight threshold
  147975. */
  147976. get highlightsThreshold(): number;
  147977. set highlightsThreshold(value: number);
  147978. /**
  147979. * Sets the amount of blur at the edges
  147980. * @param amount blur amount
  147981. */
  147982. setEdgeBlur(amount: number): void;
  147983. /**
  147984. * Sets edge blur to 0
  147985. */
  147986. disableEdgeBlur(): void;
  147987. /**
  147988. * Sets the amout of grain
  147989. * @param amount Amount of grain
  147990. */
  147991. setGrainAmount(amount: number): void;
  147992. /**
  147993. * Set grain amount to 0
  147994. */
  147995. disableGrain(): void;
  147996. /**
  147997. * Sets the chromatic aberration amount
  147998. * @param amount amount of chromatic aberration
  147999. */
  148000. setChromaticAberration(amount: number): void;
  148001. /**
  148002. * Sets chromatic aberration amount to 0
  148003. */
  148004. disableChromaticAberration(): void;
  148005. /**
  148006. * Sets the EdgeDistortion amount
  148007. * @param amount amount of EdgeDistortion
  148008. */
  148009. setEdgeDistortion(amount: number): void;
  148010. /**
  148011. * Sets edge distortion to 0
  148012. */
  148013. disableEdgeDistortion(): void;
  148014. /**
  148015. * Sets the FocusDistance amount
  148016. * @param amount amount of FocusDistance
  148017. */
  148018. setFocusDistance(amount: number): void;
  148019. /**
  148020. * Disables depth of field
  148021. */
  148022. disableDepthOfField(): void;
  148023. /**
  148024. * Sets the Aperture amount
  148025. * @param amount amount of Aperture
  148026. */
  148027. setAperture(amount: number): void;
  148028. /**
  148029. * Sets the DarkenOutOfFocus amount
  148030. * @param amount amount of DarkenOutOfFocus
  148031. */
  148032. setDarkenOutOfFocus(amount: number): void;
  148033. private _pentagonBokehIsEnabled;
  148034. /**
  148035. * Creates a pentagon bokeh effect
  148036. */
  148037. enablePentagonBokeh(): void;
  148038. /**
  148039. * Disables the pentagon bokeh effect
  148040. */
  148041. disablePentagonBokeh(): void;
  148042. /**
  148043. * Enables noise blur
  148044. */
  148045. enableNoiseBlur(): void;
  148046. /**
  148047. * Disables noise blur
  148048. */
  148049. disableNoiseBlur(): void;
  148050. /**
  148051. * Sets the HighlightsGain amount
  148052. * @param amount amount of HighlightsGain
  148053. */
  148054. setHighlightsGain(amount: number): void;
  148055. /**
  148056. * Sets the HighlightsThreshold amount
  148057. * @param amount amount of HighlightsThreshold
  148058. */
  148059. setHighlightsThreshold(amount: number): void;
  148060. /**
  148061. * Disables highlights
  148062. */
  148063. disableHighlights(): void;
  148064. /**
  148065. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  148066. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  148067. */
  148068. dispose(disableDepthRender?: boolean): void;
  148069. private _createChromaticAberrationPostProcess;
  148070. private _createHighlightsPostProcess;
  148071. private _createDepthOfFieldPostProcess;
  148072. private _createGrainTexture;
  148073. }
  148074. }
  148075. declare module BABYLON {
  148076. /** @hidden */
  148077. export var fibonacci: {
  148078. name: string;
  148079. shader: string;
  148080. };
  148081. }
  148082. declare module BABYLON {
  148083. /** @hidden */
  148084. export var diffusionProfile: {
  148085. name: string;
  148086. shader: string;
  148087. };
  148088. }
  148089. declare module BABYLON {
  148090. /** @hidden */
  148091. export var subSurfaceScatteringPixelShader: {
  148092. name: string;
  148093. shader: string;
  148094. };
  148095. }
  148096. declare module BABYLON {
  148097. /**
  148098. * Sub surface scattering post process
  148099. */
  148100. export class SubSurfaceScatteringPostProcess extends PostProcess {
  148101. /** @hidden */
  148102. texelWidth: number;
  148103. /** @hidden */
  148104. texelHeight: number;
  148105. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  148106. }
  148107. }
  148108. declare module BABYLON {
  148109. /**
  148110. * Interface for defining prepass effects in the prepass post-process pipeline
  148111. */
  148112. export interface PrePassEffectConfiguration {
  148113. /**
  148114. * Post process to attach for this effect
  148115. */
  148116. postProcess: PostProcess;
  148117. /**
  148118. * Is the effect enabled
  148119. */
  148120. enabled: boolean;
  148121. /**
  148122. * Disposes the effect configuration
  148123. */
  148124. dispose(): void;
  148125. /**
  148126. * Disposes the effect configuration
  148127. */
  148128. createPostProcess: () => PostProcess;
  148129. }
  148130. }
  148131. declare module BABYLON {
  148132. /**
  148133. * Contains all parameters needed for the prepass to perform
  148134. * screen space subsurface scattering
  148135. */
  148136. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  148137. private _ssDiffusionS;
  148138. private _ssFilterRadii;
  148139. private _ssDiffusionD;
  148140. /**
  148141. * Post process to attach for screen space subsurface scattering
  148142. */
  148143. postProcess: SubSurfaceScatteringPostProcess;
  148144. /**
  148145. * Diffusion profile color for subsurface scattering
  148146. */
  148147. get ssDiffusionS(): number[];
  148148. /**
  148149. * Diffusion profile max color channel value for subsurface scattering
  148150. */
  148151. get ssDiffusionD(): number[];
  148152. /**
  148153. * Diffusion profile filter radius for subsurface scattering
  148154. */
  148155. get ssFilterRadii(): number[];
  148156. /**
  148157. * Is subsurface enabled
  148158. */
  148159. enabled: boolean;
  148160. /**
  148161. * Diffusion profile colors for subsurface scattering
  148162. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  148163. * See ...
  148164. * Note that you can only store up to 5 of them
  148165. */
  148166. ssDiffusionProfileColors: Color3[];
  148167. /**
  148168. * Defines the ratio real world => scene units.
  148169. * Used for subsurface scattering
  148170. */
  148171. metersPerUnit: number;
  148172. private _scene;
  148173. /**
  148174. * Builds a subsurface configuration object
  148175. * @param scene The scene
  148176. */
  148177. constructor(scene: Scene);
  148178. /**
  148179. * Adds a new diffusion profile.
  148180. * Useful for more realistic subsurface scattering on diverse materials.
  148181. * @param color The color of the diffusion profile. Should be the average color of the material.
  148182. * @return The index of the diffusion profile for the material subsurface configuration
  148183. */
  148184. addDiffusionProfile(color: Color3): number;
  148185. /**
  148186. * Creates the sss post process
  148187. * @return The created post process
  148188. */
  148189. createPostProcess(): SubSurfaceScatteringPostProcess;
  148190. /**
  148191. * Deletes all diffusion profiles.
  148192. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  148193. */
  148194. clearAllDiffusionProfiles(): void;
  148195. /**
  148196. * Disposes this object
  148197. */
  148198. dispose(): void;
  148199. /**
  148200. * @hidden
  148201. * https://zero-radiance.github.io/post/sampling-diffusion/
  148202. *
  148203. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  148204. * ------------------------------------------------------------------------------------
  148205. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  148206. * PDF[r, phi, s] = r * R[r, phi, s]
  148207. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  148208. * ------------------------------------------------------------------------------------
  148209. * We importance sample the color channel with the widest scattering distance.
  148210. */
  148211. getDiffusionProfileParameters(color: Color3): number;
  148212. /**
  148213. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  148214. * 'u' is the random number (the value of the CDF): [0, 1).
  148215. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  148216. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  148217. */
  148218. private _sampleBurleyDiffusionProfile;
  148219. }
  148220. }
  148221. declare module BABYLON {
  148222. /**
  148223. * Renders a pre pass of the scene
  148224. * This means every mesh in the scene will be rendered to a render target texture
  148225. * And then this texture will be composited to the rendering canvas with post processes
  148226. * It is necessary for effects like subsurface scattering or deferred shading
  148227. */
  148228. export class PrePassRenderer {
  148229. /** @hidden */
  148230. static _SceneComponentInitialization: (scene: Scene) => void;
  148231. private _scene;
  148232. private _engine;
  148233. private _isDirty;
  148234. /**
  148235. * Number of textures in the multi render target texture where the scene is directly rendered
  148236. */
  148237. readonly mrtCount: number;
  148238. /**
  148239. * The render target where the scene is directly rendered
  148240. */
  148241. prePassRT: MultiRenderTarget;
  148242. private _mrtTypes;
  148243. private _multiRenderAttachments;
  148244. private _defaultAttachments;
  148245. private _clearAttachments;
  148246. private _postProcesses;
  148247. private readonly _clearColor;
  148248. /**
  148249. * Image processing post process for composition
  148250. */
  148251. imageProcessingPostProcess: ImageProcessingPostProcess;
  148252. /**
  148253. * Configuration for sub surface scattering post process
  148254. */
  148255. subSurfaceConfiguration: SubSurfaceConfiguration;
  148256. /**
  148257. * Should materials render their geometry on the MRT
  148258. */
  148259. materialsShouldRenderGeometry: boolean;
  148260. /**
  148261. * Should materials render the irradiance information on the MRT
  148262. */
  148263. materialsShouldRenderIrradiance: boolean;
  148264. private _enabled;
  148265. /**
  148266. * Indicates if the prepass is enabled
  148267. */
  148268. get enabled(): boolean;
  148269. /**
  148270. * How many samples are used for MSAA of the scene render target
  148271. */
  148272. get samples(): number;
  148273. set samples(n: number);
  148274. /**
  148275. * Instanciates a prepass renderer
  148276. * @param scene The scene
  148277. */
  148278. constructor(scene: Scene);
  148279. private _initializeAttachments;
  148280. private _createCompositionEffect;
  148281. /**
  148282. * Indicates if rendering a prepass is supported
  148283. */
  148284. get isSupported(): boolean;
  148285. /**
  148286. * Sets the proper output textures to draw in the engine.
  148287. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  148288. */
  148289. bindAttachmentsForEffect(effect: Effect): void;
  148290. /**
  148291. * @hidden
  148292. */
  148293. _beforeCameraDraw(): void;
  148294. /**
  148295. * @hidden
  148296. */
  148297. _afterCameraDraw(): void;
  148298. private _checkRTSize;
  148299. private _bindFrameBuffer;
  148300. /**
  148301. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  148302. */
  148303. clear(): void;
  148304. private _setState;
  148305. private _enable;
  148306. private _disable;
  148307. private _resetPostProcessChain;
  148308. private _bindPostProcessChain;
  148309. /**
  148310. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  148311. */
  148312. markAsDirty(): void;
  148313. private _update;
  148314. /**
  148315. * Disposes the prepass renderer.
  148316. */
  148317. dispose(): void;
  148318. }
  148319. }
  148320. declare module BABYLON {
  148321. /** @hidden */
  148322. export var ssao2PixelShader: {
  148323. name: string;
  148324. shader: string;
  148325. };
  148326. }
  148327. declare module BABYLON {
  148328. /** @hidden */
  148329. export var ssaoCombinePixelShader: {
  148330. name: string;
  148331. shader: string;
  148332. };
  148333. }
  148334. declare module BABYLON {
  148335. /**
  148336. * Render pipeline to produce ssao effect
  148337. */
  148338. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  148339. /**
  148340. * @ignore
  148341. * The PassPostProcess id in the pipeline that contains the original scene color
  148342. */
  148343. SSAOOriginalSceneColorEffect: string;
  148344. /**
  148345. * @ignore
  148346. * The SSAO PostProcess id in the pipeline
  148347. */
  148348. SSAORenderEffect: string;
  148349. /**
  148350. * @ignore
  148351. * The horizontal blur PostProcess id in the pipeline
  148352. */
  148353. SSAOBlurHRenderEffect: string;
  148354. /**
  148355. * @ignore
  148356. * The vertical blur PostProcess id in the pipeline
  148357. */
  148358. SSAOBlurVRenderEffect: string;
  148359. /**
  148360. * @ignore
  148361. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148362. */
  148363. SSAOCombineRenderEffect: string;
  148364. /**
  148365. * The output strength of the SSAO post-process. Default value is 1.0.
  148366. */
  148367. totalStrength: number;
  148368. /**
  148369. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  148370. */
  148371. maxZ: number;
  148372. /**
  148373. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  148374. */
  148375. minZAspect: number;
  148376. private _samples;
  148377. /**
  148378. * Number of samples used for the SSAO calculations. Default value is 8
  148379. */
  148380. set samples(n: number);
  148381. get samples(): number;
  148382. private _textureSamples;
  148383. /**
  148384. * Number of samples to use for antialiasing
  148385. */
  148386. set textureSamples(n: number);
  148387. get textureSamples(): number;
  148388. /**
  148389. * Force rendering the geometry through geometry buffer
  148390. */
  148391. private _forceGeometryBuffer;
  148392. /**
  148393. * Ratio object used for SSAO ratio and blur ratio
  148394. */
  148395. private _ratio;
  148396. /**
  148397. * Dynamically generated sphere sampler.
  148398. */
  148399. private _sampleSphere;
  148400. /**
  148401. * Blur filter offsets
  148402. */
  148403. private _samplerOffsets;
  148404. private _expensiveBlur;
  148405. /**
  148406. * If bilateral blur should be used
  148407. */
  148408. set expensiveBlur(b: boolean);
  148409. get expensiveBlur(): boolean;
  148410. /**
  148411. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  148412. */
  148413. radius: number;
  148414. /**
  148415. * The base color of the SSAO post-process
  148416. * The final result is "base + ssao" between [0, 1]
  148417. */
  148418. base: number;
  148419. /**
  148420. * Support test.
  148421. */
  148422. static get IsSupported(): boolean;
  148423. private _scene;
  148424. private _randomTexture;
  148425. private _originalColorPostProcess;
  148426. private _ssaoPostProcess;
  148427. private _blurHPostProcess;
  148428. private _blurVPostProcess;
  148429. private _ssaoCombinePostProcess;
  148430. private _prePassRenderer;
  148431. /**
  148432. * Gets active scene
  148433. */
  148434. get scene(): Scene;
  148435. /**
  148436. * @constructor
  148437. * @param name The rendering pipeline name
  148438. * @param scene The scene linked to this pipeline
  148439. * @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 }
  148440. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148441. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  148442. */
  148443. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  148444. /**
  148445. * Get the class name
  148446. * @returns "SSAO2RenderingPipeline"
  148447. */
  148448. getClassName(): string;
  148449. /**
  148450. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148451. */
  148452. dispose(disableGeometryBufferRenderer?: boolean): void;
  148453. private _createBlurPostProcess;
  148454. /** @hidden */
  148455. _rebuild(): void;
  148456. private _bits;
  148457. private _radicalInverse_VdC;
  148458. private _hammersley;
  148459. private _hemisphereSample_uniform;
  148460. private _generateHemisphere;
  148461. private _getDefinesForSSAO;
  148462. private _createSSAOPostProcess;
  148463. private _createSSAOCombinePostProcess;
  148464. private _createRandomTexture;
  148465. /**
  148466. * Serialize the rendering pipeline (Used when exporting)
  148467. * @returns the serialized object
  148468. */
  148469. serialize(): any;
  148470. /**
  148471. * Parse the serialized pipeline
  148472. * @param source Source pipeline.
  148473. * @param scene The scene to load the pipeline to.
  148474. * @param rootUrl The URL of the serialized pipeline.
  148475. * @returns An instantiated pipeline from the serialized object.
  148476. */
  148477. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  148478. }
  148479. }
  148480. declare module BABYLON {
  148481. /** @hidden */
  148482. export var ssaoPixelShader: {
  148483. name: string;
  148484. shader: string;
  148485. };
  148486. }
  148487. declare module BABYLON {
  148488. /**
  148489. * Render pipeline to produce ssao effect
  148490. */
  148491. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  148492. /**
  148493. * @ignore
  148494. * The PassPostProcess id in the pipeline that contains the original scene color
  148495. */
  148496. SSAOOriginalSceneColorEffect: string;
  148497. /**
  148498. * @ignore
  148499. * The SSAO PostProcess id in the pipeline
  148500. */
  148501. SSAORenderEffect: string;
  148502. /**
  148503. * @ignore
  148504. * The horizontal blur PostProcess id in the pipeline
  148505. */
  148506. SSAOBlurHRenderEffect: string;
  148507. /**
  148508. * @ignore
  148509. * The vertical blur PostProcess id in the pipeline
  148510. */
  148511. SSAOBlurVRenderEffect: string;
  148512. /**
  148513. * @ignore
  148514. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  148515. */
  148516. SSAOCombineRenderEffect: string;
  148517. /**
  148518. * The output strength of the SSAO post-process. Default value is 1.0.
  148519. */
  148520. totalStrength: number;
  148521. /**
  148522. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  148523. */
  148524. radius: number;
  148525. /**
  148526. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  148527. * Must not be equal to fallOff and superior to fallOff.
  148528. * Default value is 0.0075
  148529. */
  148530. area: number;
  148531. /**
  148532. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  148533. * Must not be equal to area and inferior to area.
  148534. * Default value is 0.000001
  148535. */
  148536. fallOff: number;
  148537. /**
  148538. * The base color of the SSAO post-process
  148539. * The final result is "base + ssao" between [0, 1]
  148540. */
  148541. base: number;
  148542. private _scene;
  148543. private _depthTexture;
  148544. private _randomTexture;
  148545. private _originalColorPostProcess;
  148546. private _ssaoPostProcess;
  148547. private _blurHPostProcess;
  148548. private _blurVPostProcess;
  148549. private _ssaoCombinePostProcess;
  148550. private _firstUpdate;
  148551. /**
  148552. * Gets active scene
  148553. */
  148554. get scene(): Scene;
  148555. /**
  148556. * @constructor
  148557. * @param name - The rendering pipeline name
  148558. * @param scene - The scene linked to this pipeline
  148559. * @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 }
  148560. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  148561. */
  148562. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  148563. /**
  148564. * Get the class name
  148565. * @returns "SSAORenderingPipeline"
  148566. */
  148567. getClassName(): string;
  148568. /**
  148569. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  148570. */
  148571. dispose(disableDepthRender?: boolean): void;
  148572. private _createBlurPostProcess;
  148573. /** @hidden */
  148574. _rebuild(): void;
  148575. private _createSSAOPostProcess;
  148576. private _createSSAOCombinePostProcess;
  148577. private _createRandomTexture;
  148578. }
  148579. }
  148580. declare module BABYLON {
  148581. /** @hidden */
  148582. export var screenSpaceReflectionPixelShader: {
  148583. name: string;
  148584. shader: string;
  148585. };
  148586. }
  148587. declare module BABYLON {
  148588. /**
  148589. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  148590. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  148591. */
  148592. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  148593. /**
  148594. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  148595. */
  148596. threshold: number;
  148597. /**
  148598. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  148599. */
  148600. strength: number;
  148601. /**
  148602. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  148603. */
  148604. reflectionSpecularFalloffExponent: number;
  148605. /**
  148606. * 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]
  148607. */
  148608. step: number;
  148609. /**
  148610. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  148611. */
  148612. roughnessFactor: number;
  148613. private _geometryBufferRenderer;
  148614. private _enableSmoothReflections;
  148615. private _reflectionSamples;
  148616. private _smoothSteps;
  148617. /**
  148618. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  148619. * @param name The name of the effect.
  148620. * @param scene The scene containing the objects to calculate reflections.
  148621. * @param options The required width/height ratio to downsize to before computing the render pass.
  148622. * @param camera The camera to apply the render pass to.
  148623. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  148624. * @param engine The engine which the post process will be applied. (default: current engine)
  148625. * @param reusable If the post process can be reused on the same frame. (default: false)
  148626. * @param textureType Type of textures used when performing the post process. (default: 0)
  148627. * @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)
  148628. */
  148629. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  148630. /**
  148631. * Gets wether or not smoothing reflections is enabled.
  148632. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148633. */
  148634. get enableSmoothReflections(): boolean;
  148635. /**
  148636. * Sets wether or not smoothing reflections is enabled.
  148637. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  148638. */
  148639. set enableSmoothReflections(enabled: boolean);
  148640. /**
  148641. * Gets the number of samples taken while computing reflections. More samples count is high,
  148642. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148643. */
  148644. get reflectionSamples(): number;
  148645. /**
  148646. * Sets the number of samples taken while computing reflections. More samples count is high,
  148647. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  148648. */
  148649. set reflectionSamples(samples: number);
  148650. /**
  148651. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  148652. * more the post-process will require GPU power and can generate a drop in FPS.
  148653. * Default value (5.0) work pretty well in all cases but can be adjusted.
  148654. */
  148655. get smoothSteps(): number;
  148656. set smoothSteps(steps: number);
  148657. private _updateEffectDefines;
  148658. }
  148659. }
  148660. declare module BABYLON {
  148661. /** @hidden */
  148662. export var standardPixelShader: {
  148663. name: string;
  148664. shader: string;
  148665. };
  148666. }
  148667. declare module BABYLON {
  148668. /**
  148669. * Standard rendering pipeline
  148670. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148671. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  148672. */
  148673. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  148674. /**
  148675. * Public members
  148676. */
  148677. /**
  148678. * Post-process which contains the original scene color before the pipeline applies all the effects
  148679. */
  148680. originalPostProcess: Nullable<PostProcess>;
  148681. /**
  148682. * Post-process used to down scale an image x4
  148683. */
  148684. downSampleX4PostProcess: Nullable<PostProcess>;
  148685. /**
  148686. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  148687. */
  148688. brightPassPostProcess: Nullable<PostProcess>;
  148689. /**
  148690. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  148691. */
  148692. blurHPostProcesses: PostProcess[];
  148693. /**
  148694. * Post-process array storing all the vertical blur post-processes used by the pipeline
  148695. */
  148696. blurVPostProcesses: PostProcess[];
  148697. /**
  148698. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  148699. */
  148700. textureAdderPostProcess: Nullable<PostProcess>;
  148701. /**
  148702. * Post-process used to create volumetric lighting effect
  148703. */
  148704. volumetricLightPostProcess: Nullable<PostProcess>;
  148705. /**
  148706. * Post-process used to smooth the previous volumetric light post-process on the X axis
  148707. */
  148708. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  148709. /**
  148710. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  148711. */
  148712. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  148713. /**
  148714. * Post-process used to merge the volumetric light effect and the real scene color
  148715. */
  148716. volumetricLightMergePostProces: Nullable<PostProcess>;
  148717. /**
  148718. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  148719. */
  148720. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  148721. /**
  148722. * Base post-process used to calculate the average luminance of the final image for HDR
  148723. */
  148724. luminancePostProcess: Nullable<PostProcess>;
  148725. /**
  148726. * Post-processes used to create down sample post-processes in order to get
  148727. * the average luminance of the final image for HDR
  148728. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  148729. */
  148730. luminanceDownSamplePostProcesses: PostProcess[];
  148731. /**
  148732. * Post-process used to create a HDR effect (light adaptation)
  148733. */
  148734. hdrPostProcess: Nullable<PostProcess>;
  148735. /**
  148736. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  148737. */
  148738. textureAdderFinalPostProcess: Nullable<PostProcess>;
  148739. /**
  148740. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  148741. */
  148742. lensFlareFinalPostProcess: Nullable<PostProcess>;
  148743. /**
  148744. * Post-process used to merge the final HDR post-process and the real scene color
  148745. */
  148746. hdrFinalPostProcess: Nullable<PostProcess>;
  148747. /**
  148748. * Post-process used to create a lens flare effect
  148749. */
  148750. lensFlarePostProcess: Nullable<PostProcess>;
  148751. /**
  148752. * Post-process that merges the result of the lens flare post-process and the real scene color
  148753. */
  148754. lensFlareComposePostProcess: Nullable<PostProcess>;
  148755. /**
  148756. * Post-process used to create a motion blur effect
  148757. */
  148758. motionBlurPostProcess: Nullable<PostProcess>;
  148759. /**
  148760. * Post-process used to create a depth of field effect
  148761. */
  148762. depthOfFieldPostProcess: Nullable<PostProcess>;
  148763. /**
  148764. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  148765. */
  148766. fxaaPostProcess: Nullable<FxaaPostProcess>;
  148767. /**
  148768. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  148769. */
  148770. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  148771. /**
  148772. * Represents the brightness threshold in order to configure the illuminated surfaces
  148773. */
  148774. brightThreshold: number;
  148775. /**
  148776. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  148777. */
  148778. blurWidth: number;
  148779. /**
  148780. * Sets if the blur for highlighted surfaces must be only horizontal
  148781. */
  148782. horizontalBlur: boolean;
  148783. /**
  148784. * Gets the overall exposure used by the pipeline
  148785. */
  148786. get exposure(): number;
  148787. /**
  148788. * Sets the overall exposure used by the pipeline
  148789. */
  148790. set exposure(value: number);
  148791. /**
  148792. * Texture used typically to simulate "dirty" on camera lens
  148793. */
  148794. lensTexture: Nullable<Texture>;
  148795. /**
  148796. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  148797. */
  148798. volumetricLightCoefficient: number;
  148799. /**
  148800. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  148801. */
  148802. volumetricLightPower: number;
  148803. /**
  148804. * Used the set the blur intensity to smooth the volumetric lights
  148805. */
  148806. volumetricLightBlurScale: number;
  148807. /**
  148808. * Light (spot or directional) used to generate the volumetric lights rays
  148809. * The source light must have a shadow generate so the pipeline can get its
  148810. * depth map
  148811. */
  148812. sourceLight: Nullable<SpotLight | DirectionalLight>;
  148813. /**
  148814. * For eye adaptation, represents the minimum luminance the eye can see
  148815. */
  148816. hdrMinimumLuminance: number;
  148817. /**
  148818. * For eye adaptation, represents the decrease luminance speed
  148819. */
  148820. hdrDecreaseRate: number;
  148821. /**
  148822. * For eye adaptation, represents the increase luminance speed
  148823. */
  148824. hdrIncreaseRate: number;
  148825. /**
  148826. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148827. */
  148828. get hdrAutoExposure(): boolean;
  148829. /**
  148830. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  148831. */
  148832. set hdrAutoExposure(value: boolean);
  148833. /**
  148834. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  148835. */
  148836. lensColorTexture: Nullable<Texture>;
  148837. /**
  148838. * The overall strengh for the lens flare effect
  148839. */
  148840. lensFlareStrength: number;
  148841. /**
  148842. * Dispersion coefficient for lens flare ghosts
  148843. */
  148844. lensFlareGhostDispersal: number;
  148845. /**
  148846. * Main lens flare halo width
  148847. */
  148848. lensFlareHaloWidth: number;
  148849. /**
  148850. * Based on the lens distortion effect, defines how much the lens flare result
  148851. * is distorted
  148852. */
  148853. lensFlareDistortionStrength: number;
  148854. /**
  148855. * Configures the blur intensity used for for lens flare (halo)
  148856. */
  148857. lensFlareBlurWidth: number;
  148858. /**
  148859. * Lens star texture must be used to simulate rays on the flares and is available
  148860. * in the documentation
  148861. */
  148862. lensStarTexture: Nullable<Texture>;
  148863. /**
  148864. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  148865. * flare effect by taking account of the dirt texture
  148866. */
  148867. lensFlareDirtTexture: Nullable<Texture>;
  148868. /**
  148869. * Represents the focal length for the depth of field effect
  148870. */
  148871. depthOfFieldDistance: number;
  148872. /**
  148873. * Represents the blur intensity for the blurred part of the depth of field effect
  148874. */
  148875. depthOfFieldBlurWidth: number;
  148876. /**
  148877. * Gets how much the image is blurred by the movement while using the motion blur post-process
  148878. */
  148879. get motionStrength(): number;
  148880. /**
  148881. * Sets how much the image is blurred by the movement while using the motion blur post-process
  148882. */
  148883. set motionStrength(strength: number);
  148884. /**
  148885. * Gets wether or not the motion blur post-process is object based or screen based.
  148886. */
  148887. get objectBasedMotionBlur(): boolean;
  148888. /**
  148889. * Sets wether or not the motion blur post-process should be object based or screen based
  148890. */
  148891. set objectBasedMotionBlur(value: boolean);
  148892. /**
  148893. * List of animations for the pipeline (IAnimatable implementation)
  148894. */
  148895. animations: Animation[];
  148896. /**
  148897. * Private members
  148898. */
  148899. private _scene;
  148900. private _currentDepthOfFieldSource;
  148901. private _basePostProcess;
  148902. private _fixedExposure;
  148903. private _currentExposure;
  148904. private _hdrAutoExposure;
  148905. private _hdrCurrentLuminance;
  148906. private _motionStrength;
  148907. private _isObjectBasedMotionBlur;
  148908. private _floatTextureType;
  148909. private _camerasToBeAttached;
  148910. private _ratio;
  148911. private _bloomEnabled;
  148912. private _depthOfFieldEnabled;
  148913. private _vlsEnabled;
  148914. private _lensFlareEnabled;
  148915. private _hdrEnabled;
  148916. private _motionBlurEnabled;
  148917. private _fxaaEnabled;
  148918. private _screenSpaceReflectionsEnabled;
  148919. private _motionBlurSamples;
  148920. private _volumetricLightStepsCount;
  148921. private _samples;
  148922. /**
  148923. * @ignore
  148924. * Specifies if the bloom pipeline is enabled
  148925. */
  148926. get BloomEnabled(): boolean;
  148927. set BloomEnabled(enabled: boolean);
  148928. /**
  148929. * @ignore
  148930. * Specifies if the depth of field pipeline is enabed
  148931. */
  148932. get DepthOfFieldEnabled(): boolean;
  148933. set DepthOfFieldEnabled(enabled: boolean);
  148934. /**
  148935. * @ignore
  148936. * Specifies if the lens flare pipeline is enabed
  148937. */
  148938. get LensFlareEnabled(): boolean;
  148939. set LensFlareEnabled(enabled: boolean);
  148940. /**
  148941. * @ignore
  148942. * Specifies if the HDR pipeline is enabled
  148943. */
  148944. get HDREnabled(): boolean;
  148945. set HDREnabled(enabled: boolean);
  148946. /**
  148947. * @ignore
  148948. * Specifies if the volumetric lights scattering effect is enabled
  148949. */
  148950. get VLSEnabled(): boolean;
  148951. set VLSEnabled(enabled: boolean);
  148952. /**
  148953. * @ignore
  148954. * Specifies if the motion blur effect is enabled
  148955. */
  148956. get MotionBlurEnabled(): boolean;
  148957. set MotionBlurEnabled(enabled: boolean);
  148958. /**
  148959. * Specifies if anti-aliasing is enabled
  148960. */
  148961. get fxaaEnabled(): boolean;
  148962. set fxaaEnabled(enabled: boolean);
  148963. /**
  148964. * Specifies if screen space reflections are enabled.
  148965. */
  148966. get screenSpaceReflectionsEnabled(): boolean;
  148967. set screenSpaceReflectionsEnabled(enabled: boolean);
  148968. /**
  148969. * Specifies the number of steps used to calculate the volumetric lights
  148970. * Typically in interval [50, 200]
  148971. */
  148972. get volumetricLightStepsCount(): number;
  148973. set volumetricLightStepsCount(count: number);
  148974. /**
  148975. * Specifies the number of samples used for the motion blur effect
  148976. * Typically in interval [16, 64]
  148977. */
  148978. get motionBlurSamples(): number;
  148979. set motionBlurSamples(samples: number);
  148980. /**
  148981. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  148982. */
  148983. get samples(): number;
  148984. set samples(sampleCount: number);
  148985. /**
  148986. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  148987. * @constructor
  148988. * @param name The rendering pipeline name
  148989. * @param scene The scene linked to this pipeline
  148990. * @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)
  148991. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  148992. * @param cameras The array of cameras that the rendering pipeline will be attached to
  148993. */
  148994. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  148995. private _buildPipeline;
  148996. private _createDownSampleX4PostProcess;
  148997. private _createBrightPassPostProcess;
  148998. private _createBlurPostProcesses;
  148999. private _createTextureAdderPostProcess;
  149000. private _createVolumetricLightPostProcess;
  149001. private _createLuminancePostProcesses;
  149002. private _createHdrPostProcess;
  149003. private _createLensFlarePostProcess;
  149004. private _createDepthOfFieldPostProcess;
  149005. private _createMotionBlurPostProcess;
  149006. private _getDepthTexture;
  149007. private _disposePostProcesses;
  149008. /**
  149009. * Dispose of the pipeline and stop all post processes
  149010. */
  149011. dispose(): void;
  149012. /**
  149013. * Serialize the rendering pipeline (Used when exporting)
  149014. * @returns the serialized object
  149015. */
  149016. serialize(): any;
  149017. /**
  149018. * Parse the serialized pipeline
  149019. * @param source Source pipeline.
  149020. * @param scene The scene to load the pipeline to.
  149021. * @param rootUrl The URL of the serialized pipeline.
  149022. * @returns An instantiated pipeline from the serialized object.
  149023. */
  149024. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  149025. /**
  149026. * Luminance steps
  149027. */
  149028. static LuminanceSteps: number;
  149029. }
  149030. }
  149031. declare module BABYLON {
  149032. /** @hidden */
  149033. export var stereoscopicInterlacePixelShader: {
  149034. name: string;
  149035. shader: string;
  149036. };
  149037. }
  149038. declare module BABYLON {
  149039. /**
  149040. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  149041. */
  149042. export class StereoscopicInterlacePostProcessI extends PostProcess {
  149043. private _stepSize;
  149044. private _passedProcess;
  149045. /**
  149046. * Initializes a StereoscopicInterlacePostProcessI
  149047. * @param name The name of the effect.
  149048. * @param rigCameras The rig cameras to be appled to the post process
  149049. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  149050. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  149051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149052. * @param engine The engine which the post process will be applied. (default: current engine)
  149053. * @param reusable If the post process can be reused on the same frame. (default: false)
  149054. */
  149055. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149056. }
  149057. /**
  149058. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  149059. */
  149060. export class StereoscopicInterlacePostProcess extends PostProcess {
  149061. private _stepSize;
  149062. private _passedProcess;
  149063. /**
  149064. * Initializes a StereoscopicInterlacePostProcess
  149065. * @param name The name of the effect.
  149066. * @param rigCameras The rig cameras to be appled to the post process
  149067. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  149068. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149069. * @param engine The engine which the post process will be applied. (default: current engine)
  149070. * @param reusable If the post process can be reused on the same frame. (default: false)
  149071. */
  149072. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149073. }
  149074. }
  149075. declare module BABYLON {
  149076. /** @hidden */
  149077. export var tonemapPixelShader: {
  149078. name: string;
  149079. shader: string;
  149080. };
  149081. }
  149082. declare module BABYLON {
  149083. /** Defines operator used for tonemapping */
  149084. export enum TonemappingOperator {
  149085. /** Hable */
  149086. Hable = 0,
  149087. /** Reinhard */
  149088. Reinhard = 1,
  149089. /** HejiDawson */
  149090. HejiDawson = 2,
  149091. /** Photographic */
  149092. Photographic = 3
  149093. }
  149094. /**
  149095. * Defines a post process to apply tone mapping
  149096. */
  149097. export class TonemapPostProcess extends PostProcess {
  149098. private _operator;
  149099. /** Defines the required exposure adjustement */
  149100. exposureAdjustment: number;
  149101. /**
  149102. * Creates a new TonemapPostProcess
  149103. * @param name defines the name of the postprocess
  149104. * @param _operator defines the operator to use
  149105. * @param exposureAdjustment defines the required exposure adjustement
  149106. * @param camera defines the camera to use (can be null)
  149107. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  149108. * @param engine defines the hosting engine (can be ignore if camera is set)
  149109. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  149110. */
  149111. constructor(name: string, _operator: TonemappingOperator,
  149112. /** Defines the required exposure adjustement */
  149113. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  149114. }
  149115. }
  149116. declare module BABYLON {
  149117. /** @hidden */
  149118. export var volumetricLightScatteringPixelShader: {
  149119. name: string;
  149120. shader: string;
  149121. };
  149122. }
  149123. declare module BABYLON {
  149124. /** @hidden */
  149125. export var volumetricLightScatteringPassVertexShader: {
  149126. name: string;
  149127. shader: string;
  149128. };
  149129. }
  149130. declare module BABYLON {
  149131. /** @hidden */
  149132. export var volumetricLightScatteringPassPixelShader: {
  149133. name: string;
  149134. shader: string;
  149135. };
  149136. }
  149137. declare module BABYLON {
  149138. /**
  149139. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  149140. */
  149141. export class VolumetricLightScatteringPostProcess extends PostProcess {
  149142. private _volumetricLightScatteringPass;
  149143. private _volumetricLightScatteringRTT;
  149144. private _viewPort;
  149145. private _screenCoordinates;
  149146. private _cachedDefines;
  149147. /**
  149148. * If not undefined, the mesh position is computed from the attached node position
  149149. */
  149150. attachedNode: {
  149151. position: Vector3;
  149152. };
  149153. /**
  149154. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  149155. */
  149156. customMeshPosition: Vector3;
  149157. /**
  149158. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  149159. */
  149160. useCustomMeshPosition: boolean;
  149161. /**
  149162. * If the post-process should inverse the light scattering direction
  149163. */
  149164. invert: boolean;
  149165. /**
  149166. * The internal mesh used by the post-process
  149167. */
  149168. mesh: Mesh;
  149169. /**
  149170. * @hidden
  149171. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  149172. */
  149173. get useDiffuseColor(): boolean;
  149174. set useDiffuseColor(useDiffuseColor: boolean);
  149175. /**
  149176. * Array containing the excluded meshes not rendered in the internal pass
  149177. */
  149178. excludedMeshes: AbstractMesh[];
  149179. /**
  149180. * Controls the overall intensity of the post-process
  149181. */
  149182. exposure: number;
  149183. /**
  149184. * Dissipates each sample's contribution in range [0, 1]
  149185. */
  149186. decay: number;
  149187. /**
  149188. * Controls the overall intensity of each sample
  149189. */
  149190. weight: number;
  149191. /**
  149192. * Controls the density of each sample
  149193. */
  149194. density: number;
  149195. /**
  149196. * @constructor
  149197. * @param name The post-process name
  149198. * @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)
  149199. * @param camera The camera that the post-process will be attached to
  149200. * @param mesh The mesh used to create the light scattering
  149201. * @param samples The post-process quality, default 100
  149202. * @param samplingModeThe post-process filtering mode
  149203. * @param engine The babylon engine
  149204. * @param reusable If the post-process is reusable
  149205. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  149206. */
  149207. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  149208. /**
  149209. * Returns the string "VolumetricLightScatteringPostProcess"
  149210. * @returns "VolumetricLightScatteringPostProcess"
  149211. */
  149212. getClassName(): string;
  149213. private _isReady;
  149214. /**
  149215. * Sets the new light position for light scattering effect
  149216. * @param position The new custom light position
  149217. */
  149218. setCustomMeshPosition(position: Vector3): void;
  149219. /**
  149220. * Returns the light position for light scattering effect
  149221. * @return Vector3 The custom light position
  149222. */
  149223. getCustomMeshPosition(): Vector3;
  149224. /**
  149225. * Disposes the internal assets and detaches the post-process from the camera
  149226. */
  149227. dispose(camera: Camera): void;
  149228. /**
  149229. * Returns the render target texture used by the post-process
  149230. * @return the render target texture used by the post-process
  149231. */
  149232. getPass(): RenderTargetTexture;
  149233. private _meshExcluded;
  149234. private _createPass;
  149235. private _updateMeshScreenCoordinates;
  149236. /**
  149237. * Creates a default mesh for the Volumeric Light Scattering post-process
  149238. * @param name The mesh name
  149239. * @param scene The scene where to create the mesh
  149240. * @return the default mesh
  149241. */
  149242. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  149243. }
  149244. }
  149245. declare module BABYLON {
  149246. interface Scene {
  149247. /** @hidden (Backing field) */
  149248. _boundingBoxRenderer: BoundingBoxRenderer;
  149249. /** @hidden (Backing field) */
  149250. _forceShowBoundingBoxes: boolean;
  149251. /**
  149252. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  149253. */
  149254. forceShowBoundingBoxes: boolean;
  149255. /**
  149256. * Gets the bounding box renderer associated with the scene
  149257. * @returns a BoundingBoxRenderer
  149258. */
  149259. getBoundingBoxRenderer(): BoundingBoxRenderer;
  149260. }
  149261. interface AbstractMesh {
  149262. /** @hidden (Backing field) */
  149263. _showBoundingBox: boolean;
  149264. /**
  149265. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  149266. */
  149267. showBoundingBox: boolean;
  149268. }
  149269. /**
  149270. * Component responsible of rendering the bounding box of the meshes in a scene.
  149271. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  149272. */
  149273. export class BoundingBoxRenderer implements ISceneComponent {
  149274. /**
  149275. * The component name helpfull to identify the component in the list of scene components.
  149276. */
  149277. readonly name: string;
  149278. /**
  149279. * The scene the component belongs to.
  149280. */
  149281. scene: Scene;
  149282. /**
  149283. * Color of the bounding box lines placed in front of an object
  149284. */
  149285. frontColor: Color3;
  149286. /**
  149287. * Color of the bounding box lines placed behind an object
  149288. */
  149289. backColor: Color3;
  149290. /**
  149291. * Defines if the renderer should show the back lines or not
  149292. */
  149293. showBackLines: boolean;
  149294. /**
  149295. * Observable raised before rendering a bounding box
  149296. */
  149297. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  149298. /**
  149299. * Observable raised after rendering a bounding box
  149300. */
  149301. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  149302. /**
  149303. * @hidden
  149304. */
  149305. renderList: SmartArray<BoundingBox>;
  149306. private _colorShader;
  149307. private _vertexBuffers;
  149308. private _indexBuffer;
  149309. private _fillIndexBuffer;
  149310. private _fillIndexData;
  149311. /**
  149312. * Instantiates a new bounding box renderer in a scene.
  149313. * @param scene the scene the renderer renders in
  149314. */
  149315. constructor(scene: Scene);
  149316. /**
  149317. * Registers the component in a given scene
  149318. */
  149319. register(): void;
  149320. private _evaluateSubMesh;
  149321. private _activeMesh;
  149322. private _prepareRessources;
  149323. private _createIndexBuffer;
  149324. /**
  149325. * Rebuilds the elements related to this component in case of
  149326. * context lost for instance.
  149327. */
  149328. rebuild(): void;
  149329. /**
  149330. * @hidden
  149331. */
  149332. reset(): void;
  149333. /**
  149334. * Render the bounding boxes of a specific rendering group
  149335. * @param renderingGroupId defines the rendering group to render
  149336. */
  149337. render(renderingGroupId: number): void;
  149338. /**
  149339. * In case of occlusion queries, we can render the occlusion bounding box through this method
  149340. * @param mesh Define the mesh to render the occlusion bounding box for
  149341. */
  149342. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  149343. /**
  149344. * Dispose and release the resources attached to this renderer.
  149345. */
  149346. dispose(): void;
  149347. }
  149348. }
  149349. declare module BABYLON {
  149350. interface Scene {
  149351. /** @hidden (Backing field) */
  149352. _depthRenderer: {
  149353. [id: string]: DepthRenderer;
  149354. };
  149355. /**
  149356. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  149357. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  149358. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  149359. * @returns the created depth renderer
  149360. */
  149361. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  149362. /**
  149363. * Disables a depth renderer for a given camera
  149364. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  149365. */
  149366. disableDepthRenderer(camera?: Nullable<Camera>): void;
  149367. }
  149368. /**
  149369. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  149370. * in several rendering techniques.
  149371. */
  149372. export class DepthRendererSceneComponent implements ISceneComponent {
  149373. /**
  149374. * The component name helpfull to identify the component in the list of scene components.
  149375. */
  149376. readonly name: string;
  149377. /**
  149378. * The scene the component belongs to.
  149379. */
  149380. scene: Scene;
  149381. /**
  149382. * Creates a new instance of the component for the given scene
  149383. * @param scene Defines the scene to register the component in
  149384. */
  149385. constructor(scene: Scene);
  149386. /**
  149387. * Registers the component in a given scene
  149388. */
  149389. register(): void;
  149390. /**
  149391. * Rebuilds the elements related to this component in case of
  149392. * context lost for instance.
  149393. */
  149394. rebuild(): void;
  149395. /**
  149396. * Disposes the component and the associated ressources
  149397. */
  149398. dispose(): void;
  149399. private _gatherRenderTargets;
  149400. private _gatherActiveCameraRenderTargets;
  149401. }
  149402. }
  149403. declare module BABYLON {
  149404. interface AbstractScene {
  149405. /** @hidden (Backing field) */
  149406. _prePassRenderer: Nullable<PrePassRenderer>;
  149407. /**
  149408. * Gets or Sets the current prepass renderer associated to the scene.
  149409. */
  149410. prePassRenderer: Nullable<PrePassRenderer>;
  149411. /**
  149412. * Enables the prepass and associates it with the scene
  149413. * @returns the PrePassRenderer
  149414. */
  149415. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  149416. /**
  149417. * Disables the prepass associated with the scene
  149418. */
  149419. disablePrePassRenderer(): void;
  149420. }
  149421. /**
  149422. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  149423. * in several rendering techniques.
  149424. */
  149425. export class PrePassRendererSceneComponent implements ISceneSerializableComponent {
  149426. /**
  149427. * The component name helpful to identify the component in the list of scene components.
  149428. */
  149429. readonly name: string;
  149430. /**
  149431. * The scene the component belongs to.
  149432. */
  149433. scene: Scene;
  149434. /**
  149435. * Creates a new instance of the component for the given scene
  149436. * @param scene Defines the scene to register the component in
  149437. */
  149438. constructor(scene: Scene);
  149439. /**
  149440. * Registers the component in a given scene
  149441. */
  149442. register(): void;
  149443. private _beforeCameraDraw;
  149444. private _afterCameraDraw;
  149445. private _beforeClearStage;
  149446. /**
  149447. * Serializes the component data to the specified json object
  149448. * @param serializationObject The object to serialize to
  149449. */
  149450. serialize(serializationObject: any): void;
  149451. /**
  149452. * Adds all the elements from the container to the scene
  149453. * @param container the container holding the elements
  149454. */
  149455. addFromContainer(container: AbstractScene): void;
  149456. /**
  149457. * Removes all the elements in the container from the scene
  149458. * @param container contains the elements to remove
  149459. * @param dispose if the removed element should be disposed (default: false)
  149460. */
  149461. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  149462. /**
  149463. * Rebuilds the elements related to this component in case of
  149464. * context lost for instance.
  149465. */
  149466. rebuild(): void;
  149467. /**
  149468. * Disposes the component and the associated ressources
  149469. */
  149470. dispose(): void;
  149471. }
  149472. }
  149473. declare module BABYLON {
  149474. /** @hidden */
  149475. export var outlinePixelShader: {
  149476. name: string;
  149477. shader: string;
  149478. };
  149479. }
  149480. declare module BABYLON {
  149481. /** @hidden */
  149482. export var outlineVertexShader: {
  149483. name: string;
  149484. shader: string;
  149485. };
  149486. }
  149487. declare module BABYLON {
  149488. interface Scene {
  149489. /** @hidden */
  149490. _outlineRenderer: OutlineRenderer;
  149491. /**
  149492. * Gets the outline renderer associated with the scene
  149493. * @returns a OutlineRenderer
  149494. */
  149495. getOutlineRenderer(): OutlineRenderer;
  149496. }
  149497. interface AbstractMesh {
  149498. /** @hidden (Backing field) */
  149499. _renderOutline: boolean;
  149500. /**
  149501. * Gets or sets a boolean indicating if the outline must be rendered as well
  149502. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  149503. */
  149504. renderOutline: boolean;
  149505. /** @hidden (Backing field) */
  149506. _renderOverlay: boolean;
  149507. /**
  149508. * Gets or sets a boolean indicating if the overlay must be rendered as well
  149509. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  149510. */
  149511. renderOverlay: boolean;
  149512. }
  149513. /**
  149514. * This class is responsible to draw bothe outline/overlay of meshes.
  149515. * It should not be used directly but through the available method on mesh.
  149516. */
  149517. export class OutlineRenderer implements ISceneComponent {
  149518. /**
  149519. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  149520. */
  149521. private static _StencilReference;
  149522. /**
  149523. * The name of the component. Each component must have a unique name.
  149524. */
  149525. name: string;
  149526. /**
  149527. * The scene the component belongs to.
  149528. */
  149529. scene: Scene;
  149530. /**
  149531. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  149532. */
  149533. zOffset: number;
  149534. private _engine;
  149535. private _effect;
  149536. private _cachedDefines;
  149537. private _savedDepthWrite;
  149538. /**
  149539. * Instantiates a new outline renderer. (There could be only one per scene).
  149540. * @param scene Defines the scene it belongs to
  149541. */
  149542. constructor(scene: Scene);
  149543. /**
  149544. * Register the component to one instance of a scene.
  149545. */
  149546. register(): void;
  149547. /**
  149548. * Rebuilds the elements related to this component in case of
  149549. * context lost for instance.
  149550. */
  149551. rebuild(): void;
  149552. /**
  149553. * Disposes the component and the associated ressources.
  149554. */
  149555. dispose(): void;
  149556. /**
  149557. * Renders the outline in the canvas.
  149558. * @param subMesh Defines the sumesh to render
  149559. * @param batch Defines the batch of meshes in case of instances
  149560. * @param useOverlay Defines if the rendering is for the overlay or the outline
  149561. */
  149562. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  149563. /**
  149564. * Returns whether or not the outline renderer is ready for a given submesh.
  149565. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  149566. * @param subMesh Defines the submesh to check readyness for
  149567. * @param useInstances Defines wheter wee are trying to render instances or not
  149568. * @returns true if ready otherwise false
  149569. */
  149570. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  149571. private _beforeRenderingMesh;
  149572. private _afterRenderingMesh;
  149573. }
  149574. }
  149575. declare module BABYLON {
  149576. /**
  149577. * Defines the basic options interface of a Sprite Frame Source Size.
  149578. */
  149579. export interface ISpriteJSONSpriteSourceSize {
  149580. /**
  149581. * number of the original width of the Frame
  149582. */
  149583. w: number;
  149584. /**
  149585. * number of the original height of the Frame
  149586. */
  149587. h: number;
  149588. }
  149589. /**
  149590. * Defines the basic options interface of a Sprite Frame Data.
  149591. */
  149592. export interface ISpriteJSONSpriteFrameData {
  149593. /**
  149594. * number of the x offset of the Frame
  149595. */
  149596. x: number;
  149597. /**
  149598. * number of the y offset of the Frame
  149599. */
  149600. y: number;
  149601. /**
  149602. * number of the width of the Frame
  149603. */
  149604. w: number;
  149605. /**
  149606. * number of the height of the Frame
  149607. */
  149608. h: number;
  149609. }
  149610. /**
  149611. * Defines the basic options interface of a JSON Sprite.
  149612. */
  149613. export interface ISpriteJSONSprite {
  149614. /**
  149615. * string name of the Frame
  149616. */
  149617. filename: string;
  149618. /**
  149619. * ISpriteJSONSpriteFrame basic object of the frame data
  149620. */
  149621. frame: ISpriteJSONSpriteFrameData;
  149622. /**
  149623. * boolean to flag is the frame was rotated.
  149624. */
  149625. rotated: boolean;
  149626. /**
  149627. * boolean to flag is the frame was trimmed.
  149628. */
  149629. trimmed: boolean;
  149630. /**
  149631. * ISpriteJSONSpriteFrame basic object of the source data
  149632. */
  149633. spriteSourceSize: ISpriteJSONSpriteFrameData;
  149634. /**
  149635. * ISpriteJSONSpriteFrame basic object of the source data
  149636. */
  149637. sourceSize: ISpriteJSONSpriteSourceSize;
  149638. }
  149639. /**
  149640. * Defines the basic options interface of a JSON atlas.
  149641. */
  149642. export interface ISpriteJSONAtlas {
  149643. /**
  149644. * Array of objects that contain the frame data.
  149645. */
  149646. frames: Array<ISpriteJSONSprite>;
  149647. /**
  149648. * object basic object containing the sprite meta data.
  149649. */
  149650. meta?: object;
  149651. }
  149652. }
  149653. declare module BABYLON {
  149654. /** @hidden */
  149655. export var spriteMapPixelShader: {
  149656. name: string;
  149657. shader: string;
  149658. };
  149659. }
  149660. declare module BABYLON {
  149661. /** @hidden */
  149662. export var spriteMapVertexShader: {
  149663. name: string;
  149664. shader: string;
  149665. };
  149666. }
  149667. declare module BABYLON {
  149668. /**
  149669. * Defines the basic options interface of a SpriteMap
  149670. */
  149671. export interface ISpriteMapOptions {
  149672. /**
  149673. * Vector2 of the number of cells in the grid.
  149674. */
  149675. stageSize?: Vector2;
  149676. /**
  149677. * Vector2 of the size of the output plane in World Units.
  149678. */
  149679. outputSize?: Vector2;
  149680. /**
  149681. * Vector3 of the position of the output plane in World Units.
  149682. */
  149683. outputPosition?: Vector3;
  149684. /**
  149685. * Vector3 of the rotation of the output plane.
  149686. */
  149687. outputRotation?: Vector3;
  149688. /**
  149689. * number of layers that the system will reserve in resources.
  149690. */
  149691. layerCount?: number;
  149692. /**
  149693. * number of max animation frames a single cell will reserve in resources.
  149694. */
  149695. maxAnimationFrames?: number;
  149696. /**
  149697. * number cell index of the base tile when the system compiles.
  149698. */
  149699. baseTile?: number;
  149700. /**
  149701. * boolean flip the sprite after its been repositioned by the framing data.
  149702. */
  149703. flipU?: boolean;
  149704. /**
  149705. * Vector3 scalar of the global RGB values of the SpriteMap.
  149706. */
  149707. colorMultiply?: Vector3;
  149708. }
  149709. /**
  149710. * Defines the IDisposable interface in order to be cleanable from resources.
  149711. */
  149712. export interface ISpriteMap extends IDisposable {
  149713. /**
  149714. * String name of the SpriteMap.
  149715. */
  149716. name: string;
  149717. /**
  149718. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  149719. */
  149720. atlasJSON: ISpriteJSONAtlas;
  149721. /**
  149722. * Texture of the SpriteMap.
  149723. */
  149724. spriteSheet: Texture;
  149725. /**
  149726. * The parameters to initialize the SpriteMap with.
  149727. */
  149728. options: ISpriteMapOptions;
  149729. }
  149730. /**
  149731. * Class used to manage a grid restricted sprite deployment on an Output plane.
  149732. */
  149733. export class SpriteMap implements ISpriteMap {
  149734. /** The Name of the spriteMap */
  149735. name: string;
  149736. /** The JSON file with the frame and meta data */
  149737. atlasJSON: ISpriteJSONAtlas;
  149738. /** The systems Sprite Sheet Texture */
  149739. spriteSheet: Texture;
  149740. /** Arguments passed with the Constructor */
  149741. options: ISpriteMapOptions;
  149742. /** Public Sprite Storage array, parsed from atlasJSON */
  149743. sprites: Array<ISpriteJSONSprite>;
  149744. /** Returns the Number of Sprites in the System */
  149745. get spriteCount(): number;
  149746. /** Returns the Position of Output Plane*/
  149747. get position(): Vector3;
  149748. /** Returns the Position of Output Plane*/
  149749. set position(v: Vector3);
  149750. /** Returns the Rotation of Output Plane*/
  149751. get rotation(): Vector3;
  149752. /** Returns the Rotation of Output Plane*/
  149753. set rotation(v: Vector3);
  149754. /** Sets the AnimationMap*/
  149755. get animationMap(): RawTexture;
  149756. /** Sets the AnimationMap*/
  149757. set animationMap(v: RawTexture);
  149758. /** Scene that the SpriteMap was created in */
  149759. private _scene;
  149760. /** Texture Buffer of Float32 that holds tile frame data*/
  149761. private _frameMap;
  149762. /** Texture Buffers of Float32 that holds tileMap data*/
  149763. private _tileMaps;
  149764. /** Texture Buffer of Float32 that holds Animation Data*/
  149765. private _animationMap;
  149766. /** Custom ShaderMaterial Central to the System*/
  149767. private _material;
  149768. /** Custom ShaderMaterial Central to the System*/
  149769. private _output;
  149770. /** Systems Time Ticker*/
  149771. private _time;
  149772. /**
  149773. * Creates a new SpriteMap
  149774. * @param name defines the SpriteMaps Name
  149775. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  149776. * @param spriteSheet is the Texture that the Sprites are on.
  149777. * @param options a basic deployment configuration
  149778. * @param scene The Scene that the map is deployed on
  149779. */
  149780. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  149781. /**
  149782. * Returns tileID location
  149783. * @returns Vector2 the cell position ID
  149784. */
  149785. getTileID(): Vector2;
  149786. /**
  149787. * Gets the UV location of the mouse over the SpriteMap.
  149788. * @returns Vector2 the UV position of the mouse interaction
  149789. */
  149790. getMousePosition(): Vector2;
  149791. /**
  149792. * Creates the "frame" texture Buffer
  149793. * -------------------------------------
  149794. * Structure of frames
  149795. * "filename": "Falling-Water-2.png",
  149796. * "frame": {"x":69,"y":103,"w":24,"h":32},
  149797. * "rotated": true,
  149798. * "trimmed": true,
  149799. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  149800. * "sourceSize": {"w":32,"h":32}
  149801. * @returns RawTexture of the frameMap
  149802. */
  149803. private _createFrameBuffer;
  149804. /**
  149805. * Creates the tileMap texture Buffer
  149806. * @param buffer normally and array of numbers, or a false to generate from scratch
  149807. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  149808. * @returns RawTexture of the tileMap
  149809. */
  149810. private _createTileBuffer;
  149811. /**
  149812. * Modifies the data of the tileMaps
  149813. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  149814. * @param pos is the iVector2 Coordinates of the Tile
  149815. * @param tile The SpriteIndex of the new Tile
  149816. */
  149817. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  149818. /**
  149819. * Creates the animationMap texture Buffer
  149820. * @param buffer normally and array of numbers, or a false to generate from scratch
  149821. * @returns RawTexture of the animationMap
  149822. */
  149823. private _createTileAnimationBuffer;
  149824. /**
  149825. * Modifies the data of the animationMap
  149826. * @param cellID is the Index of the Sprite
  149827. * @param _frame is the target Animation frame
  149828. * @param toCell is the Target Index of the next frame of the animation
  149829. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  149830. * @param speed is a global scalar of the time variable on the map.
  149831. */
  149832. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  149833. /**
  149834. * Exports the .tilemaps file
  149835. */
  149836. saveTileMaps(): void;
  149837. /**
  149838. * Imports the .tilemaps file
  149839. * @param url of the .tilemaps file
  149840. */
  149841. loadTileMaps(url: string): void;
  149842. /**
  149843. * Release associated resources
  149844. */
  149845. dispose(): void;
  149846. }
  149847. }
  149848. declare module BABYLON {
  149849. /**
  149850. * Class used to manage multiple sprites of different sizes on the same spritesheet
  149851. * @see https://doc.babylonjs.com/babylon101/sprites
  149852. */
  149853. export class SpritePackedManager extends SpriteManager {
  149854. /** defines the packed manager's name */
  149855. name: string;
  149856. /**
  149857. * Creates a new sprite manager from a packed sprite sheet
  149858. * @param name defines the manager's name
  149859. * @param imgUrl defines the sprite sheet url
  149860. * @param capacity defines the maximum allowed number of sprites
  149861. * @param scene defines the hosting scene
  149862. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  149863. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  149864. * @param samplingMode defines the smapling mode to use with spritesheet
  149865. * @param fromPacked set to true; do not alter
  149866. */
  149867. constructor(
  149868. /** defines the packed manager's name */
  149869. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  149870. }
  149871. }
  149872. declare module BABYLON {
  149873. /**
  149874. * Defines the list of states available for a task inside a AssetsManager
  149875. */
  149876. export enum AssetTaskState {
  149877. /**
  149878. * Initialization
  149879. */
  149880. INIT = 0,
  149881. /**
  149882. * Running
  149883. */
  149884. RUNNING = 1,
  149885. /**
  149886. * Done
  149887. */
  149888. DONE = 2,
  149889. /**
  149890. * Error
  149891. */
  149892. ERROR = 3
  149893. }
  149894. /**
  149895. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  149896. */
  149897. export abstract class AbstractAssetTask {
  149898. /**
  149899. * Task name
  149900. */ name: string;
  149901. /**
  149902. * Callback called when the task is successful
  149903. */
  149904. onSuccess: (task: any) => void;
  149905. /**
  149906. * Callback called when the task is not successful
  149907. */
  149908. onError: (task: any, message?: string, exception?: any) => void;
  149909. /**
  149910. * Creates a new AssetsManager
  149911. * @param name defines the name of the task
  149912. */
  149913. constructor(
  149914. /**
  149915. * Task name
  149916. */ name: string);
  149917. private _isCompleted;
  149918. private _taskState;
  149919. private _errorObject;
  149920. /**
  149921. * Get if the task is completed
  149922. */
  149923. get isCompleted(): boolean;
  149924. /**
  149925. * Gets the current state of the task
  149926. */
  149927. get taskState(): AssetTaskState;
  149928. /**
  149929. * Gets the current error object (if task is in error)
  149930. */
  149931. get errorObject(): {
  149932. message?: string;
  149933. exception?: any;
  149934. };
  149935. /**
  149936. * Internal only
  149937. * @hidden
  149938. */
  149939. _setErrorObject(message?: string, exception?: any): void;
  149940. /**
  149941. * Execute the current task
  149942. * @param scene defines the scene where you want your assets to be loaded
  149943. * @param onSuccess is a callback called when the task is successfully executed
  149944. * @param onError is a callback called if an error occurs
  149945. */
  149946. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149947. /**
  149948. * Execute the current task
  149949. * @param scene defines the scene where you want your assets to be loaded
  149950. * @param onSuccess is a callback called when the task is successfully executed
  149951. * @param onError is a callback called if an error occurs
  149952. */
  149953. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  149954. /**
  149955. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  149956. * This can be used with failed tasks that have the reason for failure fixed.
  149957. */
  149958. reset(): void;
  149959. private onErrorCallback;
  149960. private onDoneCallback;
  149961. }
  149962. /**
  149963. * Define the interface used by progress events raised during assets loading
  149964. */
  149965. export interface IAssetsProgressEvent {
  149966. /**
  149967. * Defines the number of remaining tasks to process
  149968. */
  149969. remainingCount: number;
  149970. /**
  149971. * Defines the total number of tasks
  149972. */
  149973. totalCount: number;
  149974. /**
  149975. * Defines the task that was just processed
  149976. */
  149977. task: AbstractAssetTask;
  149978. }
  149979. /**
  149980. * Class used to share progress information about assets loading
  149981. */
  149982. export class AssetsProgressEvent implements IAssetsProgressEvent {
  149983. /**
  149984. * Defines the number of remaining tasks to process
  149985. */
  149986. remainingCount: number;
  149987. /**
  149988. * Defines the total number of tasks
  149989. */
  149990. totalCount: number;
  149991. /**
  149992. * Defines the task that was just processed
  149993. */
  149994. task: AbstractAssetTask;
  149995. /**
  149996. * Creates a AssetsProgressEvent
  149997. * @param remainingCount defines the number of remaining tasks to process
  149998. * @param totalCount defines the total number of tasks
  149999. * @param task defines the task that was just processed
  150000. */
  150001. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  150002. }
  150003. /**
  150004. * Define a task used by AssetsManager to load meshes
  150005. */
  150006. export class MeshAssetTask extends AbstractAssetTask {
  150007. /**
  150008. * Defines the name of the task
  150009. */
  150010. name: string;
  150011. /**
  150012. * Defines the list of mesh's names you want to load
  150013. */
  150014. meshesNames: any;
  150015. /**
  150016. * Defines the root url to use as a base to load your meshes and associated resources
  150017. */
  150018. rootUrl: string;
  150019. /**
  150020. * Defines the filename or File of the scene to load from
  150021. */
  150022. sceneFilename: string | File;
  150023. /**
  150024. * Gets the list of loaded meshes
  150025. */
  150026. loadedMeshes: Array<AbstractMesh>;
  150027. /**
  150028. * Gets the list of loaded particle systems
  150029. */
  150030. loadedParticleSystems: Array<IParticleSystem>;
  150031. /**
  150032. * Gets the list of loaded skeletons
  150033. */
  150034. loadedSkeletons: Array<Skeleton>;
  150035. /**
  150036. * Gets the list of loaded animation groups
  150037. */
  150038. loadedAnimationGroups: Array<AnimationGroup>;
  150039. /**
  150040. * Callback called when the task is successful
  150041. */
  150042. onSuccess: (task: MeshAssetTask) => void;
  150043. /**
  150044. * Callback called when the task is successful
  150045. */
  150046. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  150047. /**
  150048. * Creates a new MeshAssetTask
  150049. * @param name defines the name of the task
  150050. * @param meshesNames defines the list of mesh's names you want to load
  150051. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  150052. * @param sceneFilename defines the filename or File of the scene to load from
  150053. */
  150054. constructor(
  150055. /**
  150056. * Defines the name of the task
  150057. */
  150058. name: string,
  150059. /**
  150060. * Defines the list of mesh's names you want to load
  150061. */
  150062. meshesNames: any,
  150063. /**
  150064. * Defines the root url to use as a base to load your meshes and associated resources
  150065. */
  150066. rootUrl: string,
  150067. /**
  150068. * Defines the filename or File of the scene to load from
  150069. */
  150070. sceneFilename: string | File);
  150071. /**
  150072. * Execute the current task
  150073. * @param scene defines the scene where you want your assets to be loaded
  150074. * @param onSuccess is a callback called when the task is successfully executed
  150075. * @param onError is a callback called if an error occurs
  150076. */
  150077. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150078. }
  150079. /**
  150080. * Define a task used by AssetsManager to load text content
  150081. */
  150082. export class TextFileAssetTask extends AbstractAssetTask {
  150083. /**
  150084. * Defines the name of the task
  150085. */
  150086. name: string;
  150087. /**
  150088. * Defines the location of the file to load
  150089. */
  150090. url: string;
  150091. /**
  150092. * Gets the loaded text string
  150093. */
  150094. text: string;
  150095. /**
  150096. * Callback called when the task is successful
  150097. */
  150098. onSuccess: (task: TextFileAssetTask) => void;
  150099. /**
  150100. * Callback called when the task is successful
  150101. */
  150102. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  150103. /**
  150104. * Creates a new TextFileAssetTask object
  150105. * @param name defines the name of the task
  150106. * @param url defines the location of the file to load
  150107. */
  150108. constructor(
  150109. /**
  150110. * Defines the name of the task
  150111. */
  150112. name: string,
  150113. /**
  150114. * Defines the location of the file to load
  150115. */
  150116. url: string);
  150117. /**
  150118. * Execute the current task
  150119. * @param scene defines the scene where you want your assets to be loaded
  150120. * @param onSuccess is a callback called when the task is successfully executed
  150121. * @param onError is a callback called if an error occurs
  150122. */
  150123. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150124. }
  150125. /**
  150126. * Define a task used by AssetsManager to load binary data
  150127. */
  150128. export class BinaryFileAssetTask extends AbstractAssetTask {
  150129. /**
  150130. * Defines the name of the task
  150131. */
  150132. name: string;
  150133. /**
  150134. * Defines the location of the file to load
  150135. */
  150136. url: string;
  150137. /**
  150138. * Gets the lodaded data (as an array buffer)
  150139. */
  150140. data: ArrayBuffer;
  150141. /**
  150142. * Callback called when the task is successful
  150143. */
  150144. onSuccess: (task: BinaryFileAssetTask) => void;
  150145. /**
  150146. * Callback called when the task is successful
  150147. */
  150148. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  150149. /**
  150150. * Creates a new BinaryFileAssetTask object
  150151. * @param name defines the name of the new task
  150152. * @param url defines the location of the file to load
  150153. */
  150154. constructor(
  150155. /**
  150156. * Defines the name of the task
  150157. */
  150158. name: string,
  150159. /**
  150160. * Defines the location of the file to load
  150161. */
  150162. url: string);
  150163. /**
  150164. * Execute the current task
  150165. * @param scene defines the scene where you want your assets to be loaded
  150166. * @param onSuccess is a callback called when the task is successfully executed
  150167. * @param onError is a callback called if an error occurs
  150168. */
  150169. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150170. }
  150171. /**
  150172. * Define a task used by AssetsManager to load images
  150173. */
  150174. export class ImageAssetTask extends AbstractAssetTask {
  150175. /**
  150176. * Defines the name of the task
  150177. */
  150178. name: string;
  150179. /**
  150180. * Defines the location of the image to load
  150181. */
  150182. url: string;
  150183. /**
  150184. * Gets the loaded images
  150185. */
  150186. image: HTMLImageElement;
  150187. /**
  150188. * Callback called when the task is successful
  150189. */
  150190. onSuccess: (task: ImageAssetTask) => void;
  150191. /**
  150192. * Callback called when the task is successful
  150193. */
  150194. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  150195. /**
  150196. * Creates a new ImageAssetTask
  150197. * @param name defines the name of the task
  150198. * @param url defines the location of the image to load
  150199. */
  150200. constructor(
  150201. /**
  150202. * Defines the name of the task
  150203. */
  150204. name: string,
  150205. /**
  150206. * Defines the location of the image to load
  150207. */
  150208. url: string);
  150209. /**
  150210. * Execute the current task
  150211. * @param scene defines the scene where you want your assets to be loaded
  150212. * @param onSuccess is a callback called when the task is successfully executed
  150213. * @param onError is a callback called if an error occurs
  150214. */
  150215. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150216. }
  150217. /**
  150218. * Defines the interface used by texture loading tasks
  150219. */
  150220. export interface ITextureAssetTask<TEX extends BaseTexture> {
  150221. /**
  150222. * Gets the loaded texture
  150223. */
  150224. texture: TEX;
  150225. }
  150226. /**
  150227. * Define a task used by AssetsManager to load 2D textures
  150228. */
  150229. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  150230. /**
  150231. * Defines the name of the task
  150232. */
  150233. name: string;
  150234. /**
  150235. * Defines the location of the file to load
  150236. */
  150237. url: string;
  150238. /**
  150239. * Defines if mipmap should not be generated (default is false)
  150240. */
  150241. noMipmap?: boolean | undefined;
  150242. /**
  150243. * Defines if texture must be inverted on Y axis (default is true)
  150244. */
  150245. invertY: boolean;
  150246. /**
  150247. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150248. */
  150249. samplingMode: number;
  150250. /**
  150251. * Gets the loaded texture
  150252. */
  150253. texture: Texture;
  150254. /**
  150255. * Callback called when the task is successful
  150256. */
  150257. onSuccess: (task: TextureAssetTask) => void;
  150258. /**
  150259. * Callback called when the task is successful
  150260. */
  150261. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  150262. /**
  150263. * Creates a new TextureAssetTask object
  150264. * @param name defines the name of the task
  150265. * @param url defines the location of the file to load
  150266. * @param noMipmap defines if mipmap should not be generated (default is false)
  150267. * @param invertY defines if texture must be inverted on Y axis (default is true)
  150268. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150269. */
  150270. constructor(
  150271. /**
  150272. * Defines the name of the task
  150273. */
  150274. name: string,
  150275. /**
  150276. * Defines the location of the file to load
  150277. */
  150278. url: string,
  150279. /**
  150280. * Defines if mipmap should not be generated (default is false)
  150281. */
  150282. noMipmap?: boolean | undefined,
  150283. /**
  150284. * Defines if texture must be inverted on Y axis (default is true)
  150285. */
  150286. invertY?: boolean,
  150287. /**
  150288. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  150289. */
  150290. samplingMode?: number);
  150291. /**
  150292. * Execute the current task
  150293. * @param scene defines the scene where you want your assets to be loaded
  150294. * @param onSuccess is a callback called when the task is successfully executed
  150295. * @param onError is a callback called if an error occurs
  150296. */
  150297. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150298. }
  150299. /**
  150300. * Define a task used by AssetsManager to load cube textures
  150301. */
  150302. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  150303. /**
  150304. * Defines the name of the task
  150305. */
  150306. name: string;
  150307. /**
  150308. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150309. */
  150310. url: string;
  150311. /**
  150312. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150313. */
  150314. extensions?: string[] | undefined;
  150315. /**
  150316. * Defines if mipmaps should not be generated (default is false)
  150317. */
  150318. noMipmap?: boolean | undefined;
  150319. /**
  150320. * Defines the explicit list of files (undefined by default)
  150321. */
  150322. files?: string[] | undefined;
  150323. /**
  150324. * Gets the loaded texture
  150325. */
  150326. texture: CubeTexture;
  150327. /**
  150328. * Callback called when the task is successful
  150329. */
  150330. onSuccess: (task: CubeTextureAssetTask) => void;
  150331. /**
  150332. * Callback called when the task is successful
  150333. */
  150334. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  150335. /**
  150336. * Creates a new CubeTextureAssetTask
  150337. * @param name defines the name of the task
  150338. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150339. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150340. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150341. * @param files defines the explicit list of files (undefined by default)
  150342. */
  150343. constructor(
  150344. /**
  150345. * Defines the name of the task
  150346. */
  150347. name: string,
  150348. /**
  150349. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  150350. */
  150351. url: string,
  150352. /**
  150353. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  150354. */
  150355. extensions?: string[] | undefined,
  150356. /**
  150357. * Defines if mipmaps should not be generated (default is false)
  150358. */
  150359. noMipmap?: boolean | undefined,
  150360. /**
  150361. * Defines the explicit list of files (undefined by default)
  150362. */
  150363. files?: string[] | undefined);
  150364. /**
  150365. * Execute the current task
  150366. * @param scene defines the scene where you want your assets to be loaded
  150367. * @param onSuccess is a callback called when the task is successfully executed
  150368. * @param onError is a callback called if an error occurs
  150369. */
  150370. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150371. }
  150372. /**
  150373. * Define a task used by AssetsManager to load HDR cube textures
  150374. */
  150375. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  150376. /**
  150377. * Defines the name of the task
  150378. */
  150379. name: string;
  150380. /**
  150381. * Defines the location of the file to load
  150382. */
  150383. url: string;
  150384. /**
  150385. * Defines the desired size (the more it increases the longer the generation will be)
  150386. */
  150387. size: number;
  150388. /**
  150389. * Defines if mipmaps should not be generated (default is false)
  150390. */
  150391. noMipmap: boolean;
  150392. /**
  150393. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150394. */
  150395. generateHarmonics: boolean;
  150396. /**
  150397. * 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)
  150398. */
  150399. gammaSpace: boolean;
  150400. /**
  150401. * Internal Use Only
  150402. */
  150403. reserved: boolean;
  150404. /**
  150405. * Gets the loaded texture
  150406. */
  150407. texture: HDRCubeTexture;
  150408. /**
  150409. * Callback called when the task is successful
  150410. */
  150411. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  150412. /**
  150413. * Callback called when the task is successful
  150414. */
  150415. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  150416. /**
  150417. * Creates a new HDRCubeTextureAssetTask object
  150418. * @param name defines the name of the task
  150419. * @param url defines the location of the file to load
  150420. * @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.
  150421. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150422. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150423. * @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)
  150424. * @param reserved Internal use only
  150425. */
  150426. constructor(
  150427. /**
  150428. * Defines the name of the task
  150429. */
  150430. name: string,
  150431. /**
  150432. * Defines the location of the file to load
  150433. */
  150434. url: string,
  150435. /**
  150436. * Defines the desired size (the more it increases the longer the generation will be)
  150437. */
  150438. size: number,
  150439. /**
  150440. * Defines if mipmaps should not be generated (default is false)
  150441. */
  150442. noMipmap?: boolean,
  150443. /**
  150444. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  150445. */
  150446. generateHarmonics?: boolean,
  150447. /**
  150448. * 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)
  150449. */
  150450. gammaSpace?: boolean,
  150451. /**
  150452. * Internal Use Only
  150453. */
  150454. reserved?: boolean);
  150455. /**
  150456. * Execute the current task
  150457. * @param scene defines the scene where you want your assets to be loaded
  150458. * @param onSuccess is a callback called when the task is successfully executed
  150459. * @param onError is a callback called if an error occurs
  150460. */
  150461. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150462. }
  150463. /**
  150464. * Define a task used by AssetsManager to load Equirectangular cube textures
  150465. */
  150466. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  150467. /**
  150468. * Defines the name of the task
  150469. */
  150470. name: string;
  150471. /**
  150472. * Defines the location of the file to load
  150473. */
  150474. url: string;
  150475. /**
  150476. * Defines the desired size (the more it increases the longer the generation will be)
  150477. */
  150478. size: number;
  150479. /**
  150480. * Defines if mipmaps should not be generated (default is false)
  150481. */
  150482. noMipmap: boolean;
  150483. /**
  150484. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150485. * but the standard material would require them in Gamma space) (default is true)
  150486. */
  150487. gammaSpace: boolean;
  150488. /**
  150489. * Gets the loaded texture
  150490. */
  150491. texture: EquiRectangularCubeTexture;
  150492. /**
  150493. * Callback called when the task is successful
  150494. */
  150495. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  150496. /**
  150497. * Callback called when the task is successful
  150498. */
  150499. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  150500. /**
  150501. * Creates a new EquiRectangularCubeTextureAssetTask object
  150502. * @param name defines the name of the task
  150503. * @param url defines the location of the file to load
  150504. * @param size defines the desired size (the more it increases the longer the generation will be)
  150505. * If the size is omitted this implies you are using a preprocessed cubemap.
  150506. * @param noMipmap defines if mipmaps should not be generated (default is false)
  150507. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  150508. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  150509. * (default is true)
  150510. */
  150511. constructor(
  150512. /**
  150513. * Defines the name of the task
  150514. */
  150515. name: string,
  150516. /**
  150517. * Defines the location of the file to load
  150518. */
  150519. url: string,
  150520. /**
  150521. * Defines the desired size (the more it increases the longer the generation will be)
  150522. */
  150523. size: number,
  150524. /**
  150525. * Defines if mipmaps should not be generated (default is false)
  150526. */
  150527. noMipmap?: boolean,
  150528. /**
  150529. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  150530. * but the standard material would require them in Gamma space) (default is true)
  150531. */
  150532. gammaSpace?: boolean);
  150533. /**
  150534. * Execute the current task
  150535. * @param scene defines the scene where you want your assets to be loaded
  150536. * @param onSuccess is a callback called when the task is successfully executed
  150537. * @param onError is a callback called if an error occurs
  150538. */
  150539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  150540. }
  150541. /**
  150542. * This class can be used to easily import assets into a scene
  150543. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  150544. */
  150545. export class AssetsManager {
  150546. private _scene;
  150547. private _isLoading;
  150548. protected _tasks: AbstractAssetTask[];
  150549. protected _waitingTasksCount: number;
  150550. protected _totalTasksCount: number;
  150551. /**
  150552. * Callback called when all tasks are processed
  150553. */
  150554. onFinish: (tasks: AbstractAssetTask[]) => void;
  150555. /**
  150556. * Callback called when a task is successful
  150557. */
  150558. onTaskSuccess: (task: AbstractAssetTask) => void;
  150559. /**
  150560. * Callback called when a task had an error
  150561. */
  150562. onTaskError: (task: AbstractAssetTask) => void;
  150563. /**
  150564. * Callback called when a task is done (whatever the result is)
  150565. */
  150566. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  150567. /**
  150568. * Observable called when all tasks are processed
  150569. */
  150570. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  150571. /**
  150572. * Observable called when a task had an error
  150573. */
  150574. onTaskErrorObservable: Observable<AbstractAssetTask>;
  150575. /**
  150576. * Observable called when all tasks were executed
  150577. */
  150578. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  150579. /**
  150580. * Observable called when a task is done (whatever the result is)
  150581. */
  150582. onProgressObservable: Observable<IAssetsProgressEvent>;
  150583. /**
  150584. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  150585. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  150586. */
  150587. useDefaultLoadingScreen: boolean;
  150588. /**
  150589. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  150590. * when all assets have been downloaded.
  150591. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  150592. */
  150593. autoHideLoadingUI: boolean;
  150594. /**
  150595. * Creates a new AssetsManager
  150596. * @param scene defines the scene to work on
  150597. */
  150598. constructor(scene: Scene);
  150599. /**
  150600. * Add a MeshAssetTask to the list of active tasks
  150601. * @param taskName defines the name of the new task
  150602. * @param meshesNames defines the name of meshes to load
  150603. * @param rootUrl defines the root url to use to locate files
  150604. * @param sceneFilename defines the filename of the scene file
  150605. * @returns a new MeshAssetTask object
  150606. */
  150607. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  150608. /**
  150609. * Add a TextFileAssetTask to the list of active tasks
  150610. * @param taskName defines the name of the new task
  150611. * @param url defines the url of the file to load
  150612. * @returns a new TextFileAssetTask object
  150613. */
  150614. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  150615. /**
  150616. * Add a BinaryFileAssetTask to the list of active tasks
  150617. * @param taskName defines the name of the new task
  150618. * @param url defines the url of the file to load
  150619. * @returns a new BinaryFileAssetTask object
  150620. */
  150621. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  150622. /**
  150623. * Add a ImageAssetTask to the list of active tasks
  150624. * @param taskName defines the name of the new task
  150625. * @param url defines the url of the file to load
  150626. * @returns a new ImageAssetTask object
  150627. */
  150628. addImageTask(taskName: string, url: string): ImageAssetTask;
  150629. /**
  150630. * Add a TextureAssetTask to the list of active tasks
  150631. * @param taskName defines the name of the new task
  150632. * @param url defines the url of the file to load
  150633. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150634. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  150635. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  150636. * @returns a new TextureAssetTask object
  150637. */
  150638. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  150639. /**
  150640. * Add a CubeTextureAssetTask to the list of active tasks
  150641. * @param taskName defines the name of the new task
  150642. * @param url defines the url of the file to load
  150643. * @param extensions defines the extension to use to load the cube map (can be null)
  150644. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150645. * @param files defines the list of files to load (can be null)
  150646. * @returns a new CubeTextureAssetTask object
  150647. */
  150648. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  150649. /**
  150650. *
  150651. * Add a HDRCubeTextureAssetTask to the list of active tasks
  150652. * @param taskName defines the name of the new task
  150653. * @param url defines the url of the file to load
  150654. * @param size defines the size you want for the cubemap (can be null)
  150655. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150656. * @param generateHarmonics defines if you want to automatically generate (true by default)
  150657. * @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)
  150658. * @param reserved Internal use only
  150659. * @returns a new HDRCubeTextureAssetTask object
  150660. */
  150661. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  150662. /**
  150663. *
  150664. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  150665. * @param taskName defines the name of the new task
  150666. * @param url defines the url of the file to load
  150667. * @param size defines the size you want for the cubemap (can be null)
  150668. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  150669. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  150670. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  150671. * @returns a new EquiRectangularCubeTextureAssetTask object
  150672. */
  150673. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  150674. /**
  150675. * Remove a task from the assets manager.
  150676. * @param task the task to remove
  150677. */
  150678. removeTask(task: AbstractAssetTask): void;
  150679. private _decreaseWaitingTasksCount;
  150680. private _runTask;
  150681. /**
  150682. * Reset the AssetsManager and remove all tasks
  150683. * @return the current instance of the AssetsManager
  150684. */
  150685. reset(): AssetsManager;
  150686. /**
  150687. * Start the loading process
  150688. * @return the current instance of the AssetsManager
  150689. */
  150690. load(): AssetsManager;
  150691. /**
  150692. * Start the loading process as an async operation
  150693. * @return a promise returning the list of failed tasks
  150694. */
  150695. loadAsync(): Promise<void>;
  150696. }
  150697. }
  150698. declare module BABYLON {
  150699. /**
  150700. * Wrapper class for promise with external resolve and reject.
  150701. */
  150702. export class Deferred<T> {
  150703. /**
  150704. * The promise associated with this deferred object.
  150705. */
  150706. readonly promise: Promise<T>;
  150707. private _resolve;
  150708. private _reject;
  150709. /**
  150710. * The resolve method of the promise associated with this deferred object.
  150711. */
  150712. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  150713. /**
  150714. * The reject method of the promise associated with this deferred object.
  150715. */
  150716. get reject(): (reason?: any) => void;
  150717. /**
  150718. * Constructor for this deferred object.
  150719. */
  150720. constructor();
  150721. }
  150722. }
  150723. declare module BABYLON {
  150724. /**
  150725. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  150726. */
  150727. export class MeshExploder {
  150728. private _centerMesh;
  150729. private _meshes;
  150730. private _meshesOrigins;
  150731. private _toCenterVectors;
  150732. private _scaledDirection;
  150733. private _newPosition;
  150734. private _centerPosition;
  150735. /**
  150736. * Explodes meshes from a center mesh.
  150737. * @param meshes The meshes to explode.
  150738. * @param centerMesh The mesh to be center of explosion.
  150739. */
  150740. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  150741. private _setCenterMesh;
  150742. /**
  150743. * Get class name
  150744. * @returns "MeshExploder"
  150745. */
  150746. getClassName(): string;
  150747. /**
  150748. * "Exploded meshes"
  150749. * @returns Array of meshes with the centerMesh at index 0.
  150750. */
  150751. getMeshes(): Array<Mesh>;
  150752. /**
  150753. * Explodes meshes giving a specific direction
  150754. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  150755. */
  150756. explode(direction?: number): void;
  150757. }
  150758. }
  150759. declare module BABYLON {
  150760. /**
  150761. * Class used to help managing file picking and drag'n'drop
  150762. */
  150763. export class FilesInput {
  150764. /**
  150765. * List of files ready to be loaded
  150766. */
  150767. static get FilesToLoad(): {
  150768. [key: string]: File;
  150769. };
  150770. /**
  150771. * Callback called when a file is processed
  150772. */
  150773. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  150774. private _engine;
  150775. private _currentScene;
  150776. private _sceneLoadedCallback;
  150777. private _progressCallback;
  150778. private _additionalRenderLoopLogicCallback;
  150779. private _textureLoadingCallback;
  150780. private _startingProcessingFilesCallback;
  150781. private _onReloadCallback;
  150782. private _errorCallback;
  150783. private _elementToMonitor;
  150784. private _sceneFileToLoad;
  150785. private _filesToLoad;
  150786. /**
  150787. * Creates a new FilesInput
  150788. * @param engine defines the rendering engine
  150789. * @param scene defines the hosting scene
  150790. * @param sceneLoadedCallback callback called when scene is loaded
  150791. * @param progressCallback callback called to track progress
  150792. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  150793. * @param textureLoadingCallback callback called when a texture is loading
  150794. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  150795. * @param onReloadCallback callback called when a reload is requested
  150796. * @param errorCallback callback call if an error occurs
  150797. */
  150798. 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>);
  150799. private _dragEnterHandler;
  150800. private _dragOverHandler;
  150801. private _dropHandler;
  150802. /**
  150803. * Calls this function to listen to drag'n'drop events on a specific DOM element
  150804. * @param elementToMonitor defines the DOM element to track
  150805. */
  150806. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  150807. /** Gets the current list of files to load */
  150808. get filesToLoad(): File[];
  150809. /**
  150810. * Release all associated resources
  150811. */
  150812. dispose(): void;
  150813. private renderFunction;
  150814. private drag;
  150815. private drop;
  150816. private _traverseFolder;
  150817. private _processFiles;
  150818. /**
  150819. * Load files from a drop event
  150820. * @param event defines the drop event to use as source
  150821. */
  150822. loadFiles(event: any): void;
  150823. private _processReload;
  150824. /**
  150825. * Reload the current scene from the loaded files
  150826. */
  150827. reload(): void;
  150828. }
  150829. }
  150830. declare module BABYLON {
  150831. /**
  150832. * Defines the root class used to create scene optimization to use with SceneOptimizer
  150833. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150834. */
  150835. export class SceneOptimization {
  150836. /**
  150837. * Defines the priority of this optimization (0 by default which means first in the list)
  150838. */
  150839. priority: number;
  150840. /**
  150841. * Gets a string describing the action executed by the current optimization
  150842. * @returns description string
  150843. */
  150844. getDescription(): string;
  150845. /**
  150846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150847. * @param scene defines the current scene where to apply this optimization
  150848. * @param optimizer defines the current optimizer
  150849. * @returns true if everything that can be done was applied
  150850. */
  150851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150852. /**
  150853. * Creates the SceneOptimization object
  150854. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150855. * @param desc defines the description associated with the optimization
  150856. */
  150857. constructor(
  150858. /**
  150859. * Defines the priority of this optimization (0 by default which means first in the list)
  150860. */
  150861. priority?: number);
  150862. }
  150863. /**
  150864. * Defines an optimization used to reduce the size of render target textures
  150865. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150866. */
  150867. export class TextureOptimization extends SceneOptimization {
  150868. /**
  150869. * Defines the priority of this optimization (0 by default which means first in the list)
  150870. */
  150871. priority: number;
  150872. /**
  150873. * 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
  150874. */
  150875. maximumSize: number;
  150876. /**
  150877. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150878. */
  150879. step: number;
  150880. /**
  150881. * Gets a string describing the action executed by the current optimization
  150882. * @returns description string
  150883. */
  150884. getDescription(): string;
  150885. /**
  150886. * Creates the TextureOptimization object
  150887. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150888. * @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
  150889. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150890. */
  150891. constructor(
  150892. /**
  150893. * Defines the priority of this optimization (0 by default which means first in the list)
  150894. */
  150895. priority?: number,
  150896. /**
  150897. * 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
  150898. */
  150899. maximumSize?: number,
  150900. /**
  150901. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  150902. */
  150903. step?: number);
  150904. /**
  150905. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150906. * @param scene defines the current scene where to apply this optimization
  150907. * @param optimizer defines the current optimizer
  150908. * @returns true if everything that can be done was applied
  150909. */
  150910. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150911. }
  150912. /**
  150913. * Defines an optimization used to increase or decrease the rendering resolution
  150914. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150915. */
  150916. export class HardwareScalingOptimization extends SceneOptimization {
  150917. /**
  150918. * Defines the priority of this optimization (0 by default which means first in the list)
  150919. */
  150920. priority: number;
  150921. /**
  150922. * Defines the maximum scale to use (2 by default)
  150923. */
  150924. maximumScale: number;
  150925. /**
  150926. * Defines the step to use between two passes (0.5 by default)
  150927. */
  150928. step: number;
  150929. private _currentScale;
  150930. private _directionOffset;
  150931. /**
  150932. * Gets a string describing the action executed by the current optimization
  150933. * @return description string
  150934. */
  150935. getDescription(): string;
  150936. /**
  150937. * Creates the HardwareScalingOptimization object
  150938. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  150939. * @param maximumScale defines the maximum scale to use (2 by default)
  150940. * @param step defines the step to use between two passes (0.5 by default)
  150941. */
  150942. constructor(
  150943. /**
  150944. * Defines the priority of this optimization (0 by default which means first in the list)
  150945. */
  150946. priority?: number,
  150947. /**
  150948. * Defines the maximum scale to use (2 by default)
  150949. */
  150950. maximumScale?: number,
  150951. /**
  150952. * Defines the step to use between two passes (0.5 by default)
  150953. */
  150954. step?: number);
  150955. /**
  150956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150957. * @param scene defines the current scene where to apply this optimization
  150958. * @param optimizer defines the current optimizer
  150959. * @returns true if everything that can be done was applied
  150960. */
  150961. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150962. }
  150963. /**
  150964. * Defines an optimization used to remove shadows
  150965. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150966. */
  150967. export class ShadowsOptimization extends SceneOptimization {
  150968. /**
  150969. * Gets a string describing the action executed by the current optimization
  150970. * @return description string
  150971. */
  150972. getDescription(): string;
  150973. /**
  150974. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150975. * @param scene defines the current scene where to apply this optimization
  150976. * @param optimizer defines the current optimizer
  150977. * @returns true if everything that can be done was applied
  150978. */
  150979. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150980. }
  150981. /**
  150982. * Defines an optimization used to turn post-processes off
  150983. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  150984. */
  150985. export class PostProcessesOptimization extends SceneOptimization {
  150986. /**
  150987. * Gets a string describing the action executed by the current optimization
  150988. * @return description string
  150989. */
  150990. getDescription(): string;
  150991. /**
  150992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  150993. * @param scene defines the current scene where to apply this optimization
  150994. * @param optimizer defines the current optimizer
  150995. * @returns true if everything that can be done was applied
  150996. */
  150997. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  150998. }
  150999. /**
  151000. * Defines an optimization used to turn lens flares off
  151001. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151002. */
  151003. export class LensFlaresOptimization extends SceneOptimization {
  151004. /**
  151005. * Gets a string describing the action executed by the current optimization
  151006. * @return description string
  151007. */
  151008. getDescription(): string;
  151009. /**
  151010. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151011. * @param scene defines the current scene where to apply this optimization
  151012. * @param optimizer defines the current optimizer
  151013. * @returns true if everything that can be done was applied
  151014. */
  151015. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151016. }
  151017. /**
  151018. * Defines an optimization based on user defined callback.
  151019. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151020. */
  151021. export class CustomOptimization extends SceneOptimization {
  151022. /**
  151023. * Callback called to apply the custom optimization.
  151024. */
  151025. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  151026. /**
  151027. * Callback called to get custom description
  151028. */
  151029. onGetDescription: () => string;
  151030. /**
  151031. * Gets a string describing the action executed by the current optimization
  151032. * @returns description string
  151033. */
  151034. getDescription(): string;
  151035. /**
  151036. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151037. * @param scene defines the current scene where to apply this optimization
  151038. * @param optimizer defines the current optimizer
  151039. * @returns true if everything that can be done was applied
  151040. */
  151041. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151042. }
  151043. /**
  151044. * Defines an optimization used to turn particles off
  151045. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151046. */
  151047. export class ParticlesOptimization extends SceneOptimization {
  151048. /**
  151049. * Gets a string describing the action executed by the current optimization
  151050. * @return description string
  151051. */
  151052. getDescription(): string;
  151053. /**
  151054. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151055. * @param scene defines the current scene where to apply this optimization
  151056. * @param optimizer defines the current optimizer
  151057. * @returns true if everything that can be done was applied
  151058. */
  151059. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151060. }
  151061. /**
  151062. * Defines an optimization used to turn render targets off
  151063. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151064. */
  151065. export class RenderTargetsOptimization extends SceneOptimization {
  151066. /**
  151067. * Gets a string describing the action executed by the current optimization
  151068. * @return description string
  151069. */
  151070. getDescription(): string;
  151071. /**
  151072. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151073. * @param scene defines the current scene where to apply this optimization
  151074. * @param optimizer defines the current optimizer
  151075. * @returns true if everything that can be done was applied
  151076. */
  151077. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  151078. }
  151079. /**
  151080. * Defines an optimization used to merge meshes with compatible materials
  151081. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151082. */
  151083. export class MergeMeshesOptimization extends SceneOptimization {
  151084. private static _UpdateSelectionTree;
  151085. /**
  151086. * Gets or sets a boolean which defines if optimization octree has to be updated
  151087. */
  151088. static get UpdateSelectionTree(): boolean;
  151089. /**
  151090. * Gets or sets a boolean which defines if optimization octree has to be updated
  151091. */
  151092. static set UpdateSelectionTree(value: boolean);
  151093. /**
  151094. * Gets a string describing the action executed by the current optimization
  151095. * @return description string
  151096. */
  151097. getDescription(): string;
  151098. private _canBeMerged;
  151099. /**
  151100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  151101. * @param scene defines the current scene where to apply this optimization
  151102. * @param optimizer defines the current optimizer
  151103. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  151104. * @returns true if everything that can be done was applied
  151105. */
  151106. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  151107. }
  151108. /**
  151109. * Defines a list of options used by SceneOptimizer
  151110. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151111. */
  151112. export class SceneOptimizerOptions {
  151113. /**
  151114. * Defines the target frame rate to reach (60 by default)
  151115. */
  151116. targetFrameRate: number;
  151117. /**
  151118. * Defines the interval between two checkes (2000ms by default)
  151119. */
  151120. trackerDuration: number;
  151121. /**
  151122. * Gets the list of optimizations to apply
  151123. */
  151124. optimizations: SceneOptimization[];
  151125. /**
  151126. * Creates a new list of options used by SceneOptimizer
  151127. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  151128. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  151129. */
  151130. constructor(
  151131. /**
  151132. * Defines the target frame rate to reach (60 by default)
  151133. */
  151134. targetFrameRate?: number,
  151135. /**
  151136. * Defines the interval between two checkes (2000ms by default)
  151137. */
  151138. trackerDuration?: number);
  151139. /**
  151140. * Add a new optimization
  151141. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  151142. * @returns the current SceneOptimizerOptions
  151143. */
  151144. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  151145. /**
  151146. * Add a new custom optimization
  151147. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  151148. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  151149. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  151150. * @returns the current SceneOptimizerOptions
  151151. */
  151152. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  151153. /**
  151154. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  151155. * @param targetFrameRate defines the target frame rate (60 by default)
  151156. * @returns a SceneOptimizerOptions object
  151157. */
  151158. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151159. /**
  151160. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  151161. * @param targetFrameRate defines the target frame rate (60 by default)
  151162. * @returns a SceneOptimizerOptions object
  151163. */
  151164. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151165. /**
  151166. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  151167. * @param targetFrameRate defines the target frame rate (60 by default)
  151168. * @returns a SceneOptimizerOptions object
  151169. */
  151170. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  151171. }
  151172. /**
  151173. * Class used to run optimizations in order to reach a target frame rate
  151174. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  151175. */
  151176. export class SceneOptimizer implements IDisposable {
  151177. private _isRunning;
  151178. private _options;
  151179. private _scene;
  151180. private _currentPriorityLevel;
  151181. private _targetFrameRate;
  151182. private _trackerDuration;
  151183. private _currentFrameRate;
  151184. private _sceneDisposeObserver;
  151185. private _improvementMode;
  151186. /**
  151187. * Defines an observable called when the optimizer reaches the target frame rate
  151188. */
  151189. onSuccessObservable: Observable<SceneOptimizer>;
  151190. /**
  151191. * Defines an observable called when the optimizer enables an optimization
  151192. */
  151193. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  151194. /**
  151195. * Defines an observable called when the optimizer is not able to reach the target frame rate
  151196. */
  151197. onFailureObservable: Observable<SceneOptimizer>;
  151198. /**
  151199. * Gets a boolean indicating if the optimizer is in improvement mode
  151200. */
  151201. get isInImprovementMode(): boolean;
  151202. /**
  151203. * Gets the current priority level (0 at start)
  151204. */
  151205. get currentPriorityLevel(): number;
  151206. /**
  151207. * Gets the current frame rate checked by the SceneOptimizer
  151208. */
  151209. get currentFrameRate(): number;
  151210. /**
  151211. * Gets or sets the current target frame rate (60 by default)
  151212. */
  151213. get targetFrameRate(): number;
  151214. /**
  151215. * Gets or sets the current target frame rate (60 by default)
  151216. */
  151217. set targetFrameRate(value: number);
  151218. /**
  151219. * Gets or sets the current interval between two checks (every 2000ms by default)
  151220. */
  151221. get trackerDuration(): number;
  151222. /**
  151223. * Gets or sets the current interval between two checks (every 2000ms by default)
  151224. */
  151225. set trackerDuration(value: number);
  151226. /**
  151227. * Gets the list of active optimizations
  151228. */
  151229. get optimizations(): SceneOptimization[];
  151230. /**
  151231. * Creates a new SceneOptimizer
  151232. * @param scene defines the scene to work on
  151233. * @param options defines the options to use with the SceneOptimizer
  151234. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  151235. * @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)
  151236. */
  151237. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  151238. /**
  151239. * Stops the current optimizer
  151240. */
  151241. stop(): void;
  151242. /**
  151243. * Reset the optimizer to initial step (current priority level = 0)
  151244. */
  151245. reset(): void;
  151246. /**
  151247. * Start the optimizer. By default it will try to reach a specific framerate
  151248. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  151249. */
  151250. start(): void;
  151251. private _checkCurrentState;
  151252. /**
  151253. * Release all resources
  151254. */
  151255. dispose(): void;
  151256. /**
  151257. * Helper function to create a SceneOptimizer with one single line of code
  151258. * @param scene defines the scene to work on
  151259. * @param options defines the options to use with the SceneOptimizer
  151260. * @param onSuccess defines a callback to call on success
  151261. * @param onFailure defines a callback to call on failure
  151262. * @returns the new SceneOptimizer object
  151263. */
  151264. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  151265. }
  151266. }
  151267. declare module BABYLON {
  151268. /**
  151269. * Class used to serialize a scene into a string
  151270. */
  151271. export class SceneSerializer {
  151272. /**
  151273. * Clear cache used by a previous serialization
  151274. */
  151275. static ClearCache(): void;
  151276. /**
  151277. * Serialize a scene into a JSON compatible object
  151278. * @param scene defines the scene to serialize
  151279. * @returns a JSON compatible object
  151280. */
  151281. static Serialize(scene: Scene): any;
  151282. /**
  151283. * Serialize a mesh into a JSON compatible object
  151284. * @param toSerialize defines the mesh to serialize
  151285. * @param withParents defines if parents must be serialized as well
  151286. * @param withChildren defines if children must be serialized as well
  151287. * @returns a JSON compatible object
  151288. */
  151289. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  151290. }
  151291. }
  151292. declare module BABYLON {
  151293. /**
  151294. * Class used to host texture specific utilities
  151295. */
  151296. export class TextureTools {
  151297. /**
  151298. * Uses the GPU to create a copy texture rescaled at a given size
  151299. * @param texture Texture to copy from
  151300. * @param width defines the desired width
  151301. * @param height defines the desired height
  151302. * @param useBilinearMode defines if bilinear mode has to be used
  151303. * @return the generated texture
  151304. */
  151305. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  151306. }
  151307. }
  151308. declare module BABYLON {
  151309. /**
  151310. * This represents the different options available for the video capture.
  151311. */
  151312. export interface VideoRecorderOptions {
  151313. /** Defines the mime type of the video. */
  151314. mimeType: string;
  151315. /** Defines the FPS the video should be recorded at. */
  151316. fps: number;
  151317. /** Defines the chunk size for the recording data. */
  151318. recordChunckSize: number;
  151319. /** The audio tracks to attach to the recording. */
  151320. audioTracks?: MediaStreamTrack[];
  151321. }
  151322. /**
  151323. * This can help with recording videos from BabylonJS.
  151324. * This is based on the available WebRTC functionalities of the browser.
  151325. *
  151326. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  151327. */
  151328. export class VideoRecorder {
  151329. private static readonly _defaultOptions;
  151330. /**
  151331. * Returns whether or not the VideoRecorder is available in your browser.
  151332. * @param engine Defines the Babylon Engine.
  151333. * @returns true if supported otherwise false.
  151334. */
  151335. static IsSupported(engine: Engine): boolean;
  151336. private readonly _options;
  151337. private _canvas;
  151338. private _mediaRecorder;
  151339. private _recordedChunks;
  151340. private _fileName;
  151341. private _resolve;
  151342. private _reject;
  151343. /**
  151344. * True when a recording is already in progress.
  151345. */
  151346. get isRecording(): boolean;
  151347. /**
  151348. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  151349. * @param engine Defines the BabylonJS Engine you wish to record.
  151350. * @param options Defines options that can be used to customize the capture.
  151351. */
  151352. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  151353. /**
  151354. * Stops the current recording before the default capture timeout passed in the startRecording function.
  151355. */
  151356. stopRecording(): void;
  151357. /**
  151358. * Starts recording the canvas for a max duration specified in parameters.
  151359. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  151360. * If null no automatic download will start and you can rely on the promise to get the data back.
  151361. * @param maxDuration Defines the maximum recording time in seconds.
  151362. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  151363. * @return A promise callback at the end of the recording with the video data in Blob.
  151364. */
  151365. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  151366. /**
  151367. * Releases internal resources used during the recording.
  151368. */
  151369. dispose(): void;
  151370. private _handleDataAvailable;
  151371. private _handleError;
  151372. private _handleStop;
  151373. }
  151374. }
  151375. declare module BABYLON {
  151376. /**
  151377. * Class containing a set of static utilities functions for screenshots
  151378. */
  151379. export class ScreenshotTools {
  151380. /**
  151381. * Captures a screenshot of the current rendering
  151382. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151383. * @param engine defines the rendering engine
  151384. * @param camera defines the source camera
  151385. * @param size This parameter can be set to a single number or to an object with the
  151386. * following (optional) properties: precision, width, height. If a single number is passed,
  151387. * it will be used for both width and height. If an object is passed, the screenshot size
  151388. * will be derived from the parameters. The precision property is a multiplier allowing
  151389. * rendering at a higher or lower resolution
  151390. * @param successCallback defines the callback receives a single parameter which contains the
  151391. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151392. * src parameter of an <img> to display it
  151393. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151394. * Check your browser for supported MIME types
  151395. */
  151396. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  151397. /**
  151398. * Captures a screenshot of the current rendering
  151399. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151400. * @param engine defines the rendering engine
  151401. * @param camera defines the source camera
  151402. * @param size This parameter can be set to a single number or to an object with the
  151403. * following (optional) properties: precision, width, height. If a single number is passed,
  151404. * it will be used for both width and height. If an object is passed, the screenshot size
  151405. * will be derived from the parameters. The precision property is a multiplier allowing
  151406. * rendering at a higher or lower resolution
  151407. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  151408. * Check your browser for supported MIME types
  151409. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151410. * to the src parameter of an <img> to display it
  151411. */
  151412. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  151413. /**
  151414. * Generates an image screenshot from the specified camera.
  151415. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151416. * @param engine The engine to use for rendering
  151417. * @param camera The camera to use for rendering
  151418. * @param size This parameter can be set to a single number or to an object with the
  151419. * following (optional) properties: precision, width, height. If a single number is passed,
  151420. * it will be used for both width and height. If an object is passed, the screenshot size
  151421. * will be derived from the parameters. The precision property is a multiplier allowing
  151422. * rendering at a higher or lower resolution
  151423. * @param successCallback The callback receives a single parameter which contains the
  151424. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  151425. * src parameter of an <img> to display it
  151426. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151427. * Check your browser for supported MIME types
  151428. * @param samples Texture samples (default: 1)
  151429. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151430. * @param fileName A name for for the downloaded file.
  151431. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151432. */
  151433. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  151434. /**
  151435. * Generates an image screenshot from the specified camera.
  151436. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  151437. * @param engine The engine to use for rendering
  151438. * @param camera The camera to use for rendering
  151439. * @param size This parameter can be set to a single number or to an object with the
  151440. * following (optional) properties: precision, width, height. If a single number is passed,
  151441. * it will be used for both width and height. If an object is passed, the screenshot size
  151442. * will be derived from the parameters. The precision property is a multiplier allowing
  151443. * rendering at a higher or lower resolution
  151444. * @param mimeType The MIME type of the screenshot image (default: image/png).
  151445. * Check your browser for supported MIME types
  151446. * @param samples Texture samples (default: 1)
  151447. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  151448. * @param fileName A name for for the downloaded file.
  151449. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  151450. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  151451. * to the src parameter of an <img> to display it
  151452. */
  151453. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  151454. /**
  151455. * Gets height and width for screenshot size
  151456. * @private
  151457. */
  151458. private static _getScreenshotSize;
  151459. }
  151460. }
  151461. declare module BABYLON {
  151462. /**
  151463. * Interface for a data buffer
  151464. */
  151465. export interface IDataBuffer {
  151466. /**
  151467. * Reads bytes from the data buffer.
  151468. * @param byteOffset The byte offset to read
  151469. * @param byteLength The byte length to read
  151470. * @returns A promise that resolves when the bytes are read
  151471. */
  151472. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  151473. /**
  151474. * The byte length of the buffer.
  151475. */
  151476. readonly byteLength: number;
  151477. }
  151478. /**
  151479. * Utility class for reading from a data buffer
  151480. */
  151481. export class DataReader {
  151482. /**
  151483. * The data buffer associated with this data reader.
  151484. */
  151485. readonly buffer: IDataBuffer;
  151486. /**
  151487. * The current byte offset from the beginning of the data buffer.
  151488. */
  151489. byteOffset: number;
  151490. private _dataView;
  151491. private _dataByteOffset;
  151492. /**
  151493. * Constructor
  151494. * @param buffer The buffer to read
  151495. */
  151496. constructor(buffer: IDataBuffer);
  151497. /**
  151498. * Loads the given byte length.
  151499. * @param byteLength The byte length to load
  151500. * @returns A promise that resolves when the load is complete
  151501. */
  151502. loadAsync(byteLength: number): Promise<void>;
  151503. /**
  151504. * Read a unsigned 32-bit integer from the currently loaded data range.
  151505. * @returns The 32-bit integer read
  151506. */
  151507. readUint32(): number;
  151508. /**
  151509. * Read a byte array from the currently loaded data range.
  151510. * @param byteLength The byte length to read
  151511. * @returns The byte array read
  151512. */
  151513. readUint8Array(byteLength: number): Uint8Array;
  151514. /**
  151515. * Read a string from the currently loaded data range.
  151516. * @param byteLength The byte length to read
  151517. * @returns The string read
  151518. */
  151519. readString(byteLength: number): string;
  151520. /**
  151521. * Skips the given byte length the currently loaded data range.
  151522. * @param byteLength The byte length to skip
  151523. */
  151524. skipBytes(byteLength: number): void;
  151525. }
  151526. }
  151527. declare module BABYLON {
  151528. /**
  151529. * Class for storing data to local storage if available or in-memory storage otherwise
  151530. */
  151531. export class DataStorage {
  151532. private static _Storage;
  151533. private static _GetStorage;
  151534. /**
  151535. * Reads a string from the data storage
  151536. * @param key The key to read
  151537. * @param defaultValue The value if the key doesn't exist
  151538. * @returns The string value
  151539. */
  151540. static ReadString(key: string, defaultValue: string): string;
  151541. /**
  151542. * Writes a string to the data storage
  151543. * @param key The key to write
  151544. * @param value The value to write
  151545. */
  151546. static WriteString(key: string, value: string): void;
  151547. /**
  151548. * Reads a boolean from the data storage
  151549. * @param key The key to read
  151550. * @param defaultValue The value if the key doesn't exist
  151551. * @returns The boolean value
  151552. */
  151553. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  151554. /**
  151555. * Writes a boolean to the data storage
  151556. * @param key The key to write
  151557. * @param value The value to write
  151558. */
  151559. static WriteBoolean(key: string, value: boolean): void;
  151560. /**
  151561. * Reads a number from the data storage
  151562. * @param key The key to read
  151563. * @param defaultValue The value if the key doesn't exist
  151564. * @returns The number value
  151565. */
  151566. static ReadNumber(key: string, defaultValue: number): number;
  151567. /**
  151568. * Writes a number to the data storage
  151569. * @param key The key to write
  151570. * @param value The value to write
  151571. */
  151572. static WriteNumber(key: string, value: number): void;
  151573. }
  151574. }
  151575. declare module BABYLON {
  151576. /**
  151577. * An interface for all Hit test features
  151578. */
  151579. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  151580. /**
  151581. * Triggered when new babylon (transformed) hit test results are available
  151582. */
  151583. onHitTestResultObservable: Observable<T[]>;
  151584. }
  151585. /**
  151586. * Options used for hit testing
  151587. */
  151588. export interface IWebXRLegacyHitTestOptions {
  151589. /**
  151590. * Only test when user interacted with the scene. Default - hit test every frame
  151591. */
  151592. testOnPointerDownOnly?: boolean;
  151593. /**
  151594. * The node to use to transform the local results to world coordinates
  151595. */
  151596. worldParentNode?: TransformNode;
  151597. }
  151598. /**
  151599. * Interface defining the babylon result of raycasting/hit-test
  151600. */
  151601. export interface IWebXRLegacyHitResult {
  151602. /**
  151603. * Transformation matrix that can be applied to a node that will put it in the hit point location
  151604. */
  151605. transformationMatrix: Matrix;
  151606. /**
  151607. * The native hit test result
  151608. */
  151609. xrHitResult: XRHitResult | XRHitTestResult;
  151610. }
  151611. /**
  151612. * The currently-working hit-test module.
  151613. * Hit test (or Ray-casting) is used to interact with the real world.
  151614. * For further information read here - https://github.com/immersive-web/hit-test
  151615. */
  151616. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  151617. /**
  151618. * options to use when constructing this feature
  151619. */
  151620. readonly options: IWebXRLegacyHitTestOptions;
  151621. private _direction;
  151622. private _mat;
  151623. private _onSelectEnabled;
  151624. private _origin;
  151625. /**
  151626. * The module's name
  151627. */
  151628. static readonly Name: string;
  151629. /**
  151630. * The (Babylon) version of this module.
  151631. * This is an integer representing the implementation version.
  151632. * This number does not correspond to the WebXR specs version
  151633. */
  151634. static readonly Version: number;
  151635. /**
  151636. * Populated with the last native XR Hit Results
  151637. */
  151638. lastNativeXRHitResults: XRHitResult[];
  151639. /**
  151640. * Triggered when new babylon (transformed) hit test results are available
  151641. */
  151642. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  151643. /**
  151644. * Creates a new instance of the (legacy version) hit test feature
  151645. * @param _xrSessionManager an instance of WebXRSessionManager
  151646. * @param options options to use when constructing this feature
  151647. */
  151648. constructor(_xrSessionManager: WebXRSessionManager,
  151649. /**
  151650. * options to use when constructing this feature
  151651. */
  151652. options?: IWebXRLegacyHitTestOptions);
  151653. /**
  151654. * execute a hit test with an XR Ray
  151655. *
  151656. * @param xrSession a native xrSession that will execute this hit test
  151657. * @param xrRay the ray (position and direction) to use for ray-casting
  151658. * @param referenceSpace native XR reference space to use for the hit-test
  151659. * @param filter filter function that will filter the results
  151660. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151661. */
  151662. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  151663. /**
  151664. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  151665. * @param event the (select) event to use to select with
  151666. * @param referenceSpace the reference space to use for this hit test
  151667. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  151668. */
  151669. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  151670. /**
  151671. * attach this feature
  151672. * Will usually be called by the features manager
  151673. *
  151674. * @returns true if successful.
  151675. */
  151676. attach(): boolean;
  151677. /**
  151678. * detach this feature.
  151679. * Will usually be called by the features manager
  151680. *
  151681. * @returns true if successful.
  151682. */
  151683. detach(): boolean;
  151684. /**
  151685. * Dispose this feature and all of the resources attached
  151686. */
  151687. dispose(): void;
  151688. protected _onXRFrame(frame: XRFrame): void;
  151689. private _onHitTestResults;
  151690. private _onSelect;
  151691. }
  151692. }
  151693. declare module BABYLON {
  151694. /**
  151695. * Options used for hit testing (version 2)
  151696. */
  151697. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  151698. /**
  151699. * Do not create a permanent hit test. Will usually be used when only
  151700. * transient inputs are needed.
  151701. */
  151702. disablePermanentHitTest?: boolean;
  151703. /**
  151704. * Enable transient (for example touch-based) hit test inspections
  151705. */
  151706. enableTransientHitTest?: boolean;
  151707. /**
  151708. * Offset ray for the permanent hit test
  151709. */
  151710. offsetRay?: Vector3;
  151711. /**
  151712. * Offset ray for the transient hit test
  151713. */
  151714. transientOffsetRay?: Vector3;
  151715. /**
  151716. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  151717. */
  151718. useReferenceSpace?: boolean;
  151719. }
  151720. /**
  151721. * Interface defining the babylon result of hit-test
  151722. */
  151723. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  151724. /**
  151725. * The input source that generated this hit test (if transient)
  151726. */
  151727. inputSource?: XRInputSource;
  151728. /**
  151729. * Is this a transient hit test
  151730. */
  151731. isTransient?: boolean;
  151732. /**
  151733. * Position of the hit test result
  151734. */
  151735. position: Vector3;
  151736. /**
  151737. * Rotation of the hit test result
  151738. */
  151739. rotationQuaternion: Quaternion;
  151740. /**
  151741. * The native hit test result
  151742. */
  151743. xrHitResult: XRHitTestResult;
  151744. }
  151745. /**
  151746. * The currently-working hit-test module.
  151747. * Hit test (or Ray-casting) is used to interact with the real world.
  151748. * For further information read here - https://github.com/immersive-web/hit-test
  151749. *
  151750. * Tested on chrome (mobile) 80.
  151751. */
  151752. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  151753. /**
  151754. * options to use when constructing this feature
  151755. */
  151756. readonly options: IWebXRHitTestOptions;
  151757. private _tmpMat;
  151758. private _tmpPos;
  151759. private _tmpQuat;
  151760. private _transientXrHitTestSource;
  151761. private _xrHitTestSource;
  151762. private initHitTestSource;
  151763. /**
  151764. * The module's name
  151765. */
  151766. static readonly Name: string;
  151767. /**
  151768. * The (Babylon) version of this module.
  151769. * This is an integer representing the implementation version.
  151770. * This number does not correspond to the WebXR specs version
  151771. */
  151772. static readonly Version: number;
  151773. /**
  151774. * When set to true, each hit test will have its own position/rotation objects
  151775. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  151776. * the developers will clone them or copy them as they see fit.
  151777. */
  151778. autoCloneTransformation: boolean;
  151779. /**
  151780. * Triggered when new babylon (transformed) hit test results are available
  151781. */
  151782. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  151783. /**
  151784. * Use this to temporarily pause hit test checks.
  151785. */
  151786. paused: boolean;
  151787. /**
  151788. * Creates a new instance of the hit test feature
  151789. * @param _xrSessionManager an instance of WebXRSessionManager
  151790. * @param options options to use when constructing this feature
  151791. */
  151792. constructor(_xrSessionManager: WebXRSessionManager,
  151793. /**
  151794. * options to use when constructing this feature
  151795. */
  151796. options?: IWebXRHitTestOptions);
  151797. /**
  151798. * attach this feature
  151799. * Will usually be called by the features manager
  151800. *
  151801. * @returns true if successful.
  151802. */
  151803. attach(): boolean;
  151804. /**
  151805. * detach this feature.
  151806. * Will usually be called by the features manager
  151807. *
  151808. * @returns true if successful.
  151809. */
  151810. detach(): boolean;
  151811. /**
  151812. * Dispose this feature and all of the resources attached
  151813. */
  151814. dispose(): void;
  151815. protected _onXRFrame(frame: XRFrame): void;
  151816. private _processWebXRHitTestResult;
  151817. }
  151818. }
  151819. declare module BABYLON {
  151820. /**
  151821. * Configuration options of the anchor system
  151822. */
  151823. export interface IWebXRAnchorSystemOptions {
  151824. /**
  151825. * a node that will be used to convert local to world coordinates
  151826. */
  151827. worldParentNode?: TransformNode;
  151828. /**
  151829. * If set to true a reference of the created anchors will be kept until the next session starts
  151830. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  151831. */
  151832. doNotRemoveAnchorsOnSessionEnded?: boolean;
  151833. }
  151834. /**
  151835. * A babylon container for an XR Anchor
  151836. */
  151837. export interface IWebXRAnchor {
  151838. /**
  151839. * A babylon-assigned ID for this anchor
  151840. */
  151841. id: number;
  151842. /**
  151843. * Transformation matrix to apply to an object attached to this anchor
  151844. */
  151845. transformationMatrix: Matrix;
  151846. /**
  151847. * The native anchor object
  151848. */
  151849. xrAnchor: XRAnchor;
  151850. /**
  151851. * if defined, this object will be constantly updated by the anchor's position and rotation
  151852. */
  151853. attachedNode?: TransformNode;
  151854. }
  151855. /**
  151856. * An implementation of the anchor system for WebXR.
  151857. * For further information see https://github.com/immersive-web/anchors/
  151858. */
  151859. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  151860. private _options;
  151861. private _lastFrameDetected;
  151862. private _trackedAnchors;
  151863. private _referenceSpaceForFrameAnchors;
  151864. private _futureAnchors;
  151865. /**
  151866. * The module's name
  151867. */
  151868. static readonly Name: string;
  151869. /**
  151870. * The (Babylon) version of this module.
  151871. * This is an integer representing the implementation version.
  151872. * This number does not correspond to the WebXR specs version
  151873. */
  151874. static readonly Version: number;
  151875. /**
  151876. * Observers registered here will be executed when a new anchor was added to the session
  151877. */
  151878. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  151879. /**
  151880. * Observers registered here will be executed when an anchor was removed from the session
  151881. */
  151882. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  151883. /**
  151884. * Observers registered here will be executed when an existing anchor updates
  151885. * This can execute N times every frame
  151886. */
  151887. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  151888. /**
  151889. * Set the reference space to use for anchor creation, when not using a hit test.
  151890. * Will default to the session's reference space if not defined
  151891. */
  151892. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  151893. /**
  151894. * constructs a new anchor system
  151895. * @param _xrSessionManager an instance of WebXRSessionManager
  151896. * @param _options configuration object for this feature
  151897. */
  151898. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  151899. private _tmpVector;
  151900. private _tmpQuaternion;
  151901. private _populateTmpTransformation;
  151902. /**
  151903. * Create a new anchor point using a hit test result at a specific point in the scene
  151904. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151905. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151906. *
  151907. * @param hitTestResult The hit test result to use for this anchor creation
  151908. * @param position an optional position offset for this anchor
  151909. * @param rotationQuaternion an optional rotation offset for this anchor
  151910. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151911. */
  151912. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  151913. /**
  151914. * Add a new anchor at a specific position and rotation
  151915. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  151916. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  151917. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  151918. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  151919. *
  151920. * @param position the position in which to add an anchor
  151921. * @param rotationQuaternion an optional rotation for the anchor transformation
  151922. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  151923. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  151924. */
  151925. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  151926. /**
  151927. * detach this feature.
  151928. * Will usually be called by the features manager
  151929. *
  151930. * @returns true if successful.
  151931. */
  151932. detach(): boolean;
  151933. /**
  151934. * Dispose this feature and all of the resources attached
  151935. */
  151936. dispose(): void;
  151937. protected _onXRFrame(frame: XRFrame): void;
  151938. /**
  151939. * avoiding using Array.find for global support.
  151940. * @param xrAnchor the plane to find in the array
  151941. */
  151942. private _findIndexInAnchorArray;
  151943. private _updateAnchorWithXRFrame;
  151944. private _createAnchorAtTransformation;
  151945. }
  151946. }
  151947. declare module BABYLON {
  151948. /**
  151949. * Options used in the plane detector module
  151950. */
  151951. export interface IWebXRPlaneDetectorOptions {
  151952. /**
  151953. * The node to use to transform the local results to world coordinates
  151954. */
  151955. worldParentNode?: TransformNode;
  151956. /**
  151957. * If set to true a reference of the created planes will be kept until the next session starts
  151958. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  151959. */
  151960. doNotRemovePlanesOnSessionEnded?: boolean;
  151961. }
  151962. /**
  151963. * A babylon interface for a WebXR plane.
  151964. * A Plane is actually a polygon, built from N points in space
  151965. *
  151966. * Supported in chrome 79, not supported in canary 81 ATM
  151967. */
  151968. export interface IWebXRPlane {
  151969. /**
  151970. * a babylon-assigned ID for this polygon
  151971. */
  151972. id: number;
  151973. /**
  151974. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  151975. */
  151976. polygonDefinition: Array<Vector3>;
  151977. /**
  151978. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  151979. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  151980. */
  151981. transformationMatrix: Matrix;
  151982. /**
  151983. * the native xr-plane object
  151984. */
  151985. xrPlane: XRPlane;
  151986. }
  151987. /**
  151988. * The plane detector is used to detect planes in the real world when in AR
  151989. * For more information see https://github.com/immersive-web/real-world-geometry/
  151990. */
  151991. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  151992. private _options;
  151993. private _detectedPlanes;
  151994. private _enabled;
  151995. private _lastFrameDetected;
  151996. /**
  151997. * The module's name
  151998. */
  151999. static readonly Name: string;
  152000. /**
  152001. * The (Babylon) version of this module.
  152002. * This is an integer representing the implementation version.
  152003. * This number does not correspond to the WebXR specs version
  152004. */
  152005. static readonly Version: number;
  152006. /**
  152007. * Observers registered here will be executed when a new plane was added to the session
  152008. */
  152009. onPlaneAddedObservable: Observable<IWebXRPlane>;
  152010. /**
  152011. * Observers registered here will be executed when a plane is no longer detected in the session
  152012. */
  152013. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  152014. /**
  152015. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  152016. * This can execute N times every frame
  152017. */
  152018. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  152019. /**
  152020. * construct a new Plane Detector
  152021. * @param _xrSessionManager an instance of xr Session manager
  152022. * @param _options configuration to use when constructing this feature
  152023. */
  152024. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  152025. /**
  152026. * detach this feature.
  152027. * Will usually be called by the features manager
  152028. *
  152029. * @returns true if successful.
  152030. */
  152031. detach(): boolean;
  152032. /**
  152033. * Dispose this feature and all of the resources attached
  152034. */
  152035. dispose(): void;
  152036. protected _onXRFrame(frame: XRFrame): void;
  152037. private _init;
  152038. private _updatePlaneWithXRPlane;
  152039. /**
  152040. * avoiding using Array.find for global support.
  152041. * @param xrPlane the plane to find in the array
  152042. */
  152043. private findIndexInPlaneArray;
  152044. }
  152045. }
  152046. declare module BABYLON {
  152047. /**
  152048. * Options interface for the background remover plugin
  152049. */
  152050. export interface IWebXRBackgroundRemoverOptions {
  152051. /**
  152052. * Further background meshes to disable when entering AR
  152053. */
  152054. backgroundMeshes?: AbstractMesh[];
  152055. /**
  152056. * flags to configure the removal of the environment helper.
  152057. * If not set, the entire background will be removed. If set, flags should be set as well.
  152058. */
  152059. environmentHelperRemovalFlags?: {
  152060. /**
  152061. * Should the skybox be removed (default false)
  152062. */
  152063. skyBox?: boolean;
  152064. /**
  152065. * Should the ground be removed (default false)
  152066. */
  152067. ground?: boolean;
  152068. };
  152069. /**
  152070. * don't disable the environment helper
  152071. */
  152072. ignoreEnvironmentHelper?: boolean;
  152073. }
  152074. /**
  152075. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  152076. */
  152077. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  152078. /**
  152079. * read-only options to be used in this module
  152080. */
  152081. readonly options: IWebXRBackgroundRemoverOptions;
  152082. /**
  152083. * The module's name
  152084. */
  152085. static readonly Name: string;
  152086. /**
  152087. * The (Babylon) version of this module.
  152088. * This is an integer representing the implementation version.
  152089. * This number does not correspond to the WebXR specs version
  152090. */
  152091. static readonly Version: number;
  152092. /**
  152093. * registered observers will be triggered when the background state changes
  152094. */
  152095. onBackgroundStateChangedObservable: Observable<boolean>;
  152096. /**
  152097. * constructs a new background remover module
  152098. * @param _xrSessionManager the session manager for this module
  152099. * @param options read-only options to be used in this module
  152100. */
  152101. constructor(_xrSessionManager: WebXRSessionManager,
  152102. /**
  152103. * read-only options to be used in this module
  152104. */
  152105. options?: IWebXRBackgroundRemoverOptions);
  152106. /**
  152107. * attach this feature
  152108. * Will usually be called by the features manager
  152109. *
  152110. * @returns true if successful.
  152111. */
  152112. attach(): boolean;
  152113. /**
  152114. * detach this feature.
  152115. * Will usually be called by the features manager
  152116. *
  152117. * @returns true if successful.
  152118. */
  152119. detach(): boolean;
  152120. /**
  152121. * Dispose this feature and all of the resources attached
  152122. */
  152123. dispose(): void;
  152124. protected _onXRFrame(_xrFrame: XRFrame): void;
  152125. private _setBackgroundState;
  152126. }
  152127. }
  152128. declare module BABYLON {
  152129. /**
  152130. * Options for the controller physics feature
  152131. */
  152132. export class IWebXRControllerPhysicsOptions {
  152133. /**
  152134. * Should the headset get its own impostor
  152135. */
  152136. enableHeadsetImpostor?: boolean;
  152137. /**
  152138. * Optional parameters for the headset impostor
  152139. */
  152140. headsetImpostorParams?: {
  152141. /**
  152142. * The type of impostor to create. Default is sphere
  152143. */
  152144. impostorType: number;
  152145. /**
  152146. * the size of the impostor. Defaults to 10cm
  152147. */
  152148. impostorSize?: number | {
  152149. width: number;
  152150. height: number;
  152151. depth: number;
  152152. };
  152153. /**
  152154. * Friction definitions
  152155. */
  152156. friction?: number;
  152157. /**
  152158. * Restitution
  152159. */
  152160. restitution?: number;
  152161. };
  152162. /**
  152163. * The physics properties of the future impostors
  152164. */
  152165. physicsProperties?: {
  152166. /**
  152167. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  152168. * Note that this requires a physics engine that supports mesh impostors!
  152169. */
  152170. useControllerMesh?: boolean;
  152171. /**
  152172. * The type of impostor to create. Default is sphere
  152173. */
  152174. impostorType?: number;
  152175. /**
  152176. * the size of the impostor. Defaults to 10cm
  152177. */
  152178. impostorSize?: number | {
  152179. width: number;
  152180. height: number;
  152181. depth: number;
  152182. };
  152183. /**
  152184. * Friction definitions
  152185. */
  152186. friction?: number;
  152187. /**
  152188. * Restitution
  152189. */
  152190. restitution?: number;
  152191. };
  152192. /**
  152193. * the xr input to use with this pointer selection
  152194. */
  152195. xrInput: WebXRInput;
  152196. }
  152197. /**
  152198. * Add physics impostor to your webxr controllers,
  152199. * including naive calculation of their linear and angular velocity
  152200. */
  152201. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  152202. private readonly _options;
  152203. private _attachController;
  152204. private _controllers;
  152205. private _debugMode;
  152206. private _delta;
  152207. private _headsetImpostor?;
  152208. private _headsetMesh?;
  152209. private _lastTimestamp;
  152210. private _tmpQuaternion;
  152211. private _tmpVector;
  152212. /**
  152213. * The module's name
  152214. */
  152215. static readonly Name: string;
  152216. /**
  152217. * The (Babylon) version of this module.
  152218. * This is an integer representing the implementation version.
  152219. * This number does not correspond to the webxr specs version
  152220. */
  152221. static readonly Version: number;
  152222. /**
  152223. * Construct a new Controller Physics Feature
  152224. * @param _xrSessionManager the corresponding xr session manager
  152225. * @param _options options to create this feature with
  152226. */
  152227. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  152228. /**
  152229. * @hidden
  152230. * enable debugging - will show console outputs and the impostor mesh
  152231. */
  152232. _enablePhysicsDebug(): void;
  152233. /**
  152234. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  152235. * @param xrController the controller to add
  152236. */
  152237. addController(xrController: WebXRInputSource): void;
  152238. /**
  152239. * attach this feature
  152240. * Will usually be called by the features manager
  152241. *
  152242. * @returns true if successful.
  152243. */
  152244. attach(): boolean;
  152245. /**
  152246. * detach this feature.
  152247. * Will usually be called by the features manager
  152248. *
  152249. * @returns true if successful.
  152250. */
  152251. detach(): boolean;
  152252. /**
  152253. * Get the headset impostor, if enabled
  152254. * @returns the impostor
  152255. */
  152256. getHeadsetImpostor(): PhysicsImpostor | undefined;
  152257. /**
  152258. * Get the physics impostor of a specific controller.
  152259. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  152260. * @param controller the controller or the controller id of which to get the impostor
  152261. * @returns the impostor or null
  152262. */
  152263. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  152264. /**
  152265. * Update the physics properties provided in the constructor
  152266. * @param newProperties the new properties object
  152267. */
  152268. setPhysicsProperties(newProperties: {
  152269. impostorType?: number;
  152270. impostorSize?: number | {
  152271. width: number;
  152272. height: number;
  152273. depth: number;
  152274. };
  152275. friction?: number;
  152276. restitution?: number;
  152277. }): void;
  152278. protected _onXRFrame(_xrFrame: any): void;
  152279. private _detachController;
  152280. }
  152281. }
  152282. declare module BABYLON {
  152283. /**
  152284. * The motion controller class for all microsoft mixed reality controllers
  152285. */
  152286. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  152287. protected readonly _mapping: {
  152288. defaultButton: {
  152289. valueNodeName: string;
  152290. unpressedNodeName: string;
  152291. pressedNodeName: string;
  152292. };
  152293. defaultAxis: {
  152294. valueNodeName: string;
  152295. minNodeName: string;
  152296. maxNodeName: string;
  152297. };
  152298. buttons: {
  152299. "xr-standard-trigger": {
  152300. rootNodeName: string;
  152301. componentProperty: string;
  152302. states: string[];
  152303. };
  152304. "xr-standard-squeeze": {
  152305. rootNodeName: string;
  152306. componentProperty: string;
  152307. states: string[];
  152308. };
  152309. "xr-standard-touchpad": {
  152310. rootNodeName: string;
  152311. labelAnchorNodeName: string;
  152312. touchPointNodeName: string;
  152313. };
  152314. "xr-standard-thumbstick": {
  152315. rootNodeName: string;
  152316. componentProperty: string;
  152317. states: string[];
  152318. };
  152319. };
  152320. axes: {
  152321. "xr-standard-touchpad": {
  152322. "x-axis": {
  152323. rootNodeName: string;
  152324. };
  152325. "y-axis": {
  152326. rootNodeName: string;
  152327. };
  152328. };
  152329. "xr-standard-thumbstick": {
  152330. "x-axis": {
  152331. rootNodeName: string;
  152332. };
  152333. "y-axis": {
  152334. rootNodeName: string;
  152335. };
  152336. };
  152337. };
  152338. };
  152339. /**
  152340. * The base url used to load the left and right controller models
  152341. */
  152342. static MODEL_BASE_URL: string;
  152343. /**
  152344. * The name of the left controller model file
  152345. */
  152346. static MODEL_LEFT_FILENAME: string;
  152347. /**
  152348. * The name of the right controller model file
  152349. */
  152350. static MODEL_RIGHT_FILENAME: string;
  152351. profileId: string;
  152352. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152353. protected _getFilenameAndPath(): {
  152354. filename: string;
  152355. path: string;
  152356. };
  152357. protected _getModelLoadingConstraints(): boolean;
  152358. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152359. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152360. protected _updateModel(): void;
  152361. }
  152362. }
  152363. declare module BABYLON {
  152364. /**
  152365. * The motion controller class for oculus touch (quest, rift).
  152366. * This class supports legacy mapping as well the standard xr mapping
  152367. */
  152368. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  152369. private _forceLegacyControllers;
  152370. private _modelRootNode;
  152371. /**
  152372. * The base url used to load the left and right controller models
  152373. */
  152374. static MODEL_BASE_URL: string;
  152375. /**
  152376. * The name of the left controller model file
  152377. */
  152378. static MODEL_LEFT_FILENAME: string;
  152379. /**
  152380. * The name of the right controller model file
  152381. */
  152382. static MODEL_RIGHT_FILENAME: string;
  152383. /**
  152384. * Base Url for the Quest controller model.
  152385. */
  152386. static QUEST_MODEL_BASE_URL: string;
  152387. profileId: string;
  152388. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  152389. protected _getFilenameAndPath(): {
  152390. filename: string;
  152391. path: string;
  152392. };
  152393. protected _getModelLoadingConstraints(): boolean;
  152394. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152395. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152396. protected _updateModel(): void;
  152397. /**
  152398. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  152399. * between the touch and touch 2.
  152400. */
  152401. private _isQuest;
  152402. }
  152403. }
  152404. declare module BABYLON {
  152405. /**
  152406. * The motion controller class for the standard HTC-Vive controllers
  152407. */
  152408. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  152409. private _modelRootNode;
  152410. /**
  152411. * The base url used to load the left and right controller models
  152412. */
  152413. static MODEL_BASE_URL: string;
  152414. /**
  152415. * File name for the controller model.
  152416. */
  152417. static MODEL_FILENAME: string;
  152418. profileId: string;
  152419. /**
  152420. * Create a new Vive motion controller object
  152421. * @param scene the scene to use to create this controller
  152422. * @param gamepadObject the corresponding gamepad object
  152423. * @param handedness the handedness of the controller
  152424. */
  152425. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  152426. protected _getFilenameAndPath(): {
  152427. filename: string;
  152428. path: string;
  152429. };
  152430. protected _getModelLoadingConstraints(): boolean;
  152431. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  152432. protected _setRootMesh(meshes: AbstractMesh[]): void;
  152433. protected _updateModel(): void;
  152434. }
  152435. }
  152436. declare module BABYLON {
  152437. /**
  152438. * A cursor which tracks a point on a path
  152439. */
  152440. export class PathCursor {
  152441. private path;
  152442. /**
  152443. * Stores path cursor callbacks for when an onchange event is triggered
  152444. */
  152445. private _onchange;
  152446. /**
  152447. * The value of the path cursor
  152448. */
  152449. value: number;
  152450. /**
  152451. * The animation array of the path cursor
  152452. */
  152453. animations: Animation[];
  152454. /**
  152455. * Initializes the path cursor
  152456. * @param path The path to track
  152457. */
  152458. constructor(path: Path2);
  152459. /**
  152460. * Gets the cursor point on the path
  152461. * @returns A point on the path cursor at the cursor location
  152462. */
  152463. getPoint(): Vector3;
  152464. /**
  152465. * Moves the cursor ahead by the step amount
  152466. * @param step The amount to move the cursor forward
  152467. * @returns This path cursor
  152468. */
  152469. moveAhead(step?: number): PathCursor;
  152470. /**
  152471. * Moves the cursor behind by the step amount
  152472. * @param step The amount to move the cursor back
  152473. * @returns This path cursor
  152474. */
  152475. moveBack(step?: number): PathCursor;
  152476. /**
  152477. * Moves the cursor by the step amount
  152478. * If the step amount is greater than one, an exception is thrown
  152479. * @param step The amount to move the cursor
  152480. * @returns This path cursor
  152481. */
  152482. move(step: number): PathCursor;
  152483. /**
  152484. * Ensures that the value is limited between zero and one
  152485. * @returns This path cursor
  152486. */
  152487. private ensureLimits;
  152488. /**
  152489. * Runs onchange callbacks on change (used by the animation engine)
  152490. * @returns This path cursor
  152491. */
  152492. private raiseOnChange;
  152493. /**
  152494. * Executes a function on change
  152495. * @param f A path cursor onchange callback
  152496. * @returns This path cursor
  152497. */
  152498. onchange(f: (cursor: PathCursor) => void): PathCursor;
  152499. }
  152500. }
  152501. declare module BABYLON {
  152502. /** @hidden */
  152503. export var blurPixelShader: {
  152504. name: string;
  152505. shader: string;
  152506. };
  152507. }
  152508. declare module BABYLON {
  152509. /** @hidden */
  152510. export var pointCloudVertexDeclaration: {
  152511. name: string;
  152512. shader: string;
  152513. };
  152514. }
  152515. // Mixins
  152516. interface Window {
  152517. mozIndexedDB: IDBFactory;
  152518. webkitIndexedDB: IDBFactory;
  152519. msIndexedDB: IDBFactory;
  152520. webkitURL: typeof URL;
  152521. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  152522. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  152523. WebGLRenderingContext: WebGLRenderingContext;
  152524. MSGesture: MSGesture;
  152525. CANNON: any;
  152526. AudioContext: AudioContext;
  152527. webkitAudioContext: AudioContext;
  152528. PointerEvent: any;
  152529. Math: Math;
  152530. Uint8Array: Uint8ArrayConstructor;
  152531. Float32Array: Float32ArrayConstructor;
  152532. mozURL: typeof URL;
  152533. msURL: typeof URL;
  152534. VRFrameData: any; // WebVR, from specs 1.1
  152535. DracoDecoderModule: any;
  152536. setImmediate(handler: (...args: any[]) => void): number;
  152537. }
  152538. interface HTMLCanvasElement {
  152539. requestPointerLock(): void;
  152540. msRequestPointerLock?(): void;
  152541. mozRequestPointerLock?(): void;
  152542. webkitRequestPointerLock?(): void;
  152543. /** Track wether a record is in progress */
  152544. isRecording: boolean;
  152545. /** Capture Stream method defined by some browsers */
  152546. captureStream(fps?: number): MediaStream;
  152547. }
  152548. interface CanvasRenderingContext2D {
  152549. msImageSmoothingEnabled: boolean;
  152550. }
  152551. interface MouseEvent {
  152552. mozMovementX: number;
  152553. mozMovementY: number;
  152554. webkitMovementX: number;
  152555. webkitMovementY: number;
  152556. msMovementX: number;
  152557. msMovementY: number;
  152558. }
  152559. interface Navigator {
  152560. mozGetVRDevices: (any: any) => any;
  152561. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152562. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152563. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  152564. webkitGetGamepads(): Gamepad[];
  152565. msGetGamepads(): Gamepad[];
  152566. webkitGamepads(): Gamepad[];
  152567. }
  152568. interface HTMLVideoElement {
  152569. mozSrcObject: any;
  152570. }
  152571. interface Math {
  152572. fround(x: number): number;
  152573. imul(a: number, b: number): number;
  152574. }
  152575. interface WebGLRenderingContext {
  152576. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  152577. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  152578. vertexAttribDivisor(index: number, divisor: number): void;
  152579. createVertexArray(): any;
  152580. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  152581. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  152582. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  152583. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  152584. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  152585. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  152586. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  152587. // Queries
  152588. createQuery(): WebGLQuery;
  152589. deleteQuery(query: WebGLQuery): void;
  152590. beginQuery(target: number, query: WebGLQuery): void;
  152591. endQuery(target: number): void;
  152592. getQueryParameter(query: WebGLQuery, pname: number): any;
  152593. getQuery(target: number, pname: number): any;
  152594. MAX_SAMPLES: number;
  152595. RGBA8: number;
  152596. READ_FRAMEBUFFER: number;
  152597. DRAW_FRAMEBUFFER: number;
  152598. UNIFORM_BUFFER: number;
  152599. HALF_FLOAT_OES: number;
  152600. RGBA16F: number;
  152601. RGBA32F: number;
  152602. R32F: number;
  152603. RG32F: number;
  152604. RGB32F: number;
  152605. R16F: number;
  152606. RG16F: number;
  152607. RGB16F: number;
  152608. RED: number;
  152609. RG: number;
  152610. R8: number;
  152611. RG8: number;
  152612. UNSIGNED_INT_24_8: number;
  152613. DEPTH24_STENCIL8: number;
  152614. MIN: number;
  152615. MAX: number;
  152616. /* Multiple Render Targets */
  152617. drawBuffers(buffers: number[]): void;
  152618. readBuffer(src: number): void;
  152619. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  152620. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  152621. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  152622. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  152623. // Occlusion Query
  152624. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  152625. ANY_SAMPLES_PASSED: number;
  152626. QUERY_RESULT_AVAILABLE: number;
  152627. QUERY_RESULT: number;
  152628. }
  152629. interface WebGLProgram {
  152630. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  152631. }
  152632. interface EXT_disjoint_timer_query {
  152633. QUERY_COUNTER_BITS_EXT: number;
  152634. TIME_ELAPSED_EXT: number;
  152635. TIMESTAMP_EXT: number;
  152636. GPU_DISJOINT_EXT: number;
  152637. QUERY_RESULT_EXT: number;
  152638. QUERY_RESULT_AVAILABLE_EXT: number;
  152639. queryCounterEXT(query: WebGLQuery, target: number): void;
  152640. createQueryEXT(): WebGLQuery;
  152641. beginQueryEXT(target: number, query: WebGLQuery): void;
  152642. endQueryEXT(target: number): void;
  152643. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  152644. deleteQueryEXT(query: WebGLQuery): void;
  152645. }
  152646. interface WebGLUniformLocation {
  152647. _currentState: any;
  152648. }
  152649. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  152650. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  152651. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  152652. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152653. interface WebGLRenderingContext {
  152654. readonly RASTERIZER_DISCARD: number;
  152655. readonly DEPTH_COMPONENT24: number;
  152656. readonly TEXTURE_3D: number;
  152657. readonly TEXTURE_2D_ARRAY: number;
  152658. readonly TEXTURE_COMPARE_FUNC: number;
  152659. readonly TEXTURE_COMPARE_MODE: number;
  152660. readonly COMPARE_REF_TO_TEXTURE: number;
  152661. readonly TEXTURE_WRAP_R: number;
  152662. readonly HALF_FLOAT: number;
  152663. readonly RGB8: number;
  152664. readonly RED_INTEGER: number;
  152665. readonly RG_INTEGER: number;
  152666. readonly RGB_INTEGER: number;
  152667. readonly RGBA_INTEGER: number;
  152668. readonly R8_SNORM: number;
  152669. readonly RG8_SNORM: number;
  152670. readonly RGB8_SNORM: number;
  152671. readonly RGBA8_SNORM: number;
  152672. readonly R8I: number;
  152673. readonly RG8I: number;
  152674. readonly RGB8I: number;
  152675. readonly RGBA8I: number;
  152676. readonly R8UI: number;
  152677. readonly RG8UI: number;
  152678. readonly RGB8UI: number;
  152679. readonly RGBA8UI: number;
  152680. readonly R16I: number;
  152681. readonly RG16I: number;
  152682. readonly RGB16I: number;
  152683. readonly RGBA16I: number;
  152684. readonly R16UI: number;
  152685. readonly RG16UI: number;
  152686. readonly RGB16UI: number;
  152687. readonly RGBA16UI: number;
  152688. readonly R32I: number;
  152689. readonly RG32I: number;
  152690. readonly RGB32I: number;
  152691. readonly RGBA32I: number;
  152692. readonly R32UI: number;
  152693. readonly RG32UI: number;
  152694. readonly RGB32UI: number;
  152695. readonly RGBA32UI: number;
  152696. readonly RGB10_A2UI: number;
  152697. readonly R11F_G11F_B10F: number;
  152698. readonly RGB9_E5: number;
  152699. readonly RGB10_A2: number;
  152700. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  152701. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  152702. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  152703. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  152704. readonly DEPTH_COMPONENT32F: number;
  152705. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  152706. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  152707. 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;
  152708. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  152709. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  152710. readonly TRANSFORM_FEEDBACK: number;
  152711. readonly INTERLEAVED_ATTRIBS: number;
  152712. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  152713. createTransformFeedback(): WebGLTransformFeedback;
  152714. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  152715. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  152716. beginTransformFeedback(primitiveMode: number): void;
  152717. endTransformFeedback(): void;
  152718. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  152719. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152720. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152721. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  152722. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  152723. }
  152724. interface ImageBitmap {
  152725. readonly width: number;
  152726. readonly height: number;
  152727. close(): void;
  152728. }
  152729. interface WebGLQuery extends WebGLObject {
  152730. }
  152731. declare var WebGLQuery: {
  152732. prototype: WebGLQuery;
  152733. new(): WebGLQuery;
  152734. };
  152735. interface WebGLSampler extends WebGLObject {
  152736. }
  152737. declare var WebGLSampler: {
  152738. prototype: WebGLSampler;
  152739. new(): WebGLSampler;
  152740. };
  152741. interface WebGLSync extends WebGLObject {
  152742. }
  152743. declare var WebGLSync: {
  152744. prototype: WebGLSync;
  152745. new(): WebGLSync;
  152746. };
  152747. interface WebGLTransformFeedback extends WebGLObject {
  152748. }
  152749. declare var WebGLTransformFeedback: {
  152750. prototype: WebGLTransformFeedback;
  152751. new(): WebGLTransformFeedback;
  152752. };
  152753. interface WebGLVertexArrayObject extends WebGLObject {
  152754. }
  152755. declare var WebGLVertexArrayObject: {
  152756. prototype: WebGLVertexArrayObject;
  152757. new(): WebGLVertexArrayObject;
  152758. };
  152759. // Type definitions for WebVR API
  152760. // Project: https://w3c.github.io/webvr/
  152761. // Definitions by: six a <https://github.com/lostfictions>
  152762. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  152763. interface VRDisplay extends EventTarget {
  152764. /**
  152765. * Dictionary of capabilities describing the VRDisplay.
  152766. */
  152767. readonly capabilities: VRDisplayCapabilities;
  152768. /**
  152769. * z-depth defining the far plane of the eye view frustum
  152770. * enables mapping of values in the render target depth
  152771. * attachment to scene coordinates. Initially set to 10000.0.
  152772. */
  152773. depthFar: number;
  152774. /**
  152775. * z-depth defining the near plane of the eye view frustum
  152776. * enables mapping of values in the render target depth
  152777. * attachment to scene coordinates. Initially set to 0.01.
  152778. */
  152779. depthNear: number;
  152780. /**
  152781. * An identifier for this distinct VRDisplay. Used as an
  152782. * association point in the Gamepad API.
  152783. */
  152784. readonly displayId: number;
  152785. /**
  152786. * A display name, a user-readable name identifying it.
  152787. */
  152788. readonly displayName: string;
  152789. readonly isConnected: boolean;
  152790. readonly isPresenting: boolean;
  152791. /**
  152792. * If this VRDisplay supports room-scale experiences, the optional
  152793. * stage attribute contains details on the room-scale parameters.
  152794. */
  152795. readonly stageParameters: VRStageParameters | null;
  152796. /**
  152797. * Passing the value returned by `requestAnimationFrame` to
  152798. * `cancelAnimationFrame` will unregister the callback.
  152799. * @param handle Define the hanle of the request to cancel
  152800. */
  152801. cancelAnimationFrame(handle: number): void;
  152802. /**
  152803. * Stops presenting to the VRDisplay.
  152804. * @returns a promise to know when it stopped
  152805. */
  152806. exitPresent(): Promise<void>;
  152807. /**
  152808. * Return the current VREyeParameters for the given eye.
  152809. * @param whichEye Define the eye we want the parameter for
  152810. * @returns the eye parameters
  152811. */
  152812. getEyeParameters(whichEye: string): VREyeParameters;
  152813. /**
  152814. * Populates the passed VRFrameData with the information required to render
  152815. * the current frame.
  152816. * @param frameData Define the data structure to populate
  152817. * @returns true if ok otherwise false
  152818. */
  152819. getFrameData(frameData: VRFrameData): boolean;
  152820. /**
  152821. * Get the layers currently being presented.
  152822. * @returns the list of VR layers
  152823. */
  152824. getLayers(): VRLayer[];
  152825. /**
  152826. * Return a VRPose containing the future predicted pose of the VRDisplay
  152827. * when the current frame will be presented. The value returned will not
  152828. * change until JavaScript has returned control to the browser.
  152829. *
  152830. * The VRPose will contain the position, orientation, velocity,
  152831. * and acceleration of each of these properties.
  152832. * @returns the pose object
  152833. */
  152834. getPose(): VRPose;
  152835. /**
  152836. * Return the current instantaneous pose of the VRDisplay, with no
  152837. * prediction applied.
  152838. * @returns the current instantaneous pose
  152839. */
  152840. getImmediatePose(): VRPose;
  152841. /**
  152842. * The callback passed to `requestAnimationFrame` will be called
  152843. * any time a new frame should be rendered. When the VRDisplay is
  152844. * presenting the callback will be called at the native refresh
  152845. * rate of the HMD. When not presenting this function acts
  152846. * identically to how window.requestAnimationFrame acts. Content should
  152847. * make no assumptions of frame rate or vsync behavior as the HMD runs
  152848. * asynchronously from other displays and at differing refresh rates.
  152849. * @param callback Define the eaction to run next frame
  152850. * @returns the request handle it
  152851. */
  152852. requestAnimationFrame(callback: FrameRequestCallback): number;
  152853. /**
  152854. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  152855. * Repeat calls while already presenting will update the VRLayers being displayed.
  152856. * @param layers Define the list of layer to present
  152857. * @returns a promise to know when the request has been fulfilled
  152858. */
  152859. requestPresent(layers: VRLayer[]): Promise<void>;
  152860. /**
  152861. * Reset the pose for this display, treating its current position and
  152862. * orientation as the "origin/zero" values. VRPose.position,
  152863. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  152864. * updated when calling resetPose(). This should be called in only
  152865. * sitting-space experiences.
  152866. */
  152867. resetPose(): void;
  152868. /**
  152869. * The VRLayer provided to the VRDisplay will be captured and presented
  152870. * in the HMD. Calling this function has the same effect on the source
  152871. * canvas as any other operation that uses its source image, and canvases
  152872. * created without preserveDrawingBuffer set to true will be cleared.
  152873. * @param pose Define the pose to submit
  152874. */
  152875. submitFrame(pose?: VRPose): void;
  152876. }
  152877. declare var VRDisplay: {
  152878. prototype: VRDisplay;
  152879. new(): VRDisplay;
  152880. };
  152881. interface VRLayer {
  152882. leftBounds?: number[] | Float32Array | null;
  152883. rightBounds?: number[] | Float32Array | null;
  152884. source?: HTMLCanvasElement | null;
  152885. }
  152886. interface VRDisplayCapabilities {
  152887. readonly canPresent: boolean;
  152888. readonly hasExternalDisplay: boolean;
  152889. readonly hasOrientation: boolean;
  152890. readonly hasPosition: boolean;
  152891. readonly maxLayers: number;
  152892. }
  152893. interface VREyeParameters {
  152894. /** @deprecated */
  152895. readonly fieldOfView: VRFieldOfView;
  152896. readonly offset: Float32Array;
  152897. readonly renderHeight: number;
  152898. readonly renderWidth: number;
  152899. }
  152900. interface VRFieldOfView {
  152901. readonly downDegrees: number;
  152902. readonly leftDegrees: number;
  152903. readonly rightDegrees: number;
  152904. readonly upDegrees: number;
  152905. }
  152906. interface VRFrameData {
  152907. readonly leftProjectionMatrix: Float32Array;
  152908. readonly leftViewMatrix: Float32Array;
  152909. readonly pose: VRPose;
  152910. readonly rightProjectionMatrix: Float32Array;
  152911. readonly rightViewMatrix: Float32Array;
  152912. readonly timestamp: number;
  152913. }
  152914. interface VRPose {
  152915. readonly angularAcceleration: Float32Array | null;
  152916. readonly angularVelocity: Float32Array | null;
  152917. readonly linearAcceleration: Float32Array | null;
  152918. readonly linearVelocity: Float32Array | null;
  152919. readonly orientation: Float32Array | null;
  152920. readonly position: Float32Array | null;
  152921. readonly timestamp: number;
  152922. }
  152923. interface VRStageParameters {
  152924. sittingToStandingTransform?: Float32Array;
  152925. sizeX?: number;
  152926. sizeY?: number;
  152927. }
  152928. interface Navigator {
  152929. getVRDisplays(): Promise<VRDisplay[]>;
  152930. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  152931. }
  152932. interface Window {
  152933. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  152934. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  152935. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  152936. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152937. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  152938. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  152939. }
  152940. interface Gamepad {
  152941. readonly displayId: number;
  152942. }
  152943. type XRSessionMode =
  152944. | "inline"
  152945. | "immersive-vr"
  152946. | "immersive-ar";
  152947. type XRReferenceSpaceType =
  152948. | "viewer"
  152949. | "local"
  152950. | "local-floor"
  152951. | "bounded-floor"
  152952. | "unbounded";
  152953. type XREnvironmentBlendMode =
  152954. | "opaque"
  152955. | "additive"
  152956. | "alpha-blend";
  152957. type XRVisibilityState =
  152958. | "visible"
  152959. | "visible-blurred"
  152960. | "hidden";
  152961. type XRHandedness =
  152962. | "none"
  152963. | "left"
  152964. | "right";
  152965. type XRTargetRayMode =
  152966. | "gaze"
  152967. | "tracked-pointer"
  152968. | "screen";
  152969. type XREye =
  152970. | "none"
  152971. | "left"
  152972. | "right";
  152973. type XREventType =
  152974. | "devicechange"
  152975. | "visibilitychange"
  152976. | "end"
  152977. | "inputsourceschange"
  152978. | "select"
  152979. | "selectstart"
  152980. | "selectend"
  152981. | "squeeze"
  152982. | "squeezestart"
  152983. | "squeezeend"
  152984. | "reset";
  152985. interface XRSpace extends EventTarget {
  152986. }
  152987. interface XRRenderState {
  152988. depthNear?: number;
  152989. depthFar?: number;
  152990. inlineVerticalFieldOfView?: number;
  152991. baseLayer?: XRWebGLLayer;
  152992. }
  152993. interface XRInputSource {
  152994. handedness: XRHandedness;
  152995. targetRayMode: XRTargetRayMode;
  152996. targetRaySpace: XRSpace;
  152997. gripSpace: XRSpace | undefined;
  152998. gamepad: Gamepad | undefined;
  152999. profiles: Array<string>;
  153000. }
  153001. interface XRSessionInit {
  153002. optionalFeatures?: string[];
  153003. requiredFeatures?: string[];
  153004. }
  153005. interface XRSession {
  153006. addEventListener: Function;
  153007. removeEventListener: Function;
  153008. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  153009. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  153010. requestAnimationFrame: Function;
  153011. end(): Promise<void>;
  153012. renderState: XRRenderState;
  153013. inputSources: Array<XRInputSource>;
  153014. // hit test
  153015. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  153016. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  153017. // legacy AR hit test
  153018. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  153019. // legacy plane detection
  153020. updateWorldTrackingState(options: {
  153021. planeDetectionState?: { enabled: boolean; }
  153022. }): void;
  153023. }
  153024. interface XRReferenceSpace extends XRSpace {
  153025. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  153026. onreset: any;
  153027. }
  153028. type XRPlaneSet = Set<XRPlane>;
  153029. type XRAnchorSet = Set<XRAnchor>;
  153030. interface XRFrame {
  153031. session: XRSession;
  153032. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  153033. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  153034. // AR
  153035. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  153036. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  153037. // Anchors
  153038. trackedAnchors?: XRAnchorSet;
  153039. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  153040. // Planes
  153041. worldInformation: {
  153042. detectedPlanes?: XRPlaneSet;
  153043. };
  153044. }
  153045. interface XRViewerPose extends XRPose {
  153046. views: Array<XRView>;
  153047. }
  153048. interface XRPose {
  153049. transform: XRRigidTransform;
  153050. emulatedPosition: boolean;
  153051. }
  153052. interface XRWebGLLayerOptions {
  153053. antialias?: boolean;
  153054. depth?: boolean;
  153055. stencil?: boolean;
  153056. alpha?: boolean;
  153057. multiview?: boolean;
  153058. framebufferScaleFactor?: number;
  153059. }
  153060. declare var XRWebGLLayer: {
  153061. prototype: XRWebGLLayer;
  153062. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  153063. };
  153064. interface XRWebGLLayer {
  153065. framebuffer: WebGLFramebuffer;
  153066. framebufferWidth: number;
  153067. framebufferHeight: number;
  153068. getViewport: Function;
  153069. }
  153070. declare class XRRigidTransform {
  153071. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  153072. position: DOMPointReadOnly;
  153073. orientation: DOMPointReadOnly;
  153074. matrix: Float32Array;
  153075. inverse: XRRigidTransform;
  153076. }
  153077. interface XRView {
  153078. eye: XREye;
  153079. projectionMatrix: Float32Array;
  153080. transform: XRRigidTransform;
  153081. }
  153082. interface XRInputSourceChangeEvent {
  153083. session: XRSession;
  153084. removed: Array<XRInputSource>;
  153085. added: Array<XRInputSource>;
  153086. }
  153087. interface XRInputSourceEvent extends Event {
  153088. readonly frame: XRFrame;
  153089. readonly inputSource: XRInputSource;
  153090. }
  153091. // Experimental(er) features
  153092. declare class XRRay {
  153093. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  153094. origin: DOMPointReadOnly;
  153095. direction: DOMPointReadOnly;
  153096. matrix: Float32Array;
  153097. }
  153098. declare enum XRHitTestTrackableType {
  153099. "point",
  153100. "plane"
  153101. }
  153102. interface XRHitResult {
  153103. hitMatrix: Float32Array;
  153104. }
  153105. interface XRTransientInputHitTestResult {
  153106. readonly inputSource: XRInputSource;
  153107. readonly results: Array<XRHitTestResult>;
  153108. }
  153109. interface XRHitTestResult {
  153110. getPose(baseSpace: XRSpace): XRPose | undefined;
  153111. // When anchor system is enabled
  153112. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  153113. }
  153114. interface XRHitTestSource {
  153115. cancel(): void;
  153116. }
  153117. interface XRTransientInputHitTestSource {
  153118. cancel(): void;
  153119. }
  153120. interface XRHitTestOptionsInit {
  153121. space: XRSpace;
  153122. entityTypes?: Array<XRHitTestTrackableType>;
  153123. offsetRay?: XRRay;
  153124. }
  153125. interface XRTransientInputHitTestOptionsInit {
  153126. profile: string;
  153127. entityTypes?: Array<XRHitTestTrackableType>;
  153128. offsetRay?: XRRay;
  153129. }
  153130. interface XRAnchor {
  153131. anchorSpace: XRSpace;
  153132. delete(): void;
  153133. }
  153134. interface XRPlane {
  153135. orientation: "Horizontal" | "Vertical";
  153136. planeSpace: XRSpace;
  153137. polygon: Array<DOMPointReadOnly>;
  153138. lastChangedTime: number;
  153139. }